Example #1
0
        /// <summary>
        /// Serialize the System Settings Properties
        /// </summary>
        /// <param name="systemSettingsProperties"></param>
        public static void SetSystemProperties(SystemSettings systemSettingsProperties)
        {
            var serializer = new SystemSettingsSerializer();

            var configurationFolderPath = GlobalAppSettings.GetConfigFilepath();

            if (Directory.Exists(Path.GetFullPath(configurationFolderPath)) == false)
            {
                Directory.CreateDirectory(Path.GetFullPath(configurationFolderPath));
            }

            serializer.Serialize(systemSettingsProperties, configurationFolderPath + ServerSetup.Configuration);
        }
Example #2
0
        public ActionResult Startup()
        {
            FormsAuthentication.SignOut();
            var settings = new SystemSettingsSerializer().Deserialize(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            if (settings != null)
            {
                return(new RedirectResult("/reports"));
            }
            var listTimeZone = TimeZoneInfo.GetSystemTimeZones().ToList();

            ViewBag.listTimeZone = listTimeZone;
            if (Request.Url != null)
            {
                ViewBag.DefaultUrl = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "").Replace("http://", "");
            }
            return(View("System"));
        }
Example #3
0
        public static void UpdateSystemSettings(SystemSettings updatedSystemSettings)
        {
            var tokenCryptography = new TokenCryptography();
            var systemManagement  = new SystemManagement();
            var serializer        = new SystemSettingsSerializer();

            var systemSettings = serializer.Deserialize(GlobalAppSettings.GetConfigFilepath());

            systemManagement.UpdateSystemSetting(updatedSystemSettings.MailSettingsHost,
                                                 SystemSettingKeys.MailSettingsHost.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.MailSettingsPort.ToString(),
                                                 SystemSettingKeys.MailSettingsPort.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.MailSettingsSenderName,
                                                 SystemSettingKeys.MailSettingsSenderName.ToString());
            if (!String.IsNullOrEmpty(updatedSystemSettings.MailSettingsPassword))
            {
                systemManagement.UpdateSystemSetting(
                    tokenCryptography.DoEncryption(updatedSystemSettings.MailSettingsPassword),
                    SystemSettingKeys.MailSettingsPassword.ToString());
            }
            systemManagement.UpdateSystemSetting(updatedSystemSettings.MailSettingsIsSecureAuthentication.ToString(),
                                                 SystemSettingKeys.MailSettingsIsSecureAuthentication.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.MailSettingsAddress,
                                                 SystemSettingKeys.MailSettingsAddress.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.OrganizationName,
                                                 SystemSettingKeys.OrganizationName.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.LoginLogo,
                                                 SystemSettingKeys.LoginLogo.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.MainScreenLogo,
                                                 SystemSettingKeys.MainScreenLogo.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.FavIcon,
                                                 SystemSettingKeys.FavIcon.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.WelcomeNoteText,
                                                 SystemSettingKeys.WelcomeNoteText.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.DateFormat,
                                                 SystemSettingKeys.DateFormat.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.BaseUrl,
                                                 SystemSettingKeys.BaseUrl.ToString());
            systemManagement.UpdateSystemSetting(updatedSystemSettings.TimeZone,
                                                 SystemSettingKeys.TimeZone.ToString());
        }
Example #4
0
        public ActionResult Login()
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                GlobalAppSettings.SetTimeZone();
                return(new RedirectResult("/reports"));
            }

            var settings = new SystemSettingsSerializer().Deserialize(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            if (settings == null)
            {
                return(Redirect("/startup"));
            }

            TempData["password"] = "******";
            TempData["username"] = "******";
            ViewBag.ReturnURL    = Request["returnUrl"] ?? (HttpContext.Request.Cookies["mobile_cookie"] != null ? HttpContext.Request.Cookies["mobile_cookie"].Value : "");

            return(View());
        }
Example #5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                var settings = new SystemSettingsSerializer().Deserialize(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);
                if (filterContext.HttpContext.Request.Url != null)
                {
                    string[] segments = filterContext.HttpContext.Request.Url.Segments;
                    if (settings == null || (segments.Length == 2 && (segments[1].ToLower() == "startup" || segments[1].ToLower() == "login")) || (segments.Length == 3 && ((segments[1].ToLower() == "error/" && segments[2].ToLower() == "httperror500") || (segments[1].ToLower() == "user/" && segments[2].ToLower() == "avatar"))))
                    {
                        base.OnActionExecuting(filterContext);
                    }
                    else if (GlobalAppSettings.IsLatestVersion)
                    {
                        new DatabaseSchemaUpdater();
                        GlobalAppSettings.IsLatestVersion = DatabaseSchemaUpdater.IsLatestVersion();
                        if (GlobalAppSettings.IsLatestVersion)
                        {
                            LogExtension.LogError("Application Error 500 - Error in updating database schema", null, MethodBase.GetCurrentMethod());

                            filterContext.Result = new ViewResult
                            {
                                ViewName = "../Error/HttpError500"
                            };
                        }
                        base.OnActionExecuting(filterContext);
                    }
                    else
                    {
                        base.OnActionExecuting(filterContext);
                    }
                }
            }
            catch (Exception e)
            {
                LogExtension.LogError("Exception occured in AppicationVersionValidationActionFilter :", e, MethodBase.GetCurrentMethod());
            }
        }
Example #6
0
        public ActionResult Profile()
        {
            var settings = new SystemSettingsSerializer().Deserialize(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            if (settings == null)
            {
                //FormsAuthentication.SignOut();
                return(Redirect("/startup"));
            }
            var userDetail  = _userDetails.FindUserByUserId(Convert.ToInt32(HttpContext.User.Identity.Name));
            var userGroups  = _userDetails.GetAllGroupsOfUser(Convert.ToInt32(HttpContext.User.Identity.Name));
            var groupString = string.Empty;

            for (var group = 0; group < userGroups.Count; group++)
            {
                if (group != 0)
                {
                    groupString += ", ";
                }
                groupString += userGroups[group].Name;
            }
            ViewBag.GroupList = groupString;
            return(View(userDetail));
        }