public ActionResult ChangeEmployeeStatus(string id, EmploymentAction EmploymentAction) { AppUser Employee = db.Users.Find(id); if (EmploymentAction == EmploymentAction.Hire) { String Message = "Hello " + Employee.FirstName + ",\n" + "congratulations on your renewed employment with Longhorn Cinemas." + "\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(Employee.Email, "Welcome Back to Longhorn Cinemas", Message); Employee.Archived = false; } if (EmploymentAction == EmploymentAction.Fire) { String Message = "Hello " + Employee.FirstName + ",\n\n" + "Your employment with Longhorn Cinemas has ended. We're sorry to hear you're leaving the Longhorn Family." + "\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(Employee.Email, "Goodbye, Longhorn Cinemas", Message); Employee.Archived = true; } if (ModelState.IsValid) { db.Entry(Employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("EmployeeHome")); } ViewBag.AllEmployees = GetAllEmployees(); // If we got this far, something failed, redisplay form return(View()); }
public bool CrashReport(Exception e) { if (this == Clients.NoClient) { return(false); } if (e is ThreadAbortException) { return(false); } var st = new StackTrace(e, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth)); Console.WriteLine(ConsoleColor.Red, "OpenYS Has encountered an error"); Console.WriteLine(ConsoleColor.Red, "Thus, client &e" + Username + "&c has been disconnected."); Console.WriteLine(); Console.WriteLine(Debug.GetStackTrace(e)); Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth)); //Console.WriteLine("Preparing Email."); string[] Email = Emailing.PrepareBugReportEmail(e); Emailing.SendEmail(Email[0], Email[1]); Disconnect("Crash Detected, Disconnecting due to CrashReport(e)"); return(true); }
public response SendVerificationCode(EmailProfile ep, string _to, string _code) { Emailing e = new Emailing(ep); e.Message.From = new MailAddress(ep.IncomingUser); //e.Message.Bcc.Add(new MailAddress(ep.IncomingUser)); // daca vrem sa se trimita mesajul si la noi e.Message.To.Add(_to); e.Message.Subject = String.Format("Cod acces www.compensaredirecta.ro: {0}", _code); e.Message.IsBodyHtml = true; //e.Message.Body = String.Format("Acesta este un mesaj generat automat.<br /><br />Puteti descarca documentele asociate dosarului facand click <a ses:notrack href=\"{2}\">aici</a>.<br /><br />Detalii suplimentare puteti gasi accesand linkul: <a ses:notrack href=\"{0}\">{1}</a>.<br /><br />Atasat va transmitem Cererea de despagubire.<br /><br /><br />Cu stima,<br />Echipa compensaredirecta.ro<br /><br />Va rugam sa nu raspundeti la acest email. Daca doriti sa ne contactati, scrieti-ne la [email protected].", linkDosar, this.NR_DOSAR_CASCO, linkDocumentePdf); string templateHtmlText = System.IO.File.ReadAllText(System.IO.Path.Combine(CommonFunctions.GetSettingsFolder(), "template_email_cod_acces.html")); double exp = Convert.ToDouble(ConfigurationManager.AppSettings["VerificationCodeExpiration"]); int minute = (int)(exp / 60); int secunde = (int)(exp % 60); string expiration = (minute > 0 ? minute.ToString() + " minute" : ""); expiration += (minute > 0 && secunde > 0 ? " si " : ""); expiration += (secunde > 0 ? secunde.ToString() + " secunde" : ""); templateHtmlText = templateHtmlText.Replace("{{CODE}}", _code) .Replace("{{EXPIRATION}}", expiration); e.Message.Body = templateHtmlText; response toReturn = e.SendVerificationCodeMessage(_code); return(toReturn); }
protected void btnSave_Click(object sender, EventArgs e) { string CodeEncrypt = string.Empty; StringBuilder txtContent = new StringBuilder(); txtContent.Append(rdCuerpoEmail.Content); StringBuilder js = new StringBuilder(); js.Append("function LgRespuesta() {"); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); StringBuilder sPath = new StringBuilder(); sPath.Append(Server.MapPath(".")); DataTable dUsuarios = oWeb.DeserializarTbl(sPath.ToString(), "Usuarios.bin"); if (dUsuarios != null) { if (dUsuarios.Rows.Count > 0) { DataRow[] dRows = dUsuarios.Select(" cod_tipo = 1 and notetarget <> '1' "); if (dRows != null) { if (dRows.Count() > 0) { foreach (DataRow oRow in dRows) { oEmailing.Address = oRow["eml_usuario"].ToString(); } } } dRows = null; } oEmailing.Subject = txtAsunto.Text; oEmailing.Body = txtContent; if (oEmailing.EmailSend()) { js.Append(" window.radalert('").Append(oCulture.GetResource("Mensajes", "sMessage07")).Append("', 400, 100,'" + oCulture.GetResource("Global", "MnsAtencion") + "'); "); } else { js.Append(" window.radalert('").Append(oCulture.GetResource("Error", "sError03")).Append("', 400, 100,'" + oCulture.GetResource("Global", "MnsAtencion") + "'); "); } } else { js.Append(" window.radalert('").Append(oCulture.GetResource("Error", "sError03")).Append("', 400, 100,'" + oCulture.GetResource("Global", "MnsAtencion") + "'); "); } dUsuarios = null; js.Append(" Sys.Application.remove_load(LgRespuesta); "); js.Append("};"); js.Append("Sys.Application.add_load(LgRespuesta);"); Page.ClientScript.RegisterStartupScript(this.GetType(), "LgRespuesta", js.ToString(), true); }
public async Task <ActionResult> RegisterEmployee(RegisterViewModel model) { var age = DateTime.Now.Year - model.Birthday.Year; if (age < 18) { ViewBag.Error = "Employees must be at least 18 years of age"; return(View(model)); } if (ModelState.IsValid) { //Add fields to user here so they will be saved to do the database var user = new AppUser { UserName = model.Email, Email = model.Email, //Firstname is an example - you will need to add the rest FirstName = model.FirstName, MiddleInitial = model.MiddleInitial, LastName = model.LastName, Street = model.Street, City = model.City, State = model.State, Zip = model.Zip, PhoneNumber = model.PhoneNumber, Birthday = model.Birthday }; var result = await UserManager.CreateAsync(user, model.Password); //Once you get roles working, you may want to add users to roles upon creation //await UserManager.AddToRoleAsync(user.Id, "Customer"); // --OR-- await UserManager.AddToRoleAsync(user.Id, "Employee"); if (result.Succeeded) { ////await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); String Message = "Hello " + model.FirstName + "!\n\ns" + "Welcome to the Longhorn Cinemas family!" + "\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(model.Email, "Welcome new Longhorn Cinemas Employee!", Message); return(RedirectToAction("EmployeeHome")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult DeleteConfirmed(int id) { Showing showing = db.Showings.Find(id); // saves showing's schedule to return to page int ScheduleID = showing.Schedule.ScheduleID; // if schedule is published // showing is canceled not delete if (showing.Schedule.Published && DateTime.Now < showing.ShowDate) { // go to the cancelling a showing controller showing.Schedule = null; db.SaveChanges(); // returns and loops through each user that bought tickets to the showing foreach (UserTicket t in showing.UserTickets) { // change status of tickets for canceled showing t.Status = Status.Cancelled; t.SeatNumber = Seat.Seat; db.SaveChanges(); // return popcorn points if showing is canceled if (t.Transaction.Payment == Payment.PopcornPoints) { t.Transaction.User.PopcornPoints += t.Transaction.PopcornPointsSpent; t.CurrentPrice = 0; db.SaveChanges(); } else { // take back popcorn points received from credit card payment if showing is canceled t.Transaction.User.PopcornPoints -= Convert.ToInt32(t.CurrentPrice); t.CurrentPrice = 0; db.SaveChanges(); } // emails the buyer that the showing has been canceled String Message = "Hello " + t.Transaction.User.FirstName + ",\n" + "The " + showing.ShowDate + showing.Movie.Title + "showing has been canceled.\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(t.Transaction.User.Email, "Showing Canceled", Message); } // returns to Schedule's Detail page return(RedirectToAction("Details", "Schedules", new { id = ScheduleID })); } // schedule is unpublished if (showing.Schedule.Published == false) { // delete showing from table db.Showings.Remove(showing); db.SaveChanges(); // returns to Schedule's Detail page return(RedirectToAction("Details", "Schedules", new { id = ScheduleID })); } return(View(showing)); }
protected void BtngEnviar_Click(object sender, EventArgs e) { if (bEmailOk) { string sTxtNombres = txtnombres.Text; string sTxtCelular = txtcelular.Text; string sTxtEmail = txtemail.Text; string sTxtComentarios = txtcomentarios.Text; StringBuilder sMensaje = new StringBuilder(); sMensaje.Append("<html>"); sMensaje.Append("<body>"); sMensaje.Append("Nombrse : ").Append(sTxtNombres).Append("<br>"); sMensaje.Append("Celular : ").Append(sTxtCelular).Append("<br>"); sMensaje.Append("Email : ").Append(sTxtEmail).Append("<br>"); sMensaje.Append("Comentario : ").Append(sTxtComentarios).Append("<br>"); sMensaje.Append("</body>"); sMensaje.Append("</html>"); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = Application["EmailSender"].ToString(); oEmailing.Subject = "Mensaje de contáctenos de Licenciatarios DebtControl"; oEmailing.Body = sMensaje; StringBuilder js = new StringBuilder(); js.Append("function LgRespuesta() {"); if (oEmailing.EmailSend()) { js.Append(" window.radalert('El mensaje fue enviado exitosamente.', 400, 100,''); "); } else { js.Append(" window.radalert('El mensaje no pudo ser enviado, intente más tarde.', 400, 100,''); "); } js.Append(" Sys.Application.remove_load(LgRespuesta); "); js.Append("};"); js.Append("Sys.Application.add_load(LgRespuesta);"); Page.ClientScript.RegisterStartupScript(Page.GetType(), "LgRespuesta", js.ToString(), true); txtnombres.Text = string.Empty; txtcelular.Text = string.Empty; txtemail.Text = string.Empty; txtcomentarios.Text = string.Empty; } else { StringBuilder js = new StringBuilder(); js.Append("function LgRespuesta() {"); js.Append(" window.radalert('El email ingresado no es valido, por favor vuelva a ingresarlo.', 400, 100,'Atención'); "); js.Append(" Sys.Application.remove_load(LgRespuesta); "); js.Append("};"); js.Append("Sys.Application.add_load(LgRespuesta);"); Page.ClientScript.RegisterStartupScript(Page.GetType(), "LgRespuesta", js.ToString(), true); } }
public ActionResult ConfirmTransaction([Bind(Include = "TransactionID,Payment,TransactionDate")] Transaction transaction) { Transaction t = db.Transactions.Find(transaction.TransactionID); //if (t.Payment == Payment.CreditCardNumber1) //{ // String ccType = (CreditCard.GetCreditCardType(t.User.CreditCardNumber1)); // ViewBag.Payment = String.Format("{0}{1}{2}", "**** **** **** ", (t.User.CreditCardNumber1.Substring(t.User.CreditCardNumber1.Length - 4, 4)), " " + ccType); //} //else if (t.Payment == Payment.CreditCardNumber2) //{ // String ccType = (CreditCard.GetCreditCardType(t.User.CreditCardNumber2)); // ViewBag.Payment = String.Format("{0}{1}{2}", "**** **** **** ", (t.User.CreditCardNumber2.Substring(t.User.CreditCardNumber1.Length - 4, 4)), " " + ccType); //} //else if (t.Payment == Payment.PopcornPoints) //{ // ViewBag.Payment = "PopcornPoints"; //} //else //{ // ViewBag.Payment = "Other credit card"; //} if (Utilities.TransactionValidation.TicketValidation(t) == true) { if (ModelState.IsValid) { foreach (UserTicket ut in t.UserTickets) { ut.Status = Status.Active; db.SaveChanges(); } // add popcorn points from transaction if (t.Payment != Payment.PopcornPoints) { Decimal decPopPoints = t.UserTickets.Sum(ut => ut.CurrentPrice); Int32 intPopPoints = Convert.ToInt32(decPopPoints - (decPopPoints % 1)); Int32 CurPopPoints = t.User.PopcornPoints; t.User.PopcornPoints = CurPopPoints + intPopPoints; } // save changes to database db.Entry(t).State = EntityState.Modified; db.SaveChanges(); String Message = "Hello " + t.User.FirstName + ",\n\n" + "Your order number " + t.TransactionNumber + " has been placed.\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(t.User.Email, "Order Placed", Message); return(RedirectToAction("FinalCheckoutPage", new { id = t.TransactionID })); } } return(View(transaction)); }
public ActionResult DeleteConfirmed(int id) { Transaction transaction = db.Transactions.Find(id); if (transaction.Payment == Payment.PopcornPoints) { Int32 CurPopPoints = transaction.User.PopcornPoints; Int32 intTickets = transaction.UserTickets.Count(); Int32 PPTickets = intTickets * 100; transaction.PopcornPointsSpent = 0; transaction.User.PopcornPoints = CurPopPoints + PPTickets; db.SaveChanges(); } if (transaction.Payment != Payment.PopcornPoints) { Decimal decPopPoints = transaction.UserTickets.Sum(ut => ut.CurrentPrice); Int32 intPopPoints = Convert.ToInt32(decPopPoints - (decPopPoints % 1)); //Int32 CurPopPoints = transaction .User.PopcornPoints; // TODO: Subtract popcorn points or add? transaction.User.PopcornPoints -= intPopPoints; db.SaveChanges(); //TODO: DAN - email customers that used credit card that their $ has been refunded String Message = "Hello " + transaction.User.FirstName + ",\n\n" + "The transaction number " + transaction.TransactionNumber + " has been cancelled.\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(transaction.User.Email, "Transaction Cancelled", Message); } foreach (UserTicket t in transaction.UserTickets) { t.CurrentPrice = 0; t.Status = Status.Returned; t.SeatNumber = Seat.Seat; } db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Immediately closes OpenYS due to exception and shows the user the exception code. /// </summary> /// <param name="e"></param> public static void TerminateConsole(Exception e) { if (!console_present) { return; } //DumpPDB(); if (e is ThreadAbortException) { return; } Console.Locked = true; Console.WriteLine(ConsoleColor.Red, "OpenYS Has been terminated with error:"); Console.WriteLine(); Console.WriteLine(Debug.GetStackTrace(e)); string[] Email = Emailing.PrepareCrashReportEmail(e); //SendEmail(Email[0], Email[1]); Thread.Sleep(5000); //RemovePDB(); System.Environment.Exit(0); TerminateNow(); }
public bool BugReport(Exception e) { if (this == Clients.NoClient) { return(false); } if (e is ThreadAbortException) { return(false); } var st = new StackTrace(e, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth)); Console.WriteLine(ConsoleColor.Yellow, "OpenYS Has encountered an error"); Console.WriteLine(ConsoleColor.Yellow, "Thus, clients Packet Processing has been ignored."); Console.WriteLine(); Console.WriteLine(Debug.GetStackTrace(e)); Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth)); string[] Email = Emailing.PrepareBugReportEmail(e); Emailing.SendEmail(Email[0], Email[1]); return(true); }
private static void Run(string[] args) { //Initialisation #region Initialisation Thread.CurrentThread.Name = "OpenYS Client Core"; Threads.List.Add(Thread.CurrentThread); Console._LogOutput = Log.ConsoleOutput; Console._Process = CommandManager.ProcessConsole; Console.ConsolePrompt = "&cOpenYS&f->&f"; Console.Locked = true; if (Console.console_present) { System.Console.CursorVisible = false; System.Console.Clear(); System.Console.Title = "OpenYS - YSFlight Open Source Client"; } #region OYS_Console OpenYS.OpenYSConsole.SetConsole(); OpenYS.OpenYSConsole.SetFakeClient(); OpenYS.OpenYSConsole.Username = Settings.Options.ConsoleName; OpenYS.OpenYSConsole.OP(); #endregion #region OYS_BackgroundHandler OpenYS.OpenYSBackGround.SetController(); OpenYS.OpenYSBackGround.SetFakeClient(); OpenYS.OpenYSBackGround.Username = Settings.Options.SchedulerName; OpenYS.OpenYSBackGround.OP(); #endregion Sequencers.Process = CommandManager.ProcessScheduler; Schedulers.Process = CommandManager.ProcessScheduler; OpenYS.BuildType = OpenYS._BuildType.Client; Environment.EntryAssembly = Assembly.GetExecutingAssembly(); #endregion //Begin Program. #region TRY: #if RELEASE try { #endif #endregion #region MAIN LOOP //Loading #region Loading #region ? Argument if (args.Length > 0) { if (args[0] == "/?" | args[0] == "?") { if (Console.console_present) { System.Console.WriteLine("OpenYS Open Source Server Project. (C) OfficerFlake 2015"); System.Console.WriteLine(" "); System.Console.WriteLine(" Usage: OpenYS_Client.exe [HostAddress] [HostPort] [ListenerPortNumber]"); System.Console.WriteLine(" "); System.Console.WriteLine("Thanks for using OpenYS!"); System.Environment.Exit(0); } } } #endregion #region Clear Logs Files.FileDelete("./Logs/Client_Debug.Log"); Files.FileDelete("./Logs/Console.Log"); #endregion #region Introduction Console.WriteLine(ConsoleColor.Red, "Welcome to OpenYS Client!"); Console.WriteLine(); Console.WriteLine(ConsoleColor.DarkYellow, "This client allows your YSF Client to use the extended features of OpenYS!"); Console.WriteLine(); #endregion #region Version Number Console.WriteLine(ConsoleColor.Red, "You are using version:&e " + Environment.GetCompilationDate()); Console.WriteLine(); #endregion #region LoadSettings SettingsHandler.LoadAll(); SettingsHandler.Monitor(); #endregion #region InitialSettings OpenYS.OpenYSConsole.Username = Settings.Options.ConsoleName; OpenYS.OpenYSBackGround.Username = Settings.Options.SchedulerName; OpenYS.Field = new Packets.Packet_04_FieldName(Settings.Loading.FieldName); #endregion #region Check Arguments CheckArguments(args); #endregion #region Load Commands Commands.LoadAll(); #endregion #endregion //Connection Handling Services. #region Start Server Server.Listener.Start(); OpenYS.YSFListener.ServerStarted.WaitOne(); #endregion //Timing Services. #region Lock/Unlock Console Input Console.Locked = true; Console.WriteLine("\r"); //effectively refreshes the prompt... #endregion //Sequencers.LoadAll(); //Schedulers.LoadAll(); Thread.Sleep(Timeout.Infinite); Console.TerminateConsole("End Of Program"); return; #endregion #region CATCH #if RELEASE } catch (Exception e) { if (e is ThreadAbortException) { return; } Log.Error(e); #region TRY: #if RELEASE try { #endif #endregion #region Terminate Console.Locked = true; Console.WriteLine(ConsoleColor.Red, "OpenYS Has been terminated with error:"); Console.WriteLine(); Console.WriteLine(Debug.GetStackTrace(e)); Emailing.SendCrashReportEmail(e); Thread.Sleep(5000); //RemovePDB(); System.Environment.Exit(0); Console.WriteLine(); Console.Terminate.Set(); Console.Reader.Abort(); for (int i = 10 - 1; i > 0; i--) { Console.WriteLine(String.Format("\r&cOpenYS Will Restart In &f{0}&c Seconds. ", i + 1)); Thread.Sleep(1000); } Console.WriteLine(String.Format("\r&cOpenYS Will Restart In &f1&c Second. ")); Thread.Sleep(1000); for (int i = 3; i > 0; i--) { Console.WriteLine("\r&c!!!&f OpenYS Restarting &c!!! "); Thread.Sleep(500); Console.WriteLine("\r "); Thread.Sleep(500); } Environment.RestartNow(); #endregion #region CATCH #if RELEASE } catch (Exception e2) { Console.WriteLine("Safe Restart Failed... Sorry!"); Console.WriteLine(e2.Message); Log.Error(e2); Thread.Sleep(Timeout.Infinite); Console.TerminateConsole("End Of Program"); return; } #endif #endregion } #endif #endregion }
protected void BtngEnviar_Click(object sender, EventArgs e) { string sLicenciatario = string.Empty; string sNoContrato = string.Empty; string sTxtComentarios = txtcomentarios.Text; if (!string.IsNullOrEmpty(numcontrato.Value)) { DBConn oConn = new DBConn(); if (oConn.Open()) { cContratos oContratos = new cContratos(ref oConn); oContratos.NumContrato = numcontrato.Value; DataTable dtContrato = oContratos.Get(); if (dtContrato != null) { if (dtContrato.Rows.Count > 0) { sNoContrato = dtContrato.Rows[0]["no_contrato"].ToString(); cDeudor oDeudor = new cDeudor(ref oConn); oDeudor.NKeyDeudor = dtContrato.Rows[0]["nkey_deudor"].ToString(); DataTable dtDeudor = oDeudor.Get(); if (dtDeudor != null) { if (dtDeudor.Rows.Count > 0) { sLicenciatario = dtDeudor.Rows[0]["snombre"].ToString(); } } dtDeudor = null; } } dtContrato = null; } oConn.Close(); } StringBuilder sMensaje = new StringBuilder(); sMensaje.Append("<html>"); sMensaje.Append("<body>"); if (!string.IsNullOrEmpty(numcontrato.Value)) { sMensaje.Append("Licenciatario : ").Append(sLicenciatario).Append("<br>"); sMensaje.Append("Contrato : ").Append(sNoContrato).Append("<br>"); sMensaje.Append("Periodo : ").Append(periodo.Value).Append("<br>"); } sMensaje.Append("Motivo Rechazo : ").Append(sTxtComentarios).Append("<br>"); sMensaje.Append("</body>"); sMensaje.Append("</html>"); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = Application["EmailSender"].ToString(); if (!string.IsNullOrEmpty(numcontrato.Value)) { oEmailing.Subject = "Rechazo de factura periodo " + periodo.Value + ", contrato " + sNoContrato + " de Licenciatario " + sLicenciatario; } else { oEmailing.Subject = "Rechazo de todas las facturas shortfall del sistema Licenciatario "; } oEmailing.Body = sMensaje; StringBuilder js = new StringBuilder(); js.Append("function LgRespuesta() {"); if (oEmailing.EmailSend()) { js.Append(" window.radalert('El rechazo fue enviado exitosamente.', 400, 100,''); "); } else { js.Append(" window.radalert('El rechazo no pudo ser enviado, intente más tarde.', 400, 100,''); "); } js.Append(" Sys.Application.remove_load(LgRespuesta); "); js.Append("};"); js.Append("Sys.Application.add_load(LgRespuesta);"); Page.ClientScript.RegisterStartupScript(Page.GetType(), "LgRespuesta", js.ToString(), true); txtcomentarios.Text = string.Empty; bx_msRechazo.Visible = false; bx_msRealizado.Visible = true; }
void oButton_Click(object sender, EventArgs e) { bool bExecMail = false; string sDireccion = sDireccion = "."; DBConn oConn = new DBConn(); if (oConn.Open()) { string cPath = Server.MapPath("."); string sSubject = string.Empty; string sNomApeUsrOrigen = string.Empty; string sEmailDestino = string.Empty; SysUsuario sUsuario; StringBuilder oHtml = new StringBuilder(); BinaryUsuario dUser; StringBuilder sFile = new StringBuilder(); SysRelacionUsuarios oRelacionUsuarios; StringBuilder oFolder = new StringBuilder(); oFolder.Append(Server.MapPath(".")).Append(@"\binary\"); string sType = (sender as Button).Attributes["sType"].ToString(); switch (sType) { case "P": oRelacionUsuarios = new SysRelacionUsuarios(ref oConn); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.EstRelacion = "P"; oRelacionUsuarios.Accion = "CREAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuario"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.EstRelacion = "C"; oRelacionUsuarios.Accion = "CREAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuarioRel"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); sUsuario = new SysUsuario(); sUsuario.Path = cPath; sUsuario.CodUsuario = (sender as Button).Attributes["CodUsuario"].ToString(); dUser = sUsuario.ClassGet(); if (dUser != null) { sNomApeUsrOrigen = dUser.NomUsuario + " " + dUser.ApeUsuario; } dUser = null; sUsuario.CodUsuario = (sender as Button).Attributes["CodUsuarioRel"].ToString(); dUser = sUsuario.ClassGet(); if (dUser != null) { sEmailDestino = dUser.EmlUsuario; } dUser = null; oHtml.Append("<HTML><BODY><p><font face=verdana size=2>").Append(sNomApeUsrOrigen); oHtml.Append("<br>").Append(oCulture.GetResource("Mensajes", "sMessage04")).Append("</font></p></BODY></HTML>"); sSubject = sNomApeUsrOrigen + oCulture.GetResource("Mensajes", "sMessage03") + Application["SiteName"].ToString(); sDireccion = "Escort.aspx?CodUsuario=" + (sender as Button).Attributes["CodUsuarioRel"].ToString(); bExecMail = true; break; case "C": oRelacionUsuarios = new SysRelacionUsuarios(ref oConn); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.EstRelacion = "V"; oRelacionUsuarios.Accion = "EDITAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuario"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.EstRelacion = "V"; oRelacionUsuarios.Accion = "EDITAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuarioRel"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); sUsuario = new SysUsuario(); sUsuario.Path = cPath; sUsuario.CodUsuario = (sender as Button).Attributes["CodUsuario"].ToString(); dUser = sUsuario.ClassGet(); if (dUser != null) { sNomApeUsrOrigen = dUser.NomUsuario + " " + dUser.ApeUsuario; } dUser = null; sUsuario.CodUsuario = (sender as Button).Attributes["CodUsuarioRel"].ToString(); dUser = sUsuario.ClassGet(); if (dUser != null) { sEmailDestino = dUser.EmlUsuario; } dUser = null; oHtml.Append("<HTML><BODY><p><font face=verdana size=2>").Append(sNomApeUsrOrigen); oHtml.Append("<br>").Append(oCulture.GetResource("Mensajes", "sMessage05")).Append("</font></p></BODY></HTML>"); sSubject = sNomApeUsrOrigen + oCulture.GetResource("Mensajes", "sMessage05"); bExecMail = true; break; case "N": oRelacionUsuarios = new SysRelacionUsuarios(ref oConn); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.Accion = "ELIMINAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuario"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); oRelacionUsuarios.CodUsuario = (sender as Button).Attributes["CodUsuarioRel"].ToString(); oRelacionUsuarios.CodUsuarioRel = (sender as Button).Attributes["CodUsuario"].ToString(); oRelacionUsuarios.Accion = "ELIMINAR"; oRelacionUsuarios.Put(); sFile.Length = 0; sFile.Append("RelacionUsuario_").Append((sender as Button).Attributes["CodUsuarioRel"].ToString()).Append(".bin"); oRelacionUsuarios.SerializaTblRelacionUsuarios(ref oConn, oFolder.ToString(), sFile.ToString()); break; } if (bExecMail) { Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = sEmailDestino; oEmailing.Subject = sSubject; oEmailing.Body = oHtml; oEmailing.EmailSend(); } oConn.Close(); } Response.Redirect(sDireccion); }
private static void Run(string[] args) { //Initialisation #region Initialisation Thread.CurrentThread.Name = "OpenYS Server Core"; Threads.List.Add(Thread.CurrentThread); Console._LogOutput = Log.ConsoleOutput; Console._Process = CommandManager.ProcessConsole; Console.ConsolePrompt = "&3OpenYS&f->&f"; Console.Locked = true; System.Console.CursorVisible = false; System.Console.Title = "OpenYS - YSFlight Open Source Server"; System.Console.Clear(); #region OYS_Console OpenYS.OpenYSConsole.SetConsole(); OpenYS.OpenYSConsole.SetFakeClient(); OpenYS.OpenYSConsole.Username = Settings.Options.ConsoleName; OpenYS.OpenYSConsole.OP(); OpenYS.OpenYSConsole.YSFClient.ConnectionContext = ClientIO.ConnectionContexts.Connectionless; #endregion #region OYS_BackgroundHandler OpenYS.OpenYSBackGround.SetController(); OpenYS.OpenYSBackGround.SetFakeClient(); OpenYS.OpenYSBackGround.Username = Settings.Options.SchedulerName; OpenYS.OpenYSBackGround.OP(); OpenYS.OpenYSBackGround.YSFClient.ConnectionContext = ClientIO.ConnectionContexts.Connectionless; #endregion Sequencers.Process = CommandManager.ProcessScheduler; Schedulers.Process = CommandManager.ProcessScheduler; OpenYS.BuildType = OpenYS._BuildType.Server; Environment.EntryAssembly = Assembly.GetExecutingAssembly(); #endregion //Begin Program. #region TRY: #if RELEASE try { #endif #endregion #region MAIN LOOP while (!Environment.TerminateSignal.WaitOne(0)) { //Loading #region Loading #region ? Argument if (args.Length > 0) { if (args[0] == "/?" | args[0] == "?") { System.Console.WriteLine("OpenYS Open Source Server Project. (C) OfficerFlake 2015"); System.Console.WriteLine(" "); System.Console.WriteLine(" Usage: OpenYS_Client.exe [HostAddress] [HostPort] [ListenerPortNumber]"); System.Console.WriteLine(" "); System.Console.WriteLine("Thanks for using OpenYS!"); System.Environment.Exit(0); } } #endregion #region Clear Logs Files.FileDelete("./Logs/Client_Debug.Log"); Files.FileDelete("./Logs/Console.Log"); #endregion #region Introduction Console.WriteLine(ConsoleColor.Cyan, "Welcome to OpenYS Client!"); Console.WriteLine(); #endregion #region Version Number Console.WriteLine(ConsoleColor.DarkCyan, "You are using version:&e " + Environment.GetCompilationDate()); Console.WriteLine(); #endregion #region LoadSettings SettingsHandler.LoadAll(); SettingsHandler.Monitor(); #endregion #region InitialSettings OpenYS.OpenYSConsole.Username = Settings.Options.ConsoleName; OpenYS.OpenYSBackGround.Username = Settings.Options.SchedulerName; Environment.OwnerName = Settings.Options.OwnerName; Environment.OwnerEmail = Settings.Options.OwnerEmail; Environment.ServerName = Settings.Options.ServerName; OpenYS.Field = new Packets.Packet_04_FieldName(Settings.Loading.FieldName); #endregion #region Check Arguments CheckArguments(args); #endregion #region Load Commands Commands.LoadAll(); #endregion #region Load YSF FormatYSFDirectory(); if (!Directories.DirectoryExists(Settings.Loading.YSFlightDirectory)) { Console.TerminateConsole("YSFlight Directory Not Found."); } LoadAllMetaData(); if (!World.Load(OpenYS.Field.FieldName)) { Console.TerminateConsole("FLD Name not found."); } #endregion #region Load Games Games.Racing.Initialise(); //Console.WriteLine(); #endregion #region Loading Complete! Console.WriteLine(""); Console.WriteLine(ConsoleColor.DarkYellow, "Loading Complete!"); Console.WriteLine(""); #endregion #endregion //Connection Handling Services. #region Start Server Server.Listener.Start(); OpenYS.YSFListener.ServerStarted.WaitOne(); #endregion #region External IP & IRC Threads.Add(() => { #region IRC IRC.Init(); IRC.Start(); #endregion #region External IP //Console.WriteLine(); //Console.WriteLine("&6Fetching External IP..."); //Console.WriteLine(); var ExternalIP = Environment.ExternalIP; //Console.WriteLine("&6External IP: " + Environment.ExternalIP.ToString()); #endregion }, "IRC/External IP Loading..."); //Console.WriteLine(); #endregion //Timing Services. #region Restart Timer OpenYS.StartResetTimer(); #endregion #region Lock/Unlock Console Input Console.Locked = false; Console.WriteLine("\r"); //effectively refreshes the prompt... #endregion #region SetServerTime OpenYS.SetServerTimeTicks(Settings.Weather.Time * 10); #endregion int SeqLoaded = Sequencers.LoadAll(); int SchLoaded = Schedulers.LoadAll(); Thread.Sleep(10); int LoopsPassed = 0; while (!OpenYS.Signal_ResetServer.WaitOne(0)) { #region Start Tick Update! DateTime StartUpdate = DateTime.Now; #endregion OpenYS.PollResetTimer(); //OpenYS.MicroTick(); //OpenYS.MacroTick(); //OpenYS.UpdateTimeOfDay(); //Schedulers.Poll(); //Sequencers.Poll(); //YSFlightReplays.ServerReplay.SendUpdate(); #region End Tick Update! DateTime EndUpdate = DateTime.Now; #endregion #region MicroTick Delay OpenYS.Time_LastMicroTick = DateTime.Now; int ThisUpdateTotalTime = (int)Math.Ceiling(((TimeSpan)(EndUpdate - StartUpdate)).TotalMilliseconds); if (ThisUpdateTotalTime < 100) { Thread.Sleep(100 - ThisUpdateTotalTime); //Micro Tick Delay. } //No Delay, resume immediately! - The update took over 100m/s! #endregion LoopsPassed++; } //We should reset now. //OpenYS.TickUpdaterThread.Abort(); Schedulers.StopAll(); Sequencers.StopAll(); Server.Listener.Stop(); Console.Clear(); args = Environment.CommandLineArguments; //Utilities.Restart(); } #endregion #region CATCH #if RELEASE } catch (Exception e) { if (e is ThreadAbortException) { return; } Log.Error(e); #region TRY: #if RELEASE try { #endif #endregion #region Terminate Console.Locked = true; Console.WriteLine(ConsoleColor.Red, "OpenYS Has been terminated with error:"); Console.WriteLine(); Console.WriteLine(Debug.GetStackTrace(e)); Emailing.SendCrashReportEmail(e); Thread.Sleep(5000); //RemovePDB(); System.Environment.Exit(0); Console.WriteLine(); Console.Terminate.Set(); Console.Reader.Abort(); for (int i = 10 - 1; i > 0; i--) { Console.WriteLine(String.Format("\r&cOpenYS Will Restart In &f{0}&c Seconds. ", i + 1)); Thread.Sleep(1000); } Console.WriteLine(String.Format("\r&cOpenYS Will Restart In &f1&c Second. ")); Thread.Sleep(1000); for (int i = 3; i > 0; i--) { Console.WriteLine("\r&c!!!&f OpenYS Restarting &c!!! "); Thread.Sleep(500); Console.WriteLine("\r "); Thread.Sleep(500); } Environment.RestartNow(); #endregion #region CATCH #if RELEASE } catch (Exception e2) { Console.WriteLine("Safe Restart Failed... Sorry!"); Console.WriteLine(e2.Message); Log.Error(e2); Thread.Sleep(Timeout.Infinite); Console.TerminateConsole("End Of Program"); return; } #endif #endregion } #endif #endregion }
protected void BtnAceptar_Click(object sender, EventArgs e) { dvRecomiendame.Visible = false; dvMsgResult.Visible = true; if (bEmailOk) { DataTable dParamEmail = oWeb.DeserializarTbl(Server.MapPath("."), "ParamEmail.bin"); if (dParamEmail != null) { if (dParamEmail.Rows.Count > 0) { DataRow[] oRows = dParamEmail.Select(" tipo_email = 'R' "); if (oRows != null) { if (oRows.Count() > 0) { string sNomUsuario = string.Empty; string sClientNom = string.Empty; dUsuario = new BinaryUsuario(); oUsuario = new SysUsuario(); oUsuario.Path = Server.MapPath("."); oUsuario.CodUsuario = CodUsuario.Value; dUsuario = oUsuario.ClassGet(); if (dUsuario != null) { sNomUsuario = dUsuario.NomUsuario + " " + dUsuario.ApeUsuario; } dUsuario = null; StringBuilder sPath = new StringBuilder(); StringBuilder sFile = new StringBuilder(); sFile.Append("UserArchivo_").Append(CodUsuario.Value).Append(".bin"); DataTable dArchivoUsuario = oWeb.DeserializarTbl(Server.MapPath("."), sFile.ToString()); if (dArchivoUsuario != null) { if (dArchivoUsuario.Rows.Count > 0) { DataRow[] oRowsImg = dArchivoUsuario.Select(" tip_archivo = 'P' "); if (oRowsImg != null) { if (oRowsImg.Count() > 0) { sPath.Append("/rps_onlineservice/escorts/escort_"); sPath.Append(CodUsuario.Value); sPath.Append("/"); sPath.Append(oRowsImg[0]["nom_archivo"].ToString()); } } oRowsImg = null; } dArchivoUsuario = null; } if (!string.IsNullOrEmpty(oIsUsuario.CodUsuario)) { sClientNom = oIsUsuario.Nombres; } else { sClientNom = txtNombre.Text; } StringBuilder sAsunto = new StringBuilder(); sAsunto.Append(oRows[0]["asunto_email"].ToString()); sAsunto.Replace("[USUARIO]", sNomUsuario); sAsunto.Replace("[CLIENTE]", sClientNom); StringBuilder oHtml = new StringBuilder(); oHtml.Append(oRows[0]["cuerpo_email"].ToString()); oHtml.Replace("[NOMBRE]", sClientNom); oHtml.Replace("[NOMBREAMIGO]", txtNombreAmigo.Text); oHtml.Replace("[USUARIO]", sNomUsuario); oHtml.Replace("[SITIO]", "http://" + Request.ServerVariables["HTTP_HOST"].ToString()); oHtml.Replace("[DATALINK]", "?fts=t&tp=rmd&tu=" + HttpUtility.UrlEncode(oWeb.Crypt(CodUsuario.Value))); oHtml.Replace("[IMGPHOTOUSER]", sPath.ToString()); oHtml.Replace("[NOMBRESITIO]", Application["SiteName"].ToString()); oHtml.Replace("[COMENTARIO]", txtComentario.Text); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = txtEmail.Text; oEmailing.Subject = sAsunto.ToString(); oEmailing.Body = oHtml; if (oEmailing.EmailSend()) { lblMsgResult.Text = oCulture.GetResource("Contactenos", "lblMsgResultOk"); } else { lblMsgResult.Text = oCulture.GetResource("Contactenos", "lblMsgResultNok"); } } } } } } else { lblMsgResult.Text = oCulture.GetResource("Contactenos", "lblMsgResultNok"); } }
public ActionResult Reschedule([Bind(Include = "ShowingID,ShowDate,StartHour,StartMinute,Theater, ShowingPrice")] Showing showing) { Showing showingToChange = db.Showings.Include(x => x.Schedule) .FirstOrDefault(x => x.ShowingID == showing.ShowingID); DateTime oldShowDate = showingToChange.ShowDate; //Alina added things here DateTime newShowDate = showing.ShowDate; DateTime newEndTime = newShowDate.Add(showingToChange.Movie.Runtime); Theater newTheater = showing.Theater; String ValResults = Utilities.ScheduleValidation.RescheduleValidation(newShowDate, newEndTime, newTheater); // take back to Schedules/Details if Schedule is unpublished if (showingToChange.Schedule.Published == false) { ViewBag.RescheduleError = "Schedule is unpublished. Click 'Edit' to change showings."; return(RedirectToAction("Details", "Schedules", new { id = showingToChange.Schedule.ScheduleID })); } if (ModelState.IsValid) { showingToChange.ShowDate = showing.ShowDate; showingToChange.ShowDate = showingToChange.ShowDate.AddHours(showing.StartHour).AddMinutes(showing.StartMinute).AddSeconds(0); showingToChange.StartHour = showing.StartHour; showingToChange.StartMinute = showing.StartMinute; showingToChange.EndTime = showingToChange.ShowDate.Add(showingToChange.Movie.Runtime); showingToChange.ShowingPrice = Utilities.DiscountPrice.GetBasePrice(showingToChange); // check if showing is range of current schedule if (ScheduleValidation.ShowingInRange(showingToChange)) { String ValidationMessage = ScheduleValidation.ShowingValidation(showingToChange); // checks is showing fits into current schedule if (ValidationMessage == "ok" && ValResults == "ok") { db.Entry(showingToChange).State = EntityState.Modified; db.SaveChanges(); // email each user who bought a ticket that showing has been rescheduled foreach (UserTicket t in showingToChange.UserTickets) { String Message = "Hello " + t.Transaction.User.FirstName + ",\n\n" + "The " + oldShowDate + " " + showingToChange.Movie.Title + " showing has been rescheduled to " + showingToChange.ShowDate + ".\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(t.Transaction.User.Email, "Showing Rescheduled", Message); } return(RedirectToAction("Details", "Schedules", new { id = showingToChange.Schedule.ScheduleID })); } else { ViewBag.ErrorMessage = ValidationMessage; ViewBag.ErrorMessage2 = ValResults; } } else { ViewBag.OutOfRange = "Show date is out of schedule date range"; } } return(View(showing)); }
void oButton_Click(object sender, EventArgs e) { string sNomApeUsrOrigen = string.Empty; string sEmailDestino = string.Empty; string pCodContenido = string.Empty; BinaryUsuario dUser; StringBuilder sFile = new StringBuilder(); DBConn oConn = new DBConn(); try { if (oConn.Open()) { oConn.BeginTransaction(); StringBuilder oFolder = new StringBuilder(); oFolder.Append(Server.MapPath(".")).Append(@"\binary\"); CmsContenidos oContenidos = new CmsContenidos(ref oConn); if (!string.IsNullOrEmpty((sender as Button).Attributes["CodContenidoRel"].ToString())) { oContenidos.CodContenidoRel = (sender as Button).Attributes["CodContenidoRel"].ToString(); } oContenidos.CodUsuario = oIsUsuario.CodUsuario; oContenidos.CodUsuarioRel = HttpContext.Current.Session["CodUsuarioPerfil"].ToString(); oContenidos.TextoContenido = (string.IsNullOrEmpty((sender as Button).Attributes["CodContenidoRel"].ToString()) ? (this.FindControl("txtComent_" + oIsUsuario.CodUsuario) as TextBox).Text : (this.FindControl("txt_" + (sender as Button).Attributes["CodContenidoRel"].ToString()) as TextBox).Text); oContenidos.EstContenido = "P"; oContenidos.CodNodo = pCodNodo; oContenidos.DateContenido = DateTime.Now.ToString(); oContenidos.PrvContendio = "4"; oContenidos.IpUsuario = Request.ServerVariables["REMOTE_ADDR"].ToString(); oContenidos.Accion = "CREAR"; oContenidos.Put(); pCodContenido = oContenidos.CodContenido; if (string.IsNullOrEmpty(oContenidos.Error)) { oConn.Commit(); /*sFile.Append("ContenidoUsuario_").Append(oIsUsuario.CodUsuario).Append(".bin"); * oContenidos.CodUsuarioRel = oIsUsuario.CodUsuario; * oContenidos.SerializaTblContenidoByUser(ref oConn, oFolder.ToString(), sFile.ToString()); * * sFile.Length = 0; * sFile.Append("ContenidoUsuario_").Append(HttpContext.Current.Session["CodUsuarioPerfil"].ToString()).Append(".bin"); * oContenidos.CodUsuario = HttpContext.Current.Session["CodUsuarioPerfil"].ToString(); * oContenidos.CodUsuarioRel = HttpContext.Current.Session["CodUsuarioPerfil"].ToString(); * oContenidos.SerializaTblContenidoByUser(ref oConn, oFolder.ToString(), sFile.ToString());*/ //sFile.Length = 0; //sFile.Append("Contenidos.bin"); oContenidos.SerializaContenidos(ref oConn, oFolder.ToString(), "Contenidos.bin"); oLog.CodEvtLog = "002"; oLog.IdUsuario = oLog.IdUsuario = (!string.IsNullOrEmpty(oIsUsuario.CodUsuario) ? oIsUsuario.CodUsuario : "-1"); oLog.ObsLog = "<COMENTARIOA>" + Session["CodUsuarioPerfil"].ToString(); //oLog.putLog(); SysUsuario oUsuario = new SysUsuario(); oUsuario.Path = Server.MapPath("."); oUsuario.CodUsuario = oIsUsuario.CodUsuario; dUser = oUsuario.ClassGet(); if (dUser != null) { sNomApeUsrOrigen = dUser.NomUsuario + " " + dUser.ApeUsuario; } dUser = null; oUsuario.CodUsuario = HttpContext.Current.Session["CodUsuarioPerfil"].ToString(); dUser = oUsuario.ClassGet(); if (dUser != null) { sEmailDestino = dUser.EmlUsuario; } dUser = null; StringBuilder sAsunto = new StringBuilder(); StringBuilder oHtml = new StringBuilder(); DataTable dParamEmail = oWeb.DeserializarTbl(Server.MapPath("."), "ParamEmail.bin"); if (dParamEmail != null) { if (dParamEmail.Rows.Count > 0) { DataRow[] oRows = dParamEmail.Select(" tipo_email = 'N' "); if (oRows != null) { if (oRows.Count() > 0) { sAsunto.Append(oRows[0]["asunto_email"].ToString()); sAsunto.Replace("[NOMBRESITIO]", Application["SiteName"].ToString()); sAsunto.Replace("[USUARIO]", sNomApeUsrOrigen); oHtml.Append(oRows[0]["cuerpo_email"].ToString()); oHtml.Replace("[NOMBRE]", sNomApeUsrOrigen); oHtml.Replace("[CUERPO]", (string.IsNullOrEmpty((sender as Button).Attributes["CodContenidoRel"].ToString()) ? (this.FindControl("txtComent_" + oIsUsuario.CodUsuario) as TextBox).Text : (this.FindControl("txt_" + (sender as Button).Attributes["CodContenidoRel"].ToString()) as TextBox).Text)); oHtml.Replace("[SITIO]", "http://" + Request.ServerVariables["HTTP_HOST"].ToString()); oHtml.Replace("[NOMBRESITIO]", Application["SiteName"].ToString()); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = sEmailDestino; oEmailing.Subject = (!string.IsNullOrEmpty(sAsunto.ToString()) ? sAsunto.ToString() : sNomApeUsrOrigen + oCulture.GetResource("Mensajes", "sMessage01") + Application["SiteName"].ToString()); oEmailing.Body = oHtml; oEmailing.EmailSend(); } } oRows = null; } } dParamEmail = null; } else { oConn.Rollback(); } oConn.Close(); } } catch (Exception Ex) { if (oConn.bIsOpen) { oConn.Rollback(); oConn.Close(); } } Response.Redirect("."); }
public async Task <ActionResult> RegisterCustomer(RegisterViewModel model) { var age = DateTime.Now.Year - model.Birthday.Year; if (age < 13) { ViewBag.Error = "Customers must be 13 years of age."; return(View(model)); } List <String> AllEmails = new List <String>(); foreach (AppUser user in db.Users) { AllEmails.Add(user.Email); } if (AllEmails.Contains(model.Email)) { ViewBag.Error = "An account already exists for that email address."; return(View(model)); } if (ModelState.IsValid) { //Add fields to user here so they will be saved to do the database var user = new AppUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, MiddleInitial = model.MiddleInitial, LastName = model.LastName, Street = model.Street, City = model.City, State = model.State, Zip = model.Zip, PhoneNumber = model.PhoneNumber, Birthday = model.Birthday }; var result = await UserManager.CreateAsync(user, model.Password); //Once you get roles working, you may want to add users to roles upon creation await UserManager.AddToRoleAsync(user.Id, "Customer"); // --OR-- // await UserManager.AddToRoleAsync(user.Id, "Employee"); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); String Message = "Hello " + model.FirstName + ",\n" + "a Longhorn Cinemas account has been created for you." + ".\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(model.Email, "Your Longhorn Cinemas Account", Message); return(RedirectToAction("EmployeeHome")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
protected void btnOlvPpwd_Click(object sender, EventArgs e) { string sCodUsrCrypt = string.Empty; string sNombApeUsuario = string.Empty; string sNombCrypt = string.Empty; if (bEmailOk) { DataTable dUsuario = oWeb.DeserializarTbl(Server.MapPath("."), "Usuarios.bin"); if (dUsuario != null) { DataRow[] oRow = dUsuario.Select(" eml_usuario = '" + txtEmlOlvPwd.Text + "' and est_usuario = 'V' "); if (oRow != null) { if (oRow.Count() > 0) { sCodUsrCrypt = oWeb.Crypt(oRow[0]["cod_usuario"].ToString()); sNombApeUsuario = (oRow[0]["nom_usuario"].ToString() + " " + oRow[0]["ape_usuario"].ToString()).Trim(); //sNombCrypt = oWeb.Crypt(sNombApeUsuario); DataTable dParamEmail = oWeb.DeserializarTbl(Server.MapPath("."), "ParamEmail.bin"); if (dParamEmail != null) { if (dParamEmail.Rows.Count > 0) { DataRow[] oRows = dParamEmail.Select(" tipo_email = 'W' "); if (oRows != null) { if (oRows.Count() > 0) { StringBuilder sAsunto = new StringBuilder(); sAsunto.Append(oRows[0]["asunto_email"].ToString()); sAsunto.Replace("[NOMBRESITIO]", Application["SiteName"].ToString()); StringBuilder oHtml = new StringBuilder(); oHtml.Append(oRows[0]["cuerpo_email"].ToString()); oHtml.Replace("[NOMBRE]", sNombApeUsuario); oHtml.Replace("[SITIO]", "http://" + Request.ServerVariables["HTTP_HOST"].ToString()); oHtml.Replace("[DATALINK]", "?fts=t&tp=lvc&tk=" + sCodUsrCrypt); oHtml.Replace("[NOMBRESITIO]", Application["SiteName"].ToString()); Emailing oEmailing = new Emailing(); oEmailing.FromName = Application["NameSender"].ToString(); oEmailing.From = Application["EmailSender"].ToString(); oEmailing.Address = txtEmlOlvPwd.Text; oEmailing.Subject = sAsunto.ToString(); oEmailing.Body = oHtml; if (!oEmailing.EmailSend()) { context_olvpwd.Visible = false; context_olvpwd_resp.Visible = true; ttlmsnolvpwd_resp.Text = oCulture.GetResource("LoginUsers", "lblErrOlvPwdTtResp"); lblmsnolvpwd_resp.Text = oCulture.GetResource("LoginUsers", "lblErrOlvPwdResp"); } else { context_olvpwd.Visible = false; context_olvpwd_resp.Visible = true; ttlmsnolvpwd_resp.Text = oCulture.GetResource("LoginUsers", "lblMsnOlvPwdExitTt"); lblmsnolvpwd_resp.Text = oCulture.GetResource("LoginUsers", "lblMsnOlvPwdExitRsp"); } } } } } } else { context_lblmsnoextpwd.Visible = true; lblmsnoextpwd.Text = oCulture.GetResource("LoginUsers", "lblNoExistePwd") + " " + txtEmlOlvPwd.Text; txtEmlOlvPwd.Text = ""; } dUsuario = null; } } } else { context_lblmsnoextpwd.Visible = true; lblmsnoextpwd.Text = oCulture.GetResource("Error", "sError01"); txtEmlOlvPwd.Text = ""; } }
//TODO: Removing tickets public ActionResult DeleteConfirmed(int id) { UserTicket userTicket = db.UserTickets.Find(id); if (userTicket.Status == Status.Pending) { // delete ticket Transaction t = userTicket.Transaction; t.UserTickets.Remove(userTicket); db.UserTickets.Remove(userTicket); db.SaveChanges(); // recaculate prices for all tickets in transaction foreach (UserTicket ticket in t.UserTickets) { ticket.CurrentPrice = DiscountPrice.GetTicketPrice(ticket); db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("PendingDetails", "Transactions", new { id = t.TransactionID })); } else { Transaction t = userTicket.Transaction; if (userTicket.Showing.ShowDate > DateTime.Now.AddHours(1)) { userTicket.CurrentPrice = 0; userTicket.Status = Status.Returned; userTicket.SeatNumber = Seat.Seat; db.SaveChanges(); if (t.Payment == Payment.PopcornPoints) { t.User.PopcornPoints += 100; t.PopcornPointsSpent -= 100; db.SaveChanges(); } if (t.Payment != Payment.PopcornPoints) { Int32 intPopPoints = Convert.ToInt32(userTicket.CurrentPrice - (userTicket.CurrentPrice % 1)); t.User.PopcornPoints -= intPopPoints; db.SaveChanges(); String Message = "Hello " + userTicket.Transaction.User.FirstName + ",\n\n" + "The ticket for " + userTicket.Showing.ShowDate + userTicket.Showing.Movie.Title + " has been canceled.\n\n" + "Love,\n" + "Dan"; Emailing.SendEmail(userTicket.Transaction.User.Email, "Ticket Canceled", Message); } return(RedirectToAction("Details", "Transactions", new { id = t.TransactionID })); } else { ViewBag.Error = "Tickets for movies less than one hour from the current time may not be cancelled"; } return(View(userTicket)); } }