Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="RLOC"></param>
        /// <returns></returns>
        public bool FindEticketRecords(string RLOC)
        {
            bool rv = false;
            String GetTick = "";
            if (Request.QueryString["ET"] != null)
            {
                GetTick = Request.QueryString["ET"].ToString();
            }
            try
            {
                string strFormName = "";
                if (m_GDS == "AU")
                {
                    strFormName = "AXQIETICKETAUD";
                }
                else if (m_GDS == "SG")
                {
                    strFormName = "AXQIETICKET";
                }
                else if (m_GDS == "IN")
                {
                    strFormName = "AXQIETICKETINR";
                }

                DataSet m_ProcessPNRsDS = new DataSet();
                MailRecordsBAL objMailRecordsBAL = new MailRecordsBAL("");
                List<MailRecordsModel> lstMailRecordsModel = objMailRecordsBAL.FindEticketRecords(RLOC, GetTick, strFormName);
                DataTable dt = Common.ListToDataTable(lstMailRecordsModel);
                m_ProcessPNRsDS.Tables.Add(dt);

                // check if the record exist already
                //if (m_ProcessPNRsDS.Tables != null && m_ProcessPNRsDS.Tables.Count != 0 && m_ProcessPNRsDS.Tables[0].Rows != null)
                //    return rv;

                string Created = "";
                string Subject = "";
                string LastSubject = "LastSubject";

                foreach (DataRow myRow in m_ProcessPNRsDS.Tables[0].Rows)
                {
                    string FormName = myRow["FormName"].ToString();

                    if (myRow["Created"].ToString() == Created && LastSubject == Subject)
                    {
                        // must be a copy record
                        continue;
                    }

                    Subject = myRow["Subject"].ToString();
                    if (FormName.ToUpper().IndexOf("QIETICKET") != -1)
                    {
                        Created = myRow["Created"].ToString();
                        LastSubject = Subject;

                        // look for matching surname
                        Match Ma = Regex.Match(Subject, GetNameCommand());

                        if (!Ma.Success)
                            continue;

                        string[] Names;
                        if (Ma.Groups["detail"].ToString().IndexOf("_") != -1)
                        {
                            Names = Ma.Groups["detail"].ToString().Split('_');
                        }
                        else
                        {
                            Names = Ma.Groups["detail"].ToString().Split('/');
                        }

                        string newName = Names[0].Trim();

                        if (newName == m_Surname)
                        {
                            if (myRow["FileName"] == null || myRow["FileName"].ToString().Length == 0)
                                continue;

                            string FileName = myRow["FileName"].ToString().ToUpper();
                            // now retrieve the doc and place it in the temp folder.
                            if (GetTransaction(ref FileName, myRow["TicketNumber"].ToString()))
                            {
                                Dictionary<string, string> dictionary = new Dictionary<string, string>();
                                dictionary.Add("c:/Temp/" + Path.GetFileName(FileName), myRow["Subject"].ToString());

                                var selectList = new SelectList(dictionary, "Key", "Value");
                                ViewData["ETicket"] = selectList;

                                //ListItem item = new ListItem(myRow["Subject"].ToString() + " ", "temp/" + Path.GetFileName(FileName));  //Need To Work
                                //DropDownList1.Items.Add(item);
                                if (GetTick.Length > 0)
                                {
                                    Session["output"] = "c:/Temp/" + Path.GetFileName(FileName);
                                    return true;
                                    //Response.Redirect("temp/" + Path.GetFileName(FileName), true);
                                }
                            }
                            rv = true;
                        }
                    }
                }

                m_ProcessPNRsDS.Dispose();
                GC.Collect();
                return rv;

            }
            catch (InvalidOperationException ioExp)
            {
                m_LastError += "InvalidOperationException in FindMailrecords " + m_RLOC + " : " + ioExp.Message + "\r\n";
                System.Diagnostics.Trace.WriteLine(ioExp.Message);
            }
            catch (MySqlException oleExp)
            {
                m_LastError += "MySqlException in FindMailrecords " + m_RLOC + " : " + oleExp.Message + "\r\n";
                System.Diagnostics.Trace.WriteLine(oleExp.Message);
            }
            catch (Exception e)
            {
                m_LastError += "Exception in FindMailrecords " + m_RLOC + " : " + e.Message + "\r\n";
                System.Diagnostics.Trace.WriteLine(e.Message);
            }

            return rv;
        }
