Esempio n. 1
0
        private void SearchDone(DataSetSearch ds)
        {
            FormSearchResults f = this.mainApp.SearchResultsForm;

            if (null != f)
            {
                f.SetData(ds);
            }

            this.panelBack.Cursor = Cursors.Default;
            this.comboBoxSearch.Items.Add(this.comboBoxSearch.Text);
            this.Enabled = true;

            this.mainApp.SetCursor(Cursors.Default);
        }
Esempio n. 2
0
        public DataSetSearch FindFile(String fileName, bool useMinSize, bool userMaxSize, bool useEquals, long minSize, long maxSize, long size)
        {
            /**
             * Microsoft Access is unable to store 64-bit integers.
             * To work around this problem they are stored as strings.
             * This particularly was applied to file size attribute.
             */

            try
            {
                String sql = "SELECT [Files].[Date] AS [FileDate], [Files].[Name] AS [FileName], [Files].[Size], [Disks].[Name] AS [Disk], [CDBoxes].[Name] AS [Box], [Categories].[name] AS [Category], [Categories].[id] AS [CategoryId], [CDBoxes].[id] AS [BoxId], [Disks].[id] AS [DiskID], [Files].[Parent] AS [FileParentId] " +
                    " FROM [Categories] INNER JOIN ([CDBoxes] INNER JOIN ([Disks] INNER JOIN [Files] ON [Disks].[id] = [Files].[Disk]) ON [CDBoxes].[id] = [Disks].[CDBox]) ON [Categories].[id] = [CDBoxes].[Category] " +
                    "WHERE " +
                    "([Files].[Name] LIKE '" + fileName.Replace("'", "''").Replace("*", "%") + "') ";

                if (true == useEquals)
                {
                    sql += " AND [Files].[Size] = '" + size + "'";
                }

                OleDbDataAdapter da = new OleDbDataAdapter(sql, new OleDbConnection(this.DBConString));

                DataSetSearch ds = new DataSetSearch();

                da.Fill(ds.Files);

                /**
                 * Lame solution. But what to do?
                 */
                if (true == useMinSize)
                {
                    foreach (DataSetSearch.FilesRow dr in ds.Files.Rows)
                    {
                        if (dr.Size < minSize)
                        {
                            dr.Delete();
                        }
                    }

                    ds.AcceptChanges();
                }

                if (true == userMaxSize)
                {
                    foreach (DataSetSearch.FilesRow dr in ds.Files.Rows)
                    {
                        if (dr.Size > maxSize)
                        {
                            dr.Delete();
                        }
                    }

                    ds.AcceptChanges();
                }

                return ds;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return null;
        }