private void cmdClearResultList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MessageBox.Show(this, "Вы действительно хотите очистить список?", "Журнал обработки", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } processLog.Clear(); foreach (ProcessLegendItem item in processLegend) { if(item.Status == ImportStatus.ReadyToProcess) { continue; } item.Counter = 0; } grdResult.RefreshDataSource(); grdLegend.RefreshDataSource(); LegendViewMode = LegendViewMode.None; }
private void FocusedRowChanged(int rowHandle) { if(rowHandle == GridControl.InvalidRowHandle) { LegendViewMode = LegendViewMode.None; FocusedRowChanged(null); } else { Fb2DocumentEntry documentEntry = grvResult.GetRow(rowHandle) as Fb2DocumentEntry; FocusedRowChanged(documentEntry); } }
private void FocusedRowChanged(Fb2DocumentEntry entry) { if (entry == null) { this.cmdReprocessItem.Enabled = false; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; return; } switch (entry.Status) { case ImportStatus.Added: this.LegendViewMode = LegendViewMode.BookInfo; this.briefBookInfo1.DataSource = LoadBriefBookInfo(entry.BookId ?? -1); break; case ImportStatus.FilteredOut: this.LegendViewMode = LegendViewMode.BookInfo; this.briefBookInfo1.DataSource = LoadBriefBookInfo(entry); break; case ImportStatus.Duplicate: case ImportStatus.DuplicateIDsDiffer: case ImportStatus.DuplicateNewer: case ImportStatus.DuplicateOlder: this.LegendViewMode = LegendViewMode.ConflictInfo; this.briefBookInfo1.DataSource = LoadBriefBookInfo(entry.BookId ?? -1); this.briefBookInfo2.DataSource = LoadBriefBookInfo(entry); break; case ImportStatus.ArchiveError: case ImportStatus.DatabaseError: case ImportStatus.ParsingError: this.LegendViewMode = LegendViewMode.ErrorInfo; this.emptySpaceItem1.Text = entry.ErrorText; this.emptySpaceItem1.TextVisible = true; break; default: this.LegendViewMode = LegendViewMode.None; this.emptySpaceItem1.TextVisible = false; break; } switch (this.grvResult.SelectedRowsCount) { case 0: this.cmdReprocessItem.Enabled = false; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; this.cmdViewSourceBook.Enabled = false; this.cmdViewLibraryBook.Enabled = false; break; case 1: switch (entry.Status) { case ImportStatus.FilteredOut: this.cmdReprocessItem.Enabled = true; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; this.cmdViewSourceBook.Enabled = true; this.cmdViewLibraryBook.Enabled = false; break; case ImportStatus.ReadyToProcess: case ImportStatus.ArchiveError: case ImportStatus.DatabaseError: case ImportStatus.ParsingError: this.cmdReprocessItem.Enabled = true; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; this.cmdViewSourceBook.Enabled = false; this.cmdViewLibraryBook.Enabled = false; break; case ImportStatus.Duplicate: case ImportStatus.DuplicateIDsDiffer: case ImportStatus.DuplicateNewer: case ImportStatus.DuplicateOlder: this.cmdReprocessItem.Enabled = true; this.cmdReplaceBook.Enabled = true; this.cmdCreateNewBook.Enabled = true; this.cmdViewSourceBook.Enabled = true; this.cmdViewLibraryBook.Enabled = true; break; case ImportStatus.Added: case ImportStatus.Updated: this.cmdReprocessItem.Enabled = false; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; this.cmdViewSourceBook.Enabled = false; this.cmdViewLibraryBook.Enabled = true; break; default: this.cmdReprocessItem.Enabled = false; this.cmdReplaceBook.Enabled = false; this.cmdCreateNewBook.Enabled = false; this.cmdViewSourceBook.Enabled = false; this.cmdViewLibraryBook.Enabled = false; break; } break; default: this.cmdReprocessItem.Enabled = true; this.cmdReplaceBook.Enabled = true; this.cmdCreateNewBook.Enabled = true; this.cmdViewSourceBook.Enabled = false; this.cmdViewLibraryBook.Enabled = false; break; } }
internal ImportForm(object pluginParams, ImportOptions options) : this() { if (pluginParams == null) { throw new ArgumentNullException("pluginParams"); } object pluginCallBack = CommonParams.GetParam(CommonConsts.cParamCallbackMethod, pluginParams, null, 1); this.callback = pluginCallBack as PluginCallBack; this.db = ConnectionManager.Instance().Connection<TCommonFireBirdDB>("MainConnection"); object callParams = CommonParams.AddParam(CommonConsts.cParamCallbackMethod, callback, null); callParams = CommonParams.AddParam(CommonConsts.cParamPlugin, "Configuration", callParams); callParams = CommonParams.AddParam(CommonConsts.cParamAction, "Configuration.Get", callParams); callParams = CommonParams.AddParam("Info", "SystemFolders", callParams); object result = this.callback(callParams); this.tempFolder = CommonParams.GetParam("TempFolder", result, Path.GetTempPath(), 1); if(!Directory.Exists(this.tempFolder)) { this.tempFolder = Path.GetTempPath(); } this.badFolder = CommonParams.GetParam("BadFolder", result, String.Empty, 1); this.sourceFolder = CommonParams.GetParam("SourcesFolder", result, String.Empty, 1); this.dupFolder = CommonParams.GetParam("DupFolder", result, String.Empty, 1); this.lastFolder = CommonParams.GetParam("LastFolder", result, String.Empty, 1); this.oldFileFolder = CommonParams.GetParam("OldFileFolder", result, String.Empty, 1); if(!String.IsNullOrEmpty(this.lastFolder)) { this.txtImportPath.Text = this.lastFolder; } callParams = CommonParams.AddParam(CommonConsts.cParamCallbackMethod, callback, null); callParams = CommonParams.AddParam(CommonConsts.cParamPlugin, "Configuration", callParams); callParams = CommonParams.AddParam(CommonConsts.cParamAction, "Configuration.Get", callParams); callParams = CommonParams.AddParam("Info", "MountPoint", callParams); result = this.callback(callParams); this.database = new FirebirdDataAccess(this.db); this.database.CheckDatabaseSchema(); DatabaseInfo databaseInfo = this.database.DatabaseInfo; databaseInfo.MountPoint = CommonParams.GetParam("MountPoint", result, String.Empty, 1); databaseInfo.WorkMode = CommonParams.GetParam("WorkMode", result, (short) StorageMode.FileSystem, 1); callParams = CommonParams.AddParam(CommonConsts.cParamCallbackMethod, callback, null); callParams = CommonParams.AddParam(CommonConsts.cParamPlugin, "Configuration", callParams); callParams = CommonParams.AddParam(CommonConsts.cParamAction, "Configuration.Get", callParams); callParams = CommonParams.AddParam("Info", "CurrentUserInfo", callParams); result = this.callback(callParams); databaseInfo.CurrentUserId = CommonParams.GetParam("UserID", result, -1, 1); databaseInfo.CurrentUserName = CommonParams.GetParam("UserName", result, String.Empty, 1); GenreTable.ReadGenreList(this.database); ZipConstants.DefaultCodePage = 866; SevenZipFormat.DefaultCodePage = 866; manager = new DefaultFileSystemManager(); manager.setCacheStrategy(CacheStrategy.ON_RESOLVE); manager.init(); SevenZipFileProvider provider = new SevenZipFileProvider(); provider.addListener(this); manager.addProvider("file", new DefaultLocalFileProvider()); manager.addProvider("zip", provider); manager.addExtensionMap("zip", "zip"); manager.addMimeTypeMap("application/zip", "zip"); manager.addProvider("sevenzip", provider); manager.addExtensionMap("7z", "sevenzip"); manager.addMimeTypeMap("application/x-7z-compressed", "sevenzip"); manager.addProvider("rar", provider); manager.addExtensionMap("rar", "rar"); manager.addMimeTypeMap("application/x-rar-compressed", "rar"); manager.Replicator = new DefaultFileReplicator(); properties = TypeDescriptor.GetProperties(typeof(FilterAdapter)); bufferPool = new BufferPool(4, 16384); legendViewMode = LegendViewMode.None; if (File.Exists("FBScanner.xml")) { ScannerState scannerState = LoadImportState("FBScanner.xml"); if(scannerState != null) { txtImportPath.Text = scannerState.SearchPath ?? this.lastFolder; chkIncludeSubDirs.Checked = scannerState.IncludeSubDirs ?? false; chkSelectFoundFiles.Checked = scannerState.SelectFoundFiles ?? false; filterCriteria = scannerState.Filter; if (!String.IsNullOrEmpty(filterCriteria)) { filter = new FilterEvaluator(properties, filterCriteria); } if(scannerState.Entries != null) { fileEntries = scannerState.Entries.ConvertAll(x => new ImportFileEntry(x)); foreach (ImportFileEntry fileEntry in fileEntries) { excludeList.Add(fileEntry.Uri, fileEntry); } grdSelectedFiles.DataSource = fileEntries; } if(scannerState.Legend != null) { foreach (XmlLegendItem legendItem in scannerState.Legend) { processLegend.SetCounterValue(legendItem.Status, legendItem.Counter); } } if(scannerState.Log != null) { processLog = scannerState.Log.ConvertAll(x => new Fb2DocumentEntry(x)); grdResult.DataSource = processLog; } } } dontCheckForDuplicate = options.DontCheckForDuplicate; }