Example #2
0
        /// <summary>
        /// LogToQiOnline
        /// </summary>
        protected void LogToQiOnline()
        {
            try
            {
                string TmpRloc;
                string TmpIPAddress;
                string TmpProcessorName;
                string TmpFormName;
                string TmpSubject;
                string TmpTeam;
                string TmpCompany;
                TmpRloc = GetReference;
                TmpIPAddress = GetIPAddress();
                TmpProcessorName = "DOWNLOAD_TO_CALENDAR";
                TmpFormName = "";
                TmpSubject = "Download to calendar - " + m_Surname;
                TmpTeam = "";
                TmpCompany = "";

                /////////////////////////////
                // Insert record to mailrecord before redirecting to generated document
                logger.Debug("Insert record to mailrecord");

                MailRecordsModel objMailRecordsDTO = new MailRecordsModel();
                objMailRecordsDTO.RLOC = TmpRloc;
                objMailRecordsDTO.Created = System.DateTime.UtcNow;
                objMailRecordsDTO.FromName = TmpIPAddress;
                objMailRecordsDTO.ProcessorName = TmpProcessorName;
                objMailRecordsDTO.FormName = TmpFormName;
                objMailRecordsDTO.Subject = TmpSubject;
                objMailRecordsDTO.Team = TmpTeam;
                objMailRecordsDTO.Company = TmpCompany;

                MailRecordsBAL objMailRecordsBAL = new MailRecordsBAL(SetCurrentSite);
                objMailRecordsBAL.SaveMailRecord(objMailRecordsDTO);

                //ChwLib.DatabaseManager.AddMailRecord(
                //    // RLOC / PRN
                //    TmpRloc,
                //    // Created
                //    System.DateTime.UtcNow,
                //    // FromName / To-From
                //    TmpIPAddress,
                //    // ProcessorName
                //    TmpProcessorName,
                //    // FormName / Format-Name
                //    TmpFormName,
                //    // Subject
                //    TmpSubject,
                //    // Team
                //    TmpTeam,
                //    // Company
                //    TmpCompany);

            }
            catch
            {
            }
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Surname"></param>
        /// <returns></returns>
        DataRow[] SearchDataBaseForInvoice(string Surname)
        {
            string outError = "";
            ViewBag.OutError = "";

            outError = "";
            DataRow[] rv = null;

            try
            {
                DataSet DS = new DataSet();
                MailRecordsBAL objMailRecordsBAL = new MailRecordsBAL("");
                List<MailRecordsModel> lstMailRecordsModel = objMailRecordsBAL.SearchDataBaseForInvoice(m_InvoiceNumber, m_InvoiceNumber);
                DataTable dt = Common.ListToDataTable(lstMailRecordsModel);
                DS.Tables.Add(dt);

                if (DS == null || DS.Tables == null || DS.Tables[0].Rows.Count == 0)
                {
                    logger.Warn("No records found in mailrecords table matching Invoice/Ticket Numbers provided");
                    return rv;
                }

                // need to replace all angle brackets with &lt;&gt;
                bool bFound = false;

                string Created = "";
                string RLOC = "";

                logger.Debug("Invoice/Ticket found : " + DS.Tables[0].Rows.Count.ToString());

                foreach (DataRow myRow in DS.Tables[0].Rows)
                {
                    string Subject = myRow["Subject"].ToString().ToUpper();
                    string FormName = myRow["FormName"].ToString().ToUpper();
                    string CurrentRLOC = myRow["RLOC"].ToString().ToUpper();

                    if (FormName == null || !(FormName.IndexOf("INV") != -1 || FormName.IndexOf("CRD") != -1))
                    //if (FormName == null || FormName.IndexOf("INV") == -1)
                    {
                        // must be a copy record
                        continue;
                    }

                    if (Created == myRow["Created"].ToString())
                        continue;

                    Created = myRow["Created"].ToString();

                    Match Ma = Regex.Match(Subject, GetNameCommand());
                    if (!Ma.Success)
                        continue;
                    string[] Names;
                    if (Ma.Groups["detail"].ToString().IndexOf("_") != -1)
                    {
                        Names = Ma.Groups["detail"].ToString().Split('_');
                    }
                    else
                    {
                        Names = Ma.Groups["detail"].ToString().Split('/');
                    }

                    string NewName = Names[0].Trim();

                    if (NewName.IndexOf(Surname) != -1)
                    {
                        if (CurrentRLOC != RLOC && RLOC.Length != 0)
                        {
                            logger.Error("Multiple rlocs with same name and invoice number");
                            // nned to throw some error here
                            //return RedirectToAction("Message", "MessageDisplay", new { E = 13 });
                            return null;
                            //Response.Redirect("error.aspx?E=13", true);
                        }

                        RLOC = CurrentRLOC;
                        bFound = true;

                        // must be an Invoice
                        if (m_InvoiceArray == null)
                        {
                            m_InvoiceArray = new DataRow[1];
                            m_InvoiceArray[0] = myRow;
                        }
                        else
                        {
                            DataRow[] Invoice = new DataRow[m_InvoiceArray.Length + 1];
                            m_InvoiceArray.CopyTo(Invoice, 0);
                            Invoice[Invoice.Length - 1] = myRow;
                            m_InvoiceArray = Invoice;
                        }

                    }

                }

                if (m_InvoiceArray != null)
                    logger.Debug("Records found for TKT/Invoice in DB: " + m_InvoiceArray.Length.ToString() + "");
                else
                    logger.Debug("Records found for TKT/Invoice in DB: zero");

                if (bFound)
                    return m_InvoiceArray;

            }
            catch (MySqlException oleExp)
            {
                return rv;
                ////display error details
                //outError = "<b>* Error while accessing data</b>.<br />"
                //    + oleExp.Message + "<br />" + oleExp.Source + "<p />";
                //logger.Error("Exception in Check Surname : " + oleExp.ToString());
                //ViewBag.OutError = outError;
                //return rv;  // and stop execution

            }
            catch (Exception objError)
            {

                //display error details
                outError = "<b>* Error while accessing data</b>.<br />"
                    + objError.Message + "<br />" + objError.Source + "<p />";
                logger.Error("Exception in Check Surname : " + objError.ToString());
                ViewBag.OutError = outError;
                return rv;  // and stop execution

            }
            return rv;
        }
        /// <summary>
        /// SearchDataBaseByRLOC
        /// </summary>
        /// <param name="RLOC"></param>
        /// <param name="Surname"></param>
        /// <returns></returns>
        bool SearchDataBaseByRLOC(string RLOC, string strSurname)
        {
            try
            {
                bool rv = false;
                DateTime tm = DateTime.Now.AddMonths(GetSeachMonths());
                DateTime ThreeMonths = new DateTime(tm.Year, tm.Month, 1, 0, 0, 0, 0);

                MailRecordsBAL objMailRecordsBAL = new MailRecordsBAL("");
                List<MailRecordsModel> lstMailRecordsModel = objMailRecordsBAL.SearchDataBaseByRLOC(RLOC, ThreeMonths, strSurname);
                if (lstMailRecordsModel == null)
                {
                    logger.Debug("Itinerary: No records found in mailrecords table matching criteria");
                    return rv;
                }

                DataSet DS = new DataSet();
                DataTable dt = Common.ListToDataTable(lstMailRecordsModel);
                DS.Tables.Add(dt);

                if (DS == null || DS.Tables == null || DS.Tables[0].Rows.Count == 0)
                {
                    logger.Debug("Itinerary: No records found in mailrecords table matching criteria");
                    return rv;
                }

                string Created = "";
                string LastSubject = "";

                logger.Debug("Itinerary: Mailrecords found : " + DS.Tables[0].Rows.Count.ToString());
                string[] ItinerarySearch = GetItinerarySearch().Split(',');
                string[] ItineraryProcessorNames = GetItineraryProcessorNames().Split(',');
                AllowLiveRetrieve = false;

                foreach (DataRow myRow in DS.Tables[0].Rows)
                {
                    string Subject = myRow["Subject"].ToString().ToUpper();
                    string FormName = myRow["FormName"].ToString().ToUpper();
                    string ProcessorName = myRow["ProcessorName"].ToString().ToUpper();

                    foreach (string str in ItineraryProcessorNames)
                    {
                        if (ProcessorName == str)
                        {
                            AllowLiveRetrieve = true;
                            return true;
                        }
                    }

                    bool Found = false;
                    foreach (string str in ItinerarySearch)
                    {
                        if (Subject.IndexOf(str) != -1)
                        {
                            Found = true;
                            break;
                        }
                    }

                    if (!Found)
                        continue;

                    Created = myRow["Created"].ToString();
                    LastSubject = Subject;

                    // look for matching surname
                    Match Ma = Regex.Match(Subject.ToUpper(), GetNameCommand());
                    if (!Ma.Success)
                        continue;

                    string[] Names;

                    if (Ma.Groups["detail"].ToString().IndexOf("_") != -1)
                    {
                        Names = Ma.Groups["detail"].ToString().Split('_');
                    }
                    else
                    {
                        Names = Ma.Groups["detail"].ToString().Split('/');
                    }

                    string newName = Names[0].Trim();

                    //  if (newName == Surname)
                    if (LastSubject.IndexOf(strSurname) != -1)
                    {

                        string ID = myRow["ID"].ToString();

                        if (myRow["FileName"] == null || myRow["FileName"].ToString().Length == 0)
                            continue;
                        m_FileName = myRow["FileName"].ToString().ToUpper();
                        m_FormName = myRow["FormName"].ToString().ToUpper();

                        return true;
                    }
                }
            }
            catch
            {
                return false;
            }
            finally
            {

            }
            return false;
        }
Example #5
0
        /// <summary>
        /// SearchDataBase
        /// </summary>
        /// <param name="RLOC"></param>
        /// <param name="Surname"></param>
        /// <returns></returns>
        DiskRecord[] SearchDataBase(string RLOC, string Surname)
        {
            string outError = "";
            ViewBag.OutError = "";

            ViewBag.OutError = "";
            DiskRecord[] rv = null;
            Surname = Surname.ToUpper();

            try
            {
                // now calculate the MD5 connection string
                //MySqlConnection Conn = new MySqlConnection(GetDataSourceMySQL());
                //Conn.Open();
                //string SQL = "";

                DateTime tm = DateTime.Now.AddMonths(GetSeachMonths());
                DateTime ThreeMonths = new DateTime(tm.Year, tm.Month, 1, 0, 0, 0, 0);

                DataSet DS = new DataSet();
                MailRecordsBAL objMailRecordsBAL = new MailRecordsBAL("");
                List<MailRecordsModel> lstMailRecordsModel = objMailRecordsBAL.SearchDataBase(RLOC, ThreeMonths);  //.ToString("yyyy-MM-dd HH:mm")
                DataTable dt = Common.ListToDataTable(lstMailRecordsModel);
                DS.Tables.Add(dt);

                //SQL = "SELECT ID, RLOC, Subject, TicketNumber, Created, Method, DocumentNumber, FormName, FileName FROM MailRecords where RLOC='{0}' and Created > '{1}' and PreprocStatus > 0 order by created";
                //SQL = string.Format(SQL, RLOC, ThreeMonths.ToString("yyyy-MM-dd HH:mm"));
                //MySqlCommand selectCMD = new MySqlCommand(SQL, Conn);

                //MySqlDataAdapter custDA = new MySqlDataAdapter(selectCMD);
                //DataSet DS = new DataSet();

                //custDA.Fill(DS);
                //Conn.Close();

                if (DS == null || DS.Tables == null || DS.Tables[0].Rows.Count == 0)
                {
                    logger.Debug("No records found in mailrecords table matching criteria");
                    // logger.Debug(SQL);
                    return rv;
                }

                // need to replace all angle brackets with &lt;&gt;

                string Created = "";
                string LastSubject = "";

                logger.Debug("Mailrecords found : " + DS.Tables[0].Rows.Count.ToString());
                foreach (DataRow myRow in DS.Tables[0].Rows)
                {
                    string Subject = myRow["Subject"].ToString().ToUpper();
                    string FormName = myRow["FormName"].ToString().ToUpper();
                    string CreatedTime = myRow["Created"].ToString();

                    if (!(FormName.IndexOf("INV") != -1 || FormName.IndexOf("CRD") != -1))
                        continue;

                    if (myRow["Created"].ToString() == Created && LastSubject == Subject)
                    {
                        // must be a copy record
                        continue;
                    }

                    // fill with latest record
                    Created = myRow["Created"].ToString();
                    LastSubject = Subject;

                    DiskRecord rec = new DiskRecord();
                    rec.Row = myRow;

                    Match Ma = Regex.Match(Subject, GetNameCommand());
                    if (!Ma.Success)
                        continue;

                    string[] Names;
                    if (Ma.Groups["detail"].ToString().IndexOf("_") != -1)
                    {
                        Names = Ma.Groups["detail"].ToString().Split('_');
                    }
                    else
                    {
                        Names = Ma.Groups["detail"].ToString().Split('/');
                    }

                    string NewName = Names[0].Trim();

                    //  if (NewName == Surname)
                    if (LastSubject.IndexOf(Surname) != -1)
                    {
                        //bFound = true;
                        rec.NameFound = true;
                        if (m_InvoiceArray == null)
                        {
                            m_InvoiceArray = new DataRow[1];
                            m_InvoiceArray[0] = myRow;
                        }
                        else
                        {
                            DataRow[] Invoice = new DataRow[m_InvoiceArray.Length + 1];
                            m_InvoiceArray.CopyTo(Invoice, 0);
                            Invoice[Invoice.Length - 1] = myRow;
                            m_InvoiceArray = Invoice;
                        }

                    }

                    if (rv == null)
                    {
                        rv = new DiskRecord[1];
                        rv[0] = rec;
                    }
                    else
                    {
                        DiskRecord[] Invoice = new DiskRecord[rv.Length + 1];
                        rv.CopyTo(Invoice, 0);
                        Invoice[Invoice.Length - 1] = rec;
                        rv = Invoice;
                    }

                }

                if (m_InvoiceArray != null)
                    logger.Debug("Records found for Invoice in DB: " + m_InvoiceArray.Length.ToString() + "");
                else
                    logger.Debug("Records found for Invoice in DB: zero");

            }
            catch (MySqlException oleExp)
            {

                //display error details
                ViewBag.OutError = "<b>* Error while accessing data</b>.<br />"
                    + oleExp.Message + "<br />" + oleExp.Source + "<p />";
                logger.Error("Exception in Check Surname : " + oleExp.ToString());
                return rv;  // and stop execution

            }
            catch (Exception objError)
            {

                //display error details
                ViewBag.OutError = "<b>* Error while accessing data</b>.<br />"
                    + objError.Message + "<br />" + objError.Source + "<p />";
                logger.Error("Exception in Check Surname : " + objError.ToString());
                return rv;  // and stop execution

            }
            return rv;
        }