///<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)
Exemplo n.º 2
0
        ///<summary>
        ///* Function: Function to Parse Date Time to Directory style if this directory is under Report put reportfolderDirectory AI Data
        ///* @author: Sena.kim
        ///* @parameter: string DirectoryAboveTheFile, string folderFormat (report : "yyyyMMdd" or AIDATA :  "yyyy-MM-dd")
        ///* @return: string DateFolderLocation
        ///</summary>
        static public string ParseDatetimeToDirectoryStyle(string p_directoryAboveTheDate, DateTime p_currentWorkingDate, string p_folderFormat, Environment p_currentEnvironment)
        {                                                                                                       //Parse Date Time to Directory style
            string sresultDateTime    = LogBuilder.ParseDateTimeToString(p_currentWorkingDate, p_folderFormat); // Parse the DateTime To string to get folderName
            string dateFolderLocation = "";

            if (p_currentEnvironment == Environment.productionOnlinux)
            {
                dateFolderLocation = p_directoryAboveTheDate + "/" + sresultDateTime;
            }
            else if (p_currentEnvironment == Environment.testOnWindow)
            {
                dateFolderLocation = p_directoryAboveTheDate + "\\" + sresultDateTime;
            }
            dateFolderLocation = p_directoryAboveTheDate + "/" + sresultDateTime; //Assign DateFolderLocation

            return(dateFolderLocation);
        }