protected void SetAdviserPreference()
        {
            advisorPreferenceVo = adviserPreferenceBo.GetAdviserPreference(adviserVo.advisorId);
            if (advisorPreferenceVo != null)
            {
                txtWebSiteDomainName.Text   = advisorPreferenceVo.WebSiteDomainName;
                txtLogOutPageUrl.Text       = advisorPreferenceVo.LoginWidgetLogOutPageURL;
                txtBrowserTitleBarName.Text = advisorPreferenceVo.BrowserTitleBarName;
                txtGridPageSize.Text        = advisorPreferenceVo.GridPageSize.ToString();

                if (advisorPreferenceVo.IsLoginWidgetEnable)
                {
                    rbLoginWidGetYes.Checked     = true;
                    txtLoginWidGetEmail.Text     = adviserVo.Email.Trim();
                    txtLoginWidGetEmail.ReadOnly = false;
                }
                else
                {
                    rbLoginWidGetNo.Checked       = true;
                    txtWebSiteDomainName.ReadOnly = true;
                    txtLogOutPageUrl.ReadOnly     = true;
                    txtLoginWidGetEmail.ReadOnly  = true;
                }
            }
        }
Exemple #2
0
        public AdvisorPreferenceVo GetAdviserPreference(int adviserId)
        {
            AdvisorPreferenceVo advisorPreferenceVo = new AdvisorPreferenceVo();

            try
            {
                AdvisorPreferenceDao advisorPreferenceDao = new AdvisorPreferenceDao();
                advisorPreferenceVo = advisorPreferenceDao.GetAdviserPreference(adviserId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdviserPreferenceBo.cs:GetAdviserPreference()");
                object[] objects = new object[2];
                objects[0]   = adviserId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(advisorPreferenceVo);
        }
Exemple #3
0
        public bool AdviserPreferenceSetUp(AdvisorPreferenceVo advisorPreferenceVo, int adviserId, int UserId, string strCommand)
        {
            bool isSuccess = false;

            try
            {
                AdvisorPreferenceDao advisorPreferenceDao = new AdvisorPreferenceDao();
                isSuccess = advisorPreferenceDao.AdviserPreferenceSetUp(advisorPreferenceVo, adviserId, UserId, strCommand);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdviserPreferenceBo.cs:AdviserPreferenceSetUp()");
                object[] objects = new object[2];
                objects[0]   = adviserId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(isSuccess);
        }
        private void SetAdviserPreference()
        {
            AdviserPreferenceBo adviserPreferenceBo = new AdviserPreferenceBo();
            string logoutPageURL = ConfigurationSettings.AppSettings["SSO_USER_LOGOUT_URL"];
            string loginPageURL  = ConfigurationSettings.AppSettings["SSO_USER_LOGIN_URL"];

            advisorPreferenceVo = adviserPreferenceBo.GetAdviserPreference(advisorVo.advisorId);
            if (advisorPreferenceVo != null)
            {
                UserPreference = new HttpCookie("UserPreference");
                UserPreference.Values["UserTheme"]  = "SBIOnLine";
                UserPreference.Values["OnlineUser"] = "******";
                hidUserLogOutPageUrl.Value          = logoutPageURL;
                hidUserLogInPageUrl.Value           = loginPageURL;

                if (!string.IsNullOrEmpty(loginPageURL))
                {
                    UserPreference.Values["UserLoginPageURL"] = loginPageURL;
                }

                if (!string.IsNullOrEmpty(logoutPageURL))
                {
                    UserPreference.Values["UserLogOutPageURL"] = logoutPageURL;
                }
                else if (!string.IsNullOrEmpty(advisorPreferenceVo.LoginWidgetLogOutPageURL))
                {
                    UserPreference.Values["UserLogOutPageURL"] = advisorPreferenceVo.LoginWidgetLogOutPageURL;
                }

                UserPreference.Expires = DateTime.Now.AddDays(1);
                Response.Cookies.Add(UserPreference);
                Session["AdvisorPreferenceVo"] = advisorPreferenceVo;
            }
        }
 protected void rbLoginWidGetNo_CheckedChanged(object sender, EventArgs e)
 {
     advisorPreferenceVo           = adviserPreferenceBo.GetAdviserPreference(1000);
     txtLogOutPageUrl.Text         = advisorPreferenceVo.LoginWidgetLogOutPageURL;
     txtWebSiteDomainName.Text     = advisorPreferenceVo.WebSiteDomainName;
     txtWebSiteDomainName.ReadOnly = true;
     txtLogOutPageUrl.ReadOnly     = true;
 }
Exemple #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     {
         SessionBo.CheckSession();
         advisorPrefernceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
         rmVo         = (RMVo)Session["rmVo"];
         adviserVo    = (AdvisorVo)Session["advisorVo"];
         associatesVo = (AssociatesVO)Session["associatesVo"];
     }
 }
        public AdvisorPreferenceVo GetAdviserPreference(int adviserId)
        {
            Database            db;
            DbCommand           cmdAdviserPreference;
            DataSet             dsAdviserPreference = null;
            DataTable           dtAdviserPreference = new DataTable();
            AdvisorPreferenceVo advisorPreferenceVo = new AdvisorPreferenceVo();

            try
            {
                db = DatabaseFactory.CreateDatabase("wealtherp");
                cmdAdviserPreference = db.GetStoredProcCommand("SPROC_GetAdviserPreference");
                db.AddInParameter(cmdAdviserPreference, "@AdviserId", DbType.Int32, adviserId);
                dsAdviserPreference = db.ExecuteDataSet(cmdAdviserPreference);
                dtAdviserPreference = dsAdviserPreference.Tables[0];
                if (dtAdviserPreference.Rows.Count > 0)
                {
                    advisorPreferenceVo.ValtPath            = dtAdviserPreference.Rows[0]["AP_ValtPath"].ToString();
                    advisorPreferenceVo.IsLoginWidgetEnable = Convert.ToBoolean(dtAdviserPreference.Rows[0]["AP_IsLoginWidgetActive"]);
                    if (!string.IsNullOrEmpty(dtAdviserPreference.Rows[0]["AP_LoginWidgetLogOutPageURL"].ToString()))
                    {
                        advisorPreferenceVo.LoginWidgetLogOutPageURL = dtAdviserPreference.Rows[0]["AP_LoginWidgetLogOutPageURL"].ToString();
                    }
                    advisorPreferenceVo.BrowserTitleBarName          = dtAdviserPreference.Rows[0]["AP_BrowserTitleBarName"].ToString();
                    advisorPreferenceVo.BrowserTitleBarIconImageName = dtAdviserPreference.Rows[0]["AP_BrowserTitleBarIconImageName"].ToString();
                    advisorPreferenceVo.WebSiteDomainName            = dtAdviserPreference.Rows[0]["AP_WebSiteDomainName"].ToString();
                    advisorPreferenceVo.GridPageSize = int.Parse(dtAdviserPreference.Rows[0]["AP_GridPageSize"].ToString());
                    if (dtAdviserPreference.Rows[0]["AP_IsBannerEnable"].ToString() == "1")
                    {
                        advisorPreferenceVo.IsBannerEnabled = true;
                    }
                    advisorPreferenceVo.BannerImageName = dtAdviserPreference.Rows[0]["AP_BannerImageName"].ToString();
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorPreferenceDao.cs:GetAdviserPreference()");
                object[] objects = new object[2];
                objects[0]   = adviserId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(advisorPreferenceVo);
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionBo.CheckSession();
            userVo             = (UserVo)Session["userVo"];
            advisorPrefernceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
            //CreationSuccessMessage.Visible = false;
            rmVo         = (RMVo)Session["rmVo"];
            adviserVo    = (AdvisorVo)Session["advisorVo"];
            associatesVo = (AssociatesVO)Session["associatesVo"];

            string userType     = userVo.UserType.ToLower();
            string currUserRole = Session[SessionContents.CurrentUserRole].ToString().ToLower();

            if (userType == "SuperAdmin")
            {
                this.UserRole = "advisor";
                adviserId     = 1000;
            }
            else
            {
                switch (currUserRole)
                {
                case "admin":
                case "ops":
                case "research":
                    this.UserRole = "advisor";
                    break;

                case "associates":
                    this.UserRole = currUserRole;
                    break;
                }
                rmId         = rmVo.RMId;
                branchHeadId = rmVo.RMId;
                adviserId    = adviserVo.advisorId;
            }
            if (currUserRole == "associates")
            {
                assocUsrHeirVo = (AssociatesUserHeirarchyVo)Session[SessionContents.AssociatesLogin_AssociatesHierarchy];
                agentCode      = assocUsrHeirVo.AgentCode;
            }
            if (!IsPostBack)
            {
                BindCustomerGrid();
                gvAssocCustList.Visible = true;
                if (userType == "SuperAdmin")
                {
                    gvAssocCustList.Visible = false;
                }
            }
        }
Exemple #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SessionBo.CheckSession();
     userVo             = (UserVo)Session["userVo"];
     advisorPrefernceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
     rmVo               = (RMVo)Session["rmVo"];
     advisorVo          = (AdvisorVo)Session["advisorVo"];
     associatesVo       = (AssociatesVO)Session["associatesVo"];
     assocUsrHeirVo     = (AssociatesUserHeirarchyVo)Session["associatesUserHeirarchyVo"];
     trNewOrder.Visible = false;
     BindBank();
     if (!Page.IsPostBack)
     {
         if (Request.QueryString["IsAdd"] != null)
         {
             if (Request.QueryString["IsAdd"].ToString() == "1")
             {
                 dvAddMandate.Visible = true;
                 if (Session[SessionContents.CurrentUserRole].ToString().ToLower() == "admin" || Session[SessionContents.CurrentUserRole].ToString().ToLower() == "ops" || userVo.AdviserRole.ContainsValue("CNT"))
                 {
                     txtClientCode_autoCompleteExtender.ContextKey    = advisorVo.advisorId.ToString();
                     txtClientCode_autoCompleteExtender.ServiceMethod = "GetCustCode";
                 }
                 else if (Session[SessionContents.CurrentUserRole].ToString() == "BM")
                 {
                     txtClientCode_autoCompleteExtender.ContextKey    = advisorVo.advisorId.ToString();
                     txtClientCode_autoCompleteExtender.ServiceMethod = "GetCustCode";
                 }
                 else if (Session[SessionContents.CurrentUserRole].ToString() == "RM")
                 {
                     txtClientCode_autoCompleteExtender.ContextKey    = advisorVo.advisorId.ToString();
                     txtClientCode_autoCompleteExtender.ServiceMethod = "GetCustCode";
                 }
                 else if (Session[SessionContents.CurrentUserRole].ToString() == "Associates")
                 {
                     txtClientCode_autoCompleteExtender.ContextKey    = advisorVo.advisorId.ToString();
                     txtClientCode_autoCompleteExtender.ServiceMethod = "GetCustCode";
                 }
             }
             else
             {
                 dvViewMandateMis.Visible = true;
                 BindMandateddetailsDetailsGrid(advisorVo.advisorId);
             }
         }
     }
 }
        //int changeTemp;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SessionBo.CheckSession();
                advisorPreferenceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
                if (Session["CustomerUser"] != null)
                {
                    userVo   = (UserVo)Session["CustomerUser"];
                    tempPass = 1;
                }
                else
                {
                    userVo   = (UserVo)Session["UserVo"];
                    tempPass = 0;
                }

                txtCurrentPassword.Text = "";
                hdnuname.Value          = userVo.LoginId;
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ChangePassword.ascx:Page_Load()");
                object[] objects = new object[1];
                objects[0]   = userVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemple #11
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            GeneralConfigurationVo generalconfigurationvo = new GeneralConfigurationVo();
            GeneralConfigurationBo generalvonfigurationbo = new GeneralConfigurationBo();
            HttpCookie             UserPreference;
            string userTheme = string.Empty;
            string url       = HttpContext.Current.Request.Url.AbsoluteUri;


            if (url == "http://122.166.49.40:86/" || url == "http://192.168.0.1:86/" || ConfigurationManager.AppSettings["Website_ADVISER"].ToString() != "1021")
            {
                PCGLabel.Text = "2015 @ Ampsys Consulting Pvt. Ltd.";
            }
            if (Request.Cookies["UserPreference"] != null)
            {
                // get the cookie
                HttpCookie cookie = Request.Cookies["UserPreference"];
                // get the cookie value
                userTheme           = Request.Cookies["UserPreference"].Values["UserTheme"];
                Page.Theme          = userTheme;
                lnkBrowserIcon.Href = Request.Cookies["UserPreference"].Values["UserICOFilePath"];
            }

            if (Session["advisorVo"] != null)
            {
                advisorVo = (AdvisorVo)Session["advisorVo"];
            }
            xmlPath = Server.MapPath(ConfigurationManager.AppSettings["xmllookuppath"]).ToString();
            if (advisorVo.HostId != 0)
            {
                generalconfigurationvo = generalvonfigurationbo.GetHostGeneralConfiguration(xmlPath, advisorVo.HostId);
            }
            else
            {
                generalconfigurationvo = generalvonfigurationbo.GetHostGeneralConfiguration(xmlPath, 1000);
            }

            Session[SessionContents.SAC_HostGeneralDetails] = generalconfigurationvo;
            if (Session[SessionContents.SAC_HostGeneralDetails] != null)
            {
                generalconfigurationvo = (GeneralConfigurationVo)Session[SessionContents.SAC_HostGeneralDetails];

                if (!string.IsNullOrEmpty(generalconfigurationvo.DefaultTheme))
                {
                    if (Session["Theme"] == null || Session["Theme"].ToString() == string.Empty)
                    {
                        if (string.IsNullOrEmpty(userTheme))
                        {
                            userTheme = generalconfigurationvo.DefaultTheme;
                        }
                    }
                    else if (Session["Theme"] != null)
                    {
                        userTheme = Session["Theme"].ToString();
                    }
                }
                if (!string.IsNullOrEmpty(generalconfigurationvo.ApplicationName))
                {
                    Page.Title = generalconfigurationvo.ApplicationName;
                }
            }
            //SET THE THEME FROM USER COOKIES OR DEFAULT
            Page.Theme       = userTheme;
            Session["Theme"] = userTheme;


            //if (Session["Theme"] == null || Session["Theme"].ToString() == string.Empty)
            //{
            //    Session["Theme"] = "Maroon";
            //}

            //Page.Theme = Session["Theme"].ToString();
            if (Session["AdvisorPreferenceVo"] != null)
            {
                advisorPreferenceVo        = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
                Page.Title                 = advisorPreferenceVo.BrowserTitleBarName;
                lnkBrowserIcon.Href        = "~//Images//favicon//" + advisorPreferenceVo.BrowserTitleBarIconImageName;
                hidUserLogOutPageUrl.Value = advisorPreferenceVo.LoginWidgetLogOutPageURL;

                UserPreference = new HttpCookie("UserPreference");
                UserPreference.Values["UserLoginPageURL"] = advisorPreferenceVo.WebSiteDomainName;
                if (!string.IsNullOrEmpty(Page.Theme))
                {
                    UserPreference.Values["UserTheme"] = Page.Theme.ToString();
                }
                UserPreference.Values["UserICOFilePath"] = lnkBrowserIcon.Href.ToString();
                UserPreference.Expires = DateTime.Now.AddDays(1);
                Response.Cookies.Add(UserPreference);
            }
        }
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            AdvisorPreferenceVo advisorPreferenceVo = new AdvisorPreferenceVo();

            advisorVo = (AdvisorVo)Session["advisorVo"];
            if (Session["AdvisorPreferenceVo"] != null)
            {
                advisorPreferenceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
            }

            int    selectedRecords = 0;
            string statusMessage   = string.Empty;

            advisorVo = (AdvisorVo)Session["advisorVo"];
            string logoPath = string.Empty;

            if (Page.IsValid)
            {
                //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "$.colorbox({width: '700px', overlayClose: false, inline: true, href: '#LoadImage'});", true);
                try
                {
                    foreach (GridDataItem gvr in gvUserMgt.Items)
                    {
                        if (((CheckBox)gvr.FindControl("cbRecons")).Checked == true)
                        {
                            selectedRecords++;
                            int    selectedRow = gvr.ItemIndex + 1;
                            string Phone1Details = string.Empty, phone2Details = string.Empty, phone3Details = string.Empty, PhoneNumber = string.Empty;
                            userId = int.Parse((gvUserMgt.MasterTableView.DataKeyValues[selectedRow - 1]["UserId"].ToString()));
                            Emailer      emailer        = new Emailer();
                            EmailMessage email          = new EmailMessage();
                            string       hassedPassword = string.Empty;
                            string       saltValue      = string.Empty;
                            encryption = new OneWayEncryption();
                            Random r = new Random();

                            userVo = userBo.GetUserDetails(userId);
                            string password = r.Next(20000, 100000).ToString();
                            encryption.GetHashAndSaltString(password, out hassedPassword, out saltValue);
                            userVo.Password          = hassedPassword;
                            userVo.PasswordSaltValue = saltValue;
                            userVo.OriginalPassword  = password;
                            userVo.IsTempPassword    = 1;
                            userBo.UpdateUser(userVo);

                            string userName = userVo.FirstName + " " + userVo.MiddleName + " " + userVo.LastName;

                            email.GetResetPasswordMail(userVo.LoginId, password, userName);
                            email.Subject = email.Subject.Replace("WealthERP", advisorVo.OrganizationName);
                            email.Subject = email.Subject.Replace("MoneyTouch", advisorVo.OrganizationName);
                            //email.Body = email.Body.Replace("[ORGANIZATION]", advisorVo.OrganizationName);
                            email.Body = email.Body.Replace("[CUSTOMER_NAME]", userVo.FirstName);
                            if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                            {
                                email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                            }
                            else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Citrus")
                            {
                                email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                            }

                            email.Body = email.Body.Replace("[CONTACTPERSON]", advisorVo.ContactPersonFirstName + " " + advisorVo.ContactPersonMiddleName + " " + advisorVo.ContactPersonLastName);
                            if (!string.IsNullOrEmpty(advisorVo.Designation))
                            {
                                email.Body = email.Body.Replace("[DESIGNATION]", advisorVo.Designation.Trim());
                            }
                            else
                            {
                                email.Body = email.Body.Replace("[DESIGNATION]", string.Empty);
                            }
                            if (!string.IsNullOrEmpty(advisorVo.Phone1Number.ToString()) || !string.IsNullOrEmpty(advisorVo.Phone2Number.ToString()) || !string.IsNullOrEmpty(advisorVo.Phone3Number.ToString()))
                            {
                                if (!string.IsNullOrEmpty(advisorVo.Phone1Isd) && !string.IsNullOrEmpty(advisorVo.Phone1Std) && advisorVo.Phone1Number > 1)
                                {
                                    Phone1Details = advisorVo.Phone1Isd.ToString() + "-" + advisorVo.Phone1Std.ToString() + "-" + advisorVo.Phone1Number.ToString();
                                }
                                else if (!string.IsNullOrEmpty(advisorVo.Phone1Isd) && !string.IsNullOrEmpty(advisorVo.Phone1Std) && advisorVo.Phone1Number > 1)
                                {
                                    Phone1Details = advisorVo.Phone1Std.ToString() + "-" + advisorVo.Phone1Number.ToString();
                                }
                                else if (!string.IsNullOrEmpty(advisorVo.Phone1Isd) && !string.IsNullOrEmpty(advisorVo.Phone1Std) && advisorVo.Phone1Number > 1)
                                {
                                    Phone1Details = advisorVo.Phone1Isd.ToString() + "-" + advisorVo.Phone1Number.ToString();
                                }
                                else if (string.IsNullOrEmpty(advisorVo.Phone1Isd) && string.IsNullOrEmpty(advisorVo.Phone1Std) && advisorVo.Phone1Number > 1)
                                {
                                    Phone1Details = advisorVo.Phone1Number.ToString();
                                }


                                if (!string.IsNullOrEmpty(advisorVo.Phone2Isd) && !string.IsNullOrEmpty(advisorVo.Phone2Std) && advisorVo.Phone2Number > 1)
                                {
                                    phone2Details = advisorVo.Phone2Isd.ToString() + "-" + advisorVo.Phone2Std.ToString() + "-" + advisorVo.Phone2Number.ToString();
                                }
                                else if (string.IsNullOrEmpty(advisorVo.Phone2Isd) && !string.IsNullOrEmpty(advisorVo.Phone2Std) && advisorVo.Phone2Number > 1)
                                {
                                    phone2Details = advisorVo.Phone2Std.ToString() + "-" + advisorVo.Phone2Number.ToString();
                                }
                                else if (!string.IsNullOrEmpty(advisorVo.Phone2Isd) && string.IsNullOrEmpty(advisorVo.Phone2Std) && advisorVo.Phone2Number > 1)
                                {
                                    phone2Details = advisorVo.Phone2Isd.ToString() + "-" + advisorVo.Phone2Number.ToString();
                                }
                                else if (string.IsNullOrEmpty(advisorVo.Phone2Isd) && string.IsNullOrEmpty(advisorVo.Phone2Std) && advisorVo.Phone2Number > 1)
                                {
                                    phone2Details = advisorVo.Phone2Number.ToString();
                                }

                                if (!string.IsNullOrEmpty(advisorVo.Phone3Isd) && !string.IsNullOrEmpty(advisorVo.Phone3Std) && advisorVo.Phone3Number > 1)
                                {
                                    phone3Details = advisorVo.Phone3Isd.ToString() + "-" + advisorVo.Phone3Std.ToString() + "-" + advisorVo.Phone3Number.ToString();
                                }
                                else if (string.IsNullOrEmpty(advisorVo.Phone3Isd) && !string.IsNullOrEmpty(advisorVo.Phone3Std) && advisorVo.Phone3Number > 1)
                                {
                                    phone3Details = advisorVo.Phone3Std.ToString() + "-" + advisorVo.Phone3Number.ToString();
                                }
                                else if (!string.IsNullOrEmpty(advisorVo.Phone3Isd) && string.IsNullOrEmpty(advisorVo.Phone3Std) && advisorVo.Phone3Number > 1)
                                {
                                    phone3Details = advisorVo.Phone3Isd.ToString() + "-" + advisorVo.Phone3Number.ToString();
                                }
                                else if (string.IsNullOrEmpty(advisorVo.Phone3Isd) && string.IsNullOrEmpty(advisorVo.Phone3Std) && advisorVo.Phone3Number > 1)
                                {
                                    phone3Details = advisorVo.Phone3Number.ToString();
                                }
                                if (!string.IsNullOrEmpty(Phone1Details) && !string.IsNullOrEmpty(phone2Details) && !string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = Phone1Details + "/" + phone2Details + "/" + phone3Details;
                                }
                                else if (!string.IsNullOrEmpty(Phone1Details) && !string.IsNullOrEmpty(phone2Details) && string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = Phone1Details + "/" + phone2Details;
                                }
                                else if (string.IsNullOrEmpty(Phone1Details) && !string.IsNullOrEmpty(phone2Details) && !string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = phone2Details + "/" + phone3Details;
                                }
                                else if (!string.IsNullOrEmpty(Phone1Details) && string.IsNullOrEmpty(phone2Details) && !string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = Phone1Details + "/" + phone3Details;
                                }
                                else if (!string.IsNullOrEmpty(Phone1Details) && string.IsNullOrEmpty(phone2Details) && string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = Phone1Details;
                                }
                                else if (string.IsNullOrEmpty(Phone1Details) && !string.IsNullOrEmpty(phone2Details) && string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = phone2Details;
                                }
                                else if (string.IsNullOrEmpty(Phone1Details) && string.IsNullOrEmpty(phone2Details) && !string.IsNullOrEmpty(phone3Details))
                                {
                                    PhoneNumber = phone3Details;
                                }

                                email.Body = email.Body.Replace("[PHONE]", PhoneNumber);
                            }
                            else
                            {
                                email.Body = email.Body.Replace("[PHONE]", string.Empty);
                            }

                            if (!string.IsNullOrEmpty(advisorVo.Email))
                            {
                                email.Body = email.Body.Replace("[EMAIL]", advisorVo.Email.Trim());
                            }
                            else
                            {
                                email.Body = email.Body.Replace("[EMAIL]", string.Empty);
                            }

                            email.Body = email.Body.Replace("[LOGO]", "<img src='cid:HDIImage' alt='Logo'>");

                            System.Net.Mail.AlternateView htmlView;
                            System.Net.Mail.AlternateView plainTextView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("Text view", null, "text/plain");
                            //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(hidBody.Value.Trim() + "<image src=cid:HDIImage>", null, "text/html");
                            htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("<html><body " + "style='font-family:Tahoma, Arial; font-size: 10pt;'><p>" + email.Body + "</p></body></html>", null, "text/html");
                            //Add image to HTML version
                            if (advisorVo != null)
                            {
                                logoPath = "~/Images/" + advisorVo.LogoPath;
                            }
                            if (!File.Exists(Server.MapPath(logoPath)))
                            {
                                logoPath = "~/Images/spacer.png";
                            }
                            //System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath("~/Images/") + @"\3DSYRW_4009.JPG", "image/jpeg");
                            System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath(logoPath), "image/jpeg");
                            imageResource.ContentId = "HDIImage";
                            htmlView.LinkedResources.Add(imageResource);
                            //Add two views to message.
                            email.AlternateViews.Add(plainTextView);
                            email.AlternateViews.Add(htmlView);

                            email.To.Add(userVo.Email);

                            AdviserStaffSMTPBo adviserStaffSMTPBo = new AdviserStaffSMTPBo();
                            int rmId = Convert.ToInt32(ViewState["rmId"]);
                            AdviserStaffSMTPVo adviserStaffSMTPVo = adviserStaffSMTPBo.GetSMTPCredentials(rmId);
                            if (adviserStaffSMTPVo.HostServer != null && adviserStaffSMTPVo.HostServer != string.Empty)
                            {
                                emailer.isDefaultCredentials = !Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired);

                                if (!String.IsNullOrEmpty(adviserStaffSMTPVo.Password))
                                {
                                    emailer.smtpPassword = Encryption.Decrypt(adviserStaffSMTPVo.Password);
                                }
                                emailer.smtpPort     = int.Parse(adviserStaffSMTPVo.Port);
                                emailer.smtpServer   = adviserStaffSMTPVo.HostServer;
                                emailer.smtpUserName = adviserStaffSMTPVo.Email;

                                if (Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired))
                                {
                                    if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                                    {
                                        email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                                    }
                                    else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "MoneyTouch")
                                    {
                                        email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                                    }
                                }
                            }
                            bool isMailSent = false;

                            if (userBo.UpdateUser(userVo))
                            {
                                isMailSent = emailer.SendMail(email);
                            }

                            if (isMailSent)
                            {
                                statusMessage        = "Credentials have been reset and sent to selected user";
                                tblMessage.Visible   = true;
                                ErrorMessage.Visible = false;
                                SuccessMsg.InnerText = statusMessage;
                                SuccessMsg.Visible   = true;
                            }
                            else
                            {
                                statusMessage          = "An error occurred while sending mail to selected user";
                                tblMessage.Visible     = true;
                                ErrorMessage.Visible   = true;
                                ErrorMessage.InnerText = statusMessage;
                                SuccessMsg.Visible     = false;
                            }
                        }
                    }
                    //if (selectedRecords == 0)
                    //statusMessage = "Please select RM to send Password";


                    ErrorMessage.Visible = false;
                }
                catch (BaseApplicationException Ex)
                {
                    throw Ex;
                }
                catch (Exception Ex)
                {
                    BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                    NameValueCollection      FunctionInfo = new NameValueCollection();
                    FunctionInfo.Add("Method", "RMCustomerUserDetails.ascx:btnGenerate_Click()");

                    exBase.AdditionalInformation = FunctionInfo;
                    ExceptionManager.Publish(exBase);
                    throw exBase;
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            advisorVo = (AdvisorVo)Session["advisorVo"];
            if (Session["AdvisorPreferenceVo"] != null)
            {
                advisorPreferenceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
            }
            // userVo = userBo.GetUser(txtLoginId.Text);
            userVo = userBo.GetUserReset(txtLoginId.Text, txtEmail.Text, TxtPan.Text);
            if (userVo != null)
            {
                advisorVo = advisorBo.GetAssociateAdviserUser(userVo.UserId);
            }
            Random           r = new Random();
            OneWayEncryption encryption;

            encryption = new OneWayEncryption();
            bool          isSuccess     = false;
            string        logoPath      = string.Empty;
            string        statusMessage = string.Empty;
            ScriptManager script        = new ScriptManager();


            if (userVo != null)  // && userVo.Email == txtEmail.Text )
            {
                string hassedPassword = string.Empty;
                string saltValue      = string.Empty;
                string password       = r.Next(20000, 100000).ToString();

                //userVo = userBo.GetUserDetails(userId);
                //  string userName = userVo.FirstName + " " + userVo.MiddleName + " " + userVo.LastName;
                encryption.GetHashAndSaltString(password, out hassedPassword, out saltValue);
                userVo.Password          = hassedPassword;
                userVo.PasswordSaltValue = saltValue;
                userVo.OriginalPassword  = password;
                userVo.IsTempPassword    = 1;
                //  isSuccess = userBo.UpdateUser(userVo);
                isSuccess = userBo.UpdateUserReset(userVo);

                string userName = userVo.FirstName + " " + userVo.MiddleName + " " + userVo.LastName;
                email.GetResetPasswordMail(userVo.LoginId, password, userName);
                email.Subject = email.Subject.Replace("WealthERP", advisorVo.OrganizationName);
                email.Subject = email.Subject.Replace("MoneyTouch", advisorVo.OrganizationName);
                //email.Body = email.Body.Replace("[ORGANIZATION]", advisorVo.OrganizationName);
                email.Body = email.Body.Replace("[CUSTOMER_NAME]", userVo.FirstName);
                if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                {
                    email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                }
                else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Citrus")
                {
                    email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                }

                email.Body = email.Body.Replace("[CONTACTPERSON]", advisorVo.ContactPersonFirstName + " " + advisorVo.ContactPersonMiddleName + " " + advisorVo.ContactPersonLastName);
                if (!string.IsNullOrEmpty(advisorVo.Designation))
                {
                    email.Body = email.Body.Replace("[DESIGNATION]", advisorVo.Designation.Trim());
                }
                else
                {
                    email.Body = email.Body.Replace("[DESIGNATION]", string.Empty);
                }
                if (!string.IsNullOrEmpty(advisorVo.Phone1Number.ToString()))
                {
                    email.Body = email.Body.Replace("[PHONE]", advisorVo.Phone1Std.ToString().Trim() + "-" + advisorVo.Phone1Number.ToString().Trim());
                }
                else
                {
                    email.Body = email.Body.Replace("[PHONE]", string.Empty);
                }

                if (!string.IsNullOrEmpty(advisorVo.Email))
                {
                    email.Body = email.Body.Replace("[EMAIL]", advisorVo.Email.Trim());
                }
                else
                {
                    email.Body = email.Body.Replace("[EMAIL]", string.Empty);
                }

                email.Body = email.Body.Replace("[LOGO]", "<img src='cid:HDIImage' alt='Logo'>");

                System.Net.Mail.AlternateView htmlView;
                System.Net.Mail.AlternateView plainTextView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("Text view", null, "text/plain");
                //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(hidBody.Value.Trim() + "<image src=cid:HDIImage>", null, "text/html");
                htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("<html><body " + "style='font-family:Tahoma, Arial; font-size: 10pt;'><p>" + email.Body + "</p></body></html>", null, "text/html");
                //Add image to HTML version
                if (advisorVo != null)
                {
                    logoPath = "~/Images/" + advisorVo.LogoPath;
                }
                if (!File.Exists(Server.MapPath(logoPath)))
                {
                    logoPath = "~/Images/spacer.png";
                }
                //System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath("~/Images/") + @"\3DSYRW_4009.JPG", "image/jpeg");
                System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath(logoPath), "image/jpeg");
                imageResource.ContentId = "HDIImage";
                htmlView.LinkedResources.Add(imageResource);
                //Add two views to message.
                email.AlternateViews.Add(plainTextView);
                email.AlternateViews.Add(htmlView);

                email.To.Add(userVo.Email);

                AdviserStaffSMTPBo adviserStaffSMTPBo = new AdviserStaffSMTPBo();
                int rmId = userVo.rmid;
                AdviserStaffSMTPVo adviserStaffSMTPVo = adviserStaffSMTPBo.GetSMTPCredentials(rmId);
                if (adviserStaffSMTPVo.HostServer != null && adviserStaffSMTPVo.HostServer != string.Empty)
                {
                    emailer.isDefaultCredentials = !Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired);

                    if (!String.IsNullOrEmpty(adviserStaffSMTPVo.Password))
                    {
                        emailer.smtpPassword = Encryption.Decrypt(adviserStaffSMTPVo.Password);
                    }
                    emailer.smtpPort     = int.Parse(adviserStaffSMTPVo.Port);
                    emailer.smtpServer   = adviserStaffSMTPVo.HostServer;
                    emailer.smtpUserName = adviserStaffSMTPVo.Email;

                    if (Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired))
                    {
                        if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                        {
                            email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                        }
                        else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "MoneyTouch")
                        {
                            email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                        }
                    }
                }
                bool isMailSent = false;

                if (userBo.UpdateUser(userVo))
                {
                    isMailSent = emailer.SendMail(email);
                }

                if (isMailSent)
                {
                    statusMessage        = "Credentials have been reset and sent to your mail";
                    tblMessage.Visible   = true;
                    ErrorMessage.Visible = false;
                    SuccessMsg.InnerText = statusMessage;
                    SuccessMsg.Visible   = true;
                    txtLoginId.Text      = "";
                    txtEmail.Text        = "";
                    TxtPan.Text          = "";
                }
            }
            else
            {
                statusMessage          = "Password has been not reset sucessfully";
                tblMessage.Visible     = true;
                ErrorMessage.Visible   = true;
                ErrorMessage.InnerText = statusMessage;
                SuccessMsg.Visible     = false;
                txtLoginId.Text        = "";
                txtEmail.Text          = "";
                TxtPan.Text            = "";
            }
            //if (isSuccess)
            //{
            //    tblMessage.Visible = true;
            //    SuccessMsg.Visible = true;
            //    ErrorMessage.Visible = false;
            //    SuccessMsg.InnerText = "Password has been reset successfully...";
            //    txtLoginId.Text = "";
            //    txtEmail.Text = "";
            //    TxtPan.Text = "";
            //}
            //else
            //{
            //    tblMessage.Visible = true;
            //    SuccessMsg.Visible = false;
            //    ErrorMessage.Visible = true;
            //    ErrorMessage.InnerText = "An error occurred while reseting password.";

            //}
        }
Exemple #14
0
        private bool SendMail(UserVo userVo, bool isNewLogin)
        {
            Emailer             emailer             = new Emailer();
            EmailMessage        email               = new EmailMessage();
            AdvisorPreferenceVo advisorPreferenceVo = new AdvisorPreferenceVo();

            advisorVo = (AdvisorVo)Session["advisorVo"];
            if (Session["AdvisorPreferenceVo"] != null)
            {
                advisorPreferenceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
            }
            string logoPath       = string.Empty;
            bool   isMailSent     = false;
            bool   isEmailIdBlank = false;

            try
            {
                UserVo         uservo         = (UserVo)Session["userVo"];
                AdvisorStaffBo adviserstaffbo = new AdvisorStaffBo();

                //Get SMTP settings of admin if configured.
                RMVo advrm = new RMVo();
                advrm = adviserstaffbo.GetAdvisorStaff(uservo.UserId);
                AdviserStaffSMTPBo adviserStaffSMTPBo = new AdviserStaffSMTPBo();
                AdviserStaffSMTPVo adviserStaffSMTPVo = adviserStaffSMTPBo.GetSMTPCredentials(advrm.RMId);

                //Get the mail contents
                if (userVo.Email.Trim() != string.Empty)
                {
                    email.To.Add(userVo.Email);
                    string name = userVo.FirstName + " " + userVo.MiddleName + " " + userVo.LastName;
                    if (isNewLogin)
                    {
                        email.GetCustomerAccountMail(userVo.LoginId, userVo.OriginalPassword, name);
                    }
                    else
                    {
                        email.GetResetPasswordMail(userVo.LoginId, userVo.OriginalPassword, name);
                    }
                    email.Subject = email.Subject.Replace("WealthERP", advisorVo.OrganizationName);
                    email.Subject = email.Subject.Replace("MoneyTouch", advisorVo.OrganizationName);
                    email.Body    = email.Body.Replace("[ORGANIZATION]", advisorVo.OrganizationName);
                    email.Body    = email.Body.Replace("[CUSTOMER_NAME]", userVo.FirstName);
                    if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                    {
                        email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                    }
                    else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Citrus")
                    {
                        email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                    }
                    email.Body = email.Body.Replace("[CONTACTPERSON]", advisorVo.ContactPersonFirstName + " " + advisorVo.ContactPersonMiddleName + " " + advisorVo.ContactPersonLastName);
                    if (!string.IsNullOrEmpty(advisorVo.Designation))
                    {
                        email.Body = email.Body.Replace("[DESIGNATION]", advisorVo.Designation);
                    }
                    else
                    {
                        email.Body = email.Body.Replace("[DESIGNATION]", string.Empty);
                    }
                    if (!string.IsNullOrEmpty(advisorVo.Phone1Number.ToString()))
                    {
                        email.Body = email.Body.Replace("[PHONE]", advisorVo.Phone1Std.ToString() + "-" + advisorVo.Phone1Number.ToString());
                    }
                    else
                    {
                        email.Body = email.Body.Replace("[PHONE]", string.Empty);
                    }

                    if (!string.IsNullOrEmpty(advisorVo.Email))
                    {
                        email.Body = email.Body.Replace("[EMAIL]", advisorVo.Email);
                    }
                    else
                    {
                        email.Body = email.Body.Replace("[EMAIL]", string.Empty);
                    }

                    email.Body = email.Body.Replace("[LOGO]", "<img src='cid:HDIImage' alt='Logo'>");

                    System.Net.Mail.AlternateView htmlView;
                    System.Net.Mail.AlternateView plainTextView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("Text view", null, "text/plain");
                    //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(hidBody.Value.Trim() + "<image src=cid:HDIImage>", null, "text/html");
                    htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("<html><body " + "style='font-family:Tahoma, Arial; font-size: 10pt;'><p>" + email.Body + "</p></body></html>", null, "text/html");
                    //Add image to HTML version
                    if (advisorVo != null)
                    {
                        logoPath = "~/Images/" + advisorVo.LogoPath;
                    }
                    if (!File.Exists(Server.MapPath(logoPath)))
                    {
                        logoPath = "~/Images/spacer.png";
                    }
                    //System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath("~/Images/") + @"\3DSYRW_4009.JPG", "image/jpeg");
                    System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath(logoPath), "image/jpeg");
                    imageResource.ContentId = "HDIImage";
                    htmlView.LinkedResources.Add(imageResource);
                    //Add two views to message.
                    email.AlternateViews.Add(plainTextView);
                    email.AlternateViews.Add(htmlView);
                    //Send message
                    //System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();

                    //Assign SMTP Credentials if configured.
                    if (adviserStaffSMTPVo.HostServer != null && adviserStaffSMTPVo.HostServer != string.Empty)
                    {
                        emailer.isDefaultCredentials = !Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired);

                        if (!String.IsNullOrEmpty(adviserStaffSMTPVo.Password))
                        {
                            emailer.smtpPassword = Encryption.Decrypt(adviserStaffSMTPVo.Password);
                        }
                        emailer.smtpPort     = int.Parse(adviserStaffSMTPVo.Port);
                        emailer.smtpServer   = adviserStaffSMTPVo.HostServer;
                        emailer.smtpUserName = adviserStaffSMTPVo.Email;

                        if (Convert.ToBoolean(adviserStaffSMTPVo.IsAuthenticationRequired))
                        {
                            if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                            {
                                email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                            }
                            else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "MoneyTouch")
                            {
                                email.From = new MailAddress(emailer.smtpUserName, advisorVo.OrganizationName);
                            }
                        }
                    }
                    //Sending mail...
                    isMailSent = emailer.SendMail(email);
                }
                else
                {
                    isEmailIdBlank = true;
                }
                if (isEmailIdBlank)
                {
                    if (string.IsNullOrEmpty(statusMessage))
                    {
                        statusMessage          = "No email Id specified for selected User";
                        tblMessage.Visible     = true;
                        ErrorMessage.Visible   = true;
                        ErrorMessage.InnerText = statusMessage;
                        SuccessMsg.Visible     = false;
                    }
                    else
                    {
                        statusMessage          = statusMessage + " and some selected User don't have E-mail id";
                        tblMessage.Visible     = true;
                        ErrorMessage.Visible   = true;
                        ErrorMessage.InnerText = statusMessage;
                        SuccessMsg.Visible     = false;
                    }
                }

                else if (isMailSent)
                {
                    if (string.IsNullOrEmpty(statusMessage))
                    {
                        statusMessage        = "Credentials have been sent to selected User";
                        tblMessage.Visible   = true;
                        ErrorMessage.Visible = false;
                        SuccessMsg.InnerText = statusMessage;
                        SuccessMsg.Visible   = true;
                    }
                    else if (statusMessage == "No email Id specified for slected User")
                    {
                        statusMessage        = "some selected User don't have E-mail id and Credentials have been sent sucessfully to rest of User";
                        statusMessage        = "Credentials have been sent to selected User";
                        tblMessage.Visible   = true;
                        ErrorMessage.Visible = false;
                        SuccessMsg.InnerText = statusMessage;
                        SuccessMsg.Visible   = true;
                    }
                    else
                    {
                        tblMessage.Visible   = true;
                        ErrorMessage.Visible = false;
                        SuccessMsg.InnerText = statusMessage;
                        SuccessMsg.Visible   = true;
                    }
                }
                else
                {
                    statusMessage          = "An error occurred while sending mail .. ";
                    tblMessage.Visible     = true;
                    ErrorMessage.Visible   = true;
                    ErrorMessage.InnerText = statusMessage;
                    SuccessMsg.Visible     = false;
                }
            }
            catch (Exception ex)
            {
            }
            return(isMailSent);
        }
        public bool AdviserPreferenceSetUp(AdvisorPreferenceVo advisorPreferenceVo, int adviserId, int UserId, string strCommand)
        {
            Database  db;
            DbCommand cmdAdviserPreferenceSetUp;
            DataTable dtAdviserPreference = new DataTable();
            // string LoginWidgetLogOutPageURL=null;
            bool isSuccess = false;

            try
            {
                db = DatabaseFactory.CreateDatabase("wealtherp");
                cmdAdviserPreferenceSetUp = db.GetStoredProcCommand("SPROC_UpdateAdviserPreference");
                if (!string.IsNullOrEmpty(strCommand))
                {
                    db.AddInParameter(cmdAdviserPreferenceSetUp, "@strCommand", DbType.String, strCommand);
                }
                else
                {
                    db.AddInParameter(cmdAdviserPreferenceSetUp, "@strCommand", DbType.String, DBNull.Value);
                }

                db.AddInParameter(cmdAdviserPreferenceSetUp, "@AdviserId", DbType.Int32, adviserId);
                db.AddInParameter(cmdAdviserPreferenceSetUp, "@IsLoginWidgetEnable", DbType.Int16, advisorPreferenceVo.IsLoginWidgetEnable);
                if (!string.IsNullOrEmpty(advisorPreferenceVo.LoginWidgetLogOutPageURL))
                {
                    db.AddInParameter(cmdAdviserPreferenceSetUp, "@LoginWidgetLogOutPageURL", DbType.String, advisorPreferenceVo.LoginWidgetLogOutPageURL);
                }
                if (!string.IsNullOrEmpty(advisorPreferenceVo.BrowserTitleBarName))
                {
                    db.AddInParameter(cmdAdviserPreferenceSetUp, "@BrowserTitleBarName", DbType.String, advisorPreferenceVo.BrowserTitleBarName);
                }
                if (!string.IsNullOrEmpty(advisorPreferenceVo.WebSiteDomainName))
                {
                    db.AddInParameter(cmdAdviserPreferenceSetUp, "@WebSiteDomainName", DbType.String, advisorPreferenceVo.WebSiteDomainName);
                }
                db.AddInParameter(cmdAdviserPreferenceSetUp, "@GridPageSize", DbType.Int32, advisorPreferenceVo.GridPageSize);
                db.AddInParameter(cmdAdviserPreferenceSetUp, "@UserId", DbType.String, UserId);
                if (db.ExecuteNonQuery(cmdAdviserPreferenceSetUp) != 0)
                {
                    isSuccess = true;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorPreferenceDao.cs:AdviserPreferenceSetUp()");
                object[] objects = new object[2];
                objects[0]   = adviserId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(isSuccess);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionBo.CheckSession();
            userVo             = (UserVo)Session["userVo"];
            advisorPrefernceVo = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"];
            rmVo           = (RMVo)Session["rmVo"];
            adviserVo      = (AdvisorVo)Session["advisorVo"];
            associatesVo   = (AssociatesVO)Session["associatesVo"];
            assocUsrHeirVo = (AssociatesUserHeirarchyVo)Session["associatesUserHeirarchyVo"];


            if (Session[SessionContents.CurrentUserRole].ToString().ToLower() == "admin" || Session[SessionContents.CurrentUserRole].ToString().ToLower() == "ops" || userVo.AdviserRole.ContainsValue("CNT"))
            {
                txtCustomerName_autoCompleteExtender.ContextKey    = adviserVo.advisorId.ToString();
                txtCustomerName_autoCompleteExtender.ServiceMethod = "GetAdviserCustomerName";
                txtPansearch_autoCompleteExtender.ContextKey       = adviserVo.advisorId.ToString();
                txtPansearch_autoCompleteExtender.ServiceMethod    = "GetAdviserCustomerPan";
                txtClientCode_autoCompleteExtender.ContextKey      = adviserVo.advisorId.ToString();
                txtClientCode_autoCompleteExtender.ServiceMethod   = "GetCustCode";
            }

            if (Request.QueryString["reqId"] != null)
            {
                OnlineUserSessionBo.CheckSession();
                adviserVo  = (AdvisorVo)Session["advisorVo"];
                customerVo = (CustomerVo)Session["customerVo"];
                userVo     = (UserVo)Session["userVo"];
                BindTransactionGrid();
            }
            else
            {
                OnlineUserSessionBo.CheckSession();
                adviserVo  = (AdvisorVo)Session["advisorVo"];
                customerVo = (CustomerVo)Session["customerVo"];
                userVo     = (UserVo)Session["userVo"];


                fromDate             = DateTime.Now.AddMonths(-1);
                txtFrom.SelectedDate = fromDate.Date;
                txtTo.SelectedDate   = DateTime.Now;
            }
            if (!Page.IsPostBack)
            {
                BindAMC();
                Bindscheme();
                if (Request.QueryString["systematicId"] != null && Request.QueryString["AccountId"] != null && Request.QueryString["schemeplanCode"] != null && Request.QueryString["IsSourceAA"] != null && Request.QueryString["customerId"] != null)
                {
                    systematicId   = int.Parse(Request.QueryString["systematicId"].ToString());
                    AccountId      = int.Parse(Request.QueryString["AccountId"].ToString());
                    schemeplanCode = int.Parse(Request.QueryString["schemeplanCode"].ToString());
                    IsSourceAA     = int.Parse(Request.QueryString["IsSourceAA"].ToString());
                    customerid     = int.Parse(Request.QueryString["customerId"].ToString());
                    BindTransactionGrid();
                }
            }
            else
            {
                Bindscheme();
                fromDate             = DateTime.Now.AddMonths(-1);
                txtFrom.SelectedDate = fromDate.Date;
                txtTo.SelectedDate   = DateTime.Now;
            }
        }
        public static void SendMail(string To, string Cc, string Bcc, string Subject, string Body, ArrayList Attachments, string from, string emailTypeCode, DataTable dtAdviserSMTP, out string fromSMTPEmail, DataSet dsEmailTemplateDetails, out string statusMessage)
        {
            statusMessage = "";
            fromSMTPEmail = "";

            string templateId = string.Empty;
            string reportType = string.Empty;
            AdvisorPreferenceVo advisorPreferenceVo = null;
            AdvisorVo           advisorVo           = null;
            CustomerVo          customerVo          = null;
            RMVo                rmVo                           = null;
            AdvisorBo           advisorBo                      = new AdvisorBo();
            CustomerBo          customerBo                     = new CustomerBo();
            AdvisorStaffBo      advisorStaffBo                 = new AdvisorStaffBo();
            AdviserPreferenceBo adviserPreferenceBo            = new AdviserPreferenceBo();
            DataTable           dtEmailOutgoingParameterValues = dsEmailTemplateDetails.Tables[0];
            DataTable           dtEmailTemplateParameters      = dsEmailTemplateDetails.Tables[1];
            DataTable           dtAdviserEmailTemplate         = dsEmailTemplateDetails.Tables[2];
            DataTable           dtAdviserTemplateParametersPre = dsEmailTemplateDetails.Tables[3];

            _SMTPFrom = from;
            SetAdviserSMTP(dtAdviserSMTP, _SMTPFrom);

            SmtpClient   smtpClient = new SmtpClient();
            EmailMessage email      = new EmailMessage();

            //MailMessage email = new MailMessage(_SMTPFromDisplay, To);
            _SMTPUsername = GetSMTPUserFromPool();
            fromSMTPEmail = _SMTPUsername;

            email.To.Add(To);
            //string name = userVo.FirstName + " " + userVo.MiddleName + " " + userVo.LastName;

            email.ReadSendMailTemplate(emailTypeCode);

            foreach (DataRow dr in dtEmailOutgoingParameterValues.Rows)
            {
                switch (dr["WP_ParameterCode"].ToString())
                {
                case "AID":
                    advisorVo           = advisorBo.GetAdvisor(Convert.ToInt32(dr["WRD_InputParameterValue"].ToString()));
                    advisorPreferenceVo = adviserPreferenceBo.GetAdviserPreference(advisorVo.advisorId);
                    break;

                case "CID":
                    customerVo = customerBo.GetCustomer(Convert.ToInt32(dr["WRD_InputParameterValue"].ToString()));
                    rmVo       = advisorStaffBo.GetAdvisorStaffDetails(customerVo.RmId);
                    break;

                case "RT":
                    reportType = Convert.ToString(dr["WRD_InputParameterValue"]);
                    break;
                }
            }

            foreach (DataRow dr in dtAdviserEmailTemplate.Rows)
            {
                if (dr["WERPTTM_TypeCode"].ToString() == emailTypeCode)
                {
                    email.Body = email.Body.Replace("[EMAIL_BODY]", dr["AHTMLT_TemplateBody"].ToString());
                    templateId = dr["AHTMLT_Id"].ToString();
                    break;
                }
            }

            foreach (DataRow dr in dtEmailTemplateParameters.Rows)
            {
                string templateCode = dr["WERPTPM_TemplateParameterCode"].ToString();
                switch (templateCode)
                {
                case "[ADVISER_NAME]":
                    email.Body = email.Body.Replace(templateCode, advisorVo.FirstName + " " + advisorVo.MiddleName + " " + advisorVo.LastName);
                    break;

                case "[ADVISER_PHONE]":
                    email.Body = email.Body.Replace(templateCode, advisorVo.Phone1Std + "-" + advisorVo.Phone1Number);
                    break;

                case "[ADVISER_MOBILE]":
                    email.Body = email.Body.Replace(templateCode, advisorVo.MobileNumber.ToString());
                    break;

                case "[ADVISER_EMAIL]":
                    email.Body = email.Body.Replace(templateCode, advisorVo.Email.ToString());
                    break;

                case "[A_WEB_SITE]":
                    email.Body = email.Body.Replace(templateCode, advisorPreferenceVo.WebSiteDomainName.ToString());
                    break;

                case "[RM_NAME]":
                    email.Body = email.Body.Replace(templateCode, rmVo.FirstName + " " + rmVo.MiddleName + " " + rmVo.LastName);
                    break;

                case "[RM_MOBILE]":
                    email.Body = email.Body.Replace(templateCode, rmVo.Mobile.ToString());
                    break;

                case "[RM_EMAIL]":
                    email.Body = email.Body.Replace(templateCode, rmVo.Email.ToString());
                    break;

                case "[CUSTOMER_FIRST_NAME]":
                    email.Body = email.Body.Replace(templateCode, customerVo.FirstName);
                    break;

                case "[CUSTOMER_MIDDLE_NAME]":
                    email.Body = email.Body.Replace(templateCode, customerVo.MiddleName);
                    break;

                case "[CUSTOMER_LAST_NAME]":
                    email.Body = email.Body.Replace(templateCode, customerVo.LastName);
                    break;

                case "[START_LINE]":
                    email.Body = email.Body.Replace(templateCode, "<font face=" + "\"" + "[TEXT_FONT_NAME]" + "\"" + " size=" + "\"" + "[TEXT_FONT_SIZE]" + "\"" + " color=" + "\"" + "[TEXT_COLOR]" + "\"" + ">");
                    break;

                case "[END_LINE]":
                    email.Body = email.Body.Replace(templateCode, "</font>");
                    break;

                case "[LINE_BREAK]":
                    email.Body = email.Body.Replace(templateCode, "<br />");
                    break;

                case "[ONE_EMPTY_SPACE]":
                    email.Body = email.Body.Replace(templateCode, "&nbsp;");
                    break;

                case "[HYPERLINK_START]":
                    email.Body = email.Body.Replace(templateCode, "<a href=" + "\"" + "[A_WEB_SITE]" + "\"" + "target=" + "\"" + "_blank" + "\"" + ">");
                    break;

                case "[HYPERLINK_END]":
                    email.Body = email.Body.Replace(templateCode, "</a>");
                    break;

                case "[FONT_BOLD_START]":
                    email.Body = email.Body.Replace(templateCode, "<b>");
                    break;

                case "[FONT_BOLD_END]":
                    email.Body = email.Body.Replace(templateCode, "</b>");
                    break;

                case "[TEXT_FONT_NAME]":
                    email.Body = email.Body.Replace(templateCode, GetTemplateParamerValue(dtAdviserTemplateParametersPre, templateId, dr["WERPTPM_ParameterCode"].ToString()));
                    break;

                case "[TEXT_FONT_SIZE]":
                    email.Body = email.Body.Replace(templateCode, GetTemplateParamerValue(dtAdviserTemplateParametersPre, templateId, dr["WERPTPM_ParameterCode"].ToString()));
                    break;

                case "[TEXT_COLOR]":
                    email.Body = email.Body.Replace(templateCode, GetTemplateParamerValue(dtAdviserTemplateParametersPre, templateId, dr["WERPTPM_ParameterCode"].ToString()));
                    break;

                case "[REPORT_TYPE]":
                    //string reportType = GetTemplateParamerValue(dtAdviserTemplateParametersPre, reportTypeCode, dr["WERPTPM_ParameterCode"].ToString());
                    email.Body    = email.Body.Replace(templateCode, reportType);
                    email.Subject = email.Subject.Replace(templateCode, reportType);
                    break;
                }


                //email.Subject = email.Subject.Replace("MoneyTouch", advisorVo.OrganizationName);


                //email.Body = email.Body.Replace("[ORGANIZATION]", advisorVo.OrganizationName);
                //email.Body = email.Body.Replace("[CUSTOMER_NAME]", userVo.FirstName);
                //if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Wealtherp")
                //{
                //    email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                //}
                //else if (ConfigurationSettings.AppSettings["HostName"].ToString() == "Citrus")
                //{
                //    email.Body = email.Body.Replace("[WEBSITE]", advisorPreferenceVo.WebSiteDomainName);
                //}
                //email.Body = email.Body.Replace("[CONTACTPERSON]", advisorVo.ContactPersonFirstName + " " + advisorVo.ContactPersonMiddleName + " " + advisorVo.ContactPersonLastName);
                //if (!string.IsNullOrEmpty(advisorVo.Designation))
                //    email.Body = email.Body.Replace("[DESIGNATION]", advisorVo.Designation);
                //else
                //    email.Body = email.Body.Replace("[DESIGNATION]", string.Empty);
                //if (!string.IsNullOrEmpty(advisorVo.Phone1Number.ToString()))
                //    email.Body = email.Body.Replace("[PHONE]", advisorVo.Phone1Std.ToString() + "-" + advisorVo.Phone1Number.ToString());
                //else
                //    email.Body = email.Body.Replace("[PHONE]", string.Empty);

                //if (!string.IsNullOrEmpty(advisorVo.Email))
                //    email.Body = email.Body.Replace("[EMAIL]", advisorVo.Email);
                //else
                //    email.Body = email.Body.Replace("[EMAIL]", string.Empty);


                //if (_SMTPDefaultCredentials == true)
                //{
                //    NetworkCredential basicCredential = new NetworkCredential(_SMTPUsername, _SMTPPassword);
                //    smtpClient.UseDefaultCredentials = false;
                //    smtpClient.Credentials = basicCredential;
                //}
                //else
                //{
                //    smtpClient.UseDefaultCredentials = true;
                //}

                //smtpClient.Host = _SMTPServer;
                //if (_SMTPPort > 0)
                //    smtpClient.Port = _SMTPPort;

                ////Hardcoding SSL settings for gmail SMTP
                //if (_SMTPServer.Contains("smtp.gmail.com") || _SMTPServer.Contains("smtp.live.com"))
                //{
                //    smtpClient.EnableSsl = true;

                //}

                //if (Cc != null && Cc.Trim().Length > 0)
                //    mail.CC.Add(Cc);
                //if (Bcc != null && Bcc.Trim().Length > 0)
                //    mail.Bcc.Add(Bcc);

                //if (!string.IsNullOrEmpty(_SMTPFromDisplay.Trim()))
                //{
                //    if (_SMTPDefaultCredentials == true)
                //    {
                //        MailAddress md1 = new MailAddress(_SMTPUsername, _SMTPFromDisplay);
                //        mail.From = md1;
                //    }

                //    if (!string.IsNullOrEmpty(from.Trim()))
                //    {
                //        MailAddress md3 = new MailAddress(_SMTPFrom, _SMTPFromDisplay);
                //        mail.ReplyTo = md3;
                //    }
                //}



                //mail.Subject = Subject;
                //mail.IsBodyHtml = true;
                //mail.Body = Body;

                //if (mail.AlternateViews.Count != 0)
                //{
                //    foreach (AlternateView altrView in mail.AlternateViews)
                //    {
                //        mail.AlternateViews.Add(altrView);
                //    }
                //}

                //smtpClient.Send(mail);
            }

            foreach (object obj in Attachments)
            {
                Attachment attachment = attachment = new Attachment(obj.ToString());
                email.Attachments.Add(attachment);
            }

            //SendMail(To, Cc, Bcc, email.Subject.ToString(), email.Body.ToString(), Attachments, from, dtAdviserSMTP,out fromSMTPEmail);

            email.Body = email.Body.Replace("[A_WEB_SITE]", advisorPreferenceVo.WebSiteDomainName.ToString());


            email.Body = email.Body.Replace("[A_LOGO]", "<img src='cid:HDIImage' alt='Logo'>");
            string logoPath = string.Empty;

            System.Net.Mail.AlternateView htmlView;
            System.Net.Mail.AlternateView plainTextView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("Text view", null, "text/plain");
            //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(hidBody.Value.Trim() + "<image src=cid:HDIImage>", null, "text/html");
            htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(email.Body, null, "text/html");
            //Add image to HTML version
            if (advisorVo != null)
            {
                logoPath = _AdviserLogoDirectory + "\\" + advisorVo.LogoPath;
            }
            if (!File.Exists(logoPath))
            {
                logoPath = _AdviserLogoDirectory + "\\spacer.png";
            }
            //System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(Server.MapPath("~/Images/") + @"\3DSYRW_4009.JPG", "image/jpeg");
            System.Net.Mail.LinkedResource imageResource = new System.Net.Mail.LinkedResource(logoPath, "image/jpeg");
            imageResource.ContentId = "HDIImage";
            htmlView.LinkedResources.Add(imageResource);
            //Add two views to message.
            email.AlternateViews.Add(plainTextView);
            email.AlternateViews.Add(htmlView);

            //SendMail(To, Cc, Bcc, email.Subject.ToString(), email.Body.ToString(), Attachments, from, dtAdviserSMTP, out fromSMTPEmail);

            SendMail(email, out statusMessage);
        }
Exemple #18
0
        bool GridViewCultureFlag = true; //For gridview currency culture export to excel

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (BindGroupHead() == "IE7 Compatibility View")
            //{
            //    HtmlMeta force = new HtmlMeta();
            //    force.HttpEquiv = "X-UA-Compatible";
            //    force.Content = "IE=edge";


            //    //Header.GetType.AddAt(0, force);
            //}
            try
            {
                SessionBo.CheckSession();
                this.Page.Culture   = "en-GB";
                advisorPreferenceVo = (AdvisorPreferenceVo)(Session["AdvisorPreferenceVo"]);

                // PageSize = (AdvisorPreferenceVo)Session["AdvisorPreferenceVo"].ToString();
                path      = Server.MapPath(ConfigurationManager.AppSettings["xmllookuppath"].ToString());
                advisorVo = (AdvisorVo)Session[SessionContents.AdvisorVo];
                rmVo      = (RMVo)Session[SessionContents.RmVo];

                if (Session[SessionContents.CurrentUserRole].ToString().ToLower() == "admin" || Session[SessionContents.CurrentUserRole].ToString().ToLower() == "ops")
                {
                    txtParentCustomer_autoCompleteExtender.ContextKey    = advisorVo.advisorId.ToString();
                    txtParentCustomer_autoCompleteExtender.ServiceMethod = "GetAdviserGroupCustomerName";
                }
                else if (Session[SessionContents.CurrentUserRole].ToString().ToLower() == "rm")
                {
                    txtParentCustomer_autoCompleteExtender.ContextKey    = rmVo.RMId.ToString();
                    txtParentCustomer_autoCompleteExtender.ServiceMethod = "GetParentCustomerName";
                }


                if (!IsPostBack)
                {
                    if (Cache["EquityTransactionDetails" + advisorVo.advisorId.ToString()] != null)
                    {
                        Cache.Remove("EquityTransactionDetails" + advisorVo.advisorId.ToString());
                    }
                    rbtnPickDate.Checked      = true;
                    rbtnPickPeriod.Checked    = false;
                    trRange.Visible           = true;
                    trPeriod.Visible          = false;
                    tdGroupHead.Visible       = false;
                    lblGroupHead.Visible      = false;
                    txtParentCustomer.Visible = false;
                    rfvGroupHead.Visible      = false;
                    Msgerror.Visible          = false;
                    gvMFTransactions.Visible  = false;
                    BindLastTradeDate();
                    txtFromDate.SelectedDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                    txtToDate.SelectedDate   = DateTime.Parse(DateTime.Now.ToShortDateString());

                    //    if (txtFromDate.SelectedDate != null || txtToDate.SelectedDate != null)
                    //        BindGrid(txtFromDate.SelectedDate.Value, txtToDate.SelectedDate.Value);
                    //    else
                    //        //  Panel2.Visible = false;
                    //        Msgerror.Visible = false;
                    //   // trMessage.Visible = false;
                }
                Msgerror.Visible = false;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "RMMultipleTransactionView.ascx:PageLoad()");

                object[] objects = new object[2];
                objects[0]   = advisorVo;
                objects[1]   = path;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }