Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var bus = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://localhost/"), hst =>
                {
                    hst.Username("guest");
                    hst.Password("guest");
                });
            });

            var           senUri = new Uri("rabbitmq://localhost/MailQue");
            ISendEndpoint send   = bus.GetSendEndpoint(senUri).Result;

            UserMail mail1 = new UserMail()
            {
                User = new User {
                    Mail = "*****@*****.**", Name = "feyyaz acet"
                }, Subject = "Sample MassTransit With RabbitMQ  ", Body = "RabbitMQ and MassTransit say Hello"
            };

            send.Send(mail1).Wait();

            UserMail mail2 = new UserMail()
            {
                User = new User {
                    Mail = "*****@*****.**", Name = "feyyaz acet"
                }, Subject = "Sample MassTransit With RabbitMQ  ", Body = "RabbitMQ and MassTransit say Hello"
            };

            send.Send(mail2).Wait();

            Console.ReadKey();
        }
Exemplo n.º 2
0
 public void SetSystem(UISocialManager manager, UserMail userMail)
 {
     _manager       = manager;
     _userMail      = userMail;
     lblTime.text   = userMail.SendTime.ToString(GameManager.localization.GetText("Arena_LastMatchFormatDate"));
     lblHeader.text = _userMail.Title;
 }
Exemplo n.º 3
0
        public void UpdateMailRead(int userID, MailReadUpdate mailRead)
        {
            UserMail userMail = _context.UserMails.Where(um => um.MailID == mailRead.MailID && um.UserID == userID).First();

            userMail.Read = mailRead.Read;
            _context.SaveChanges();
        }
