private static void SendMail(GridProteinFoldingEntities ctx, Guid guid, string message, string webServerName) { //Sent e-mail SmtpClient smtpClient = new SmtpClient(); Process process = ctx.Process.FirstOrDefault(p => p.guid == guid); aspnet_Users user = new GridProteinFolding_MemberShipEntities().aspnet_Users.FirstOrDefault(u => u.UserId == process.userId); try { string key = string.Empty; System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(user.aspnet_Membership.LoweredEmail, user.UserName); string subject = "eFolding - Simulation"; string body = "Simulation " + process.guid.ToString() + message; body += "</br>Direct access: " + string.Format("http://" + webServerName + "/Pages/SimulationAddEdit.aspx?guId={0}", process.guid.ToString()); smtpClient.Send(to, subject, body); } catch (Exception ex) { GICO.WriteLine(ex); } finally { smtpClient = null; } }
private string User(Guid userId) { string userName = string.Empty; using (GridProteinFolding_MemberShipEntities ctx = new GridProteinFolding_MemberShipEntities()) { aspnet_Users user = ctx.aspnet_Users.FirstOrDefault(c => c.UserId == userId); if (user == null) { userName = "******"; } else { userName = user.UserName; } } return(userName); }
private static void Condicional(Guid guid, GridProteinFoldingEntities ctx, Process temp, ref BasicEnums.State state, ref RequestorInfo requestorInfo) { aspnet_Users user = new GridProteinFolding_MemberShipEntities().aspnet_Users.FirstOrDefault(u => u.UserId == temp.userId); if (state == BasicEnums.State.Processing) { GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "Processing", temp.macAddr, temp.machineName)); string message = " was started!"; if (temp.emailNotification == Convert.ToByte(BasicEnums.EmailNotification.Enviar)) { SendMail(ctx, guid, message, user); } Expurg(guid, ctx); } if (state == BasicEnums.State.BULK) { #region BULK GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "BULK", temp.macAddr, temp.machineName)); //ExtendedDirectoryInfo dirBaseServer = new ExtendedDirectoryInfo(ConfigurationManager.AppSettings["dirBaseServer"].ToString()); //object[] parameters = new object[2]; //parameters[0] = dirBaseServer + @"\" + guid + @"\Seed"; //parameters[1] = guid.ToString(); //ctx.ExecuteStoreCommand("EXEC dbo.BunkFiles {0},{1}", parameters); state = BasicEnums.State.ClearTempClient; temp.status_id = Convert.ToByte(state); ctx.SaveChanges(); #endregion #region ClearTempServer GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "ClearTempServer", temp.macAddr, temp.machineName)); DeleteFileServer_temp(guid); state = BasicEnums.State.Finalized; temp.status_id = Convert.ToByte(state); ctx.SaveChanges(); #endregion } //if (state == Enums.BasicEnums.State.Excel) //{ // Applications objApplications = new Applications(); // GICO.Write("Excel.."); // objApplications.Excel(param); // GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!"); // objApplications = null; // state = Enums.BasicEnums.State.Origin; // temp.status_id = Convert.ToByte(state); // ctx.SaveChanges(); //} //if (state == Enums.BasicEnums.State.Origin) //{ // ProcessData(param.dataToProcess.Guid); // Applications objApplications = new Applications(); // GICO.Write("Origin.."); // objApplications.Origin(param.dataToProcess.Guid); // GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!"); // objApplications = null; // state = Enums.BasicEnums.State.ClearTempClient; // temp.status_id = Convert.ToByte(state); // ctx.SaveChanges(); //} //if (state == BasicEnums.State.ClearTempServer) //{ // GICO.WriteLine(guid, String.Format("{0} {1}:", DateTime.Now, "ClearTempServer..")); // DeleteFileServer_temp(guid); // state = BasicEnums.State.Finalized; // temp.status_id = Convert.ToByte(state); // ctx.SaveChanges(); //} //if (state == Enums.BasicEnums.State.Decrypt) //{ // Applications objApplications = new Applications(); // GICO.Write("Decrypt.."); // objApplications.Decrypt(param); // GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!"); // objApplications = null; // state = Enums.BasicEnums.State.Web; // temp.status_id = Convert.ToByte(state); // ctx.SaveChanges(); //} //if (state == Enums.BasicEnums.State.Web) //{ // Applications objApplications = new Applications(); // GICO.Write("Web.."); // objApplications.Web(param); // GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!"); // objApplications = null; // state = Enums.BasicEnums.State.Finalized; // temp.status_id = Convert.ToByte(state); // ctx.SaveChanges(); //} if (state == BasicEnums.State.Finalized) { GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "Finalized", temp.macAddr, temp.machineName)); if (temp.emailNotification == Convert.ToByte(BasicEnums.EmailNotification.Enviar)) { string message = "was completed!"; SendMail(ctx, guid, message, user); } } }