Пример #1
0
        private void doTransfer(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker     = sender as BackgroundWorker;
            CaseInfo         workerCase = (CaseInfo)e.Argument;

            Util.CreateDirectory(workerCase.CaseDirectory);

            Util.ProgressInfo         pi           = new Util.ProgressInfo();
            List <Util.FileSelection> transferList = new List <Util.FileSelection>();

            // DEBUG
            //System.Threading.Thread.Sleep(60000);


            foreach (Util.FileSelection fileSelection in workerCase.Files)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                pi.CurrentFileSrc = fileSelection.Path;
                pi.CurrentFileDst = Case.CaseDirectory;

                worker.ReportProgress(Util.ProgressInfo.PercentageDone, pi);
                bool copyResult = false;
                switch (fileSelection.Type)
                {
                case Util.FileSelectionType.DIRECTORY:
                    List <Util.FileSelection> fileList = Util.DirectoryCopy(fileSelection.Path, Case.CaseDirectory, recursive: true, overwrite: Case.OverwriteExistingFiles);
                    lock (pi.TransferredFiles)
                    {
                        pi.TransferredFiles = fileList;
                    }
                    transferList.AddRange(fileList);
                    break;

                case Util.FileSelectionType.FILE:
                    Util.FileSelection file = Util.FileCopy(fileSelection.Path, Case.CaseDirectory, overwrite: Case.OverwriteExistingFiles);

                    lock (pi.TransferredFiles)
                    {
                        pi.TransferredFiles = new List <Util.FileSelection>(1);
                        pi.TransferredFiles.Add(file);
                    }
                    transferList.Add(file);
                    break;
                }
                fileSelection.State = Util.FileState.TRANSFERRED;
            }
            pi.TransferredFiles = transferList;
            e.Result            = pi;
        }
Пример #2
0
        public static void AddTransferredFileToCaseDB(Util.FileSelection fileSelection, CaseInfo theCase)
        {
            string qry = $"INSERT OR REPLACE INTO {TABLE_CASE_CONTENT}(CaseNumber, Path, FileType, ArchiveDate) VALUES('{theCase.Number}', '{fileSelection.Path}', '{fileSelection.Type}', '{DateTime.Now.ToString(DATETIME_FORMAT)}')";

            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
            {
                SQLiteCommand command = new SQLiteCommand(qry, connection);

                connection.Open();
                command.ExecuteNonQuery();
                connection.Close();
            }
        }
Пример #3
0
        public static void AddTransferredFileToCaseDB(Util.FileSelection fileSelection, CaseInfo theCase)
        {
            string prc = "prc_content_add";

            MySqlCommand cmd = new MySqlCommand(prc, connection)
            {
                CommandType = CommandType.StoredProcedure,
            };

            cmd.Parameters.AddWithValue("@case_number", theCase.Number);
            cmd.Parameters.AddWithValue("@path", fileSelection.Path);
            cmd.Parameters.AddWithValue("@filetype", fileSelection.Type);
            //cmd.Parameters.AddWithValue("@archive_date", DateTime.Now);
            cmd.Parameters.AddWithValue("@archive_date", "2017-12-12");
            cmd.ExecuteNonQuery();
        }