예제 #1
0
        private void fromDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                //DataTable dtTANs = PepsiLiteDataAccess.DataOperations.RetrieveTANIDS_All();
                DataTable dtTANs = PepsiLiteDataAccess.DataOperations.GetCompletedTANs();
                if (dtTANs != null)
                {
                    if (dtTANs.Rows.Count > 0)
                    {
                        ArrayList lstTans = Validations.GetArrayListFromDataTable(dtTANs, 0);
                        if (lstTans != null)
                        {
                            if (lstTans.Count > 0)
                            {
                                Forms.frmSelectTAN_Xml objSelTan_Xml = new Forms.frmSelectTAN_Xml();
                                objSelTan_Xml.AvailTANs = lstTans;
                                if (objSelTan_Xml.ShowDialog() == DialogResult.OK)
                                {
                                    Cursor = Cursors.WaitCursor;

                                    DataTable dtTanDetails   = null;
                                    bool      blWriteStatus  = false;
                                    string    strXmlFilePath = "";

                                    for (int i = 0; i < objSelTan_Xml.SelectedTANs.Count; i++)
                                    {
                                        if (objSelTan_Xml.SelectedTANs.Count == 1)
                                        {
                                            dtTanDetails = PepsiLiteDataAccess.DataOperations.RetrieveTANDetails(objSelTan_Xml.SelectedTANs[i].ToString());

                                            if (dtTanDetails != null)
                                            {
                                                if (dtTanDetails.Rows.Count > 0)
                                                {
                                                    strXmlFilePath = objSelTan_Xml.FolderName + "\\" + objSelTan_Xml.SelectedTANs[i].ToString() + ".xml";

                                                    WriteOutPutXMLFile.WriteXmlFileUsingDataTable(dtTanDetails, objSelTan_Xml.SelectedTANs[i].ToString(), strXmlFilePath);

                                                    frmXMLViewer xmlView = new frmXMLViewer();
                                                    xmlView.FileName  = strXmlFilePath;
                                                    xmlView.MdiParent = this;
                                                    xmlView.Show();
                                                }
                                                else
                                                {
                                                    MessageBox.Show("No data found", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("No data found", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            dtTanDetails = PepsiLiteDataAccess.DataOperations.RetrieveTANDetails(objSelTan_Xml.SelectedTANs[i].ToString());

                                            strXmlFilePath = objSelTan_Xml.FolderName + "\\" + objSelTan_Xml.SelectedTANs[i].ToString() + ".xml";

                                            WriteOutPutXMLFile.WriteXmlFileUsingDataTable(dtTanDetails, objSelTan_Xml.SelectedTANs[i].ToString(), strXmlFilePath);
                                            blWriteStatus = true;
                                        }
                                    }
                                    if (blWriteStatus)
                                    {
                                        openFileDialog1.FileName = strXmlFilePath;
                                        openFileDialog1.ShowDialog();
                                    }
                                    Cursor = Cursors.Default;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No TANs are available");
                    }
                }
                else
                {
                    MessageBox.Show("No TANs are available");
                }
            }
            catch (Exception ex)
            {
                PepsiLiteErrorHandling.WriteErrorLog(ex.ToString());
            }
        }
예제 #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());
            }
        }