Exemplo n.º 1
0
        private void Login(string LoginId, string Password)
        {
            var response = new LogonService().LoginUser(LoginId, Password, HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);

            Session.Timeout = AppConfigurationHelper.GetValue <int>(ConfigKeys.SessionTimeout);
            UserEntity user        = DataHelper.GetObject <UserEntity>(response);
            var        userSession = DataHelper.GetObject <UserSession>(response);

            SessionClass.LoginUserEntity = user;
            // SessionClass.FinancialYearId = new AcademicYearData().GetAcademicYear().Where(x => x.IsActive == true).FirstOrDefault().FinancialYearId;


            var userData = new UserSessionData {
                UserDisplayName = user.UserName, UserId = user.UserId, RoleId = user.RoleId, LoginTime = DateTime.Now, MenuList = DataHelper.GetListLevelZero <MenuEntity>(response)
            };

            var contextInfo = new ContextInfo {
                UserId = userSession.UserId, SessionId = userSession.Sessionid
            };

            Session[ctlMasterPage.ContextInfo]       = contextInfo;
            Session[ctlMasterPage.UserSessionObject] = userData;

            FormsAuthentication.SetAuthCookie(Page.User.Identity.Name, false);

            // Response.Redirect("~/UI/AdminDashBoard.aspx", false);

            Response.Redirect("~/UI/DashBoard.aspx", false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends the Email
        /// </summary>
        /// <param name="lstTo">List of To email addresses</param>
        /// <param name="strSubject">Subject of Email</param>
        /// <param name="strBody">Body of Email</param>
        /// <param name="isHtml">if set to <c>true</c> [is HTML].</param>
        public void Send(IList <string> lstTo, string strSubject, string strBody, bool isHtml = false)
        {
            try
            {
                if (!AppConfigurationHelper.GetValue <bool>(ConfigKeys.EnableAlerts))
                {
                    return;
                }

                LogWriter.GetLogWriter().Debug("Sending email to " + string.Join(",", lstTo.ToArray()) + " Subject:" + strSubject + " Body:" + strBody);
                var mailMessage = new MailMessage {
                };
                mailMessage.From = new MailAddress(FromAddress);
                foreach (string strTo in lstTo)
                {
                    mailMessage.To.Add(new MailAddress(strTo));
                }
                mailMessage.Subject    = strSubject;
                mailMessage.Body       = strBody;
                mailMessage.IsBodyHtml = isHtml;

                var smtp = new SmtpClient(SmtpServer, Port)
                {
                };

                if (UseCredentials)
                {
                    smtp.Credentials = new NetworkCredential(Username, Password, Domain);
                }

                smtp.Send(mailMessage);
            }
            catch (Exception ex)
            {
                LogWriter.GetLogWriter().Exception(ex);
            }
        }
Exemplo n.º 3
0
        public void Send(string subject, string body, ListDictionary replacements, bool isHtml, params string[] recipients)
        {
            try
            {
                if (!AppConfigurationHelper.GetValue <bool>(ConfigKeys.EnableAlerts))
                {
                    return;
                }

                LogWriter.GetLogWriter().Debug(string.Format("Sending email to {0} Subject:{1} Body:{2}", string.Join(";", recipients), subject, body));

                var md = new MailDefinition
                {
                    From       = FromAddress,
                    Subject    = subject,
                    IsBodyHtml = isHtml
                };

                var smtp = new SmtpClient(SmtpServer, Port);
                if (UseCredentials)
                {
                    smtp.Credentials = new NetworkCredential(Username, Password, Domain);
                }

                if (File.Exists(body))
                {
                    md.BodyFileName = body;
                    smtp.Send(md.CreateMailMessage(string.Join(";", recipients), replacements == null ? new ListDictionary() : replacements, new System.Web.UI.Control()));
                }
                else
                {
                    smtp.Send(md.CreateMailMessage(string.Join(";", recipients), replacements == null ? new ListDictionary() : replacements, body, new System.Web.UI.Control()));
                }
            }
            catch (Exception ex) { LogWriter.GetLogWriter().Exception(ex); }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Will return the name
        /// </summary>
        /// <param name="fName">First Name</param>
        /// <param name="mName">Middle Name</param>
        /// <param name="lName">Last Name</param>
        /// <returns></returns>
        public static string DisplayNameFormat(string fName, string mName, string lName)
        {
            var displayNameFormat = AppConfigurationHelper.GetValue <string>(ConfigKeys.DisplayNameFormat);

            return(displayNameFormat.Replace("<L>", lName).Replace("<F>", fName).Replace("<M>", mName != string.Empty ? mName : string.Empty));
        }