Exemple #1
0
        private static string GetTextFile(DataTable dt, int PlanID, string FileName, string ConText)
        {
            string rtnStr = "";

            if ((PlanID != 999) && (PlanID != 10206))
            {
                if (dt.Columns.IndexOf("SiteVisit") > -1)
                {
                    dt.Columns.Remove("SiteVisit");
                }
                if (dt.Columns.IndexOf("ChartAudit") > -1)
                {
                    dt.Columns.Remove("ChartAudit");
                }
            }
            if (dt.Columns.IndexOf("Practice") > -1)
            {
                dt.Columns.Remove("Practice");
            }
            if (dt.Columns.IndexOf("Images") > -1)
            {
                dt.Columns.Remove("Images");
            }
            if (dt.Columns.IndexOf("Status") > -1)
            {
                dt.Columns.Remove("Status");
            }
            if (dt.Columns.IndexOf("OI") > -1)
            {
                dt.Columns.Remove("OI");
                if (!AppHelper.IsContCred(PlanID))
                {
                    if (dt.Columns.IndexOf("LicExp") > -1)
                    {
                        dt.Columns.Remove("LicExp");
                    }
                    if (dt.Columns.IndexOf("InsExp") > -1)
                    {
                        dt.Columns.Remove("InsExp");
                    }
                    if (dt.Columns.IndexOf("DEAExp") > -1)
                    {
                        dt.Columns.Remove("DEAExp");
                    }
                    if (dt.Columns.IndexOf("SDCExp") > -1)
                    {
                        dt.Columns.Remove("SDCExp");
                    }
                }
            }
            if (dt.Columns.IndexOf("Delink") > -1)
            {
                dt.Columns.Remove("Delink");
            }
            if (dt.Columns.IndexOf("Fax") > -1)
            {
                dt.Columns.Remove("Fax");
            }
            if (dt.Columns.IndexOf("Com") > -1)
            {
                dt.Columns.Remove("Com");
            }
            if (dt.Columns.IndexOf("CPR") > -1)
            {
                dt.Columns.Remove("CPR");
            }

            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter txtWriter = new StreamWriter(ms))
                {
                    if (dt.Rows.Count != 0)
                    {
                        int    numColumns = dt.Columns.Count;
                        string line       = "";
                        foreach (DataColumn column in dt.Columns)
                        {
                            line = line + "\"" + column.ColumnName + "\",";
                        }
                        txtWriter.WriteLine(line);

                        int i     = 0;
                        int total = dt.Rows.Count;
                        foreach (DataRow row in dt.Rows)
                        {
                            line = "";
                            foreach (DataColumn column in dt.Columns)
                            {
                                string val = row[column].ToString().Trim();
                                if (val == "")
                                {
                                    line = line + ",";
                                }
                                else
                                {
                                    line = line + "\"" + AppHelper.FormatDate(val) + "\",";
                                }
                            }
                            txtWriter.WriteLine(line);

                            Console.SetCursorPosition(ConText.Length, Console.CursorTop);
                            Console.Write(i++ + " of " + total);
                        }
                    }
                    else
                    {
                        txtWriter.WriteLine("No Data Files");
                    }
                    txtWriter.Close();
                }

                rtnStr = MemoryStreamToFile(ms, FileName, PlanID);
            }

            return(rtnStr);
        }
