예제 #1
0
        public void ForgetPasswordNew(string url, string email, string code)
        {
            GetBody(53);

            m_body = m_body.Replace("[RestorePass]", (DomainUtil.GetSubdomainLink(url) + "/service/restore" + "?email=" + email + "&token=" + code).Trim());
            m_body = m_body.Replace("[RestorePass2]", (DomainUtil.GetSubdomainLink(url).Replace(".", "<span>.</span>") + "/<span>service</span>/restore" + "?email=" + email.Replace("@", "<span>@</span>").Replace(".", "<span>.</span>") + "&token=" + code).Trim());
            m_body = m_body.Replace("[RestoreCode]", code);
        }
예제 #2
0
        public void CampusSecurityAlert(string caseUrl, string caseId, string platformManagerName, string platformManagerCell)
        {
            GetBody(51);

            m_body = m_body.Replace("[CaseUrl]", (DomainUtil.GetSubdomainLink(caseUrl) + "/newCase/Index/" + caseUrl).Trim());
            m_body = m_body.Replace("[CaseId]", caseId);
            m_body = m_body.Replace("[PlatformManagerName]", platformManagerName);
            m_body = m_body.Replace("[PlatformManagerCell]", platformManagerCell);
        }
예제 #3
0
        public void NewMediator(string adminName, string companyName, string baseUrl, string link, string username, string password)
        {
            GetBody(52);

            m_body = m_body.Replace("[AdminName]", adminName);
            m_body = m_body.Replace("[CompanyName]", companyName);
            m_body = m_body.Replace("[BaseUrl]", DomainUtil.GetSubdomainLink(link) + "/login/index?loginField=" + username);
            m_body = m_body.Replace("[Link]", DomainUtil.GetSubdomainLink(link) + "/settings/index");
            m_body = m_body.Replace("[Username]", username);
            m_body = m_body.Replace("[Password]", password);
            m_body = m_body.Replace("[Username]", username);
        }
예제 #4
0
        public string InviteMediator(string email)
        {
            email = email.ToLower().Trim();

            user _user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (_user == null || _user.id == 0)
            {
                return(App_LocalResources.GlobalRes.EmptyData);
            }

            if (_user.role_id == 8)
            {
                return(App_LocalResources.GlobalRes.EmptyData);
            }

            if (string.IsNullOrEmpty(email))
            {
                return(App_LocalResources.GlobalRes.EmptyData);
            }
            if (!m_EmailHelper.IsValidEmail(email))
            {
                return(App_LocalResources.GlobalRes.EmailInvalid);
            }

            UserModel um = new UserModel(_user.id);

            List <string> _company_user_emails = new List <string>();

            _company_user_emails = (db.user.Where(t => ((t.company_id == um._user.company_id) && (t.role_id != ECLevelConstants.level_informant))).Select(t => t.email.Trim().ToLower())).ToList();

            List <int> _company_user_allowed = new List <int>();

            _company_user_allowed = (db.user.Where(t => ((t.company_id == um._user.company_id) && (t.role_id != ECLevelConstants.level_informant))).Select(t => t.id)).ToList();

            if (_company_user_emails.Contains(email))
            {
                return(App_LocalResources.GlobalRes.MediatorAlreadyRegistered + "!");
            }

            if ((db.invitation.Any(t => ((t.email.ToLower().Trim() == email) && (t.used_flag == 1) && (_company_user_allowed.Contains(t.sent_by_user_id))))) || (db.user.Any(u => ((u.email.ToLower().Trim() == email.ToLower().Trim() && u.role_id != 8)))))
            {
                return(App_LocalResources.GlobalRes.MediatorAlreadyRegistered);
            }

            if (db.invitation.Any(t => ((t.email.ToLower().Trim() == email) && (_company_user_allowed.Contains(t.sent_by_user_id)))))
            {
                return(App_LocalResources.GlobalRes.AlreadyInvited);
            }


            string generated_code = StringUtil.RandomString(6);
            // create invitation in db

            invitation _invitation = new invitation();

            _invitation.code            = generated_code;
            _invitation.comment         = "";
            _invitation.created_on      = DateTime.Now;
            _invitation.email           = email.Trim().ToLower();
            _invitation.sent_by_user_id = _user.id;
            _invitation.used_flag       = 0;

            db.invitation.AddOrUpdate(_invitation);
            db.SaveChanges();
            // add _invitation to db

            // send email with code to email address


            if ((email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(email.Trim()))
            {
                List <string> to  = new List <string>();
                List <string> cc  = new List <string>();
                List <string> bcc = new List <string>();

                to.Add(email.Trim());
                ///     bcc.Add("*****@*****.**");

                EC.Business.Actions.Email.EmailManagement em = new EC.Business.Actions.Email.EmailManagement();
                EC.Business.Actions.Email.EmailBody       eb = new EC.Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower());

                CompanyModel cm = new CompanyModel(_user.company_id);
                eb.MediatorInvited(_user.first_nm, _user.last_nm, _user.first_nm, _user.last_nm, cm._company.company_nm, generated_code, DomainUtil.GetSubdomainLink(Request.Url.AbsoluteUri.ToLower()) + "/new/?code=" + generated_code + "&email=" + email);
                string body = eb.Body;
                em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_MediatorInvited, body, true);
            }

            return(App_LocalResources.GlobalRes._Completed.ToLower());
        }
예제 #5
0
        public void GetBody(int body_selector)
        {
            switch (body_selector)
            {
            case 1:
                // request for contact on front site - its internal email - for me/margot
                m_filename = "NewRequest";
                break;

            case 2:
                // company registered   - message for Admin mediator ( no cc to Partner as login info here. msg for partner would be in PartnerNewCompanyArrived)
                m_filename = "NewCompany";
                break;

            case 3:
                // case submitted - message for admin mediators
                m_filename = "NewCase";
                break;

            case 4:
                // case submitted with involved mediators- individual message for admin mediators w/o involved
                m_filename = "NewCaseInvolved";
                break;

            case 5:
                // individual message for mediators in case
                m_filename = "NewMessage";
                break;

            case 6:
                // task for mediator ( cc for the one who assigned?)
                m_filename = "NewTask";
                break;

            case 7:
                // case promoted - individual message for mediators in case
                m_filename = "NextStep";
                break;

            case 8:
                // case reopened - individual message for mediators in case
                m_filename = "CaseReopened";
                break;

            case 9:
                // case needs to be signed-off ( by 2 top mediator levels only)
                m_filename = "CaseCloseApprove";
                break;

            case 10:
                // case needs to be signed-off ( by 2 top mediator levels only)
                m_filename = "CaseCloseApprovePlatformManager";
                break;

            case 11:
                // case escalated - don't have red button to escalate yet
                m_filename = "EscalatedCase";
                break;

            case 12:
                // case escalated because of timeline violation
                m_filename = "EscalatedCaseTimeline";
                break;

            case 13:
                // new mediator registered - message for mediator - no cc for admin, as login here
                m_filename = "NewUser";
                break;

            case 14:
                // new mediator registered - message for admin mediator
                m_filename = "NewUserArrived";
                break;

            case 15:
                // case promoted - individual message for mediators in case
                m_filename = "SeniorMediatorCaseConfirm";
                break;

            case 20:
                // new company invitation sent - message for new company ( cc for partner??)
                m_filename = "PartnerNewCompany";
                break;

            case 21:
                // new company registered - message for partner
                m_filename = "PartnerNewCompanyArrived";
                break;

            case 22:
                // new company status changed - message for company  ( cc for partner???)
                m_filename = "PartnerNewCompanyStatusChange";
                break;


            case 30:
                // new case submitted - message for reporter
                m_filename = "ReporterNewCase";
                break;

            case 31:
                // new case message - message for reporter
                m_filename = "ReporterNewMessage";
                break;

            case 32:
                // case promoted to next step - message for reporter
                m_filename = "ReporterNewStep";
                break;

            case 33:
                // // case re-opened - message for reporter
                m_filename = "ReporterCaseReopened";
                break;

            case 40:
                //mediator assigned to case   (?? cc for the one who assigned?)
                m_filename = "MediatorAssigned";
                break;

            case 41:
                // mediator invited to company  (??I think we don't need cc for the one who invited?)
                m_filename = "MediatorInvited";
                break;

            case 42:
                //mediator status promoted to Active ONLY (??I think we don't need cc for the one who changed status?)
                m_filename = "MediatorStatusChange";
                break;

            case 43:
                // mediator Role changed to any - (??I think we don't need cc for the one who changed?)
                m_filename = "MediatorRoleChange";
                break;

            case 50:
                // message to mediator with the link to update password
                m_filename = "ForgetPassword";
                break;

            case 51:
                // message to mediator with the link to update password
                m_filename = "CampusSecurityAlert";
                break;

            case 52:
                // message to mediator with the link to update password
                m_filename = "MediatorInvitedUserCreated";
                break;

            case 53:
                // message to mediator with the link to update password
                m_filename = "ForgetPasswordNew";
                break;

            case 60:
                // message about case deadline past due
                m_filename = "CaseDeadlinePastDue";
                break;
            }

            string appPath = Path.GetFullPath("~/EmailText/" + m_filename + ".html");
            string path1   = Path.Combine(Environment.CurrentDirectory, @"EmailText\", m_filename + ".html");
            string path    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\emails\", m_filename + ".html");
            /// string path1 = Path.Combine(AppDomain.CurrentDomain.ExecuteAssembly, @"EmailText\", m_filename + ".html");
            ///
            string temp = "";

            m_body = "";

            if (File.Exists(path))
            {
                temp = path;
                string text = System.IO.File.ReadAllText(path);
                m_body = text;

                string entrance_link = DomainUtil.GetSubdomainLink(path) + "/Index/Start";

                m_body = m_body.Replace("[BaseUrl]", entrance_link);
            }

            /*      string assemblyName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
             *    string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
             *
             *    if (System.IO.File.Exists(AppDomain.CurrentDomain.RelativeSearchPath + '\\' +
             *        assemblyName.Substring(0, assemblyName.IndexOf(',')) + ".html"))
             *    {
             *
             *       temp = AppDomain.CurrentDomain.RelativeSearchPath + '\\' +
             *            assemblyName.Substring(0, assemblyName.IndexOf(',')) + ".html";
             *    }
             *    else if (System.IO.File.Exists(AppDomain.CurrentDomain.RelativeSearchPath + '\\' + "Content" + '\\' + "emails" + '\\' + m_filename + ".html"))
             *    {
             *        temp = AppDomain.CurrentDomain.RelativeSearchPath + '\\' + "Content" + '\\' + "emails" + '\\' + m_filename + ".html";
             *    }
             *    else if (System.IO.File.Exists(System.IO.Path.GetDirectoryName(assemblyPath) + '\\' +
             *        assemblyName.Substring(0, assemblyName.IndexOf(',')) + ".html"))
             *    {
             *       temp = System.IO.Path.GetDirectoryName(assemblyPath) + '\\' +
             *            assemblyName.Substring(0, assemblyName.IndexOf(',')) + ".html";
             *    }
             *    else if (System.IO.File.Exists(System.IO.Path.GetDirectoryName(assemblyPath) + '\\' + "Content" + '\\' + "emails" + '\\' + m_filename + ".html"))
             *    {
             *        temp = System.IO.Path.GetDirectoryName(assemblyPath) + '\\' + "Content" + '\\' + "emails" + '\\'  + m_filename + ".html";
             *    }*/
        }