private void MemoForm_Load(object sender, EventArgs e) { if (Global.IS_WOLFCOM) { this.HeaderPanel.BackgroundImage = (Image)Properties.Resources.topbar45; } LangCtrl.reText(this); if (dRecord != null) { ListBox.Items.Clear(); using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { dRecord = rpmDataFile.GetDataFile(RecId); foreach (FileMemo fileMemo in dRecord.FileMemos) { ListBox.Items.Add(new ListItem() { Text = fileMemo.ShortDesc, Description = string.Format("{0} - {1} [{2}]", fileMemo.Timestamp, fileMemo.AccountName, fileMemo.BadgeNumber), Tag = fileMemo.Id }); } } } SetLanguage(); }
public void ListTags(Guid FileID) { File_ID = FileID; using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { DataFile dataFile = rpmDataFile.GetDataFile(FileID); FileName = string.Format("{0}{1}", dataFile.StoredFileName, dataFile.FileExtension); } vListBox.Items.Clear(); vListBox.SelectedIndex = -1; using (RPM_VideoTag rpmVideoTag = new RPM_VideoTag()) { TagList = rpmVideoTag.GetTagList(FileID); foreach (VideoTag tag in TagList) { ListItem listItem = new ListItem(); listItem.Text = string.Format("{0}", tag.ShortDesc); TimeSpan timeSpan1 = new TimeSpan(0, 0, Convert.ToInt32(tag.StartTime)); TimeSpan timeSpan2 = new TimeSpan(0, 0, Convert.ToInt32(tag.EndTime)); string str1 = string.Format("{0:00}:{1:00}:{2:D2}", timeSpan1.Hours, timeSpan1.Minutes, timeSpan1.Seconds); string str2 = string.Format("{0:00}:{1:00}:{2:D2}", timeSpan2.Hours, timeSpan2.Minutes, timeSpan2.Seconds); listItem.Description = string.Format("{0} - {1}", str1, str2); listItem.Tag = tag; listItem.ImageIndex = 0; vListBox.Items.Add(listItem); } } }
private void EditorForm_Load(object sender, EventArgs e) { SetLanguage(); Text = LangCtrl.GetString("dlg_MemoEditor", "Memo Editor"); LoadVoices(); if (DocList.Equals(null)) { DocList = new List <DOCData>(); } if (DocList.Count > 0) { int num = 0; mnu_LoadFile.Visible = false; mnu_Save.Visible = false; try { using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { foreach (DOCData doc in DocList) { FileMemo memo = rpmDataFile.GetMemo(doc.RecId); if (PageBreak) { textControl1.Append(memo.Memo, StringStreamType.RichTextFormat, AppendSettings.StartWithNewSection); } else { textControl1.Append(memo.Memo, StringStreamType.RichTextFormat, AppendSettings.None); } IsReadOnly = true; ++num; } textControl1.EditMode = EditMode.ReadOnly; } } catch (Exception ex) { string message = ex.Message; } } else { try { if (!RTF.Equals(string.Empty)) { textControl1.Load(RTF, StringStreamType.RichTextFormat); } } catch { } } string stringData; textControl1.Save(out stringData, StringStreamType.RichTextFormat); Hash = stringData.GetHashCode(); textControl1.BackgroundStyle = BackgroundStyle.ColorScheme; textControl1.BorderStyle = TXTextControl.BorderStyle.None; }
private bool IsMemos() { bool flag = false; using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { if (rPMDataFile.GetMemoCount(this.sRecord.dRecord.Id) > 0) { flag = true; } } return(flag); }
private void CopySelectedFiles() { btn_Close.Enabled = false; btn_OK.Enabled = false; progBar.Visible = true; progBar.Maximum = this.FileList.Count; progBar.Invalidate(); Application.DoEvents(); using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { int num = 1; foreach (Guid file in this.FileList) { progBar.Value = num++; progBar.Invalidate(); rpmDataFile.GetDataFile(file).AccountId = AccountID; } } Close(); }
public void LoadData(Guid Id) { if (Global.IS_WOLFCOM) { HeaderPanel.BackgroundImage = (Image)Properties.Resources.topbar45; } using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { DataFile dataFile = rpmDataFile.GetDataFile(Id); txtFileTimestamp.Text = dataFile.FileTimestamp.ToString(); txtFileSize.Text = string.Format("{0}", dataFile.FileSize); txtFileExt.Text = dataFile.FileExtension; txtFileName.Text = dataFile.OriginalFileName; txtAdded.Text = dataFile.FileAddedTimestamp.ToString(); txtCAD.Text = dataFile.CADNumber; txtRMS.Text = dataFile.RMSNumber; txtSet.Text = dataFile.SetName; txtClassification.Text = dataFile.Classification; } }
private void LoadNodes() { this.ROOT.Nodes.Clear(); try { using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { Guid accountID = this.AccountID; string text = this.txtSetID.Text; DateTime value = this.FromDate.Value.Value; DateTime?nullable = this.ToDate.Value; foreach (DataFile setList in rPMDataFile.GetSetList(accountID, text, value, nullable.Value)) { if (string.IsNullOrEmpty(setList.SetName)) { continue; } NodeRecord nodeRecord = new NodeRecord() { Name = setList.SetName, RecType = NodeType.PARENT, ImgIdx = 1 }; vTreeNode _vTreeNode = new vTreeNode(nodeRecord.Name) { ImageIndex = 1, Tag = nodeRecord, TooltipText = string.Format("{0}\n{1}\n{2}", setList.FileTimestamp, setList.Classification, setList.ShortDesc) }; this.ROOT.Nodes.Add(_vTreeNode); } } } catch { } }
private void mnuProfileData_Click(object sender, EventArgs e) { this.BackColor = Color.FromArgb(250, 250, 250); ProfileData profileDatum = new ProfileData(this.sRecord); using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { rPMDataFile.ViewFileData(this.sRecord.dRecord.Id); } if (profileDatum.ShowDialog(this) == DialogResult.OK) { this.sRecord = profileDatum.sRecord; using (RPM_DataFile rPMDataFile1 = new RPM_DataFile()) { this.sRecord.Action = ACTION.UPDATE; rPMDataFile1.SaveUpdate(this.sRecord.dRecord); rPMDataFile1.Save(); this.lblDesc.Text = this.sRecord.dRecord.ShortDesc; this.Callback(this, new CmdSlideEventArgs(this.sRecord)); } this.SetSlideData(); } this.SetSelectMode(); }
private void mnuAddMemo_Click(object sender, EventArgs e) { this.BackColor = Color.FromArgb(250, 250, 250); EditorForm editorForm = new EditorForm(this.sRecord.SlideNumber); if (editorForm.ShowDialog(this) == DialogResult.OK) { FileMemo fileMemo = new FileMemo() { AccountName = this.aRecord.ToString(), BadgeNumber = this.aRecord.BadgeNumber, Timestamp = new DateTime?(DateTime.Now), Memo = editorForm.RTF, Text = editorForm.DocText }; if (fileMemo.Text.Length >= 64) { fileMemo.ShortDesc = this.CleanInput(fileMemo.Text.Substring(0, 64)); } else { fileMemo.ShortDesc = this.CleanInput(fileMemo.Text); } using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { DataFile dataFile = rPMDataFile.GetDataFile(this.sRecord.dRecord.Id); fileMemo.DataFile = dataFile; dataFile.FileMemos.Add(fileMemo); rPMDataFile.SaveUpdate(dataFile); rPMDataFile.Save(); } this.sRecord.IsMemo = true; this.Thumbnail.Invalidate(); this.SetSelectMode(); } }
private void CopyMemos(DataFile dRecord) { try { if (dRecord != null) { using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { foreach (FileMemo fileMemo in rPMDataFile.GetDataFile(dRecord.Id).FileMemos) { string shortDesc = fileMemo.ShortDesc; string str = Path.Combine(this.FolderName, string.Format("{0}.rtf", shortDesc)); using (StreamWriter streamWriter = new StreamWriter(str)) { streamWriter.Write(fileMemo.Memo); } } } } } catch { } }
private void btn_Search_Click(object sender, EventArgs e) { try { int num1 = 0; int num2 = 0; if (ValidateSearch()) { DataPanel.Controls.Clear(); DataPanel.SuspendLayout(); SECURITY security = Global.GlobalAccount.Security; Guid guid = Guid.Empty; List <DataFile> dataFileList1 = new List <DataFile>(); string str = string.Empty; using (RPM_DataFile rpmDataFile = new RPM_DataFile()) { List <DataFile> dataFileList2 = rpmDataFile.QryGlobalCatalog(btnByFileDate.Checked, FromDate.Value.Value, ToDate.Value.Value, txtRMS.Text, txtCAD.Text, txtSet.Text, chk_FilterEvidence.Checked); if (dataFileList2.Count > 0) { foreach (DataFile df in dataFileList2) { if (guid != df.AccountId) { guid = df.AccountId; using (RPM_Account rpmAccount = new RPM_Account()) { Account account = rpmAccount.GetAccount(df.AccountId); str = string.Format("{0} • {1}", account.ToString(), account.BadgeNumber); string data = string.Format("Rank: {0}", account.Rank); AccountPanel accountPanel = new AccountPanel(str, data, account.Security); DataPanel.Controls.Add(accountPanel); DataPanel.Controls.SetChildIndex(accountPanel, 0); ++num2; } } if (security <= df.Security) { CatalogObject catalogObject = new CatalogObject(num1 + 1, df, str); DataPanel.Controls.Add(catalogObject); DataPanel.Controls.SetChildIndex(catalogObject, 0); ++num1; } } } else { Label label = new Label(); label.Dock = DockStyle.Top; label.Font = new Font("Verdana", 16f); label.Text = LangCtrl.GetString("gc_NoResults", "NO RESULTS FOUND"); DataPanel.Controls.Add(label); } } gcFileCount.Text = string.Format(LangCtrl.GetString("gcFileCount", "Files: {0}"), num1); gc_Accounts.Text = string.Format(LangCtrl.GetString("gc_Accounts", "Accounts: {0}"), num2); } object[] objArray = new object[] { FromDate.Value.Value, ToDate.Value.Value, txtRMS.Text, txtCAD.Text, chk_FilterEvidence.Checked, num2, num1 }; string str2 = string.Format("{0} to {1} RMS: {2} CAD: {3} Evidence: {4} RESULT> Accounts: {5} Files: {6}", objArray); Global.Log("SEARCH GC", string.Concat("Global Catalog> ", str2)); } catch (Exception ex) { MessageBox.Show(ex.Message); } DataPanel.ResumeLayout(); }
private void RunUpload() { this.Filter = string.Empty; using (RPM_FileExt rPMFileExt = new RPM_FileExt()) { List <FileExt> fileExtensions = rPMFileExt.GetFileExtensions(); int num2 = 0; if (fileExtensions.Count <= 0) { this.Filter = ".DAT,.GPS,.EXIF"; } else { foreach (FileExt fileExtension in fileExtensions) { if (num2 <= 0) { Upload upload1 = this; upload1.Filter = string.Concat(upload1.Filter, fileExtension.Ext); } else { Upload upload2 = this; upload2.Filter = string.Concat(upload2.Filter, ",", fileExtension.Ext); } num2++; } } if (!this.Filter.Contains(".GPS")) { Upload upload3 = this; upload3.Filter = string.Concat(upload3.Filter, ",.GPS"); } if (!this.Filter.Contains(".DAT")) { Upload upload4 = this; upload4.Filter = string.Concat(upload4.Filter, ",.DAT"); } if (!this.Filter.Contains(".EXIF")) { Upload upload5 = this; upload5.Filter = string.Concat(upload5.Filter, ",.EXIF"); } } if (this.FileNames == null) { if (string.IsNullOrEmpty(this.SourcePath)) { return; } this.fileEntries = Directory.GetFiles(this.SourcePath); } else if ((int)this.FileNames.Length > 0) { this.fileEntries = this.FileNames; } this.FileList.Clear(); string[] strArrays = this.Filter.Split(new char[] { ',' }); string[] strArrays1 = this.fileEntries; for (int i = 0; i < (int)strArrays1.Length; i++) { string str = strArrays1[i]; bool flag = false; string upper = Path.GetExtension(str).ToUpper(); if ((int)strArrays.Length > 0) { string[] strArrays2 = strArrays; int num3 = 0; while (num3 < (int)strArrays2.Length) { string str1 = strArrays2[num3]; if (string.IsNullOrEmpty(str1) || !upper.Equals(str1.ToUpper())) { num3++; } else { flag = true; goto Label0; } } } Label0: if (!flag) { this.FileList.Add(str, false); } } HashAlgorithm sHA1 = HashAlgorithms.SHA1; switch (Global.DefaultHashAlgorithm) { 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; } } this.progBar.Maximum = this.FileList.Count; Image thumbnailImage = Resources.folder; this.i = 0; foreach (KeyValuePair <string, bool> fileList in this.FileList) { string key = fileList.Key; FileInfo fileInfo = new FileInfo(key); base.BeginInvoke(new MethodInvoker(() => { try { vProgressBar u003cu003e4_this = this.progBar; Upload upload = this; int num = upload.i + 1; int num1 = num; upload.i = num; u003cu003e4_this.Value = num1; this.lblStatus.Text = "Uploading..."; this.lblFileCount.Text = string.Format("{0} of {1}", this.i, this.FileList.Count); this.lblFileName.Text = string.Format("{0} • {1}", Path.GetFileName(fileList.Key), Utilities.BytesToString(fileInfo.Length)); } catch (Exception exception) { this.CancelFlag = true; } })); if (!File.Exists(key)) { continue; } FileData fileDatum = new FileData(); try { string extension = Path.GetExtension(key); if (!this.IsRawName) { fileDatum.FileName = Guid.NewGuid().ToString(); } else { fileDatum.FileName = Path.GetFileNameWithoutExtension(key); } fileDatum.OriginalFileName = Path.GetFileNameWithoutExtension(key); fileDatum.FileExt = extension; fileDatum.FileHashCode = "Pending..."; fileDatum.FileSize = fileInfo.Length; fileDatum.FileTimestamp = fileInfo.LastWriteTime; this.TimeStamp = fileDatum.FileTimestamp.ToString(); fileDatum.Server = this.Server; fileDatum.RelativePath = this.RelativePath; fileDatum.IsDat = fileList.Value; MemoryStream memoryStream = new MemoryStream(); (new FFMpegConverter()).GetVideoThumbnail(key, memoryStream); Image image = Image.FromStream(memoryStream); thumbnailImage = image.GetThumbnailImage(220, 130, null, IntPtr.Zero); this.picBox.SizeMode = PictureBoxSizeMode.StretchImage; this.picBox.Image = (Image)thumbnailImage.Clone(); fileDatum.Thumbnail = (Image)thumbnailImage.Clone(); } catch (Exception exception1) { string upper1 = Path.GetExtension(key).ToUpper(); string str2 = upper1; if (upper1 != null) { switch (str2) { case ".WAV": { fileDatum.Thumbnail = Utilities.resizeImage(48, 48, Resources.audio); this.picBox.SizeMode = PictureBoxSizeMode.CenterImage; this.picBox.Image = fileDatum.Thumbnail; goto Label1; } case ".JPG": case ".BMP": case ".GIF": case ".TIF": case ".PNG": { Image image1 = Image.FromFile(key); fileDatum.Thumbnail = image1.GetThumbnailImage(220, 130, null, IntPtr.Zero); this.picBox.SizeMode = PictureBoxSizeMode.StretchImage; this.picBox.Image = fileDatum.Thumbnail; goto Label1; } } } Icon winLogo = SystemIcons.WinLogo; fileDatum.Thumbnail = Utilities.resizeImage(48, 48, Icon.ExtractAssociatedIcon(key).ToBitmap()); this.picBox.SizeMode = PictureBoxSizeMode.CenterImage; this.picBox.Image = fileDatum.Thumbnail; //TODO : goto Label1 :; } this.picBox.Invalidate(); string str3 = Path.Combine(this.TargetPath, string.Concat(fileDatum.FileName, fileDatum.FileExt)); this.Callback(this, new CmdEventArgs(fileDatum)); string str4 = str3; try { if (!File.Exists(str3)) { this.progFile.Value = 0; this.progFile.Text = string.Empty; this.FileCount++; this.CopyFileWithProgress(key, str3); string empty = string.Empty; string[] strArrays3 = strArrays; for (int j = 0; j < (int)strArrays3.Length; j++) { string str5 = strArrays3[j]; string str6 = Path.Combine(Path.GetDirectoryName(key), string.Concat(Path.GetFileNameWithoutExtension(key), str5)); if (File.Exists(str6)) { this.progFile.Value = 0; this.progFile.Text = string.Empty; base.BeginInvoke(new MethodInvoker(() => this.lblFileName.Text = Path.GetFileName(Path.GetFileName(str6)))); str3 = Path.Combine(this.TargetPath, string.Concat(fileDatum.FileName, str5)); empty = str5; this.SourceFileName = str6; this.TargetFileName = str3; this.CopyFileWithProgress(str6, str3); } } FileInfo fileInfo1 = new FileInfo(str4); if (!(fileDatum.FileSize != fileInfo1.Length | this.CancelFlag)) { using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { DataFile dataFile = new DataFile() { AccountId = this.AccountID, Classification = "Unclassified", FileAddedTimestamp = new DateTime?(DateTime.Now), FileExtension = fileDatum.FileExt, FileExtension2 = empty, HashAlgorithm = Global.DefaultHashAlgorithm, FileHashCode = Hash.GetHashFromFile(str3, sHA1), FileSize = fileDatum.FileSize, FileTimestamp = new DateTime?(fileDatum.FileTimestamp), GPS = "", IsEncrypted = new bool?(false), IsPurged = new bool?(false), OriginalFileName = fileDatum.OriginalFileName, PurgeFileName = "", Rating = 0, Security = SECURITY.UNCLASSIFIED, SetName = "" }; if (!string.IsNullOrEmpty(this.SETID)) { dataFile.SetName = this.SETID; object[] originalFileName = new object[] { dataFile.OriginalFileName, fileDatum.FileName, dataFile.FileExtension, this.SETID }; Global.Log("SET COPY", string.Format("Copy File: {0} -> {1}{2} into SET ID {3}", originalFileName)); } dataFile.ShortDesc = string.Concat(fileDatum.OriginalFileName, fileDatum.FileExt); dataFile.StoredFileName = fileDatum.FileName; dataFile.Thumbnail = Utilities.ImageToByte(fileDatum.Thumbnail); dataFile.TrackingID = Guid.Empty; dataFile.UNCName = this.UNCRoot; dataFile.UNCPath = this.DataPath; dataFile.MachineName = this.MachineName; dataFile.MachineAccount = this.MachineAccount; dataFile.UserDomain = this.MachineDomain; dataFile.SourcePath = Path.GetDirectoryName(key); //TODO: Метод был изменен на свойство dataFile.LoginID = Global.LoginIDName; rPMDataFile.SaveUpdate(dataFile); rPMDataFile.Save(); } } else { Global.Log("UPLOAD_FAIL", string.Format("Upload failed for {0} / Cancel upload.", this.SourceFileName)); if (File.Exists(str3)) { File.Delete(str3); } } } } catch { } Thread.Sleep(250); if (this.CancelFlag) { break; } } base.BeginInvoke(new MethodInvoker(() => { try { this.ShowTimestamp = false; this.lblFileName.Text = string.Empty; this.picBox.Image = Resources.check64; this.lblStatus.Text = "Upload Complete"; this.lblFileName.Text = string.Empty; this.progFile.Value = 0; this.progBar.Value = 0; this.progFile.Invalidate(); this.progBar.Invalidate(); this.UploadCompleteCallback(); } catch (Exception exception) { this.UploadCompleteCallback(); } })); }
public bool DeleteSlideFile(int days) { this.sRecord.Action = ACTION.NONE; bool flag = false; if (days > 0 && (this.sRecord.dRecord.Classification.ToUpper().Equals("UNCLASSIFIED") || string.IsNullOrEmpty(this.sRecord.dRecord.Classification))) { DateTime value = this.sRecord.dRecord.FileAddedTimestamp.Value; value = value.AddDays((double)days); if (DateTime.Now > value) { this.picDelete.Visible = true; Application.DoEvents(); DateTime now = DateTime.Now; object[] year = new object[] { now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond }; string str = string.Format("{0}{1:00}{2:00}_{3:00}{4:00}{5:00}.{6:0000}.zip", year); string str1 = Path.Combine(this.sRecord.dRecord.UNCName, this.sRecord.dRecord.UNCPath); string str2 = Path.Combine(Network.FormatPath(str1), string.Format("{0}{1}", this.sRecord.dRecord.StoredFileName, this.sRecord.dRecord.FileExtension)); if (!File.Exists(str2)) { MessageBox.Show(this, string.Format(LangCtrl.GetString("sld_SourceFile", "Source File Not Found: {0}"), str2), "File Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { string empty = string.Empty; string empty1 = string.Empty; using (RPM_GlobalConfig rPMGlobalConfig = new RPM_GlobalConfig()) { GlobalConfig configRecord = rPMGlobalConfig.GetConfigRecord("RET_UNC_ROOT"); if (configRecord != null) { empty = configRecord.Value; } configRecord = rPMGlobalConfig.GetConfigRecord("RET_UNC_PATH"); if (configRecord != null) { empty1 = configRecord.Value; } } if (!string.IsNullOrEmpty(empty) && !string.IsNullOrEmpty(empty1)) { string str3 = Network.FormatPath(Path.Combine(empty, empty1)); if (!Directory.Exists(str3)) { MessageBox.Show(this, LangCtrl.GetString("sld_ArchiveFolder", "Archive Folder Not Set!\nContact your system administrator."), "Archive Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (Zip.ZipToFile(str2, str3, str)) { using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { DataFile dataFile = rPMDataFile.GetDataFile(this.sRecord.dRecord.Id); dataFile.PurgeFileName = str; dataFile.PurgeTimestamp = new DateTime?(DateTime.Now); dataFile.IsPurged = new bool?(true); rPMDataFile.SaveUpdate(dataFile); rPMDataFile.Save(); try { File.Delete(str2); } catch (Exception exception1) { Exception exception = exception1; MessageBox.Show(this, exception.Message, "Delete Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } if (!File.Exists(str2)) { Global.Log("USER DELETE", string.Format("File: {0}", str2)); flag = true; } } } } } this.picDelete.Visible = false; Application.DoEvents(); } } return(flag); }
private void LogScan() { string str = Path.Combine(this.FilePath, this.DocName); FileInfo fileInfo = new FileInfo(str); using (RPM_DataFile rPMDataFile = new RPM_DataFile()) { DataFile dataFile = new DataFile() { AccountId = this.AccountID, Classification = "Unclassified", FileAddedTimestamp = new DateTime?(DateTime.Now), FileExtension = ".PDF", FileExtension2 = "" }; HashAlgorithm sHA1 = HashAlgorithms.SHA1; switch (Global.DefaultHashAlgorithm) { 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; } } dataFile.FileHashCode = Hash.GetHashFromFile(str, sHA1); dataFile.FileSize = fileInfo.Length; dataFile.FileTimestamp = new DateTime?(fileInfo.LastWriteTime); dataFile.GPS = ""; dataFile.IsEncrypted = new bool?(false); dataFile.IsPurged = new bool?(false); dataFile.OriginalFileName = this.DocGuid.ToString(); dataFile.PurgeFileName = ""; dataFile.Rating = 0; dataFile.Security = AccountSecurity.GetByString(this.cboSecurity.Text); dataFile.SetName = ""; dataFile.ShortDesc = this.txtTitle.Text; dataFile.StoredFileName = this.DocGuid.ToString(); dataFile.Thumbnail = Utilities.ImageToByte(this.ThumbnailImage); dataFile.TrackingID = Guid.Empty; dataFile.UNCName = this.UNC; dataFile.UNCPath = this.DataPath; string machineName = Environment.MachineName; string userName = Environment.UserName; string userDomainName = Environment.UserDomainName; dataFile.MachineName = machineName; dataFile.MachineAccount = userName; dataFile.UserDomain = userDomainName; dataFile.SourcePath = this.ScannerName; dataFile.LoginID = Global.LoginIDName; rPMDataFile.SaveUpdate(dataFile); rPMDataFile.Save(); } }
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 { } })); }