Exemplo n.º 1
0
 private void mnu_DeleteSnapshot_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "Delete snapshot?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     using (RPM_Snapshot rpmSnapshot = new RPM_Snapshot())
     {
         if (File.Exists(this.FilePath))
         {
             try
             {
                 File.Delete(this.FilePath);
             }
             catch (Exception ex)
             {
                 string message = ex.Message;
             }
         }
         if (File.Exists(this.FilePath))
         {
             return;
         }
         rpmSnapshot.Delete(this.Id);
         rpmSnapshot.Save();
         this.Dispose();
     }
 }
Exemplo n.º 2
0
        public void LoadSnaphots()
        {
            bool b = false;

            if (Global.IsRights(Global.RightsProfile, UserRights.EXPORT))
            {
                b = true;
            }
            ImagePanel.Controls.Clear();
            using (RPM_Snapshot rpmSnapshot = new RPM_Snapshot())
            {
                List <Snapshot> snapshots = rpmSnapshot.GetSnapshots(this.FileID);
                if (snapshots.Count <= 0)
                {
                    return;
                }
                foreach (Snapshot rec in snapshots)
                {
                    ImagePanel imagePanel = new ImagePanel();
                    Image      image      = Utilities.ByteArrayToImage(rec.Thumbnail);
                    imagePanel.CanExport(b);
                    if (Global.IsRedact && Global.IsRights(Global.RightsProfile, UserRights.REDACT))
                    {
                        imagePanel.IsRedact(true);
                    }
                    imagePanel.SetImage(rec, image);
                    ImagePanel.Controls.Add(imagePanel);
                }
            }
        }