Exemple #2
0
        /*private static string GetReportsTxt(string FileName, int PlanID, string ConText)
         * {
         *  string rtnStr = "";
         *
         *  try
         *  {
         *      DataTable dt = GetInvDates(PlanID);
         *      string abbrev = AppHelper.PlanAbbrev(PlanID);
         *
         *      using (MemoryStream ms = new MemoryStream())
         *      {
         *          using (StreamWriter txtFile = new StreamWriter(ms))
         *          {
         *              List<string> linesLst = new List<string>();
         *              int i = 0;
         *
         *              foreach (DataRow dr in dt.Rows)
         *              {
         *                  DateTime invDate = Convert.ToDateTime(dr["InvDate"]);
         *                  string month = invDate.ToString("MM");
         *                  string day = invDate.ToString("dd");
         *                  string year = invDate.ToString("yyyy");
         *                  string root = (invDate.Year == DateTime.Now.Year ? "Current" : "Archive " + year);
         *
         *                  string rptFile = string.Format(@"\\Reports\{0}\{1}\{2}\{3}\Reports.txt", root, month, abbrev, day);
         *                  if (File.Exists(rptFile))
         *                  {
         *                      using (StreamReader sr = new StreamReader(rptFile))
         *                      {
         *                          using (StringReader reader = new StringReader(sr.ReadToEnd()))
         *                          {
         *                              string line = null;
         *                              while ((line = reader.ReadLine()) != null)
         *                              {
         *                                  if ((line != "No Data Files") && (!linesLst.Contains(line)))
         *                                  {
         *                                      txtFile.WriteLine(line);
         *                                      linesLst.Add(line);
         *                                  }
         *
         *                                  Console.SetCursorPosition(ConText.Length, Console.CursorTop);
         *                                  Console.Write(i++);
         *                              }
         *                              reader.Close();
         *                          }
         *                          sr.Close();
         *                      }
         *                  }
         *              }
         *              if (linesLst.Count <= 0) { txtFile.WriteLine("No Data Files"); }
         *              txtFile.Close();
         *          }
         *          rtnStr = MemoryStreamToFile(ms, FileName, PlanID);
         *      }
         *  }
         *  catch (Exception E)
         *  {
         *      AppHelper.LogError(E);
         *  }
         *
         *  return rtnStr;
         * }*/
        private static string GetSFRTextFile(string FileName, string SFRFileName, int PlanID, string ConText)
        {
            string rtnStr = "";

            try
            {
                DataTable dt     = GetInvDates(PlanID);
                string    abbrev = AppHelper.PlanAbbrev(PlanID);

                using (MemoryStream ms = new MemoryStream())
                {
                    using (StreamWriter txtFile = new StreamWriter(ms))
                    {
                        List <string> linesLst = new List <string>();
                        int           i        = 0;

                        foreach (DataRow dr in dt.Rows)
                        {
                            DateTime invDate = Convert.ToDateTime(dr["InvDate"]);
                            string   month   = invDate.ToString("MM");
                            string   day     = invDate.ToString("dd");
                            string   year    = invDate.ToString("yyyy");
                            //string root = (invDate.Year == DateTime.Now.Year ? "Current" : "Archive " + year);
                            string root    = year;
                            string rptFile = string.Format(@"\\OldReports\{0}\{1}\{2}\{3}\{4}", root, month, abbrev, day, SFRFileName);

                            //string rptFile = string.Format(@"\\Reports\{0}\{1}\{2}\{3}\{4}", root, month, abbrev, day, SFRFileName);
                            if (File.Exists(rptFile))
                            {
                                using (StreamReader sr = new StreamReader(rptFile))
                                {
                                    using (StringReader reader = new StringReader(sr.ReadToEnd()))
                                    {
                                        string line = null;
                                        while ((line = reader.ReadLine()) != null)
                                        {
                                            if ((line != "No Data Files") && (!linesLst.Contains(line)))
                                            {
                                                txtFile.WriteLine(line);
                                                linesLst.Add(line);
                                            }

                                            Console.SetCursorPosition(ConText.Length, Console.CursorTop);
                                            Console.Write(i++);
                                        }
                                        reader.Close();
                                    }
                                    sr.Close();
                                }
                            }
                        }
                        if (linesLst.Count <= 0)
                        {
                            txtFile.WriteLine("No Data Files");
                        }
                        txtFile.Close();
                    }
                    rtnStr = MemoryStreamToFile(ms, FileName, PlanID);
                }
            }
            catch (Exception E)
            {
                AppHelper.LogError(E);
            }

            return(rtnStr);
        }