Exemple #1
0
 public Processing(clsVerification mVerify)
 {
     InitializeComponent();
     this.objVerify = mVerify;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="reportEntry"></param>
 public frmReportEntry(clsVerification reportEntry)
 {
     InitializeComponent();
     this.objProjData = reportEntry;
 }
        private void btnGenerate_Click_1(object sender, EventArgs e)
        {
            #region Valitaion Input Feilds
            string RequiredFields = string.Empty;
            if (String.IsNullOrEmpty(txtAcName.Text.Trim()))
            {
                RequiredFields += "* Account Name \r\n";
            }
            if (String.IsNullOrEmpty(txtProjName.Text.Trim()))
            {
                RequiredFields += "* Project Name \r\n";
            }
            if (String.IsNullOrEmpty(txtGITS.Text.Trim()))
            {
                RequiredFields += "* GITS Case ID \r\n";
            }
            if (String.IsNullOrEmpty(dtRestored.Text.Trim()))
            {
                RequiredFields += "* Date of Restored \r\n";
            }
            if (String.IsNullOrEmpty(txtBackupLoc.Text.Trim()))
            {
                RequiredFields += "* Backup Location \r\n";
            }
            if (String.IsNullOrEmpty(txtCLName.Text.Trim()))
            {
                RequiredFields += "* CL Name \r\n";
            }

            if (!String.IsNullOrEmpty(RequiredFields))
            {
                lblDescription.Text  = "Please enter the following mandatory fields: \r\n";
                lblDescription.Text += RequiredFields;
                return;
            }

            #endregion

            Microsoft.Win32.RegistryKey EasySVNdiff = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("ReportUserDetails");
            EasySVNdiff.SetValue("AccountName", txtAcName.Text);
            EasySVNdiff.SetValue("ProjectName", txtProjName.Text);
            EasySVNdiff.SetValue("CLName", txtCLName.Text);
            EasySVNdiff.Close();

            clsVerification objReport = new clsVerification();

            objReport.TextFile = "EasySVNdiff_DetailedLog" + DateTime.Now.ToString().Replace("/", "").Replace(" ", "").Replace(":", "") + ".txt";

            StringBuilder sbReport = new StringBuilder();
            sbReport.Append("<!DOCTYPE html><html lang='en'><head><meta charset='utf-8' /><title>SVN Repository Backup Restoration Verification</title>");
            sbReport.Append("<style type='text/css' media='screen,print'> body {font-family:Segoe UI, arial,verdana; width:900px; margin:0 auto;} .table-header{background:#047CC1;} .column-name{background:#99CCFF;}</style></head>");
            sbReport.Append("<body><tr><td align='left' width='200px'><img src='https://www.csscorp.com/sites/all/themes/csscorp/images/css_corp_logo.jpg'/></td><td align='right'><h2><p align='center' nowrap><font color='#545456'>SVN Repository Backup Restoration Verification</font></p></h2></td></tr></table>");
            sbReport.Append("<table border='0' class='table-header' cellpadding='1' cellspacing='1' width='100%' align='center'><tr height='15'><td colspan='2'><div style='color:#D4FFFF; font-weight:bold'> Project Info:</div></td></tr>");
            sbReport.Append("<tr><td class='column-name' width='50%'> Account Name</td><td bgcolor='white' width='50%'> " + txtAcName.Text + "</td></tr><tr><td bgcolor='#99CCFF'> Project Name</td><td bgcolor='white'> " + txtProjName.Text + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> Repository URL</td><td bgcolor='white'> " + objProjData.LiveURL + "</td></tr><tr><td bgcolor='#99CCFF'> GITS Case ID</td><td bgcolor='white'> " + txtGITS.Text + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> Back-Up Date</td><td bgcolor='white'> " + objProjData.BackupDate + "</td></tr><tr><td bgcolor='#99CCFF'> Date of Restoration</td><td bgcolor='white'> " + dtRestored.Value + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> Date of Verification</td><td bgcolor='white'> " + System.DateTime.Today + "</td></tr><tr><td bgcolor='#99CCFF'> Backup location (including server name) / Local machine path</td><td bgcolor='white'> " + txtBackupLoc.Text + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> Restored location (including server name) / Local machine path</td><td bgcolor='white'> " + objProjData.BackupURL + "</td></tr><tr><td bgcolor='#99CCFF'> Date of Restoration</td><td bgcolor='white'> " + dtRestored.Value + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> CL Name (or the person who performs the verification)</td><td bgcolor='white'> " + txtCLName.Text + "</td></tr>");
            sbReport.Append("<tr><td class='column-name'> Tool used to perform the verification</td><td bgcolor='white'> EasySVNdiff</td></tr>");
            sbReport.Append("</table><br/><br/><table border='0' bgcolor='047CC1' cellpadding='1' cellspacing='1' width='100%' align='center'><tr height='15'><td width='100%'><div style='color:#D4FFFF; font-weight:bold'> Verification Log: <a href='" + objReport.TextFile + "' style='color:#D4FFFF; float:right; font-size:10px;'>Detailed log </a> </div></td></tr>");
            sbReport.Append("<tr><td bgcolor='white'><div style='border:1 solid #002776;width:100%;font-family:courier new; font-size:12px;'> " + objProjData.LogSummary.Replace("\n", "<br>") + "</div></td></tr>");
            sbReport.Append("</table><br/><br/><table border='0' bgcolor='047CC1' cellpadding='1' cellspacing='1' width='100%' align='center'><tr><td width='100%' height='15'><div style='color:#D4FFFF; font-weight:bold'> Verification Result:</div></td></tr>");
            sbReport.Append("<tr><td bgcolor='white'>");



            //sbReport.Append("<!DOCTYPE html><html lang='en'><head><meta charset='utf-8' /><title>SVN Repository Backup Restoration Verification</title></head>");
            //sbReport.Append("<body style='font-family:Segoe UI, arial,verdana; width:900px; margin:0 auto;'><table border='0' width='100%'><tr><td align='left'><img src='https://www.csscorp.com/sites/all/themes/csscorp/images/css_corp_logo.jpg'/></td><td align='left'><h2><p align='center' nowrap><font color='#545456'>SVN Repository Backup Restoration Verification</font></p></h2></td></tr></table>");
            //sbReport.Append("<table border='0' bgcolor='047CC1' cellpadding='1' cellspacing='1' width='100%' align='center'><tr height='15'><td colspan='2'><div style='color:#D4FFFF; font-weight:bold'> Project Info:</div></td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF' width='50%'> Account Name</td><td bgcolor='white' width='50%'> " + txtAcName.Text + "</td></tr><tr><td bgcolor='#99CCFF'> Project Name</td><td bgcolor='white'> " + txtProjName.Text + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> Repository URL</td><td bgcolor='white'> " + objProjData.LiveURL + "</td></tr><tr><td bgcolor='#99CCFF'> GITS Case ID</td><td bgcolor='white'> " + txtGITS.Text + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> Back-Up Date</td><td bgcolor='white'> " + objProjData.BackupDate + "</td></tr><tr><td bgcolor='#99CCFF'> Date of Restoration</td><td bgcolor='white'> " + dtRestored.Value + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> Date of Verification</td><td bgcolor='white'> " + System.DateTime.Today + "</td></tr><tr><td bgcolor='#99CCFF'> Backup location (including server name) / Local machine path</td><td bgcolor='white'> " + txtBackupLoc.Text + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> Restored location (including server name) / Local machine path</td><td bgcolor='white'> " + objProjData.BackupURL + "</td></tr><tr><td bgcolor='#99CCFF'> Date of Restoration</td><td bgcolor='white'> " + dtRestored.Value + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> CL Name (or the person who performs the verification)</td><td bgcolor='white'> " + txtCLName.Text + "</td></tr>");
            //sbReport.Append("<tr><td bgcolor='#99CCFF'> Tool used to perform the verification</td><td bgcolor='white'> EasySVNdiff</td></tr>");
            //sbReport.Append("</table><br/><br/><table border='0' bgcolor='047CC1' cellpadding='1' cellspacing='1' width='100%' align='center'><tr height='15'><td width='100%'><div style='color:#D4FFFF; font-weight:bold'> Verification Log: <a href='" + objReport.TextFile + "' style='color:#D4FFFF; float:right; font-size:10px;'>Detailed log </a> </div></td></tr>");
            //sbReport.Append("<tr><td bgcolor='white'><div style='border:1 solid #002776;width:100%;font-family:courier new'> " + objProjData.LogSummary.Replace("\n", "<br>") + "</div></td></tr>");
            //sbReport.Append("</table><br/><br/><table border='0' bgcolor='047CC1' cellpadding='1' cellspacing='1' width='100%' align='center'><tr><td width='100%' height='15'><div style='color:#D4FFFF; font-weight:bold'> Verification Result:</div></td></tr>");
            //sbReport.Append("<tr><td bgcolor='white'>");

            if (objProjData.DiffResult == true)
            {
                sbReport.Append("<div style='border:1 solid #002776;width:100%;color:green'><b> Both the following SVN repositories are SAME.</b></div><br>");
            }
            else
            {
                sbReport.Append("<div style='border:1 solid #002776;width:100%;color:red'><b>Both the following SVN repositories are DIFFERENT.</b></div><br>");
            }

            sbReport.Append("<table border='1' borderColorLight='#EAEAEE' borderColorDark='#EAEAEE'><tr><td bgcolor='#8cc8ea'>Live Repository URL </td><td><a href='" + objProjData.LiveURL + "'>" + objProjData.LiveURL + "</a></td></tr><tr><td bgcolor='#8cc8ea'>Backup-Restored Repository URL </td><td><a href='" + objProjData.BackupURL + "'>" + objProjData.BackupURL + "</a><br>");
            sbReport.Append("</td></tr></table><br></td></tr></table><br><br><hr style='color:gray;height:1px' noshade/><div style='background-color:#666666;color:#c2b497;font-size:11px;text-align:center;line-height:25px;'>This is an auto-generated report by EasySVNdiff tool. &copy; CSS Corp.</div></body></html>");

            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\EasySVNdiff_Report" + DateTime.Now.ToString().Replace("/", "").Replace(" ", "").Replace(":", "") + ".html";
            using (StreamWriter outfile = new StreamWriter(mydocpath))
            {
                outfile.Write(sbReport.ToString());
            }

            System.Diagnostics.Process.Start("IExplore.exe", mydocpath);

            //Save the detailed log into a text file.
            if (chkSaveToFile.Checked == true)
            {
                mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + objReport.TextFile;
                using (StreamWriter outfile = new StreamWriter(mydocpath))
                {
                    outfile.WriteLine("EasySVNdiff Detailed Log:");
                    outfile.WriteLine("-------------------------" + System.Environment.NewLine);
                    outfile.WriteLine(objProjData.VerificationLog.Replace("\n", System.Environment.NewLine));
                    outfile.WriteLine("");
                    outfile.WriteLine("Differences found between the Repositories (if any):");
                    outfile.WriteLine("----------------------------------------------------" + System.Environment.NewLine);
                    outfile.WriteLine(objProjData.FindDiff.Replace("\n", System.Environment.NewLine));
                }

                MessageBox.Show("The Restoration Verification report and the text file containing detailed log have been placed on your Desktop folder for your future references.", "EasySVNdiff- SVN Repository Verification Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else
            {
                MessageBox.Show("The Restoration Verification report has been placed on your Desktop folder for your future references.", "EasySVNdiff- SVN Repository Verification Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Next button is used to navigate to next form, before that it will validate the inputs given by the user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNext_Click_1(object sender, EventArgs e)
        {
            lblDescription.Text = "Please wait...";
            lblDescription.Refresh();
            UserInput.ActiveForm.Update();
            try
            {
                clsVerification objUserData = new clsVerification();

                objUserData.UserName   = txtUserName.Text.Trim();
                objUserData.Password   = txtPassword.Text.Trim();
                objUserData.LiveURL    = txtLiveURL.Text.Trim();
                objUserData.BackupURL  = txtBackUpURL.Text.Trim();
                objUserData.BackupDate = dtpBackUpDate.Text.Trim();
                objUserData.LocalDrive = txtLocalDrive.Text.Trim();

                #region Valitaion Input Feilds
                string RequiredFields = string.Empty;
                if (String.IsNullOrEmpty(txtUserName.Text.Trim()))
                {
                    RequiredFields += "* User Name \r\n";
                }
                if (String.IsNullOrEmpty(txtPassword.Text.Trim()))
                {
                    RequiredFields += "* Password \r\n";
                }
                if (String.IsNullOrEmpty(txtLiveURL.Text.Trim()))
                {
                    RequiredFields += "* Live SVN URL \r\n";
                }
                if (String.IsNullOrEmpty(txtBackUpURL.Text.Trim()))
                {
                    RequiredFields += "* Backup SVN URL \r\n";
                }
                if (String.IsNullOrEmpty(dtpBackUpDate.Text.Trim()))
                {
                    RequiredFields += "* Backup date \r\n";
                }
                if (String.IsNullOrEmpty(txtLocalDrive.Text.Trim()))
                {
                    RequiredFields += "* Temporary Folder \r\n";
                }

                if (!String.IsNullOrEmpty(RequiredFields))
                {
                    lblDescription.Text  = "Please enter the following fields \r\n";
                    lblDescription.Text += RequiredFields;
                    lblDescription.Refresh();
                    UserInput.ActiveForm.Update();
                    return;
                }

                #endregion

                if (objUserData.CheckLoginLive() && objUserData.CheckLoginBack() && objUserData.CheckPath())
                {
                    Microsoft.Win32.RegistryKey EasySVNdiff = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("RepoUserDetails");
                    EasySVNdiff.SetValue("Name", txtUserName.Text);
                    EasySVNdiff.SetValue("LiveURL", txtLiveURL.Text);
                    EasySVNdiff.SetValue("LocalDrive", txtLocalDrive.Text);
                    EasySVNdiff.Close();

                    //RegistryKey rk = Registry.CurrentUser;

                    var processing = new Processing(objUserData);
                    processing.Show();
                    this.Hide();
                }

                else
                {
                    lblDescription.Text = "Please Check the input fields";
                    lblDescription.Refresh();
                    UserInput.ActiveForm.Update();
                }
            }
            catch (Exception ex)
            {
            }
        }