Example #1
0
        private void cmdFilter_Click(object sender, EventArgs e)
        {
            BookFilterEditor editor = new BookFilterEditor(db);
            editor.FilterString = this.filterCriteria ?? String.Empty;
            if(editor.ShowDialog(this) == DialogResult.OK)
            {
                this.filterCriteria = editor.FilterString;

                this.filter = null;
                if (!String.IsNullOrEmpty(this.filterCriteria))
                {
                    this.filter = new FilterEvaluator(properties, this.filterCriteria);
                }
            }
        }
Example #2
0
        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;
        }