예제 #1
0
파일: AdminBl.cs 프로젝트: andreyu/Reports
 public void SetModel(SettingsModel model)
 {
     Settings settings = SettingsDao.LoadFirst();
     if (settings != null)
     {
         model.Id = settings.Id;
         model.Version = settings.Version;
         model.BillingEmail = settings.BillingEmail;
         model.BillingLogin = settings.BillingLogin;
         model.BillingPassword = settings.BillingPassword;
         model.BillingPort = settings.BillingPort;
         model.BillingSmtp = settings.BillingSmtp;
         model.DownloadDictionaryFilePath = settings.DownloadDictionaryFilePath;
         model.ExportImportEmail = settings.ExportImportEmail;
         model.NotificationEmail = settings.NotificationEmail;
         model.NotificationLogin = settings.NotificationLogin;
         model.NotificationPassword = settings.NotificationPassword;
         model.NotificationPort = settings.NotificationPort;
         model.NotificationSmtp = settings.NotificationSmtp;
         model.ReleaseEmployeeDeleteDate = settings.ReleaseEmployeeDeleteDate.ToString("dd.MM.yyyy");
         model.SendEmailToManagerAboutNew = settings.SendEmailToManagerAboutNew;
         model.UploadTimesheetFilePath = settings.UploadTimesheetFilePath;
     }
     else
     {
         model.NotificationPort = 25;
         model.BillingPort = 25;
         model.ReleaseEmployeeDeleteDate =
             new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)
                 .AddMonths(-3).ToString("dd.MM.yyyy");
     }
 }
예제 #2
0
파일: AdminBl.cs 프로젝트: andreyu/Reports
 public void SaveSettings(SettingsModel model)
 {
     try
     {
         var settings = new Settings();
         if (model.Id > 0)
             settings = SettingsDao.Load(model.Id);
         settings.BillingEmail = model.BillingEmail;
         settings.BillingLogin = model.BillingLogin;
         settings.BillingPassword = model.BillingPassword;
         settings.BillingPort = model.BillingPort;
         settings.BillingSmtp = model.BillingSmtp;
         settings.DownloadDictionaryFilePath = model.DownloadDictionaryFilePath;
         settings.ExportImportEmail = model.ExportImportEmail;
         settings.NotificationEmail = model.NotificationEmail;
         settings.NotificationLogin = model.NotificationLogin;
         settings.NotificationPassword = model.NotificationPassword;
         settings.NotificationPort = model.NotificationPort;
         settings.NotificationSmtp = model.NotificationSmtp;
         settings.ReleaseEmployeeDeleteDate = model.ValidReleaseEmployeeDeleteDate;
         settings.SendEmailToManagerAboutNew = model.SendEmailToManagerAboutNew;
         settings.UploadTimesheetFilePath = model.UploadTimesheetFilePath;
         settings = SettingsDao.MergeAndFlush(settings);
         model.Id = settings.Id;
         model.Version = settings.Version;
     }
     catch (Exception ex)
     {
         Log.Error("Exception", ex);
         model.Error = string.Format("Исключение {0} ", ex.GetBaseException().Message);
     }
 }
예제 #3
0
 public ActionResult Settings(SettingsModel model)
 {
     CheckUserRole(false);
     if(!ValidateModel(model))
         return View(model);
     AdminBl.SaveSettings(model);
     if(!string.IsNullOrEmpty(model.Error))
         ModelState.AddModelError("Error", model.Error);
     return View(model);
 }
예제 #4
0
 protected bool ValidateModel(SettingsModel model)
 {
     if(!string.IsNullOrEmpty(model.ReleaseEmployeeDeleteDate))
     {
         DateTime releaseDate;
         if (!DateTime.TryParse(model.ReleaseEmployeeDeleteDate, out releaseDate))
             ModelState.AddModelError("ReleaseEmployeeDeleteDate", "Поле <Удалить сотрудников(и их документы),уволеных до> должно быть датой.");
         else if (releaseDate >= DateTime.Today)
             ModelState.AddModelError("ReleaseEmployeeDeleteDate", "Поле <Удалить сотрудников(и их документы),уволеных до> должно быть датой в прошлом.");
         else
             model.ValidReleaseEmployeeDeleteDate = releaseDate;
     }
     if(!CheckFileExists(model.DownloadDictionaryFilePath))
         ModelState.AddModelError("DownloadDictionaryFilePath", "<Путь к файлу для загрузки справочника ...> - файл не существует.");
     CheckDirectoryAndFileNameExists(model.UploadTimesheetFilePath);
     return ModelState.IsValid;
 }
예제 #5
0
 public ActionResult Settings()
 {
     CheckUserRole(false);
     SettingsModel model = new SettingsModel();
     AdminBl.SetModel(model);
     return View(model);
 }