Пример #1
0
        protected void Application_Start()
        {
            DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
            {
                ContextCondition = (context => DeviceDetection.IsMobile)
            });

            GlobalFilters.Filters.Add(new NoCacheActionFilter
            {
                Duration    = 1,
                VaryByParam = "none",
                Location    = OutputCacheLocation.Client,
                NoStore     = true
            });
            //GlobalFilters.Filters.Add(new AppicationVersionValidationActionFilter());
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            GlobalAppSettings.IsLatestVersion = DatabaseSchemaUpdater.IsLatestVersion();
        }
Пример #2
0
        public void UpdateSystemSettings(string systemSettingsData)
        {
            var systemSettings = JsonConvert.DeserializeObject <SystemSettings>(systemSettingsData);

            SystemSettingsModel.UpdateSystemSettings(systemSettings);
            GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);
        }
Пример #3
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);
        }
Пример #4
0
        public void SetSystemSettings(string globalAdminDetails, string systemSettingsData)
        {
            LogExtension.LogInfo("Initializes system settings at first time", MethodBase.GetCurrentMethod());
            var systemSettingsProperties = JsonConvert.DeserializeObject <SystemSettings>(systemSettingsData);
            var globalAdminDetail        = JsonConvert.DeserializeObject <User>(globalAdminDetails);

            systemSettingsProperties.SqlConfiguration.AuthenticationType = 0;

            GlobalAppSettings.DbSupport = systemSettingsProperties.SqlConfiguration.ServerType;

            var systemSettingsModel = new SystemStartUpPageModel();

            SystemStartUpPageModel.SetSystemProperties(systemSettingsProperties);
            Connection.ConnectionString = _tokenCryptography.Decrypt(systemSettingsProperties.SqlConfiguration.ConnectionString);

            var systemSettings = new SystemSettings
            {
                OrganizationName         = "Grout",
                WelcomeNoteText          = "Welcome to Grout",
                ActivationExpirationDays = 3,
                DateFormat     = "MM/dd/yyyy",
                FavIcon        = "Grout_Favicon.png",
                LoginLogo      = "Grout_Login_Logo.png",
                MainScreenLogo = "Grout_Main_Logo.png",
                ReportCount    = 20,
                TimeZone       = TimeZoneInfo.Local.Id,
                Language       = "en-US",
                BaseUrl        = new UriBuilder(HttpContext.Request.Url.Scheme, HttpContext.Request.Url.Host, HttpContext.Request.Url.Port).ToString().TrimEnd('/')
            };

            //Insert System Settings
            systemSettingsModel.InsertSystemSettings(systemSettings, _tokenCryptography.Decrypt(systemSettingsProperties.SqlConfiguration.ConnectionString));

            //Initialize System Settings
            GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            //Add System Administrator
            SystemStartUpPageModel.AddSystemAdmin(globalAdminDetail.UserName.ToLower(), CultureInfo.CurrentCulture.TextInfo.ToTitleCase(globalAdminDetail.FirstName), CultureInfo.CurrentCulture.TextInfo.ToTitleCase(globalAdminDetail.LastName),
                                                  globalAdminDetail.Email.ToLower(), globalAdminDetail.Password);

            DatabaseSchemaUpdater.UpdateLaterversionToServerVersion(DatabaseSchemaUpdater.GetLatestVersion());
            GlobalAppSettings.IsLatestVersion = false;

            //Add Sample Reports
            SystemStartUpPageModel.InsertSampleReports();
        }
Пример #5
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"));
        }
Пример #6
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());
        }
Пример #7
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());
        }
Пример #8
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());
            }
        }
Пример #9
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));
        }