public void ExtractFiles() { try { archivePath = form1.archivePath; archiveName = FileUtil.GetFileNameWithoutExtensionByFilePath(archivePath); if (FileUtil.FileSize(archivePath) > 0) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tStep1:Extract archive files", Color.Blue, true); //obtain desired dataExtractedPath dataExtractedPath = FileUtil.GetPathExtractedArchive(archiveName); //start extract data to specified location ArchiveUtil.UnzipFile(archivePath, dataExtractedPath); //set path to relevant Info from .meta file form1.metaDataExtractedPath = FileUtil.GetPathOfExtractedMetaFile(dataExtractedPath); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tOK...", Color.Blue, true); //activate button of Load DB ComponentsUtil.SetButtonVisibility(form1.GetLoadButton()); } else { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "Archive size is 0", Color.Red, true); } } catch (Exception ex) { throw ex; }; }
public void StartBuildArchive() { //retrive archivatorDTO object archivatorDTO = form1.archivatorDTO; if (archivatorDTO != null && archivatorDTO.Delimiter != null && archivatorDTO.Destination != null && archivatorDTO.Source != null && archivatorDTO.StartIndex != null) { //check if source dir exist on disk if (!Directory.Exists(archivatorDTO.Source)) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tSource dir not exist..", Color.Red, true); return; } //process .meta file and build zipFile ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tStarting build archive files..", Color.Green, true); ArchiveController archiveCtrl = new ArchiveController(form1); bool builtZip = archiveCtrl.BuildZipFile(); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tFinished build archive file..", Color.Green, true); //if ZipFile was built succesfully then delete .meta from (source ) .meta file unzipped if (builtZip) { FileUtil.DeleteFile(archiveCtrl.pathMetadata); } } }
public void ParseMetaDataInfo() { try { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tStep2:Parse content from .meta file", Color.Blue, true); listMetaData = ParserUtil.ParseMetaContent(form1.metaDataExtractedPath, form1.delimterMeta); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tOK...", Color.Blue, true); } catch (Exception ex) { throw ex; }; }
public void InsertMetadataInAccessDB() { try { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tStep3:Insert data in Access DB", Color.Blue, true); AccessBLL.InsertDataDB(listMetadata); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tOK...", Color.Blue, true); } catch (Exception ex) { throw ex; }; }
/// <summary> /// This method call ArchiveController which extract data from specific archive file /// </summary> public void StartExtractDataFromArchive() { try { ArchiveController archiveCtrl = new ArchiveController(form1); archiveCtrl.ExtractFiles(); } catch (Exception ex) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), String.Format("\t\tError: {0}", ex.Message), Color.Red, true); } }
/// <summary> /// This method call controller which insert records in DB based on List of objects /// </summary> /// <param name="form1"></param> /// <param name="listMetadata"></param> public void StartLoadDataInAccessDB(Form1 form1, List <MetadataDTO> listMetadata) { try { AccessDBController accesDBCtrl = new AccessDBController(form1, listMetadata); accesDBCtrl.InsertMetadataInAccessDB(); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "Succesfully inserted...", Color.Green, true); } catch (Exception ex) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), String.Format("\t\tError: {0}", ex.Message), Color.Red, true); } }
/// <summary> /// This method call controller which parse content from .meta file /// </summary> public void StartParseMetaDataInfo() { try { MetaDataInfoController metadataCtrl = new MetaDataInfoController(form1); metadataCtrl.ParseMetaDataInfo(); //if not null send data to AccessDBController if (metadataCtrl.listMetaData != null) { StartLoadDataInAccessDB(form1, metadataCtrl.listMetaData); } }catch (Exception ex) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), String.Format("\t\tError: {0}", ex.Message), Color.Red, true); } }
public bool BuildZipFile() { try { //message info step1 (create .meta file) ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tStep1:Create .meta file", Color.Blue, true); //build meta file FileController fileCtrl = new FileController(form1); string metaDataContent = fileCtrl.BuildMetaFile(); pathMetadata = String.Format(@"{0}\{1}", archivatorDTO.Source, "InfoImages.meta"); FileUtil.BuildFile(metaDataContent, pathMetadata); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tOK..", Color.Blue, true); //message info step2 (create .zip file) ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tStep2:Create archive file", Color.Blue, true); //build zip file string[] imagesPath = FileUtil.GetImagesFromDir(archivatorDTO.Source); string destinationZipData = String.Format(@"{0}\{1}.zip", archivatorDTO.Destination, DateUtil.GetDateYYYMMDDHHMMSS()); ArchiveUtil.ZipData(imagesPath, pathMetadata, destinationZipData); //Check if zip file was built succesfully if (File.Exists(destinationZipData)) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tOK..", Color.Blue, true); zipBuilt = true; } else { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\t\tZip file not built..", Color.Red, true); }; return(zipBuilt); } catch (Exception ex) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), String.Format("\t\tError:{0}", ex.Message), Color.Red, true); return(zipBuilt); }; }
public void StartParseXMLEntries() { //load xml structure in an object XMLController xmlCtrl = new XMLController(form1); archivatorDTO = xmlCtrl.ConvertXMLToObject(); if (archivatorDTO != null) { //show XML data loaded in a gridView DataGridViewController.FillGridViewWithDataLoaded(form1); //made visible CreateArchive button ComponentsUtil.SetButtonVisibility(form1.GetCreateArchiveButton()); //message to createArchive ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "\tPress CreateArchive to build archive..", Color.Green, true); //maintain object to used later form1.archivatorDTO = archivatorDTO; } }
public ArchivatorDTO ConvertXMLToObject() { try { if (form1.xmlPath != string.Empty && form1.xmlPath != null) { XMLConverter xmlConv = new XMLConverter(); string xmlInputData = File.ReadAllText(form1.xmlPath); archivatorDTO = xmlConv.Deserialize <ArchivatorDTO>(xmlInputData); ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "XML structure is OK..", Color.Green, true); } else { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), "Error please check XML structure", Color.Red, true); } return(archivatorDTO); } catch (Exception ex) { ComponentsUtil.AppendTextToRichTextBox(form1.GetRichTextBoxInfo(), String.Format("Error Load XML: {0}", ex.Message), Color.Red, true); return(archivatorDTO); }; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.LoadToDatabaseButton = new System.Windows.Forms.Button(); this.UploadArchiveButton = new System.Windows.Forms.Button(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Info; this.splitContainer1.Panel1.Controls.Add(this.LoadToDatabaseButton); this.splitContainer1.Panel1.Controls.Add(this.UploadArchiveButton); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); this.splitContainer1.Panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.splitContainer1_Panel2_Paint); this.splitContainer1.Size = new System.Drawing.Size(800, 450); this.splitContainer1.SplitterDistance = 186; this.splitContainer1.TabIndex = 0; // // LoadToDatabaseButton // this.LoadToDatabaseButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("LoadToDatabaseButton.BackgroundImage"))); this.LoadToDatabaseButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.LoadToDatabaseButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.LoadToDatabaseButton.Location = new System.Drawing.Point(30, 182); this.LoadToDatabaseButton.Name = "LoadToDatabaseButton"; this.LoadToDatabaseButton.Size = new System.Drawing.Size(130, 140); this.LoadToDatabaseButton.TabIndex = 1; this.LoadToDatabaseButton.Text = "LoadInDataBase"; this.LoadToDatabaseButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.LoadToDatabaseButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.LoadToDatabaseButton.UseVisualStyleBackColor = true; this.LoadToDatabaseButton.Visible = false; this.LoadToDatabaseButton.Click += new System.EventHandler(this.LoadToDatabaseButton_Click); // // UploadArchiveButton // this.UploadArchiveButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("UploadArchiveButton.BackgroundImage"))); this.UploadArchiveButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.UploadArchiveButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.UploadArchiveButton.Location = new System.Drawing.Point(30, 12); this.UploadArchiveButton.Name = "UploadArchiveButton"; this.UploadArchiveButton.Size = new System.Drawing.Size(130, 140); this.UploadArchiveButton.TabIndex = 0; this.UploadArchiveButton.Text = "ExtractArchive"; this.UploadArchiveButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.UploadArchiveButton.UseVisualStyleBackColor = true; this.UploadArchiveButton.Click += new System.EventHandler(this.UploadArchiveButton_Click); // // splitContainer2 // this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer2.Panel1 // this.splitContainer2.Panel1.Controls.Add(this.richTextBox1); // // splitContainer2.Panel2 // this.splitContainer2.Panel2.BackColor = System.Drawing.SystemColors.GradientActiveCaption; this.splitContainer2.Panel2.Controls.Add(this.textBox2); this.splitContainer2.Panel2.Controls.Add(this.pictureBox1); this.splitContainer2.Size = new System.Drawing.Size(610, 450); this.splitContainer2.SplitterDistance = 159; this.splitContainer2.TabIndex = 0; // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(14, 12); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.ReadOnly = true; this.richTextBox1.Size = new System.Drawing.Size(584, 129); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; ComponentsUtil.AppendTextToRichTextBox(richTextBox1, "Press button ExtractArchive...", Color.Green, true); // // textBox2 // this.textBox2.BackColor = System.Drawing.SystemColors.ActiveCaption; this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textBox2.ForeColor = System.Drawing.Color.DarkGreen; this.textBox2.Location = new System.Drawing.Point(14, 3); this.textBox2.Name = "textBox2"; this.textBox2.ReadOnly = true; this.textBox2.Size = new System.Drawing.Size(288, 20); this.textBox2.TabIndex = 2; this.textBox2.Text = "Below is a structure example of Archive structure"; // // pictureBox1 // this.pictureBox1.ErrorImage = null; this.pictureBox1.Image = global::IronMountainEx2DArchiveDBUploader.Properties.Resources.ArchiveStructure; this.pictureBox1.InitialImage = null; this.pictureBox1.Location = new System.Drawing.Point(14, 29); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(288, 194); this.pictureBox1.TabIndex = 1; this.pictureBox1.TabStop = false; // // openFileDialog1 // this.openFileDialog1.FileName = "openFileDialog1"; this.openFileDialog1.Filter = "\"Zip Files|*.zip;*.rar\";"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.splitContainer1); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "IronMountainAppDBUploader"; this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false); this.splitContainer2.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); }