public static SystemSettings GetSystemSettings() { var systemSettingsResult = new GlobalAppSettings().GetSystemSettings().DataTable.AsEnumerable() .Select(a => new { Key = a.Field <string>(GlobalAppSettings.DbColumns.DB_SystemSettings.Key), Value = a.Field <string>(GlobalAppSettings.DbColumns.DB_SystemSettings.Value) } ).ToDictionary(a => a.Key, a => a.Value); var systemSettings = new SystemSettings { OrganizationName = systemSettingsResult[SystemSettingKeys.OrganizationName.ToString()], LoginLogo = systemSettingsResult[SystemSettingKeys.LoginLogo.ToString()], MainScreenLogo = systemSettingsResult[SystemSettingKeys.MainScreenLogo.ToString()], FavIcon = systemSettingsResult[SystemSettingKeys.FavIcon.ToString()], WelcomeNoteText = systemSettingsResult[SystemSettingKeys.WelcomeNoteText.ToString()], Language = systemSettingsResult[SystemSettingKeys.Language.ToString()], TimeZone = systemSettingsResult[SystemSettingKeys.TimeZone.ToString()], DateFormat = systemSettingsResult[SystemSettingKeys.DateFormat.ToString()], BaseUrl = systemSettingsResult[SystemSettingKeys.BaseUrl.ToString()], ActivationExpirationDays = Convert.ToInt32(systemSettingsResult[SystemSettingKeys.ActivationExpirationDays.ToString()]), MailSettingsAddress = systemSettingsResult[SystemSettingKeys.MailSettingsAddress.ToString()], MailSettingsHost = systemSettingsResult[SystemSettingKeys.MailSettingsHost.ToString()], MailSettingsSenderName = systemSettingsResult[SystemSettingKeys.MailSettingsSenderName.ToString()], MailSettingsPort = Convert.ToInt32(systemSettingsResult[SystemSettingKeys.MailSettingsPort.ToString()]) == 0?25:Convert.ToInt32(systemSettingsResult[SystemSettingKeys.MailSettingsPort.ToString()]), MailSettingsIsSecureAuthentication = Convert.ToBoolean( systemSettingsResult[SystemSettingKeys.MailSettingsIsSecureAuthentication.ToString()]) }; return(systemSettings); }
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(); }
protected override void OnStop() { var serviceStopTime = new ServiceStopTime { ScheduleEndTime = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture) }; try { var schedulerExportPath = GlobalAppSettings.GetSchedulerExportPath(); if (Directory.Exists(schedulerExportPath) == false) { Directory.CreateDirectory(schedulerExportPath); } new SchedulerJob().SerializeTime(serviceStopTime, GlobalAppSettings.GetSchedulerExportPath() + "config.xml"); LogExtension.LogInfo("Service stopped", MethodBase.GetCurrentMethod()); } catch (Exception e) { LogExtension.LogError("Exception is thrown while stopping service", e, MethodBase.GetCurrentMethod()); } finally { base.OnStop(); } }
public ActionResult Avatar(string username, double imageSize) { var image = String.Empty; try { var user = _userDetails.FindUserByUserId(int.Parse(username)); if (String.IsNullOrWhiteSpace(user.Avatar)) { return(GetDefaultAvatar()); } image = GlobalAppSettings.GetProfilePicturesPath() + user.UserName + "//" + imageSize + "//" + user.Avatar; } catch { var avatarName = _userDetails.FindUserByUserName(username).Avatar; if (String.IsNullOrWhiteSpace(avatarName)) { return(GetDefaultAvatar()); } image = GlobalAppSettings.GetProfilePicturesPath() + username + "//" + imageSize + "//" + avatarName; } return(File(image, "image/png")); }
public void UpdateSystemSettings(string systemSettingsData) { var systemSettings = JsonConvert.DeserializeObject <SystemSettings>(systemSettingsData); SystemSettingsModel.UpdateSystemSettings(systemSettings); GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration); }
public JsonResult UpdateProfilePicture(ProfilePicture selection) { var timeNow = DateTime.UtcNow; var formattedString = GlobalAppSettings.GetFormattedTimeZone(timeNow, selection.UserId); var imageName = _userProfile.UpdateUserAvatarDetails(selection, timeNow); return(Json(new { imageName, formattedString })); }
public string GetFormattedTimeZone(DateTime timeNow, int userId) { var timeZone = new UserManagement().GetUserPreferTimeZone(userId); DateTime date = GlobalAppSettings.GetCovertedTimeZone(timeNow, timeZone); var formattedString = date.ToString(GlobalAppSettings.SystemSettings.DateFormat + " hh:mm:ss tt"); return(formattedString); }
static void Main() { GlobalAppSettings.Init(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); }
public JsonResult TransferImage(string path, string username) { var userId = _userDetails.GetUserId(username); DateTime timeNow = DateTime.UtcNow; var formattedString = GlobalAppSettings.GetFormattedTimeZone(timeNow, userId); var imageName = _userProfile.DefaultavatarTransfer(path, username, timeNow); return(Json(new { imageName, formattedString })); }
public static void UpdateSession() { var userDetail = new UserManagement().FindUserByUserId(Convert.ToInt32(HttpContext.Current.User.Identity.Name)); HttpContext.Current.Session["displayname"] = userDetail.DisplayName; HttpContext.Current.Session["firstname"] = userDetail.FirstName; HttpContext.Current.Session["lastname"] = userDetail.LastName; HttpContext.Current.Session["IsAdmin"] = GlobalAppSettings.IsAdmin(userDetail.UserId); }
public void LoadSettings() { try { _appSettings = StorageManager.DeserializeObjectFromFile <GlobalAppSettings>(this.settingsFilePath, APP_SERIALIZATION_KEY) ?? new GlobalAppSettings(); } catch (Exception ex) { LogWriter.WriteLog(ex.Message); } }
/// <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); }
public ActionResult Avatar(string username, double imageSize) { var avatarName = userDetails.FindUserByUserName(username).Avatar; if (String.IsNullOrWhiteSpace(avatarName)) { return(new UserController().GetDefaultAvatar()); } var image = GlobalAppSettings.GetProfilePicturesPath() + username + "/" + imageSize + "/" + avatarName; return(File(image, "image/png")); }
public ActionResult ForgotPassword(string key) { if (String.IsNullOrWhiteSpace(key)) { return(View()); } var userDetail = _userManagement.IsValidEmail(key) ? _userManagement.FindUserByEmail(key) : _userManagement.FindUserByUserName(key); if (userDetail == null) { TempData["errorMessage"] = "Invalid username or email address"; return(View()); } else { var result = _userManagement.SetResetPasswordForUser(userDetail.UserId); if (result.Success) { var resetPasswordCode = result.Value.ToString(); var emailBody = "<html xmlns='http://www.w3.org/1999/xhtml' xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'><meta name='viewport' content='width=device-width'> <!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> <o:PixelsPerInch>96</o:PixelsPerInch> </o:OfficeDocumentSettings></xml><![endif]--></head><body style='min-width: 100%;-webkit-text-size-adjust: 100%;-ms-text-size-adjust: 100%;margin: 0;padding: 0;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;text-align: left;line-height: 19px;font-size: 14px;background-color: rgb(244,244,244);padding-top: 10px;width: 100% !important;'><center style='width: 100%;min-width: 580px;'><table style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='email-container' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;border-collapse: collapse !important;'><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='email-header' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0px 0px 10px;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;background-color: #ef5350;padding-right: 10px;padding-left: 10px;padding-top: 10px;padding-bottom: 18px;border-top-right-radius: 5px;border-top-left-radius: 5px;border-collapse: collapse !important;'><table class='body container' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;height: 100%;width: 580px;margin: 0;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;line-height: 19px;font-size: 14px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='sync-inc wrapper' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 2px 10px 10px;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;position: relative;border-collapse: collapse !important;'><h6 style='color: white;font-family: "Segoe UI",sans-serif !important;font-weight: 500;padding: 0;margin: 0;text-align: left;line-height: 1.3;word-break: normal;font-size: 20px;font-style: normal;'><a href='" + GlobalAppSettings.SystemSettings.BaseUrl + "/accounts/login' style='color: white;text-decoration: none;'>" + GlobalAppSettings.SystemSettings.OrganizationName + "</a></h6></td></tr></tbody></table><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 50px 0px 10px 273px;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;position: relative;border-collapse: collapse !important;'><img src='" + GlobalAppSettings.SystemSettings.BaseUrl + "/Content/Images/Application/" + GlobalAppSettings.SystemSettings.MainScreenLogo + "' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: auto;max-width: 100%;float: none;clear: both;margin: 0 auto;'></td></tr><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='welcome wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0px 0px 17px;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;position: relative;border-collapse: collapse !important;'><h6 style='color: white;font-family: "Segoe UI",sans-serif;font-weight: lighter;padding: 0;margin: 0;text-align: center;line-height: 1.3;word-break: normal;font-size: 20px;'>RESET YOUR LOST PASSWORD</h6></td></tr></tbody></table></td></tr></tbody></table><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='message-body' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0px 0px 10px;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;background-color: white;padding-right: 10px;padding-left: 10px;border-bottom-right-radius: 5px;border-bottom-left-radius: 5px;border-collapse: collapse !important;'><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='activation-msg' style='padding-top: 20px;padding-left: 4px; padding-bottom: 7px; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto; vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;border-collapse: collapse !important;'><p style='margin-bottom: 4px;margin: 0;color: #353535;font-family: "Segoe UI",sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 12px;'>Hello " + userDetail.DisplayName + ",</p></td></tr></tbody></table><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='activation-msg' style='padding-top: 5px;padding-left: 4px; padding-bottom: 18px; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto; vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;border-collapse: collapse !important;'><p style='margin-bottom: 4px;margin: 0;color: #353535;font-family: "Segoe UI",sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 12px;'>We have received a request to reset the password for your grout account. Please click Reset to set a new password.</p></td></tr></tbody></table><table style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td style='padding-left: 4px;padding-bottom: 0px; padding-top: 0px; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;border-collapse: collapse !important;'><table class='block-grid five-up' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;width: 100%;max-width: 580px;'><tbody><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='activate-btn center' style='border-radius: 3px; padding: 0px;'><div><!--[if mso]><v:roundrect xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w='urn:schemas-microsoft-com:office:word' href='" + GlobalAppSettings.SystemSettings.BaseUrl + "/accounts/forgot-password/change-password?userid=" + userDetail.UserId + "&recoverycode=" + resetPasswordCode + "' style='height:28px;v-text-anchor:middle;width:100px;' arcsize='11%' stroke='f' fillcolor='#ef5350'><w:anchorlock/><center><![endif]--><a href='" + GlobalAppSettings.SystemSettings.BaseUrl + "/accounts/forgot-password/change-password?userid=" + userDetail.UserId + "&recoverycode=" + resetPasswordCode + "'style='background-color:#ef5350;border-radius:3px;color:#ffffff;display:inline-block; font-family: "Segoe UI",sans-serif; font-size:14px;font-weight:500;line-height:28px;text-align:center;text-decoration:none;width:100px;-webkit-text-size-adjust:none;'>RESET</a><!--[if mso]></center></v:roundrect><![endif]--></div></td></tr></tbody></table></td></tr></tbody></table><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 580px;'><tr style='padding: 0;vertical-align: top;text-align: left;'><td class='signature' style='padding-left: 4px;padding-bottom: 0px; padding-top: 18px; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;vertical-align: top;text-align: left;color: #222222;font-family: "Helvetica", "Segoe UI", sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;border-collapse: collapse !important;'><p style='margin-bottom: 6px;color: #353535;font-family: "Segoe UI",sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 12px;margin-top: 0px;'>Regards,</p><p style='margin: 0;margin-bottom: 10px;color: #353535;font-family: "Segoe UI",sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 12px;'>" + GlobalAppSettings.SystemSettings.OrganizationName + " </p></td></tr></table></td></tr></tbody></table></td></tr></tbody></table></center></body></html>"; GlobalAppSettings.SendCustomMail(userDetail.Email, emailBody, GlobalAppSettings.SystemSettings.OrganizationName + ": Reset password"); TempData["message"] = "An email with instructions on how to change your password has been sent to " + userDetail.Email; return(Redirect("/accounts/forgot-password/code-confirmation?userId=" + userDetail.UserId)); } else { TempData["errorMessage"] = "Internal server error. Please try again."; return(View()); } } }
public ActionResult UploadFileFormAction() { var result = ""; var userList = new List <Dictionary <string, string> >(); var uploadedCsvPath = ""; var httpPostedFileBase = Request.Files["csvfile"]; if (httpPostedFileBase != null && httpPostedFileBase.ContentLength > 0) { var fileName = httpPostedFileBase.FileName.Split('\\').Last(); var extension = Path.GetExtension(fileName); var uploadedFilesPath = GlobalAppSettings.GetUploadedFilesPath(); if (Directory.Exists(uploadedFilesPath) == false) { Directory.CreateDirectory(uploadedFilesPath); } if (extension == ".csv") { uploadedCsvPath = String.Format("{0}\\{1}", uploadedFilesPath, fileName); if (System.IO.File.Exists(uploadedCsvPath)) { System.IO.File.Delete(uploadedCsvPath); } httpPostedFileBase.SaveAs(uploadedCsvPath); userList = new UserManagementModel().SaveuserBulkUpload(uploadedCsvPath); result = "Success"; } else { result = "Error"; } } ViewBag.Pathname = uploadedCsvPath; ViewBag.UsersList = Json(new { Data = userList }); ViewBag.UserExists = httpPostedFileBase != null && userList.Count == 0; ViewBag.ser = GlobalAppSettings.Serializer.Serialize(ViewBag.UsersList); ViewBag.UserCount = userList.Count; ViewBag.result = result; return(View()); }
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(); }
/// <summary> /// Post action for getting the password and confirm password and resetting it. /// If the user id and reset code doesn't match with database, the error message showed here, otherwise it will show the change password form. /// After changed the password, the user will be redirected to the login page. /// </summary> /// <returns></returns> public ActionResult UpdatePassword() { FormsAuthentication.SignOut(); Session.Abandon(); var userId = Convert.ToInt32(Request["userId"]); var code = Request["recoveryCode"]; var password = Request["password"]; var userDetail = _userManagement.FindUserByUserId(userId); if (userDetail.ResetPasswordCode == code) { var encrypt = new Cryptography(); var encryptedPassword = Convert.ToBase64String(encrypt.Encryption(password)); var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.Password, Value = encryptedPassword }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ModifiedDate, Value = DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ResetPasswordCode, Value = _userManagement.GenerateRandomCode(12) }, }; var result = _userManagement.UpdateUserProfileDetails(updateColumns, userId); if (result) { TempData["User"] = "******"; return(Redirect("../login")); } else { TempData["Message"] = "Internal server error while updating password. Please try again."; return(Redirect("../forgot-Password/change-password?userid=" + userId + "&recovercode=" + code)); } } TempData["Message"] = "Invalid link"; return(Redirect("../accounts/forgot-Password/change-password?userid=" + userId + "&recovercode=" + code)); }
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")); }
public bool DeleteAvatar(int userId) { var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.Picture, Value = null }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ModifiedDate, Value = DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; return(_userDetails.UpdateUserProfileDetails(updateColumns, userId)); }
public void ReschedulePastSchedulerJobs(DateTime currentTime) { if (!File.Exists(GlobalAppSettings.GetSchedulerExportPath() + "config.xml")) { return; } try { var serviceStopTime = DeserializeTime(GlobalAppSettings.GetSchedulerExportPath() + "config.xml"); var lastProcessedDate = Convert.ToDateTime(serviceStopTime.ScheduleEndTime, CultureInfo.InvariantCulture); var pastSchedules = scheduleJobProcessor.GetFailedJobs(lastProcessedDate, currentTime); scheduleJobProcessor.RescheduleUnProcessedJobs(pastSchedules); File.Delete(GlobalAppSettings.GetSchedulerExportPath() + "config.xml"); } catch (Exception e) { LogExtension.LogError("Exception while re scheduling past schedules", e, MethodBase.GetCurrentMethod()); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.User.Identity.IsAuthenticated == false) { filterContext.Result = new RedirectResult("/login", true); } else { var isAdmin = GlobalAppSettings.IsAdmin(Convert.ToInt32(filterContext.HttpContext.User.Identity.Name)); if (isAdmin == false) { filterContext.Result = new ViewResult { ViewName = "../Home/PermissionDenied" }; } } base.OnActionExecuting(filterContext); }
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()); }
public string GetallimagesofParticularUser(string username) { var pat = GlobalAppSettings.GetProfilePicturesPath(); var path = pat + username + "\\150\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(@pat + username); } var d = new DirectoryInfo(path); var files = d.GetFiles("*.png") .OrderByDescending(t => t.LastWriteTime) .Take(3) .Union(d.GetFiles("*.jpg")) .Union(d.GetFiles("etc")) .ToArray(); //Getting Text files var imagelist = files.Select(file => "/Content/images/ProfilePictures/" + username + "/150/" + file.Name).ToList(); return(imagelist.Aggregate("", (current, value) => current + "<div style='float:left;' class='Imageclickevent' ><img class='image-settings-for-upload grayscale' src='" + value + "'/></div>")); }
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()); }
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()); } }
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)); }
public JsonResult ActivateUser() { var userId = userDetails.GetUserId(Request["username"]); var output = new Dictionary <string, string>(); JsonResult jsonOutput; try { var userobj = new User { FirstName = Request["firstname"], UserName = Request["username"], Email = Request["email"], ActivationCode = userDetails.GenerateRandomCode(12), ActivationExpirationDate = DateTime.UtcNow.AddDays(GlobalAppSettings.SystemSettings.ActivationExpirationDays) }; const bool isResendActivationCode = false; var activationUrl = GlobalAppSettings.SystemSettings.BaseUrl + "/accounts/activate?ActivationCode=" + userobj.ActivationCode; var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ModifiedDate, Value = DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ActivationCode, Value = userobj.ActivationCode }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ActivationExpirationDate, Value = userobj.ActivationExpirationDate.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; var result = userDetails.UpdateUserProfileDetails(updateColumns, userId); if (result) { UserManagementModel.SendActivationCode(userobj.FirstName, userobj.UserName, userobj.Email, activationUrl, userobj.ActivationExpirationDate, isResendActivationCode); output.Add("result", "success"); jsonOutput = Json(new { Data = output }); } else { output.Add("result", "error"); jsonOutput = Json(new { Data = output }); } } catch (Exception) { output.Add("result", "error"); jsonOutput = Json(new { Data = output }); } return(jsonOutput); }
public JsonResult UpdateUserProfile() { int userId = this.userDetails.GetUserId(HttpContext.Request["username"]); var currentUserDetails = this.userDetails.FindUserByUserId(userId); var currentEmail = currentUserDetails.Email; var timeNow = DateTime.UtcNow; if (currentEmail != HttpContext.Request["email"]) { var emailList = this.userDetails.GetAllActiveEmails(); var isEmailExist = emailList.Find(f => f.Email == HttpContext.Request["email"]) == null; if (isEmailExist) { var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.Email, Value = HttpContext.Request["email"] } }; this.userDetails.UpdateUserProfileDetails(updateColumns, userId); } else { var result = new { status = false, key = "email", value = "E-mail already exists" }; return(Json(new { Data = result })); } } try { var fullName = currentUserDetails.FirstName; if (fullName != HttpContext.Request["firstname"]) { var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.FirstName, Value = HttpContext.Request["fullname"] } }; this.userDetails.UpdateUserProfileDetails(updateColumns, userId); } var updateDetails = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.FirstName, Value = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["firstname"]) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.LastName, Value = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["lastname"]) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.Contact, Value = HttpContext.Request["mobile"] }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.DisplayName, Value = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["firstname"]) + " " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpContext.Request["lastname"]) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.ModifiedDate, Value = timeNow.ToString(GlobalAppSettings.GetDateTimeFormat()) }, new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_User.IsActive, Value = HttpContext.Request["status"] } }; this.userDetails.UpdateUserProfileDetails(updateDetails, userId); } catch (Exception) { var result = new { status = false, key = "error", value = "User profile updation has been failed" }; return(Json(new { Data = result })); } var formattedString = GetFormattedTimeZone(timeNow, userId); var finalResult = new { status = true, key = "success", value = "User profile has been updated successfully." }; return(Json(new { Data = finalResult, formattedString })); }
public JsonResult GenerateDatabase(string data) { LogExtension.LogInfo("Generating database", MethodBase.GetCurrentMethod()); var i = 0; var databaseCredentials = JsonConvert.DeserializeObject <DataBaseConfiguration>(data); var isSql = databaseCredentials.ServerType.ToString(); object result; if (String.Equals(isSql, "MSSQL", StringComparison.OrdinalIgnoreCase)) { string connectionString; if (!databaseCredentials.IsWindowsAuthentication) { connectionString = "Data Source=" + databaseCredentials.ServerName + ";user id=" + databaseCredentials.UserName + ";password="******"Server=" + databaseCredentials.ServerName + "; Integrated Security=yes;"; } var sqldbScript = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + WebConfigurationManager.AppSettings["SystemConfigurationPath"] + ServerSetup.SqlTables); var dbCreationScript = "USE [master]; CREATE DATABASE [" + databaseCredentials.DataBaseName + "];"; var isDatabaseExist = CheckDatabaseExists(connectionString, databaseCredentials.DataBaseName); if (isDatabaseExist) { var failResult = new { key = false, value = "Database name is already exist" }; return(Json(new { Data = failResult })); } var connection = new SqlConnection(connectionString); #region Create Database var isDatabaseCreated = false; try { LogExtension.LogInfo("Creating database in SQL server", MethodBase.GetCurrentMethod()); var command = new SqlCommand(dbCreationScript, connection); connection.Open(); command.ExecuteNonQuery(); isDatabaseCreated = true; } catch (SqlException ex) { isDatabaseCreated = false; LogExtension.LogInfo("Error in creating SQL Database", MethodBase.GetCurrentMethod()); LogExtension.LogError("Error in creating SQL Database", ex, MethodBase.GetCurrentMethod()); var failResult = new { key = false, value = ex.Message }; return(Json(new { Data = failResult })); } finally { connection.Close(); } LogExtension.LogInfo("Is database created?" + isDatabaseCreated.ToString(), MethodBase.GetCurrentMethod()); #endregion if (isDatabaseCreated) { var tabelCreationScript = "USE [" + databaseCredentials.DataBaseName + "]; " + sqldbScript.OpenText().ReadToEnd(); try { LogExtension.LogInfo("Creating database tables in SQL server", MethodBase.GetCurrentMethod()); var command = new SqlCommand(tabelCreationScript, connection); connection.Open(); command.ExecuteNonQuery(); } catch (SqlException ex) { LogExtension.LogInfo("Error in creating SQL Database tables", MethodBase.GetCurrentMethod()); LogExtension.LogError("Error in creating SQL Database", ex, MethodBase.GetCurrentMethod()); var failResult = new { key = false, value = ex.Message }; return(Json(new { Data = failResult })); } finally { connection.Close(); } LogExtension.LogInfo("SQL database tables created successfully.", MethodBase.GetCurrentMethod()); if (!databaseCredentials.IsWindowsAuthentication) { connectionString = "Data Source=" + databaseCredentials.ServerName + ";Initial Catalog=" + databaseCredentials.DataBaseName + ";user id=" + databaseCredentials.UserName + ";password="******"Server=" + databaseCredentials.ServerName + ";Initial Catalog=" + databaseCredentials.DataBaseName + "; Integrated Security=yes;"; } } result = new { key = true, value = _tokenCryptography.DoEncryption(connectionString) }; } else { var sqlcedbScript = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + WebConfigurationManager.AppSettings["SystemConfigurationPath"] + ServerSetup.SqlTables); var appDataFolderPath = GlobalAppSettings.GetAppDataFolderPath(); if (Directory.Exists(appDataFolderPath) == false) { Directory.CreateDirectory(appDataFolderPath); } else { Array.ForEach(Directory.GetFiles(appDataFolderPath), System.IO.File.Delete); } var connStr = "Data Source = " + appDataFolderPath + "ReportServer.sdf; Password = reportserver"; using (var engine = new SqlCeEngine(connStr)) { LogExtension.LogInfo("Creating SQLCE database", MethodBase.GetCurrentMethod()); engine.CreateDatabase(); } var script = sqlcedbScript.OpenText().ReadToEnd(); SqlCeConnection conn = null; try { conn = new SqlCeConnection(connStr); conn.Open(); var cmd = conn.CreateCommand(); var splitter = new[] { ";" }; var commandTexts = script.Split(splitter, StringSplitOptions.RemoveEmptyEntries); foreach (string commandText in commandTexts) { cmd.CommandText = commandText; cmd.ExecuteNonQuery(); } } catch (Exception ex) { LogExtension.LogInfo("Error in creating SQL CE Database", MethodBase.GetCurrentMethod()); LogExtension.LogError("Error in creating SQL CE Database", ex, MethodBase.GetCurrentMethod()); } finally { if (conn != null) { conn.Close(); } } result = new { key = true, value = _tokenCryptography.DoEncryption(connStr) }; } return(Json(new { Data = result })); }
private ApplicationSettingsService() { _appSettings = new GlobalAppSettings(); Initialize(); }