Exemplo n.º 4
0
        public ActionResult ForgotPassword(string emailValue, int Type)
        {
            try
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    string link = string.Empty;
                    var    user = ctx.Users.Where(a => a.Email == emailValue).FirstOrDefault();
                    if (user != null && user.UsersID > 0)
                    {
                        string resetPasswordParameter        = string.Format("{0}#{1}#{2}", SystemEnum.RoleType.User.GetHashCode(), user.UsersID, DateTime.Now.AddMinutes(ProjectConfiguration.ResetPasswordExpireTime).ToString(ProjectConfiguration.EmailDateTimeFormat));
                        string encryptResetPasswordParameter = EncryptionDecryption.GetEncrypt(resetPasswordParameter);
                        string encryptResetPasswordUrl       = string.Format("{0}?q={1}", ProjectConfiguration.SiteUrlBase + TradingLicense.Web.Pages.Controllers.Account + "/" + Actions.ResetPassword, encryptResetPasswordParameter);

                        if (UserMail.SendForgotPassword(user.Email, user.Username, encryptResetPasswordUrl))
                        {
                            return(Json(new object[] { Convert.ToInt32(MessageType.success), MessageType.success.ToString(), Messages.Mailsend }, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            return(Json(new object[] { Convert.ToInt32(MessageType.danger), MessageType.danger.ToString(), Messages.ContactToAdmin }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json(new object[] { Convert.ToInt32(MessageType.danger), MessageType.danger.ToString(), Messages.InvalidEmail }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                // ErrorLogHelper.Log(ex);
                return(Json(new object[] { Convert.ToInt32(MessageType.danger), MessageType.danger.ToString(), Messages.ContactToAdmin }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
        protected void btnSubmitAll_Click(object sender, EventArgs e)
        {
            if (txtEmailTo.Text.Trim() != "")
            {
                string   directoryPath = @"D:\Projects\Smart Library\Source Code\trunk\SmartLibrary.Admin\EmailTemplates";
                bool     sent          = false;
                string[] fileEntries   = Directory.GetFiles(directoryPath);
                foreach (string fileName in fileEntries)
                {
                    if (!fileName.Contains("MasterEmailTemplate"))
                    {
                        sent = UserMail.SendTestEmail(fileName.Replace(directoryPath, "").Replace("\\", "").Replace(".html", ""), txtEmailTo.Text.Trim());
                    }
                }

                if (sent)
                {
                    lblError.Text = "Email Sent Successfully.";
                }
                else
                {
                    lblError.Text = "There is an error while sending email.";
                }
            }
        }
Exemplo n.º 6
0
        public async Task <bool> AutCreateAccountAsync(UserMail userMail)
        {
            var user = new ApplyTriadfsUser {
                UserName = userMail.emailid, Email = userMail.emailid, FullName = userMail.FirstName
            };
            var result = await _userManager.CreateAsync(user, userMail.pwd);

            if (result.Succeeded)
            {
                //  _logger.LogInformation("User created a new account with password.");
                var loggedIn = await _signInManager.PasswordSignInAsync(userMail.emailid, userMail.pwd, false, lockoutOnFailure : false);

                if (loggedIn.Succeeded)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public bool AddData(UserMail obj)
        {
            obj.CrateDate = DateTime.Now;
            dbcontext.UserMail.Add(obj);
            if (obj.Type == "年假")
            {
                float day = GetVocation(obj.UserId) - obj.SumDay;  //请年假减去年假
                if (day < 0)
                {
                    return(false);
                }
                else
                {
                    var UpdateVocation = (from x in dbcontext.UserVocation where x.UserId == obj.UserId select x).FirstOrDefault();
                    UpdateVocation.Vacation = day;
                }
            }

            if (dbcontext.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        public JsonResult InviteCustomer(string email)
        {
            Customer objCustomer      = this.memberDataBL.GetCustomerList(new Customer()).Where(x => x.Email == email).FirstOrDefault();
            var      encryptLoginType = EncryptionDecryption.EncryptByTripleDES(LoginType.Guest.GetHashCode().ToString());

            if (objCustomer == null)
            {
                string         signUpParameter        = string.Format("{0}", email);
                string         encryptsignUpParameter = EncryptionDecryption.EncryptByTripleDES(signUpParameter);
                string         signUpURL  = string.Format("{0}?q={1}&loginType={2}", ProjectConfiguration.FrontEndSiteUrl + Controllers.ActiveDirectory + "/" + Actions.SignUp, encryptsignUpParameter, encryptLoginType);
                EmailViewModel emailModel = new EmailViewModel()
                {
                    Email      = email,
                    ResetUrl   = signUpURL,
                    LanguageId = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                };
                if (UserMail.SendInviteMail(emailModel))
                {
                    return(this.Json(new { status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = Messages.EmailSent, title = Infrastructure.SystemEnumList.Title.Member.GetDescription(), JsonRequestBehavior.AllowGet }));
                }
                else
                {
                    return(this.Json(new { status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.ErrorMessage, title = Infrastructure.SystemEnumList.Title.Member.GetDescription(), JsonRequestBehavior.AllowGet }));
                }
            }
            else
            {
                return(this.Json(new { status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.MemberAlreadyRegistered, title = Infrastructure.SystemEnumList.Title.Member.GetDescription(), JsonRequestBehavior.AllowGet }));
            }
        }
Exemplo n.º 9
0
        public ActionResult ForgotPassword(Login model)
        {
            User userModel = this.userDataBL.GetUsersList(new User()).Where(m => m.Email == model.Email).FirstOrDefault();

            if (userModel != null)
            {
                string         resetPasswordParameter        = string.Format("{0}#{1}", userModel.Id, DateTime.Now.AddMinutes(ProjectConfiguration.ResetPasswordExpireTime).ToString(ProjectConfiguration.EmailDateTimeFormat));
                string         encryptResetPasswordParameter = EncryptionDecryption.EncryptByTripleDES(resetPasswordParameter);
                string         encryptResetPasswordUrl       = string.Format("{0}?q={1}", ProjectConfiguration.SiteUrlBase + Controllers.Account + "/" + Actions.ResetPassword, encryptResetPasswordParameter);
                EmailViewModel emailModel = new EmailViewModel()
                {
                    Email      = userModel.Email,
                    Name       = userModel.FirstName + " " + userModel.LastName,
                    ResetUrl   = encryptResetPasswordUrl,
                    LanguageId = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                };
                if (UserMail.SendForgotPassword(emailModel))
                {
                    this.AddToastMessage(Resources.General.Success, Messages.EmailSent, SystemEnumList.MessageBoxType.Success);
                    return(this.RedirectToAction(Actions.Index, Controllers.Account));
                }
                else
                {
                    this.AddToastMessage(Resources.General.Error, Messages.PasswordEmailSendFail, SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.ForgotPassword, model));
                }
            }
            else
            {
                this.AddToastMessage(Resources.General.Error, Messages.UserAccountNotmatched, SystemEnumList.MessageBoxType.Error);
                return(this.View(Views.ForgotPassword, model));
            }
        }
Exemplo n.º 10
0
 public WindowMailMessageViewModel(MailUserControl mailUserControl, UserMail message, WindowMailMessage windowMailMessage)
 {
     this.windowMailMessage = windowMailMessage;
     this.mailUserControl   = mailUserControl;
     this.message           = message;
     BodyMessage            = message.BodyMessage;
     Heading     = message.Heading;
     TimeMessage = message.TimeMessage;
 }
Exemplo n.º 11
0
        public async Task <IActionResult> VerifyPasswordAsync([FromBody] UserMail userMail)
        {
            bool result = await AutCreateAccountAsync(userMail);

            ReturnResult rst = new ReturnResult();

            rst.success = result;
            rst.message = " ";
            return(Ok(rst));
        }
        public WindowMailMessage(MailUserControl mailUserControl, UserMail message)
        {
            InitializeComponent();
            this.mailUserControl = mailUserControl;
            WindowMailMessageViewModel windowMailMessageViewModel = new WindowMailMessageViewModel(mailUserControl, message, this);

            DataContext = windowMailMessageViewModel;
            this.mailUserControl.timer.Stop();
            this.mailUserControl.ComboBoxRecipients_SelectionChanged();
        }
Exemplo n.º 13
0
        public static void UserShengJiTaRank()
        {
            Ranking <UserRank> rankList = RankingFactory.Get <UserRank>(ShengJiTaRanking.RankingKey);

            if (rankList != null)
            {
                if (DateTime.Now.Hour == 0)
                {
                    foreach (UserRank userRank in rankList)
                    {
                        GameUser usergame = new PersonalCacheStruct <GameUser>().FindKey(userRank.UserID);
                        if (usergame != null && userRank.ScoreStar > 0)
                        {
                            // 信件通知玩家 “您在XX-XX的“勇闯圣吉塔”活动中名列XX榜第N,排名奖励M金币已经发送到您的账号中,请及时查收!”
                            TjxMailService mailService = new TjxMailService(usergame);
                            var            mail        = new UserMail(Guid.NewGuid());
                            mail.UserId       = userRank.UserID.ToInt();
                            mail.MailType     = (int)MailType.System;
                            mail.ToUserID     = userRank.UserID.ToInt();
                            mail.FromUserName = LanguageManager.GetLang().St_SystemMailTitle;
                            mail.Title        = LanguageManager.GetLang().St_SystemMailTitle;
                            mail.SendDate     = DateTime.Now;

                            IGameLanguage    gameLanguage = LanguageManager.GetLang();
                            SJTRankRewarInfo SJTRankRewar = new ShareCacheStruct <SJTRankRewarInfo>().FindKey(userRank.SJTRankId, userRank.SJTRankType.ToInt());
                            if (SJTRankRewar != null)
                            {
                                if (usergame.UserLv >= 10 && usergame.UserLv < 30)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaQintTong, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }
                                if (usergame.UserLv >= 30 && usergame.UserLv < 54)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaBaiYin, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }
                                if (usergame.UserLv >= 55)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaHuangJin, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }

                                mailService.Send(mail);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public async Task <IActionResult> UserLogin(UserMail userMail)
        {
            bool   flagset    = false;
            string strMessage = string.Empty;
            string strId      = string.Empty;
            //  _logger.LogInformation("User created a new account with password.");
            var loggedIn = await _signInManager.PasswordSignInAsync(userMail.emailid, userMail.pwd, false, lockoutOnFailure : false);

            if (loggedIn.Succeeded)
            {
                flagset    = true;
                strMessage = "New record created";
                strId      = "0";
            }
            return(Ok(new { status = flagset, message = strMessage, Id = strId }));
        }
Exemplo n.º 15
0
        public void Configuration(IAppBuilder app)
        {
            app.UseStaticFiles("/css");
            app.UseStaticFiles("/Content");
            app.UseStaticFiles("/parts");
            app.UseStaticFiles("/Scripts");
            app.UseStaticFiles("/templates");


            Database.SetInitializer(new CreateDatabaseIfNotExists <HelpContext>());
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <HelpContext, Migrations.Configuration>());
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

            app.MapSignalR();
            var m = new UserMail();
        }
Exemplo n.º 16
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtEmailTemplate.Text.Trim() != "" && txtEmailTo.Text.Trim() != "")
            {
                bool sent = UserMail.SendTestEmail(txtEmailTemplate.Text.Trim(), txtEmailTo.Text.Trim());

                if (sent)
                {
                    lblError.Text = "Email Sent Successfully.";
                }
                else
                {
                    lblError.Text = "There is an error while sending email.";
                }
            }
        }
Exemplo n.º 17
0
        //public class UserMail
        //{

        //}
        public ActionResult SendMail(DateTime fromDate, DateTime toDate, string week)
        {
            try
            {
                string fileName    = "Tuan" + week + "_" + fromDate.Year.ToString();
                string path        = Server.MapPath("~/Template/" + fileName + ".docx");
                var    modalActive = _extaSrv.GetDataExtraActiveToSendMail(fromDate, toDate);
                GenerateDocument(modalActive, fromDate, toDate, week);
                List <UserMail> temp = new List <UserMail>();
                foreach (var item in modalActive)
                {
                    var x = _extaSrv.GetDataJoinerToSendMail(item.PID);
                    foreach (var q in x)
                    {
                        UserMail v = new UserMail();
                        v.email = _extaSrv.GetEmail(q.TeacherCode);
                        v.name  = _extaSrv.GetName(q.TeacherCode);
                        if (temp != null)
                        {
                            int kt = 0;
                            foreach (var w in temp)
                            {
                                if (w.email == v.email)
                                {
                                    kt = 1;
                                    break;
                                }
                            }
                            if (kt == 0)
                            {
                                temp.Add(v);
                            }
                        }
                        else
                        {
                            temp.Add(v);
                        }
                    }
                }
                var kq = _extaSrv.SendMail(week, fromDate.Year.ToString(), path, temp);
                return(Json(new { returnData = kq }));
            }
            catch (Exception ex)
            {
                return(Json(new { returnData = false }));
            }
        }
Exemplo n.º 18
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int gold    = 0;
            int diamo   = 0;
            int valiBet = 0;

            if (!int.TryParse(txtGold.Text, out gold))
            {
                MessageBox("赠送金币格式不正确");
                return;
            }
            if (!int.TryParse(TextDimao.Text, out diamo))
            {
                MessageBox("赠送金币格式不正确");
                return;
            }
            if (!int.TryParse(txtVileBet.Text, out valiBet))
            {
                MessageBox("赠送金币格式不正确");
                return;
            }
            UserMail mail = new UserMail();

            mail.Title   = TextTitle.Text;
            mail.MState  = 0;
            mail.Msg     = TextBox1.Text;
            mail.Valibet = valiBet;
            mail.GoldNum = gold;
            mail.DiamNum = diamo;
            mail.UserID  = 0;
            if (Convert.ToInt32(txtGameID.Text) > 0)
            {
                AccountsInfo acc = FacadeManage.aideAccountsFacade.GetAccountInfoByGameId(Convert.ToInt32(txtGameID.Text));
                if (acc == null)
                {
                    MessageBox("玩家不存在");
                    return;
                }
                mail.UserID = acc.UserID;
            }
            int res = FacadeManage.aidePlatformFacade.SendMail(mail);

            if (res > 0)
            {
                MessageBox("发送成功");
            }
        }
Exemplo n.º 19
0
        public HttpResponseMessage GetAdminsAbilitati(int idSender)
        {
            BackendUserService bus   = new BackendUserService();
            UsersMailModel     model = new UsersMailModel();

            try
            {
                List <BackendUser> listaUtentiAbilitati = bus.GetDipendentiDipartimentoAbilitati(idSender);
                var             ListaAdmins             = listaUtentiAbilitati.Where(x => x.RoleMail > 0);
                List <UserMail> list = new List <UserMail>();
                foreach (BackendUser b in ListaAdmins)
                {
                    UserMail u = new UserMail()
                    {
                        UserId   = (int)b.UserId,
                        UserName = b.UserName
                    };
                    list.Add(u);
                }
                model.success   = "true";
                model.UsersList = list.ToArray();
                model.Totale    = list.Count.ToString();
            }
            catch (Exception ex)
            {
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ErrorLogInfo error = new ErrorLogInfo();
                    error.freeTextDetails = ex.Message;
                    error.logCode         = "ERR_U002";
                    error.loggingAppCode  = "PEC";
                    error.loggingTime     = System.DateTime.Now;
                    error.uniqueLogID     = System.DateTime.Now.Ticks.ToString();
                    log.Error(error);
                    model.message = ex.Message;
                    model.success = "false";
                }
                else
                {
                    model.message = ex.Message;
                    model.success = "false";
                }
                return(this.Request.CreateResponse <UsersMailModel>(HttpStatusCode.OK, model));
            }
            return(this.Request.CreateResponse <UsersMailModel>(HttpStatusCode.OK, model));
        }
Exemplo n.º 20
0
 public ActionResult ResetPassword1(ResetPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         User u = context.Users.FirstOrDefault(us => us.EmailAddress.Equals(model.Email));
         if (u == null)
         {
             ModelState.AddModelError("email", "Email addresse blev ikke fundet.");
         }
         else
         {
             UserMail um = new UserMail();
             um.SendPasswordRecovery(model.Email);
             return(View("PasswordResetRequested"));
         }
     }
     return(View("ResetPassword", model));
 }
Exemplo n.º 21
0
        public static List <UserMail> GetAllUsers()
        {
            BackendUserService bus         = new BackendUserService();
            List <BackendUser> listaUtenti = bus.GetAllUsers();
            List <UserMail>    list        = new List <UserMail>();

            foreach (BackendUser b in listaUtenti)
            {
                UserMail u = new UserMail()
                {
                    UserId   = (int)b.UserId,
                    UserName = b.UserName
                };
                list.Add(u);
            }

            return(list);
        }
Exemplo n.º 22
0
        public JsonResult SendMessage(Message message)
        {
            if (this.ModelState.IsValid)
            {
                message.IsSendByAdmin = true;
                message.SenderId      = ProjectSession.UserId;
                int status = this.messageDataBL.Save <Message>(message, false, false);
                if (status > 0)
                {
                    Customer customer = this.messageDataBL.SelectObject <Customer>(message.CustomerId);

                    EmailViewModel emailModel = new EmailViewModel()
                    {
                        Email        = customer.Email,
                        Name         = customer.Name,
                        AdminMessage = message.Description,
                        LanguageId   = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                    };
                    UserMail.MessageAlertForCustomer(emailModel);
                    return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = Messages.SendMessageSuccess, title = General.Send + " " + General.Message }, JsonRequestBehavior.DenyGet));
                }

                return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.SendMessageError }, JsonRequestBehavior.DenyGet));
            }
            else
            {
                string errorMsg = string.Empty;
                foreach (ModelState modelState in this.ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        if (!string.IsNullOrEmpty(errorMsg))
                        {
                            errorMsg = errorMsg + " , ";
                        }

                        errorMsg = errorMsg + error.ErrorMessage;
                    }
                }

                return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = errorMsg }, JsonRequestBehavior.DenyGet));
            }
        }
Exemplo n.º 23
0
    public void SetDetail(UserMail userMail)
    {
        _userMail       = userMail;
        lblFrom.text    = GameManager.localization.GetText("Social_Form") + " " + _userMail.Sender.Base.NickName;
        lblSubject.text = GameManager.localization.GetText("Social_Subject") + " " + _userMail.Title;
        Invoke("SetTextMail", 0.5f);
        if (_userMail.SenderId == 0)
        {
            btnTakeAll.gameObject.SetActive(false);
            btnAddFriend.gameObject.SetActive(false);
        }
        else
        {
            btnTakeAll.gameObject.SetActive(false);
            btnAddFriend.gameObject.SetActive(true);
        }
        SetItem(userMail.Items);

        //userMail.
    }
        public (bool isNotValid, List <string> errors) Validate()
        {
            List <string> errorList = new List <string>();

            if (Password.Length >= 30 || Password.Length < 5)
            {
                errorList.Add("Password length must be between 5 and 30 characters!");
            }

            if (UserMail.Contains("ü") || UserMail.Contains("ç") || UserMail.Contains("ğ") || UserMail.Contains("ı") || UserMail.Contains("ş") || UserMail.Contains("ö"))
            {
                errorList.Add("E-Mail address cannot have special characters!");
            }

            if (UserName.Contains("ü") || UserName.Contains("ç") || UserName.Contains("ğ") || UserName.Contains("ı") || UserName.Contains("ş") || UserName.Contains("ö"))
            {
                errorList.Add("User Name address cannot have special characters!");
            }

            return(errorList.Count > 0, errorList);
        }
