Esempio n. 1
0
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                openFileDialog1.Filter = "SDF|*.sdf|TXT|*.txt";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string strFileName = openFileDialog1.FileName;
                    if (strFileName.Trim() != "")
                    {
                        System.IO.FileInfo finfo = new System.IO.FileInfo(strFileName);
                        if (finfo.Length > 0)
                        {
                            string strFileName_TAN = System.IO.Path.GetFileNameWithoutExtension(strFileName);

                            if (Validations.IsValidTanNumber(strFileName_TAN.Trim()))
                            {
                                FormCollection frmColl   = Application.OpenForms;
                                frmReviewer    frmReview = null;
                                bool           blFrmOpen = false;

                                foreach (Form frm in frmColl)
                                {
                                    if (frm.Name.ToUpper() == "FRMREVIEWER")
                                    {
                                        frmReview = (frmReviewer)frm;
                                        if (frmReview.FileName == strFileName)
                                        {
                                            blFrmOpen = true;
                                            frmReview.Show();
                                            frmReview.WindowState = FormWindowState.Maximized;
                                        }
                                    }
                                }
                                if (!blFrmOpen)
                                {
                                    #region Code Commented
                                    //DialogResult diares = MessageBox.Show("Do you want to check duplicate records?","Check duplicates",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
                                    //if (diares == DialogResult.Yes)
                                    //{
                                    //    int intDupRCnt = 0;
                                    //    int intTotalRCnt = 0;

                                    //    intDupRCnt = ChemistryOperations.GetDuplicateRecordsCount(strFileName.Trim(), out intTotalRCnt);

                                    //    if (intDupRCnt > 0)
                                    //    {
                                    //        diares = MessageBox.Show(intDupRCnt + " duplicate records found out of " + intTotalRCnt + " record(s). \r\n Do you want to delete duplicates?", "Delete duplicates", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                    //        if (diares == DialogResult.Yes)
                                    //        {
                                    //            if (ChemistryOperations.DeleteAllDuplicateStructures(strFileName.Trim(), out intTotalRCnt, out intDupRCnt))
                                    //            {
                                    //                MessageBox.Show(intDupRCnt + " duplicate records deleted out of " + intTotalRCnt + "record(s)");
                                    //            }
                                    //        }
                                    //    }
                                    //    else
                                    //    {
                                    //        MessageBox.Show("No duplicate records found out of " + intTotalRCnt + " record(s)");
                                    //    }
                                    //    frmReview = new frmReviewer();
                                    //    frmReview.FileName = strFileName.Trim();
                                    //    frmReview.TANNumber = strFileName_TAN.Trim();
                                    //    frmReview.MdiParent = this;
                                    //    frmReview.Show();
                                    //}
                                    #endregion

                                    frmReview           = new frmReviewer();
                                    frmReview.FileName  = strFileName.Trim();
                                    frmReview.TANNumber = strFileName_TAN.Trim();
                                    frmReview.MdiParent = this;
                                    frmReview.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Not a valid file name with TAN Number", "In valid file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Can not read empty file", "Empty file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 2
0
        private void fromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                openFileDialog1.Filter = "SDF|*.sdf|TXT|*.txt";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string strFilePath = openFileDialog1.FileName;
                    if (strFilePath.Trim() != "")
                    {
                        System.IO.FileInfo finfo = new System.IO.FileInfo(strFilePath);
                        if (finfo.Length > 0)
                        {
                            string strFileName_TAN = System.IO.Path.GetFileNameWithoutExtension(strFilePath);

                            string strDirPath = System.IO.Path.GetDirectoryName(strFilePath);

                            if (Validations.IsValidTanNumber(strFileName_TAN.Trim()))
                            {
                                string strXmlPath = strDirPath + "\\" + strFileName_TAN + ".xml";

                                FormCollection frmColl   = Application.OpenForms;
                                frmXMLViewer   xmlView   = null;
                                bool           blFrmOpen = false;

                                foreach (Form frm in frmColl)
                                {
                                    if (frm.Name.ToUpper() == "FRMXMLVIEWER")
                                    {
                                        xmlView = (frmXMLViewer)frm;

                                        if (xmlView.FileName == strXmlPath)
                                        {
                                            blFrmOpen = true;
                                            xmlView.Show();
                                            xmlView.WindowState = FormWindowState.Maximized;
                                        }
                                    }
                                }
                                if (!blFrmOpen)
                                {
                                    //statStripLbl_User.Text = "Generating XML, please wait...";
                                    toolSProgBar.Visible = true;

                                    if (WriteOutPutXMLFile.WriteXmlFileUsingXSD(strFilePath, strFileName_TAN, strXmlPath))
                                    {
                                        //statStripLbl_User.Text = "Validating XML...";
                                        string strXMLSchema = AppDomain.CurrentDomain.BaseDirectory + "PatentEnhancedPrioritySubstanceIndexing-2.3.xsd";// "PEPSILiteSchema.xsd";

                                        string strErr_out = "";
                                        if (Validations.ValidateXmlAgainstSchema(strXmlPath, strXMLSchema, out strErr_out))
                                        {
                                            toolSProgBar.Visible = false;

                                            xmlView           = new frmXMLViewer();
                                            xmlView.FileName  = strXmlPath;
                                            xmlView.MdiParent = this;
                                            xmlView.Show();
                                        }
                                        else
                                        {
                                            toolSProgBar.Visible = false;
                                            MessageBox.Show(strErr_out, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }
                                    else
                                    {
                                        //statStripLbl_User.Text = "";
                                        toolSProgBar.Visible = false;
                                        MessageBox.Show("Error in writing Xml file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                            else
                            {
                                toolSProgBar.Visible = false;
                                MessageBox.Show("Not a valid file name with TAN Number");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Can not read empty file", "Empty file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }