Exemplo n.º 1
0
        public virtual void ForgotPassword(User user)
        {
            if (user != null)
            {
                var mail = user.UserMail;
                var link = "http://" + CurrentHttpContext.Request.Url.Authority + "/Account/Index";
                if (!string.IsNullOrEmpty(user.AccessToken))
                {
                    link = "http://" + CurrentHttpContext.Request.Url.Authority + "/Account/DetailRegister?token=" + CurrentHttpContext.Server.UrlEncode(user.AccessToken);
                }
                ViewBag.Mail = mail;
                ViewBag.Link = link;

                var mailObj = Populate(x =>
                {
                    x.Subject = "OATS Reset Forgot Password";
                    x.ViewName = "ForgotPassword";
                    x.To.Add(user.UserMail);
                });
                var client = new SmtpClientWrapperOATS();
                client.OnSendingError += (ex) =>
                {
                    if (OnForgotPasswordCallback != null)
                    {
                        OnForgotPasswordCallback.Invoke(false);
                    }
                };
                client.SendCompleted += (sender, e) =>
                {
                    if (OnForgotPasswordCallback != null)
                    {
                        OnForgotPasswordCallback.Invoke(true);
                    }
                };
                mailObj.SendAsync("oats", client);
            }
        }
Exemplo n.º 2
0
        public virtual void InviteUsers(List<Invitation> invitations)
        {
            initMailCount = invitations.Count;
            tempMailCount = initMailCount;
            invitations.ForEach(i =>
            {
                var client = new SmtpClientWrapperOATS();
                client.OnSendingError += (ex) =>
                {
                    unSentMailCount++;
                    tempMailCount--;
                    AcknowledgeCallback();
                };
                client.SendCompleted += (sender, e) =>
                {
                    if (e.Error != null || e.Cancelled)
                    {
                        unSentMailCount++;
                    }
                    else {
                        sentMailCount++;
                        var invitationIdObj = e.UserState;
                        if (invitationIdObj != null&&invitationIdObj is int) {
                            var invitationId = (int)invitationIdObj;
                            listSent.Add(invitationId);

                        }
                    }
                    tempMailCount--;
                    AcknowledgeCallback();
                };
                this.InviteUser(invitations.FirstOrDefault()).SendAsync(i.InvitationID, client);
            });
        }
Exemplo n.º 3
0
        public virtual void NofityNewUser(User user, User invitor)
        {
            if (user != null)
            {
                var mail = user.UserMail;
                var link = "http://" + CurrentHttpContext.Request.Url.Authority + "/Account/Index";
                var invitorName = string.Empty;
                if (invitor != null)
                {
                    if (string.IsNullOrEmpty(invitor.Name))
                    {
                        invitorName = invitor.UserMail;
                    }
                    else {
                        invitorName = invitor.Name + " (Email: "+invitor.UserMail+" )";
                    }
                }
                if (!string.IsNullOrEmpty(user.AccessToken))
                {
                    link = "http://" + CurrentHttpContext.Request.Url.Authority + "/Account/DetailRegister?token=" + CurrentHttpContext.Server.UrlEncode(user.AccessToken);
                }
                ViewBag.Invitor = invitorName;
                ViewBag.Mail = mail;
                ViewBag.Link = link;

                var mailObj = Populate(x =>
                {
                    x.Subject = "OATS Notify for New User";
                    x.ViewName = "NotifyNewUser";
                    x.To.Add(user.UserMail);
                });
                var client = new SmtpClientWrapperOATS();
                client.OnSendingError += (ex) =>
                {
                    if (OnNotifyNewUserCallback != null)
                    {
                        OnNotifyNewUserCallback.Invoke(false);
                    }
                };
                client.SendCompleted += (sender, e) =>
                {
                    if (OnNotifyNewUserCallback != null)
                    {
                        OnNotifyNewUserCallback.Invoke(true);
                    }
                };
                mailObj.SendAsync("oats", client);
            }
        }