Exemplo n.º 25
0
        public async Task <IActionResult> GeneratePasswordAsync([FromBody] UserMail userMail)
        {
            var existUser = _userManager.FindByEmailAsync(userMail.emailid);

            if (existUser.Result == null)
            {
                string strGeneratePwd = GenerateRandomPassword();
                string strBodyMsg     = "<p>Please enter this password <code><b>" + strGeneratePwd + "</b></code> to proceed with your loan application.</p>";

                // Create New User Account
                var user = new ApplyTriadfsUser {
                    UserName = userMail.emailid, Email = userMail.emailid, FullName = userMail.FirstName
                };
                var result = await _userManager.CreateAsync(user, strGeneratePwd);

                if (result.Succeeded)
                {
                    await emailSender.SendEmailAsync(userMail.emailid, "Submit new application", strBodyMsg);

                    return(Ok(new { success = true, message = "Pls check you mailbox, and enter generated password here in password textbox." }));
                }

                return(Ok(new { success = false, message = "Error occur" }));
            }
            else
            {
                var user = _userManager.FindByEmailAsync(userMail.emailid);

                string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user.Result);

                string         strGeneratePwd       = GenerateRandomPassword();
                IdentityResult passwordChangeResult = await _userManager.ResetPasswordAsync(user.Result, resetToken, strGeneratePwd);

                string strBodyMsg = "<p>Please enter this password <code><b>" + strGeneratePwd + "</b></code> to proceed with your loan application.</p>";

                await emailSender.SendEmailAsync(userMail.emailid, "Submit new application", strBodyMsg);

                return(Ok(new { success = true, message = "Pls check you mailbox, and enter generated password here in password textbox." }));
            }
        }
Exemplo n.º 26
0
        public IHttpActionResult GetForgotPassword(UserMail userMail)
        {
            if (userMail == null || string.IsNullOrEmpty(userMail.Mail) || string.IsNullOrWhiteSpace(userMail.Mail))
            {
                return(NotFound());
            }

            var user = db.Users.FirstOrDefault(u => u.Email.Trim().ToLower() == userMail.Mail.Trim().ToLower());

            if (user == null)
            {
                return(NotFound());
            }
            EmailService             emailService = new EmailService();
            ForgotPasswordEmailModel model        = new ForgotPasswordEmailModel
            {
                Name     = user.UserName,
                Password = Protector.Decrypt(user.Password)
            };

            var templateService  = new RazorEngine.Templating.TemplateService();
            var templateFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Services", "Email", "ForgotPasswordEmailTemplate.cshtml");
            var emailHtmlBody    = templateService.Parse(File.ReadAllText(templateFilePath), model, null, null);

            try
            {
                IdentityMessage msg = new IdentityMessage();
                msg.Subject     = "Loglig";
                msg.Body        = emailHtmlBody;
                msg.Destination = user.Email;
                emailService.SendAsync(msg);
            }
            catch (Exception ex)
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Exemplo n.º 27
0
 private void AddMailRecipientsToDB(List <string> recipients, RecipientType recipientType, int mailID)
 {
     if (recipients != null)
     {
         foreach (string email in recipients)
         {
             User usr = _context.Users.Where(x => x.Email == email).FirstOrDefault();
             if (usr == null)
             {
                 continue;
             }
             UserMail um = new UserMail
             {
                 UserID        = usr.ID,
                 MailID        = mailID,
                 RecipientType = recipientType,
                 Read          = false,
             };
             _context.UserMails.Add(um);
         }
     }
     _context.SaveChanges();
 }
Exemplo n.º 28
0
        /*private void createAdmin(string userName, string userMail, string userPw)
         * {
         *  var user = new User()
         *  {
         *      Name = userName,
         *      Email = userMail,
         *      Password = userPw
         *  };
         *  userService.CreateUser(user);
         * }*/

        private void submitbtn_Click(object sender, EventArgs e)
        {
            // Arra kell figyelni, hogy a userName = email címmel a UserService-ben !!!!
            UserMail = uname.Text;
            string pw = password.Text;

            var user = new User()
            {
                Name     = "Marci",
                Email    = UserMail,
                Password = pw,
                Group_id = "1"
            };

            if (UserMail.Trim() != string.Empty && pw.Trim() != string.Empty)
            {
                userService.CreateUser(user);
                // Arra kell figyelni, hogy a userName = email címmel a UserService-ben !!!!
                UserSuccessfullyAuthenticated = userService.LoginUser(UserMail, pw);

                if (!UserSuccessfullyAuthenticated)
                {
                    MessageBox.Show("Sikertelen bejelentkezés!");
                    return;
                }
                else
                {
                    // user adatainak lekérése
                    UserData = userService.GetUserData(UserMail);
                    MessageBox.Show("Sikeres bejelentkezés " + UserData.Name + " " + UserData.Email);
                    Close();
                }
            }

            //System.Windows.Forms.MessageBox.Show(uName);
        }
Exemplo n.º 29
0
        public async Task <IActionResult> GeneratePasswordOnlyAsync([FromBody] UserMail userMail)
        {
            var existUser = _userManager.FindByEmailAsync(userMail.emailid);

            if (existUser.Result != null)
            {
                var user = _userManager.FindByEmailAsync(userMail.emailid);

                string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user.Result);

                string         strGeneratePwd       = GenerateRandomPassword();
                IdentityResult passwordChangeResult = await _userManager.ResetPasswordAsync(user.Result, resetToken, strGeneratePwd);

                string strBodyMsg = "<p>Please enter this password <code><b>" + strGeneratePwd + "</b></code> to proceed with your loan application.</p>";

                await emailSender.SendEmailAsync(userMail.emailid, "Submit new application", strBodyMsg);

                return(Ok(new { success = true, message = "Pls check you mailbox, and enter generated password here in password textbox." }));
            }
            else
            {
                return(Ok(new { success = false, message = "Error while generating password." }));
            }
        }
