public virtual IActionResult MaintenanceDeleteGuests(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var startDateValue = model.DeleteGuests.StartDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteGuests.StartDate.Value, _dateTimeHelper.CurrentTimeZone); var endDateValue = model.DeleteGuests.EndDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteGuests.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); model.DeleteGuests.NumberOfDeletedCustomers = _customerService.DeleteGuestCustomers(startDateValue, endDateValue, model.DeleteGuests.OnlyWithoutShoppingCart); return(View(model)); }
public ActionResult Maintenance() { var model = new MaintenanceModel(); model.DeleteGuests.EndDate = DateTime.UtcNow.AddDays(-7); model.DeleteGuests.OnlyWithoutShoppingCart = true; // image cache stats long imageCacheFileCount = 0; long imageCacheTotalSize = 0; _imageCache.Value.CacheStatistics(out imageCacheFileCount, out imageCacheTotalSize); model.DeleteImageCache.FileCount = imageCacheFileCount; model.DeleteImageCache.TotalSize = Prettifier.BytesToString(imageCacheTotalSize); return(View(model)); }
public virtual IActionResult MaintenanceDeleteAlreadySentQueuedEmails(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var startDateValue = model.DeleteAlreadySentQueuedEmails.StartDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteAlreadySentQueuedEmails.StartDate.Value, _dateTimeHelper.CurrentTimeZone); var endDateValue = model.DeleteAlreadySentQueuedEmails.EndDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteAlreadySentQueuedEmails.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); model.DeleteAlreadySentQueuedEmails.NumberOfDeletedEmails = _queuedEmailService.DeleteAlreadySentEmails(startDateValue, endDateValue); return(View(model)); }
public virtual async Task <IActionResult> BackupAction(MaintenanceModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var action = Request.Form["action"]; var fileName = Request.Form["backupFileName"]; fileName = _fileProvider.GetFileName(_fileProvider.GetAbsolutePath(fileName)); var backupPath = _maintenanceService.GetBackupPath(fileName); try { switch (action) { case "delete-backup": { _fileProvider.DeleteFile(backupPath); _notificationService.SuccessNotification(string.Format(await _localizationService.GetResourceAsync("Admin.System.Maintenance.BackupDatabase.BackupDeleted"), fileName)); } break; case "restore-backup": { await _dataProvider.RestoreDatabaseAsync(backupPath); _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.System.Maintenance.BackupDatabase.DatabaseRestored")); } break; } } catch (Exception exc) { await _notificationService.ErrorNotificationAsync(exc); } //prepare model model = await _commonModelFactory.PrepareMaintenanceModelAsync(model); return(View(model)); }
public async Task Update(MaintenanceModel MaintenanceModel) { ValidateMaintenanceIfNotExist(MaintenanceModel); var editMaintenance = await _MaintenanceRepository.GetByIdAsync(MaintenanceModel.ID); if (editMaintenance == null) { throw new ApplicationException($"Entity could not be loaded."); } ObjectMapper.Mapper.Map <MaintenanceModel, Maintenance>(MaintenanceModel, editMaintenance); editMaintenance.ModifyDate = DateTime.Now; editMaintenance.ModifiedBy = 1; await _MaintenanceRepository.UpdateAsync(editMaintenance); _logger.LogInformation($"Entity successfully updated - NetlogAppService"); }
/// <summary> /// Prepare maintenance model /// </summary> /// <param name="model">Maintenance model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the maintenance model /// </returns> public virtual Task<MaintenanceModel> PrepareMaintenanceModelAsync(MaintenanceModel model) { if (model == null) throw new ArgumentNullException(nameof(model)); model.DeleteGuests.EndDate = DateTime.UtcNow.AddDays(-7); model.DeleteGuests.OnlyWithoutShoppingCart = true; model.DeleteAbandonedCarts.OlderThan = DateTime.UtcNow.AddDays(-182); model.DeleteAlreadySentQueuedEmails.EndDate = DateTime.UtcNow.AddDays(-7); model.BackupSupported = _dataProvider.BackupSupported; //prepare nested search model PrepareBackupFileSearchModel(model.BackupFileSearchModel); return Task.FromResult(model); }
public JsonResult UpdateDatabaseData(MaintenanceModel maintenance) { var result = 0; DBMaintenance dbmaintenance = new DBMaintenance(); if (maintenance.ProcessType == "1") { result = dbmaintenance.UpdateReleasingData(maintenance); } else if (maintenance.ProcessType == "2") { result = dbmaintenance.UpdateReceivingData(maintenance); } if (result != 0) { return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(result)); }
public ActionResult MaintenanceDeleteFiles(MaintenanceModel model) { DateTime?startDateValue = (model.DeleteExportedFiles.StartDate == null) ? null : (DateTime?)_dateTimeHelper.Value.ConvertToUtcTime(model.DeleteExportedFiles.StartDate.Value, _dateTimeHelper.Value.CurrentTimeZone); DateTime?endDateValue = (model.DeleteExportedFiles.EndDate == null) ? null : (DateTime?)_dateTimeHelper.Value.ConvertToUtcTime(model.DeleteExportedFiles.EndDate.Value, _dateTimeHelper.Value.CurrentTimeZone).AddDays(1); model.DeleteExportedFiles.NumberOfDeletedFiles = 0; string path = string.Format("{0}Content\\files\\exportimport\\", this.Request.PhysicalApplicationPath); foreach (var fullPath in System.IO.Directory.GetFiles(path)) { try { var fileName = Path.GetFileName(fullPath); if (fileName.Equals("index.htm", StringComparison.InvariantCultureIgnoreCase)) { continue; } if (fileName.Equals("placeholder", StringComparison.InvariantCultureIgnoreCase)) { continue; } var info = new FileInfo(fullPath); if ((!startDateValue.HasValue || startDateValue.Value < info.CreationTimeUtc) && (!endDateValue.HasValue || info.CreationTimeUtc < endDateValue.Value)) { System.IO.File.Delete(fullPath); model.DeleteExportedFiles.NumberOfDeletedFiles++; } } catch (Exception exc) { NotifyError(exc, false); } } return(View(model)); }
public ActionResult MaintenanceExecuteSql(MaintenanceModel model) { if (model.SqlQuery.HasValue()) { var dbContext = EngineContext.Current.Resolve <IDbContext>(); try { dbContext.ExecuteSqlThroughSmo(model.SqlQuery); NotifySuccess("The sql command was executed successfully."); } catch (Exception ex) { NotifyError("Error executing sql command: {0}".FormatCurrentUI(ex.Message)); } } return(View(model)); }
public ActionResult MaintenanceExecuteSql(MaintenanceModel model) { if (model.SqlQuery.HasValue()) { var dbContext = EngineContext.Current.Resolve <IDbContext>(); try { dbContext.ExecuteSqlThroughSmo(model.SqlQuery); NotifySuccess(T("Admin.System.Maintenance.SqlQuery.Succeeded")); } catch (Exception exception) { NotifyError(exception); } } return(View(model)); }
public virtual ActionResult MaintenanceDeleteFiles(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } DateTime?startDateValue = (model.DeleteExportedFiles.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteExportedFiles.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.DeleteExportedFiles.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteExportedFiles.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); model.DeleteExportedFiles.NumberOfDeletedFiles = 0; string path = Path.Combine(this.Request.PhysicalApplicationPath, "content\\files\\exportimport"); foreach (var fullPath in Directory.GetFiles(path)) { try { var fileName = Path.GetFileName(fullPath); if (fileName.Equals("index.htm", StringComparison.InvariantCultureIgnoreCase)) { continue; } var info = new FileInfo(fullPath); if ((!startDateValue.HasValue || startDateValue.Value < info.CreationTimeUtc) && (!endDateValue.HasValue || info.CreationTimeUtc < endDateValue.Value)) { System.IO.File.Delete(fullPath); model.DeleteExportedFiles.NumberOfDeletedFiles++; } } catch (Exception exc) { ErrorNotification(exc, false); } } return(View(model)); }
public virtual ActionResult BackupDatabase(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } try { _maintenanceService.BackupDatabase(); this.SuccessNotification(_localizationService.GetResource("Admin.System.Maintenance.BackupDatabase.BackupCreated")); } catch (Exception exc) { ErrorNotification(exc); } return(View(model)); }
public virtual IActionResult ReIndexTables(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } try { _maintenanceService.ReIndexTables(); SuccessNotification(_localizationService.GetResource("Admin.System.Maintenance.ReIndexTables.Complete")); } catch (Exception exc) { ErrorNotification(exc); } return(View(model)); }
public virtual IActionResult MaintenanceDeleteFiles(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var startDateValue = model.DeleteExportedFiles.StartDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteExportedFiles.StartDate.Value, _dateTimeHelper.CurrentTimeZone); var endDateValue = model.DeleteExportedFiles.EndDate == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.DeleteExportedFiles.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); model.DeleteExportedFiles.NumberOfDeletedFiles = 0; foreach (var fullPath in _fileProvider.GetFiles(_fileProvider.GetAbsolutePath(EXPORT_IMPORT_PATH))) { try { var fileName = _fileProvider.GetFileName(fullPath); if (fileName.Equals("index.htm", StringComparison.InvariantCultureIgnoreCase)) { continue; } var info = _fileProvider.GetFileInfo(_fileProvider.Combine(EXPORT_IMPORT_PATH, fileName)); var lastModifiedTimeUtc = info.LastModified.UtcDateTime; if ((!startDateValue.HasValue || startDateValue.Value < lastModifiedTimeUtc) && (!endDateValue.HasValue || lastModifiedTimeUtc < endDateValue.Value)) { _fileProvider.DeleteFile(fullPath); model.DeleteExportedFiles.NumberOfDeletedFiles++; } } catch (Exception exc) { ErrorNotification(exc, false); } } return(View(model)); }
public async Task <ActionResult> RequestService(MaintenanceModel RQ) { ServiceCallDataResponseResult oServiceCall = new ServiceCallDataResponseResult(); oServiceCall.ServiceCallData.Add(new ServiceCall { CardCode = RQ.CardCode, CardName = RQ.CardName, Subject = RQ.Subject }); ServiceReponse objResponse = await Connector.RequestMaintenance(oServiceCall) as ServiceReponse; if (objResponse is ServiceReponse && objResponse.isSuccess && !string.IsNullOrEmpty(objResponse.ReturnNumber)) { RQ.IsRequested = true; RQ.RequestReffNo = objResponse.ReturnNumber; } return(View(@"~\Views\Maintenance\MaintenanceSummary.cshtml", RQ)); }
public virtual ActionResult Maintenance() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var model = new MaintenanceModel(); model.DeleteGuests = new MaintenanceModel.DeleteGuestsModel { OnlyWithoutAction = true, EndDate = DateTime.Now.AddDays(-1) }; model.DeleteExportedFiles = new MaintenanceModel.DeleteExportedFilesModel { EndDate = DateTime.Now.AddDays(-182) }; return(View(model)); }
public async Task<IActionResult> MaintenanceConvertPicture([FromServices] IPictureService pictureService, [FromServices] MediaSettings mediaSettings) { var model = new MaintenanceModel(); model.ConvertedPictureModel.NumberOfConvertItems = 0; if (pictureService.StoreInDb) { var pictures = pictureService.GetPictures(); foreach (var picture in pictures) { if (!picture.MimeType.Contains("webp")) { using var image = SKBitmap.Decode(picture.PictureBinary); SKData d = SKImage.FromBitmap(image).Encode(SKEncodedImageFormat.Webp, mediaSettings.DefaultImageQuality); await pictureService.UpdatePicture(picture.Id, d.ToArray(), "image/webp", picture.SeoFilename, picture.AltAttribute, picture.TitleAttribute, true, false); model.ConvertedPictureModel.NumberOfConvertItems += 1; } } } return View(model); }
/// <returns>A task that represents the asynchronous operation</returns> public virtual async Task <IActionResult> ReIndexTables(MaintenanceModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } try { await _dataProvider.ReIndexTablesAsync(); _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.System.Maintenance.ReIndexTables.Complete")); } catch (Exception exc) { await _notificationService.ErrorNotificationAsync(exc); } return(View(model)); }
public ManifestModel GenerateManifest(Xamarin.Essentials.Location location, string manifestId = "") { List <MaintainKeg> kegs = new List <MaintainKeg>(); MaintainKeg keg = null; MaintenanceModel model = new MaintenanceModel { MaintenanceDoneRequestModel = new MaintenanceDoneRequestModel() }; foreach (var item in BarcodeCollection) { keg = new MaintainKeg { Barcode = item.Barcode, ScanDate = DateTimeOffset.Now, ValidationStatus = 4 }; kegs.Add(keg); model.MaintenanceDoneRequestModel.Kegs.Add(keg); } foreach (var item in ConstantManager.MaintainTypeCollection.Where(x => x.IsToggled == true).Select(y => y.Id).ToList()) { model.MaintenanceDoneRequestModel.ActionsPerformed.Add(item); } model.MaintenanceDoneRequestModel.DatePerformed = DateTimeOffset.Now.AddDays(-2); model.MaintenanceDoneRequestModel.LocationId = ConstantManager.Partner.PartnerId; model.MaintenanceDoneRequestModel.MaintenancePostingId = _uuidManager.GetUuId(); model.MaintenanceDoneRequestModel.Latitude = (long)location.Latitude; model.MaintenanceDoneRequestModel.Longitude = (long)location.Longitude; model.MaintenanceDoneRequestModel.Notes = Notes; model.MaintenanceDoneRequestModel.PartnerModel = ConstantManager.Partner; return(_manifestManager.GetManifestDraft(eventTypeEnum: EventTypeEnum.REPAIR_MANIFEST, manifestId: !string.IsNullOrEmpty(manifestId) ? manifestId : _uuidManager.GetUuId(), barcodeCollection: BarcodeCollection, (long)location.Latitude, (long)location.Longitude, tags: ConstantManager.Tags, ConstantManager.TagsStr, partnerModel: ConstantManager.Partner, newPallets: new List <NewPallet>(), batches: new List <NewBatch>(), closedBatches: new List <string>(), model, validationStatus: 4, contents: "")); }
public ActionResult Maintenance() { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var model = new MaintenanceModel(); model.DeleteGuests.EndDate = DateTime.UtcNow.AddDays(-7); model.DeleteGuests.OnlyWithoutShoppingCart = true; // image cache stats long imageCacheFileCount = 0; long imageCacheTotalSize = 0; _imageCache.Value.CacheStatistics(out imageCacheFileCount, out imageCacheTotalSize); model.DeleteImageCache.FileCount = imageCacheFileCount; model.DeleteImageCache.TotalSize = Prettifier.BytesToString(imageCacheTotalSize); return(View(model)); }
public virtual IActionResult BackupDatabase(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } try { _dataProvider.BackupDatabase(_maintenanceService.CreateNewBackupFilePath()); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.System.Maintenance.BackupDatabase.BackupCreated")); } catch (Exception exc) { _notificationService.ErrorNotification(exc); } //prepare model model = _commonModelFactory.PrepareMaintenanceModel(new MaintenanceModel()); return(View(model)); }
public virtual ActionResult BackupAction(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var action = this.Request.Form["action"]; var fileName = this.Request.Form["backupFileName"]; var backupPath = _maintenanceService.GetBackupPath(fileName); try { switch (action) { case "delete-backup": { System.IO.File.Delete(backupPath); this.SuccessNotification(string.Format(_localizationService.GetResource("Admin.System.Maintenance.BackupDatabase.BackupDeleted"), fileName)); } break; case "restore-backup": { _maintenanceService.RestoreDatabase(backupPath); this.SuccessNotification(_localizationService.GetResource("Admin.System.Maintenance.BackupDatabase.DatabaseRestored")); } break; } } catch (Exception exc) { ErrorNotification(exc); } return(View(model)); }
public ActionResult MaintenanceExecuteSql(MaintenanceModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if (model.SqlQuery.HasValue()) { var dbContext = EngineContext.Current.Resolve <IDbContext>(); try { dbContext.ExecuteSqlThroughSmo(model.SqlQuery); NotifySuccess("The sql command was executed successfully."); } catch (Exception ex) { NotifyError("Error executing sql command: {0}".FormatCurrentUI(ex.Message)); } } return(View(model)); }
//[ValidateAntiForgeryToken] public ActionResult ResetPassword(MaintenanceModel maintenance) { DBConnection(); DBMaintenance dBMaintenance = new DBMaintenance(); var result = dBMaintenance.ResetPassword(maintenance); maintenance = dBMaintenance.PopulateUserInformationDB(maintenance.UserID); //ViewBag.LoginAuthentication = "Login"; //ViewBag.HeaderSuccess = string.Format("New password set."); //ViewBag.MessageSuccess = string.Format("Your Password has been changed."); Session["UserID"] = maintenance.UserID; Session["Fullname"] = maintenance.Fullname; Session["UserRoleID"] = maintenance.RoleID; Session["UserRole"] = maintenance.RoleName; Session["Department"] = maintenance.DepartmentID; Session["GroupID"] = maintenance.GroupID; Session["DesignationID"] = maintenance.DesignationID; Session["GroupName"] = maintenance.Group; Session["DesignationName"] = maintenance.Designation; FormsAuthentication.SetAuthCookie(Session["UserID"].ToString(), false); // render Session into Authentication Cookie SqlDependency.Start(con); SqlDependency.Start(con2); SqlDependency.Start(con3); NotificationComponent NC = new NotificationComponent(); NC.group = maintenance.DesignationID; NC.Notificaton(maintenance.DesignationID); NC.UpdateItemRequestNotificaton(); NC.NotificatonItem(); NC.NotificatonUpdateItem(); return(Json(result)); }
public ActionResult MaintenanceExecuteSql(MaintenanceModel model) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if (model.SqlQuery.HasValue()) { var dbContext = EngineContext.Current.Resolve <IDbContext>(); try { dbContext.ExecuteSqlThroughSmo(model.SqlQuery); NotifySuccess(T("Admin.System.Maintenance.SqlQuery.Succeeded")); } catch (Exception exception) { NotifyError(exception); } } return(View(model)); }
public async Task <MaintenanceModel> Create(MaintenanceModel MaintenanceModel) { await ValidateMaintenanceIfExist(MaintenanceModel); var mappedEntity = ObjectMapper.Mapper.Map <Maintenance>(MaintenanceModel); if (mappedEntity == null) { throw new ApplicationException($"Entity could not be mapped."); } mappedEntity.CreateDate = DateTime.Now; mappedEntity.ModifyDate = DateTime.Now; mappedEntity.CreatedBy = 1; mappedEntity.ModifiedBy = 1; mappedEntity.IsDeleted = false; var newEntity = await _MaintenanceRepository.AddAsync(mappedEntity); _logger.LogInformation($"Entity successfully added - NetlogAppService"); var newMappedEntity = ObjectMapper.Mapper.Map <MaintenanceModel>(newEntity); return(newMappedEntity); }
public async Task <IActionResult> MaintenanceClearMostViewed(MaintenanceModel model) { await _mediator.Send(new ClearMostViewedCommand()); return(View(model)); }
private static void OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { Control control = sender as Control; ICommand command = (ICommand)control.GetValue(CommandProperty); object commandParameter = control.GetValue(CommandParameterProperty); if (sender is TreeViewItem) { if (!((TreeViewItem)sender).IsSelected) { return; } } IInputElement element = e.MouseDevice.DirectlyOver; if (element != null && element is FrameworkElement) { if (((FrameworkElement)element) is DataGridColumnHeader || ((FrameworkElement)element) is GridViewColumnHeader) { e.Handled = true; } else { if (sender is DataGrid) { if (sender is DataGrid grid && grid.SelectedItems != null && grid.SelectedItems.Count == 1) { if (grid.SelectedItem is DataRowView rowView) { DataRow row = rowView.Row; //do something with the underlying data //if (command.CanExecute(commandParameter)) //{ object[] values = new object[2]; values[0] = row["ProjectID"]; values[1] = commandParameter; command.Execute(values); //command.Execute(row["ProjectID"]); e.Handled = true; //} } } } else { if (sender is ListView lv && lv.SelectedItem != null && lv.SelectedItems.Count == 1) { if (lv.SelectedItem.GetType().Equals(typeof(MaintenanceModel))) { MaintenanceModel rowView = lv.SelectedItem as MaintenanceModel; if (rowView != null) { // ListViewItem row = rowView..Row; //do something with the underlying data //if (command.CanExecute(commandParameter)) //{ object[] values = new object[2]; values[0] = rowView.ProjectID; values[1] = commandParameter; command.Execute(values); //command.Execute(rowView.ProjectID); e.Handled = true; //} } } else if (lv.SelectedItem.GetType().Equals(typeof(EPModel))) { EPModel rowView = lv.SelectedItem as EPModel; if (rowView != null) { object[] values = new object[3]; values[0] = rowView.ProjectID; values[1] = rowView.ID; values[2] = commandParameter; command.Execute(values); e.Handled = true; } } else if (lv.SelectedItem.GetType().Equals(typeof(MilestoneModel))) { MilestoneModel rowView = lv.SelectedItem as MilestoneModel; if (rowView != null) { object[] values = new object[3]; values[0] = rowView.ProjectID; values[1] = rowView.ID; values[2] = commandParameter; command.Execute(values); e.Handled = true; } } } } //if (command.CanExecute(commandParameter)) //{ // command.Execute(commandParameter); // e.Handled = true; //} } } }
public ActionResult MaintenanceDeleteFiles(MaintenanceModel model) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } DateTime?startDateValue = (model.DeleteExportedFiles.StartDate == null) ? null : (DateTime?)_dateTimeHelper.Value.ConvertToUtcTime(model.DeleteExportedFiles.StartDate.Value, _dateTimeHelper.Value.CurrentTimeZone); DateTime?endDateValue = (model.DeleteExportedFiles.EndDate == null) ? null : (DateTime?)_dateTimeHelper.Value.ConvertToUtcTime(model.DeleteExportedFiles.EndDate.Value, _dateTimeHelper.Value.CurrentTimeZone).AddDays(1); model.DeleteExportedFiles.NumberOfDeletedFiles = 0; model.DeleteExportedFiles.NumberOfDeletedFolders = 0; var appPath = this.Request.PhysicalApplicationPath; string[] paths = new string[] { appPath + @"Content\files\exportimport\", appPath + @"Exchange\", appPath + @"App_Data\ExportProfiles\" }; foreach (var path in paths) { foreach (var fullPath in System.IO.Directory.GetFiles(path)) { try { var fileName = Path.GetFileName(fullPath); if (fileName.Equals("index.htm", StringComparison.InvariantCultureIgnoreCase)) { continue; } if (fileName.Equals("placeholder", StringComparison.InvariantCultureIgnoreCase)) { continue; } var info = new FileInfo(fullPath); if ((!startDateValue.HasValue || startDateValue.Value < info.CreationTimeUtc) && (!endDateValue.HasValue || info.CreationTimeUtc < endDateValue.Value)) { if (FileSystemHelper.Delete(fullPath)) { ++model.DeleteExportedFiles.NumberOfDeletedFiles; } } } catch (Exception exc) { NotifyError(exc, false); } } var dir = new DirectoryInfo(path); foreach (var dirInfo in dir.GetDirectories()) { if ((!startDateValue.HasValue || startDateValue.Value < dirInfo.LastWriteTimeUtc) && (!endDateValue.HasValue || dirInfo.LastWriteTimeUtc < endDateValue.Value)) { FileSystemHelper.ClearDirectory(dirInfo.FullName, true); ++model.DeleteExportedFiles.NumberOfDeletedFolders; } } } // clear unreferenced profile folders var importProfileFolders = _importProfileService.Value.GetImportProfiles() .Select(x => x.FolderName) .ToList(); var infoImportProfiles = new DirectoryInfo(CommonHelper.MapPath("~/App_Data/ImportProfiles")); foreach (var infoSubFolder in infoImportProfiles.GetDirectories()) { if (!importProfileFolders.Contains(infoSubFolder.Name)) { FileSystemHelper.ClearDirectory(infoSubFolder.FullName, true); ++model.DeleteExportedFiles.NumberOfDeletedFolders; } } return(View(model)); }
public IActionResult MaintenanceDeleteFiles(MaintenanceModel model) { //TO DO model.DeleteExportedFiles.NumberOfDeletedFiles = 0; return(View(model)); }