Exemplo n.º 3
0
 private void mnu_DeleteAllSnapshots_Click(object sender, EventArgs e)
 {
     if (ImagePanel.Controls.Count <= 0 || MessageBox.Show(this, LangCtrl.GetString("tn_DeleteAll", "Delete All Snapshot Images?"), "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     using (RPM_Snapshot rpmSnapshot = new RPM_Snapshot())
     {
         rpmSnapshot.DeleteAllSnapshots(FileID);
         rpmSnapshot.Save();
     }
     ImagePanel.Controls.Clear();
 }
Exemplo n.º 4
0
 private void CopyThumbnails(DataFile df)
 {
     try
     {
         string originalFileName = df.OriginalFileName;
         using (RPM_Snapshot rPMSnapshot = new RPM_Snapshot())
         {
             List <Snapshot> snapshots = rPMSnapshot.GetSnapshots(df.Id);
             if (snapshots.Count > 0)
             {
                 foreach (Snapshot snapshot in snapshots)
                 {
                     string str  = Path.Combine(snapshot.UNCName, snapshot.UNCPath);
                     string str1 = Path.Combine(str, snapshot.StoredFileName);
                     string str2 = Path.Combine(this.FolderName, string.Concat(snapshot.StoredFileName, snapshot.FileExtension));
                     File.Copy(str1, str2, true);
                 }
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 5
0
        private void Export()
        {
            this.FileFolders.Clear();
            Stopwatch stopwatch = new Stopwatch();
            int       num       = 0;

            if (FileID.Count > 0)
            {
                stopwatch.Start();
                progBar.Maximum = FileID.Count;
                using (RPM_DataFile rPMDataFile = new RPM_DataFile())
                {
                    foreach (Guid fileID in FileID)
                    {
                        progFile.Value = 0;
                        DataFile   dataFile    = rPMDataFile.GetDataFile(fileID);
                        string     folderPath  = FolderPath;
                        ExportForm exportForm  = this;
                        int        folderCount = exportForm.FolderCount;
                        int        num1        = folderCount;
                        exportForm.FolderCount = folderCount + 1;
                        FolderName             = Path.Combine(folderPath, string.Format("FILE_{0}", num1));
                        if (!Directory.Exists(FolderName))
                        {
                            Directory.CreateDirectory(FolderName);
                            Network.SetAcl(FolderName);
                        }
                        FileFolders.Add(FolderName);
                        ListItem     listItem1     = new ListItem();
                        vProgressBar _vProgressBar = progBar;
                        ExportForm   exportForm1   = this;
                        int          fileCount     = exportForm1.FileCount;
                        int          num2          = fileCount;
                        exportForm1.FileCount = fileCount + 1;
                        _vProgressBar.Value   = num2;
                        progBar.Invalidate();
                        Application.DoEvents();
                        picThumbnail.Image = Utilities.ByteArrayToImage(dataFile.Thumbnail);
                        picThumbnail.Invalidate();
                        Application.DoEvents();
                        WriteFileInfo(dataFile);
                        CopyFile(dataFile);
                        listItem1.Text = string.Format("Export: {0}", string.Concat(dataFile.OriginalFileName, dataFile.FileExtension));
                        HashAlgorithm sHA1 = HashAlgorithms.SHA1;
                        switch (dataFile.HashAlgorithm)
                        {
                        case HASH_ALGORITHM.MD5:
                        {
                            sHA1 = HashAlgorithms.MD5;
                            break;
                        }

                        case HASH_ALGORITHM.SHA1:
                        {
                            sHA1 = HashAlgorithms.SHA1;
                            break;
                        }

                        case HASH_ALGORITHM.SHA256:
                        {
                            sHA1 = HashAlgorithms.SHA256;
                            break;
                        }

                        case HASH_ALGORITHM.SHA384:
                        {
                            sHA1 = HashAlgorithms.SHA384;
                            break;
                        }

                        case HASH_ALGORITHM.SHA512:
                        {
                            sHA1 = HashAlgorithms.SHA512;
                            break;
                        }

                        case HASH_ALGORITHM.RIPEMD160:
                        {
                            sHA1 = HashAlgorithms.RIPEMD160;
                            break;
                        }
                        }
                        string hashFromFile = Hash.GetHashFromFile(TargetFileName, sHA1);
                        BeginInvoke(new MethodInvoker(() => {
                            lblExportFileName.Text = string.Concat(dataFile.OriginalFileName, dataFile.FileExtension);
                            lblExportHash.Text     = Convert.ToString(hashFromFile);
                        }));
                        if (!hashFromFile.Equals(dataFile.FileHashCode))
                        {
                            num++;
                            listItem1.Description = string.Format(LangCtrl.GetString("txt_FileHashFail", "File validate Failed {0} x {1}"), dataFile.FileHashCode, hashFromFile);
                            listItem1.ImageIndex  = 2;
                            vListBox.Items.Insert(listItem1, 0);
                        }
                        else
                        {
                            listItem1.ImageIndex  = 1;
                            listItem1.Description = string.Format(LangCtrl.GetString("txt_HashVerified", "File Hash code Verified: {0}"), hashFromFile);
                        }
                        vListBox.Items.Insert(listItem1, 0);
                        CopyMemos(dataFile);
                        CopyThumbnails(dataFile);
                        Global.Log("EXPORT", string.Format(LangCtrl.GetString("txt_DiscExport", "Export: {0}{1} - {2}"), dataFile.StoredFileName, dataFile.FileExtension, dataFile.ShortDesc));
                        Application.DoEvents();
                        int num3 = 0;
                        try
                        {
                            using (RPM_Snapshot rPMSnapshot = new RPM_Snapshot())
                            {
                                List <Snapshot> snapshots = rPMSnapshot.GetSnapshots(fileID);
                                if (snapshots.Count > 0)
                                {
                                    foreach (Snapshot snapshot in snapshots)
                                    {
                                        string str1 = Path.Combine(snapshot.UNCName, snapshot.UNCPath);
                                        SourceFileName = Network.FormatPath(Path.Combine(str1, snapshot.StoredFileName));
                                        string str2 = string.Concat("Snapshot_", num3, snapshot.FileExtension);
                                        TargetFileName = Path.Combine(FolderName, str2);
                                        if (!File.Exists(SourceFileName))
                                        {
                                            continue;
                                        }
                                        File.Copy(SourceFileName, TargetFileName, true);
                                        num3++;
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (EFD.IsZipFile)
                    {
                        BeginInvoke(new MethodInvoker(() => {
                            ListItem listItem = new ListItem()
                            {
                                ImageIndex = 5,
                                Text       = LangCtrl.GetString("txt_SecuringFiles", "Securing Selected Files...Please wait...")
                            };
                            vListBox.Items.Insert(listItem, 0);
                        }));
                        if (EFD.ZipName.Contains("."))
                        {
                            EFD.ZipName = this.EFD.ZipName.Substring(0, this.EFD.ZipName.IndexOf('.'));
                        }
                        //TODO : ref
                        ExportFileData eFD = EFD;
                        eFD.ZipName = string.Concat(eFD.ZipName, ".zip");
                        if (Zip.ZipFolders(this.FileFolders, Path.Combine(this.FolderPath, this.EFD.ZipName), this.EFD.ZipPwd))
                        {
                            Global.Log("EXPORT_ZIP", string.Format(LangCtrl.GetString("txt_ExportSecure", "Export secure file {0}"), Path.Combine(this.FolderPath, this.EFD.ZipName)));
                            foreach (string fileFolder in this.FileFolders)
                            {
                                Directory.Delete(fileFolder, true);
                            }
                        }
                    }
                    stopwatch.Stop();
                    base.BeginInvoke(new MethodInvoker(() => {
                        this.picThumbnail.Image     = null;
                        this.lblExportFileName.Text = string.Empty;
                        this.lblExportHash.Text     = string.Empty;
                        TimeSpan timeSpan           = TimeSpan.FromMilliseconds((double)stopwatch.ElapsedMilliseconds);
                        string str        = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D2}", new object[] { timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds });
                        ListItem listItem = new ListItem();
                        if (this.EFD.IsZipFile)
                        {
                            listItem.ImageIndex = 5;
                            listItem.Text       = string.Format(LangCtrl.GetString("txt_SecureFileCreated", "Secure File Created > {0}"), this.EFD.ZipName);
                            this.vListBox.Items.Insert(listItem, 0);
                        }
                        listItem = new ListItem();
                        if (!this.IsDVD)
                        {
                            listItem.ImageIndex = 3;
                            listItem.Text       = string.Format(LangCtrl.GetString("txt_ExportCompleted", "Export Completed > {0} Files in {1}"), this.FileID.Count, str);
                            Global.Log("EXPORT-COMPLETE", listItem.Text);
                        }
                        else
                        {
                            listItem.ImageIndex = 4;
                            listItem.Text       = string.Format(LangCtrl.GetString("txt_DiscPrep", "Disc Prep Completed > {0} Files in {1}"), this.FileID.Count, str);
                        }
                        listItem.Description = string.Format(LangCtrl.GetString("txt_ExportFileErrors", "File Errors: {0}"), num);
                        this.vListBox.Items.Insert(listItem, 0);
                        base.BeginInvoke(new MethodInvoker(() => {
                            this.lblExportFileName.Text = string.Empty;
                            this.lblExportHash.Text     = string.Empty;
                        }));
                    }));
                }
            }
            base.BeginInvoke(new MethodInvoker(() => {
                try
                {
                    if (!this.IsDVD)
                    {
                        this.picThumbnail.SizeMode = PictureBoxSizeMode.CenterImage;
                        this.picThumbnail.Image    = Properties.Resources.export;
                        this.lbl_FileName.Text     = LangCtrl.GetString("txt_FileExportCompleted", "File Export Completed...");
                        this.lbl_HashCode.Text     = string.Empty;
                    }
                    else
                    {
                        this.picThumbnail.SizeMode = PictureBoxSizeMode.CenterImage;
                        this.picThumbnail.Image    = Properties.Resources.burndisc;
                        this.lbl_FileName.Text     = LangCtrl.GetString("txt_RecToDisc", "Record Files to Disc...");
                        this.lbl_HashCode.Text     = string.Empty;
                        (new ExportCD()
                        {
                            RootFolder = this.TEMP_FOLDER
                        }).ShowDialog(this);
                        DirectoryInfo directoryInfo = new DirectoryInfo(this.TEMP_FOLDER);
                        FileInfo[] files            = directoryInfo.GetFiles();
                        for (int i = 0; i < (int)files.Length; i++)
                        {
                            files[i].Delete();
                        }
                        DirectoryInfo[] directories = directoryInfo.GetDirectories();
                        for (int j = 0; j < (int)directories.Length; j++)
                        {
                            directories[j].Delete(true);
                        }
                        Directory.Delete(this.TEMP_FOLDER);
                        this.BurnCompleteCallback();
                    }
                }
                catch
                {
                }
            }));
        }