Exemplo n.º 30
0
        public override bool TakeAction()
        {
            var cacheSet = new ShareCacheStruct <UserFriends>();

            if (_friendId != "" && _friendId != ContextUser.UserID)
            {
                //找到本玩家的数据
                List <UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID);
                int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum");
                //添加的好友上限
                if (friendArray.Count >= friendNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend;
                    return(false);
                }

                //查看是否在user库中有该玩家
                GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(_friendId);
                if (userInfo == null)
                {
                    UserCacheGlobal.LoadOffline(_friendId);
                    userInfo = new GameDataCacheSet <GameUser>().FindKey(_friendId);
                }
                if (userInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St9103_NotFriendsUserID;
                    return(false);
                }

                //在好友表中查找本玩家 和添加好友的关系
                var userFriend  = cacheSet.FindKey(ContextUser.UserID, _friendId);
                var userFriend1 = cacheSet.FindKey(_friendId, ContextUser.UserID);
                //同意
                if (_ops == 1)
                {
                    //有信息表 没信息表
                    if (userFriend == null)
                    {
                        //创建新的数据 并且添加成关注类型
                        var friends = new UserFriends
                        {
                            UserID     = ContextUser.UserID,
                            FriendID   = _friendId,
                            FriendType = FriendType.Friend
                        };
                        cacheSet.Add(friends, GameEnvironment.CacheGlobalPeriod);
                        //todo test
                        friends.ChatTime = DateTime.Now;
                    }
                    else
                    {
                        //玩家原来就有数据
                        //判断两个玩家的关系
                        if (userFriend.FriendType == FriendType.Friend)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn;
                            return(false);
                        }
                        userFriend.FriendType = FriendType.Friend;
                    }

                    //判断对方是否有和本玩家的数据 如果没有创建 有改状态
                    if (userFriend1 == null)
                    {
                        var friends2 = new UserFriends
                        {
                            UserID     = _friendId,
                            FriendID   = ContextUser.UserID,
                            FriendType = FriendType.Friend,
                        };
                        cacheSet.Add(friends2, GameEnvironment.CacheGlobalPeriod);
                        //todo test
                        friends2.ChatTime = DateTime.Now;
                    }
                    else
                    {
                        userFriend1.FriendType = FriendType.Friend;
                    }

                    //加为好友成功后发送一条邮件
                    try
                    {
                        Guid     newGuid  = Guid.NewGuid();
                        UserMail userMail = new UserMail(newGuid);
                        userMail.UserId       = Int32.Parse(_friendId);
                        userMail.MailType     = MailType.Friends;
                        userMail.Title        = LanguageManager.GetLang().St_AskFirendMailTitle;
                        userMail.Content      = string.Format(LanguageManager.GetLang().St_FirendNotice, ContextUser.NickName);
                        userMail.SendDate     = DateTime.Now;
                        userMail.FromUserId   = Int32.Parse(ContextUser.UserID);
                        userMail.FromUserName = ContextUser.NickName;
                        TjxMailService mailService = new TjxMailService(ContextUser);
                        mailService.Send(userMail);

                        var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId);
                        noticeMail.ReplyStatus = 1;
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    //不同意
                    TjxMailService mailService = new TjxMailService(ContextUser);
                    var            noticeMail  = mailService.ReadMail(ContextUser.UserID, _mailId);
                    noticeMail.ReplyStatus = 1;
                }
            }
            return(true);
        }