Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [SqlProcedure]
- public static int CustomMethod(int id_email, out string sError)
- {
- int mReturn = 0;
- DataSet ds = new DataSet();
- sError = string.Empty;
- Dictionary<int, string> ListFile = new Dictionary<int, string>();
- try
- {
- ds = retornarQuery(strQuery: "ZeusFW_Email_List " + id_email);
- if (ds.Tables[0].Rows.Count > 0)
- {
- for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
- {
- DataRow row = ds.Tables[0].Rows[i];
- string ds_to_name = (string)row["ds_to_name"];
- string ds_to_email = (string)row["ds_to_email"];
- string ds_cc_email = (string)row["ds_cc_email"];
- string ds_bcc_email = (string)row["ds_bcc_email"];
- string ds_idiom = (string)row["ds_idiom"];
- string ds_subject = (string)row["ds_subject"];
- string ds_body = (string)row["ds_body"];
- int am_sent_times = (int)row["am_sent_times"];
- int in_process = (int)row["in_process"];
- int am_email_port = (int)row["am_email_port"];
- string ds_email_host = (string)row["ds_email_host"];
- string ds_email_user = (string)row["ds_email_user"];
- string ds_email_password = (string)row["ds_email_password"];
- int am_email_html = (int)row["am_email_html"];
- int am_email_ssl = (int)row["am_email_ssl"];
- string ds_email_name = (string)row["ds_email_name"];
- string ds_email_xsl = (string)row["ds_email_xsl"];
- int in_email_log = (int)row["in_email_log"];
- DeliveryNotificationOptions am_notificationoptions = NotificationOptions((int)row["am_notificationoptions"]);
- MailPriority am_priority = Priority((int)row["am_priority"]);
- if (in_process == 0 && am_email_html == 1)
- {
- ds_body = DoXSLT(ds_body, ds_email_xsl);
- }
- ZeusFrameworkSmtp.ZeusFrameworkSmtp email = new ZeusFrameworkSmtp.ZeusFrameworkSmtp();
- email.AddFrom = ds_email_user;
- email.AddName = ds_email_name;
- email.AddTo.Add(ds_to_email);
- if (ds_cc_email != null || !ds_cc_email.Equals("")) email.AddCC = ds_cc_email;
- if (ds_bcc_email != null || !ds_bcc_email.Equals("")) email.AddBcc = ds_bcc_email;
- if (am_sent_times > 0) { ds_subject = "Re#" + am_sent_times + " " + ds_subject; }
- email.Subject = ds_subject;
- email.Body = ds_body;
- email.BodyHtml = (am_email_html == 0 ? false : true);
- email.Server = ds_email_host;
- email.Port = am_email_port;
- email.User = ds_email_user;
- email.Password = ds_email_password;
- email.EnableSsl = (am_email_ssl == 0 ? false : true); ;
- email.NotificationOptions = am_notificationoptions;
- email.Priority = am_priority;
- am_sent_times = am_sent_times + 1;
- if (ds.Tables[1].Rows.Count > 0)
- {
- for (int j = 0; j <= ds.Tables[1].Rows.Count - 1; j++)
- {
- DataRow rowAttachments = ds.Tables[1].Rows[j];
- if (id_email == (int)rowAttachments["id_email"])
- {
- if ((int)rowAttachments["in_delete_file"] == 1) ListFile.Add(j, (string)rowAttachments["ds_full_path"]);
- email.AddAttachments.Add((string)rowAttachments["ds_full_path"]);
- }
- }
- }
- bool bresult = email.Send(out sError);
- //if (bresult) { mReturn = 1; Database.ZeusFW_Email_Update(id_email, am_sent_times, sError, in_email_log).Run(); }
- if (string.IsNullOrEmpty(sError) || sError.Equals("ESTOY EJECUTANDO EL METODO")) sError = "Operación completada con éxito.";
- if (ListFile.Count > 0)
- {
- foreach (KeyValuePair<int, string> item in ListFile)
- {
- if (item.Key == 1) File.Delete(item.Value.ToString());
- }
- ListFile.Clear();
- }
- }
- }
- else sError = "No se encontró el ID";
- }
- catch (Exception ex)
- {
- StringBuilder s = new StringBuilder();
- //sError = sError + "-" + "Error executing SQL statement information: " + ex.Message + "id_email : " + id_email.ToString() + "Conn : " + Database.ConnectionString + ex.StackTrace.ToString();
- LogWindows _LogWindows = new LogWindows();
- _LogWindows.Save("Zeus", sError, System.Diagnostics.EventLogEntryType.Error);
- //SqlContext.Pipe.Send("Error executing SQL statement information: " + ex.Message + "id_email> " + id_email_aux.ToString() + "Conn>" + Database.ConnectionString);
- }
- return mReturn;
- }
- CREATE PROCEDURE [dbo].[CustomMethod]
- @id_email int
- ,@sError nvarchar(2000)=NULL OUTPUT
- WITH EXECUTE AS CALLER
- AS
- EXTERNAL NAME [AssemblyNamespace].[AssemblyNamespace.AssemblyNamespace1].[CustomMethod]
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement