public AuditEventListModel(String HolderName, List<AuditEvent> AuditEvents)
 {
     this.HolderName = HolderName;
     this.AuditEvents = AuditEvents;
     Filter = new AuditEventListFilter();
     AppParams = new ApplicationParameters();
 }
        public AuditEventListModel(string HolderName)
        {
            int result = 0;
            this.Filter = new AuditEventListFilter();
            AppParams = new ApplicationParameters();

            int TotalItems = 0;
            this.HolderName = HolderName;
            this.Filter.ItemsPerPage = (HttpContext.Current.Request["s"] != null && int.TryParse(HttpContext.Current.Request["s"], out result)) ? result : int.Parse(AppParams.AppUiPagingSize.Value);
            this.Filter.CurrentPage = (HttpContext.Current.Request["p"] != null && int.TryParse(HttpContext.Current.Request["p"], out result)) ? result : 1;

            this.Filter.SortColumn = (HttpContext.Current.Request["c"] != null && int.TryParse(HttpContext.Current.Request["c"], out result)) ? result : 3;
            this.Filter.SortOrderAsc = (HttpContext.Current.Request["o"] != null && (int.TryParse(HttpContext.Current.Request["o"], out result)) ? (result == 1 ? true : false) : false);
            this.Filter.SortColumnName = "EventID";
            this.Filter.Search = (HttpContext.Current.Request["q"] != null ? HttpUtility.UrlDecode(HttpContext.Current.Request["q"]) : "");

            switch (this.Filter.SortColumn)
            {
                case 1: Filter.SortColumnName = "EventType"; break;
                case 2: Filter.SortColumnName = "Created"; break;
                case 3: Filter.SortColumnName = "EventID"; break;
                case 4: Filter.SortColumnName = "EventSource"; break;
                case 5: Filter.SortColumnName = "IPAddress"; break;
                case 6: Filter.SortColumnName = "MemberEmail"; break;
                case 7: Filter.SortColumnName = "Description"; break;
            }

            this.AuditEvents  = Web.Admin.Logic.Collections.AuditEvents.Get(this.Filter,out TotalItems);
            this.TotalItems = TotalItems;
        }
 public MemberListModel(String HolderName, List<Member> Members)
 {
     this.HolderName = HolderName;
     this.Members = Members;
     Filter = new MemberListFilter();
     AppParams = new ApplicationParameters();
 }
        public RoleListModel(string HolderName)
        {
            int result = 0;
            Filter = new RoleListFilter();
            AppParams = new ApplicationParameters();

            int TotalItems = 0;
            this.HolderName = HolderName;
            this.Filter.ItemsPerPage = (HttpContext.Current.Request["s"] != null && int.TryParse(HttpContext.Current.Request["s"], out result)) ? result : int.Parse(AppParams.AppUiPagingSize.Value);
            this.Filter.CurrentPage = (HttpContext.Current.Request["p"] != null && int.TryParse(HttpContext.Current.Request["p"], out result)) ? result : 1;

            this.Filter.SortColumn = (HttpContext.Current.Request["c"] != null && int.TryParse(HttpContext.Current.Request["c"], out result)) ? result : 1;
            this.Filter.SortOrderAsc = (HttpContext.Current.Request["o"] != null && (int.TryParse(HttpContext.Current.Request["o"], out result)) ? (result == 1 ? true : false) : true);

            this.Filter.SortColumnName = "RoleID";
            switch (this.Filter.SortColumn)
            {
                case 2: this.Filter.SortColumnName = "Name"; break;
                case 3: this.Filter.SortColumnName = "MemberCount"; break;
                case 6: this.Filter.SortColumnName = "Created"; break;
                case 7: this.Filter.SortColumnName = "Modified"; break;
                case 5: this.Filter.SortColumnName = "Settings"; break;
            }

            this.Roles = Web.Admin.Logic.Collections.Roles.Get(Filter, out TotalItems);
            this.TotalItems = TotalItems;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Send email to a recipient and BCC members.
        /// </summary>
        /// <param name="FromName">Sender name.</param>
        /// <param name="FromEmail">Sender email.</param>
        /// <param name="ToName">Recipient name.</param>
        /// <param name="ToEmail">Recipient email.</param>
        /// <param name="Bcc">BCC recipient emails.</param>
        /// <param name="Subject">Mail subject.</param>
        /// <param name="Body">Mail body.</param>
        /// <returns>True if an email has been sent succesfully.</returns>
        public static bool SendMail(string FromName, string FromEmail, string ToName, string ToEmail, string Bcc, string Subject, string Body)
        {
            ApplicationParameters AppParams = Parameters;
            var    fromAddress  = new MailAddress(FromEmail, FromName);
            var    toAddress    = new MailAddress(ToEmail, ToName);
            string fromPassword = AppParams.MailServerSmtpPassword.Value;
            string subject      = Subject;
            string body         = Body;

            var smtp = new SmtpClient
            {
                Host           = Parameters.MailServerSmtpHost.Value,
                Port           = int.Parse(AppParams.MailServerSmtpPort.Value),
                EnableSsl      = bool.Parse(AppParams.MailServerSmtpSSLEnabled.Value),
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                Timeout        = 20000
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            })

                try
                {
                    if (Bcc != null && Bcc.Length > 0)
                    {
                        message.Bcc.Add(Bcc);
                    }
                    else
                    {
                        Bcc = "";
                    }

                    string Title = String.Format(AuditEvent.TheEmailhasBeenSent, FromName, FromEmail, ToName, ToEmail, Bcc, Subject);
                    smtp.Send(message);
                    AuditEvent.AppEventSuccess(FromEmail, Title, "##Details%%" + Title + "\r\n\r\nE-mail message:\r\n" + Body + "%%");
                    return(true);
                }
                catch (Exception ex)
                {
                    AuditEvent.AddAppEvent(
                        new AuditEventItem
                    {
                        EventType   = AuditEventType.Error,
                        IPAddress   = HttpContext.Current.Request.UserHostAddress,
                        MemberEmail = AppParams.GeneralAdminEmail.Value,
                        Description = ex.Message,
                        Details     = AuditEvent.GetSessionDetails("E-mail message:\r\n" + body + "\r\nStackTrace:\r\n" + ex.StackTrace)
                    }
                        );

                    return(false);
                }
        }
 public RoleListModel()
 {
     Roles = new List<Role>();
     Filter = new RoleListFilter();
     HolderName = "";
     Filter.ItemsPerPage = 5;
     Filter.CurrentPage = 1;
     AppParams = new ApplicationParameters();
 }
 public DomainListModel()
 {
     Domains = new List<Domain>();
     Filter = new DomainListFilter();
     HolderName = "";
     Filter.ItemsPerPage = 5;
     Filter.CurrentPage = 1;
     AppParams = new ApplicationParameters();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets true if email domain is allowed for sing-up. You can change the list of allowed mail domain via admin UI.
        /// </summary>
        /// <param name="Email">E-mail address.</param>
        /// <returns>True if email domain is allowed for sing-up.</returns>
        public static bool IsMailDomainAllowed(string Email)
        {
            string[] host     = (Email.Split('@'));
            string   hostname = host[1];

            ApplicationParameters _params = new ApplicationParameters();

            string[] _excludes = _params.RegistrationMailDomainRestrictionList.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            // Allow All
            if (_params.RegistrationMailDomainRestriction.Value == "1")
            {
                foreach (String _exclude in _excludes)
                {
                    if (_exclude.Trim().ToLower() == hostname.Trim())
                    {
                        return(false);
                    }
                }

                return(true);
            }
            // Deny All
            else if (_params.RegistrationMailDomainRestriction.Value == "2")
            {
                foreach (String _exclude in _excludes)
                {
                    if (_exclude.Trim().ToLower() == hostname.Trim())
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }
        public MemberListModel(string HolderName)
        {
            int result = 0;
            this.Filter = new MemberListFilter();
            AppParams = new ApplicationParameters();

            int TotalItems = 0;
            this.HolderName = HolderName;
            this.Filter.ItemsPerPage = (HttpContext.Current.Request["s"] != null && int.TryParse(HttpContext.Current.Request["s"], out result)) ? result : int.Parse(AppParams.AppUiPagingSize.Value);
            this.Filter.CurrentPage = (HttpContext.Current.Request["p"] != null && int.TryParse(HttpContext.Current.Request["p"], out result)) ? result : 1;

            this.Filter.SortColumn = (HttpContext.Current.Request["c"] != null && int.TryParse(HttpContext.Current.Request["c"], out result)) ? result : 1;
            this.Filter.SortOrderAsc = (HttpContext.Current.Request["o"] != null && (int.TryParse(HttpContext.Current.Request["o"], out result)) ? (result == 1 ? true : false) : true);
            this.Filter.SortColumnName = "MemberID";
            this.Filter.Search = (HttpContext.Current.Request["q"] != null ? HttpUtility.UrlDecode(HttpContext.Current.Request["q"]) : "");

            if (HttpContext.Current.Request["f"] != null)
            {
                if (HttpContext.Current.Request["f"] == "or")
                    Filter.RoleFilterCondition = MemberListFilterRoleConditon.OR;
                else if (HttpContext.Current.Request["f"] == "and")
                    Filter.RoleFilterCondition = MemberListFilterRoleConditon.AND;
            }

            switch (this.Filter.SortColumn)
            {
                case 2: this.Filter.SortColumnName = "Name"; break;
                case 4: this.Filter.SortColumnName = "Email"; break;
                case 5: this.Filter.SortColumnName = "LastLogin"; break;
                case 6: this.Filter.SortColumnName = "Created"; break;
            }

            this.Filter.AlphabetFilter = StringToList(HttpContext.Current.Request["a"] != null ? HttpContext.Current.Request["a"]  : "");
            this.Filter.RolesFilter = StringToList(HttpContext.Current.Request["r"] != null ? HttpContext.Current.Request["r"] : "");

            this.Members  = Web.Admin.Logic.Collections.Members.Get(this.Filter,out TotalItems);
            this.TotalItems = TotalItems;
        }
        /// <summary>
        /// Gets true if email domain is allowed for sing-up. You can change the list of allowed mail domain via admin UI.
        /// </summary>
        /// <param name="Email">E-mail address.</param>
        /// <returns>True if email domain is allowed for sing-up.</returns>
        public static bool IsMailDomainAllowed(string Email)
        {
            string[] host = (Email.Split('@'));
            string hostname = host[1];

            ApplicationParameters _params = new ApplicationParameters();
            string[] _excludes = _params.RegistrationMailDomainRestrictionList.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            // Allow All
            if (_params.RegistrationMailDomainRestriction.Value == "1")
            {
                foreach (String _exclude in _excludes)
                {
                    if (_exclude.Trim().ToLower() == hostname.Trim())
                        return false;
                }

                return true;
            }
            // Deny All
            else if (_params.RegistrationMailDomainRestriction.Value == "2")
            {
                foreach (String _exclude in _excludes)
                {
                    if (_exclude.Trim().ToLower() == hostname.Trim())
                        return true;
                }

                return false;
            }

            return false;
        }
 public AuditEventListModel()
 {
     AuditEvents = new List<AuditEvent>();
     Filter = new AuditEventListFilter();
     AppParams = new ApplicationParameters();
 }
 public MemberListModel()
 {
     Members = new List<Member>();
     Filter = new MemberListFilter();
     AppParams = new ApplicationParameters();
 }