示例#1
0
        public bool ProcessAllWholesaler()
        {
            bool status = false;

            try
            {
                //Console.WriteLine(@"*********************************
                //    1   Amerisource
                //    2   Anda
                //    3   ASD
                //    4   BioCARE
                //    5   Cardinal
                //    6   CardinalSPD
                //    7   Curascript
                //    8   Dakota
                //    9   HDSmith
                //    10  Kinray
                //    11  McKesson
                //    12  MckessonSP
                //    13  Metro Medical Supply
                //    14  MorrisDickson
                //    15  NC Mutual
                //    16  R & S Pharma
                //    17  RDC
                //    18  SmithDrug
                //    19  Valley Wholesale
                //    20  ValueDrug");

                //            //Console.WriteLine("*********************************");



                Console.WriteLine(@"************ wrpid **********************
                7       Amerisource
                143     Anda
                116     ASD
                14821   BioCARE
                9       Cardinal
                14695   CardinalSPD
                27039   Curascript
                147     Dakota
                11      HDSmith
                10      Kinray
                8       McKesson
                15945   MckessonSP
                135     Metro Medical Supply
                29      MorrisDickson
                80      NC Mutual
                14691   R & S Pharma
                6       RDC
                36      SmithDrug
                57      Valley Wholesale
                77      ValueDrug");

                Console.WriteLine("*********************************");



                ConfigurationManager.AppSettings["reportlogfile"] = ConfigurationManager.AppSettings["reportlogfile"].Replace("Date", DateTime.Now.ToString("yyyyMMdd"));


                File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                   Environment.NewLine + " ******************* Parsing Started : " + DateTime.Now.ToShortDateString() + "***************************");



                for (int i = 0; i <= wrpid_array.Length - 1; i++)
                {
                    importFileRows = 0;


                    int wrpid = wrpid_array[i];


                    string ParserFile_wrpid = ConfigurationManager.AppSettings["ParserFile_wrpid"];

                    try
                    {
                        if (int.Parse(ParserFile_wrpid) > 0)
                        {
                            wrpid = int.Parse(ParserFile_wrpid);
                            //  i=wrpid_array.Length - 1;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("ParserFile_wrpid = " + ParserFile_wrpid + " Invalid");

                        File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                           Environment.NewLine + "ParserFileID = " + ParserFile_wrpid + " Invalid");

                        return(false);
                    }



                    Console.WriteLine(GetwholesalerNameBy_wrpid(wrpid) + " - Searching File ");


                    File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                       Environment.NewLine + GetwholesalerNameBy_wrpid(wrpid) + "  - Searching File : " + DateTime.Now);



                    // truncate temp table before insert data
                    int importTypeId = Getwholesaler_ID_By_wrpid(wrpid);
                    _crudRepo = new CrudRepo();
                    _crudRepo.PreParsingProcess(importTypeId);


                    FileInfo[] filesInDir = GetwholesalerPathBy_wrpid(wrpid);

                    Console.WriteLine(" ");
                    Console.WriteLine("*****    " + filesInDir.Length + "  -  Files ***** ");
                    Console.WriteLine(" ");

                    foreach (FileInfo foundFile in filesInDir)
                    {
                        Console.WriteLine("*********************************");
                        Console.WriteLine(foundFile.Name);

                        File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                           Environment.NewLine + foundFile.Name + " Parsing Started : " + DateTime.Now);

                        try
                        {
                            status = ProcessWholesaler(wrpid, foundFile.FullName);
                        }
                        catch (Exception ex)
                        {
                            bool send_mail = SendEmail_error(ex.ToString());
                        }

                        File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                           Environment.NewLine + GetwholesalerNameBy_wrpid(wrpid) + " Parsing status : " + status + " : " + DateTime.Now);
                    }

                    if (status)
                    {
                        ListImportFileRows[i] = importFileRows;
                    }


                    if (int.Parse(ParserFile_wrpid) > 0)
                    {
                        i = wrpid_array.Length - 1;
                    }
                }


                bool send = SendEmail_success(ListImportFileRows);
            }
            catch (Exception ex)
            {
                Console.WriteLine("error = " + ex.ToString());

                File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"],
                                   Environment.NewLine + ex.ToString());


                bool send = SendEmail_error(ex.ToString());

                //  Console.ReadLine();
            }

            return(status);
        }