///<summary>
        ///* Function: Initialze and assign the Specified share folder location, line name, report and aidata folderlocation
        /// This function proves that those specific folders exist.!--
        ///* @author: Sena.kim
        ///* @parameter:string Sharefolderlocation, directory name as line name eg line2/3/4
        ///* @return: None
        ///</summary>
        public int AssignLineStatus(string p_shareFolderLocation, string p_directoryName, int i, string p_reportfolderName, string p_aifolderName)
        {
            int Linenumber = i + 2;

            m_LineName = "MC" + Linenumber + "LINE";
            // m_LineName = p_directoryName;
            //reset variales,
            m_linefolderLocation = p_shareFolderLocation + p_directoryName;

            m_reportfolderlocation  = m_linefolderLocation + p_reportfolderName; //"/report";
            m_aidatafolderlocation  = m_linefolderLocation + p_aifolderName;     //'"/aidata";
            m_ModuleMessageBody     = new Queue <ModuleMessageBody>();
            m_currentdateFolderInfo = new DateFolderInfo();
            m_IsThereLineFolder     = DirectoryReader.IsDirectoryExistInThefolder(m_linefolderLocation);
            if (m_IsThereLineFolder == true)
            {
                m_IsThereReportFolder = DirectoryReader.IsDirectoryExistInThefolder(m_reportfolderlocation);
                m_IsThereAIFolder     = DirectoryReader.IsDirectoryExistInThefolder(m_aidatafolderlocation);

                if (m_IsThereReportFolder == true && m_IsThereAIFolder == true)
                {
                    LogBuilder.LogWrite(LogBuilder.MessageStatus.Usual, m_LineName + ": ReportFolder & AIFolder Detected and Successfully Assigned.");
                }
                else if (m_IsThereReportFolder == false && m_IsThereAIFolder == false)
                {
                }
                else if (m_IsThereReportFolder == false || m_IsThereAIFolder == false)
                {
                    LogBuilder.LogWrite(LogBuilder.MessageStatus.Usual, m_LineName + ": ReportFolder or AIFolder Is Not Detected.");
                }
            }
            return(Linenumber);
        }
 public bool Equals(DateFolderInfo other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.WorkingDate.Equals(other.WorkingDate));
 }
        ///<summary>
        ///* Function: Initialze and assign the Specified share folder location, line name, report and aidata folderlocation
        /// This function proves that those specific folders exist.!--
        ///* @author: Sena.kim
        ///* @parameter: fileType ( "*.csv") folder path
        ///* @return: None
        ///</summary>
        public void SetbadProductsInfoUnderDateFolder(DateFolderInfo p_datefolderInfo)
        {
            int dataError = 0;


            if (m_IsThereReportFolder == true && m_IsThereAIFolder == true)
            {
                //does directory have csv files? save csv files
                FileInfo[] di = DirectoryReader.Readfromfolder("*.csv", p_datefolderInfo.DateFolderLocationUnderReport);


                for (int i = 0; i < di.Length; i++)
                {
                    if (di[i] != null)
                    {
                        int      badcount           = 0;
                        int      barcodeError       = 0;
                        string[] allLines           = DirectoryReader.ReadAllLinesOfAFile(di[i].Name, p_datefolderInfo.DateFolderLocationUnderReport);//File.ReadAllLines(fileLocation);
                        var      csvLinesData       = allLines.Skip(1);
                        var      varbadProductsInfo = (from line in csvLinesData
                                                       let data = line.Split(",")
                                                                  select new
                        {
                            Date = data[0],
                            Model = data[1],
                            BarCode = data[2],
                            Result = data[3]
                        })
                                                      .Where(data => data.Result == "NG").ToList(); // end of linq
                        foreach (var s in varbadProductsInfo)
                        {
                            bool IsNotError = DirectoryReader.checkStringForContainingAlphabet(s.BarCode);
                            if (IsNotError == true)
                            {
                                badcount++;
                                p_datefolderInfo.BadProductsToPass.Enqueue(new BadProductInfo()
                                {
                                    Date = s.Date, Model = s.Model, BarCode = s.BarCode, Result = s.Result
                                });
                            }
                            else
                            {
                                barcodeError++;
                                dataError++;
                            }
                        }
                        // m_badProductsInfo.TrimExcess();
                        LogBuilder.LogWrite(LogBuilder.MessageStatus.Usual, "Reading " + p_datefolderInfo.WorkingDate + " " + di[i].Name + "....." + "No. of BadProducts #" + badcount);
                    }
                } // end of for loop
            }     // end of  if (IsThereReportFolder == true && IsThereAIFolder == true)Z

            string dateformat = LogBuilder.ParseDateTimeToString(p_datefolderInfo.WorkingDate, "yyyy-MM-dd");

            LogBuilder.LogWrite(LogBuilder.MessageStatus.Usual, "Folder :" + dateformat + " Total bad products :" + p_datefolderInfo.BadProductsToPass.Count + " DataError :" + dataError.ToString());
        }// end of  public SetDecisionResultUnderReportFolder(string p_dateFolderLocation)
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            DateFolderInfo objAsPart = obj as DateFolderInfo;

            if (objAsPart == null)
            {
                return(false);
            }
            else
            {
                return(Equals(objAsPart));
            }
        }
        }// end of  public SetDecisionResultUnderReportFolder(string p_dateFolderLocation)

        public Queue <ModuleMessageBody> ProcessBadReportsUnderSingleDates(DateFolderInfo p_datefolderInfo)
        {
            if (p_datefolderInfo.BadProductsToPass != null)
            {
                p_datefolderInfo.BadProductsToPass.TrimExcess();
                int tempmax = p_datefolderInfo.BadProductsToPass.Count;
                for (int i = 0; i < tempmax; i++)
                {
                    BadProductInfo singlebadInfo = p_datefolderInfo.BadProductsToPass.Dequeue();
                    p_datefolderInfo.BadProductsToPass.TrimExcess();
                    string     fileApsstring = "", fileCepstring = "", fileRawstring = "";
                    FileInfo[] apsFi = Readfromfolder(singlebadInfo.BarCode, "*.csv", p_datefolderInfo.APSFolderLocation);
                    FileInfo[] cepFi = Readfromfolder(singlebadInfo.BarCode, "*.csv", p_datefolderInfo.CepFolderLocation);
                    FileInfo[] rawFi = Readfromfolder(singlebadInfo.BarCode, "*.csv", p_datefolderInfo.RawDataFolderLocation);

                    if (apsFi.Count() > 0)
                    {
                        fileApsstring = apsFi[0].ToString();
                    }
                    if (cepFi.Count() > 0)
                    {
                        fileCepstring = cepFi[0].ToString();
                    }
                    if (rawFi.Count() > 0)
                    {
                        fileRawstring = rawFi[0].ToString();
                    }

                    m_ModuleMessageBody.Enqueue(new ModuleMessageBody()
                    {
                        LineName       = m_LineName,
                        BadProductInfo = (new BadProductInfo()
                        {
                            Date = singlebadInfo.Date,
                            Model = singlebadInfo.Model,
                            BarCode = singlebadInfo.BarCode,
                            Result = singlebadInfo.Result,
                        }),
                        Raw = fileRawstring,
                        Cep = fileCepstring,
                        Aps = fileApsstring
                    });
                }
            }
            return(m_ModuleMessageBody);
        }
 ///<summary>
 ///* Function: Initialze and assign the Specified share folder location, line name, report and aidata folderlocation
 /// This function proves that those specific folders exist.!--
 ///* @author: Sena.kim
 ///* @parameter: fileType ( "*.csv") folder path
 ///* @return: None
 ///</summary>
 public void SetbadProductsInfoUnderDateFolderUsingSQL(DateFolderInfo p_datefolderInfo)
 {
     // if (m_IsThereReportFolder == true && m_IsThereAIFolder == true)
     // {
     //     FileInfo[] di = DirectoryReader.Readfromfolder("*.csv", p_datefolderInfo.DateFolderLocationUnderReport);//does directory have csv files? save csv files
     //     for (int i = 0; i < di.Length; i++)
     //     {
     //         if (di[i] != null)
     //         {
     //             DataTable csvData = new DataTable();
     //             try
     //             {
     //                 using (TextFieldParser csvReader = new TextFieldParser(csv_file_path))
     //                 {
     //                     csvReader.SetDelimiters(new string[] { "," });
     //                     csvReader.HasFieldsEnclosedInQuotes = true;
     //                     string[] colFields = csvReader.ReadFields();
     //                     foreach (string column in colFields)
     //                     {
     //                         DataColumn datecolumn = new DataColumn(column);
     //                         datecolumn.AllowDBNull = true;
     //                         csvData.Columns.Add(datecolumn);
     //                     }
     //                     while (!csvReader.EndOfData)
     //                     {
     //                         string[] fieldData = csvReader.ReadFields();
     //                         //Making empty value as null
     //                         for (int i = 0; i < fieldData.Length; i++)
     //                         {
     //                             if (fieldData[i] == "")
     //                             {
     //                                 fieldData[i] = null;
     //                             }
     //                         }
     //                         csvData.Rows.Add(fieldData);
     //                     }
     //                 }
     //             }
     //             catch (Exception ex)
     //             {
     //             }
     //             return csvData;
     //         }
     //     }
     // }
 }
        ///<summary>
        ///* Function: Setting today's date folder.!--
        /// This function proves that those specific folders exist.!--
        ///* @author: Sena.kim
        ///* @parameter:string Sharefolderlocation, directory name as line name eg line2/3/4
        ///* @return: None
        ///</summary>

        private DateFolderInfo SetSingleDateFolderInfo(Environment p_currentEnvironment)
        {
            m_currentEnvironment = p_currentEnvironment;
            string   dateFolderLocation = "";
            DateTime currentworkingDate = LogBuilder.GetKoreanFormatTime();//GetToday's date

            dateFolderLocation = DirectoryReader.ParseDatetimeToDirectoryStyle(m_reportfolderlocation, currentworkingDate, "yyyyMMdd", m_currentEnvironment);
            DateFolderInfo todayDateFolderInfo = (new DateFolderInfo()
            {
                WorkingDate = currentworkingDate,
                DateFolderLocationUnderReport = dateFolderLocation,
                APSFolderLocation = this.GetApsCepRawLocation(m_apsfolderName, RestultFileType.APS, currentworkingDate),
                CepFolderLocation = this.GetApsCepRawLocation(m_cepfolderName, RestultFileType.CEP, currentworkingDate),
                RawDataFolderLocation = this.GetApsCepRawLocation(m_rawfolderName, RestultFileType.RAW, currentworkingDate),
                //BadProductsWithErrors = new Queue<BadProductInfo>(),
                BadProductsToPass = new Queue <BadProductInfo>(),
                isProcessingComplete = false,
            });

            return(todayDateFolderInfo);
        }