예제 #1
0
        public bool CompareSrcDes(Queue <KeyValuePair <string, string> > srcQueue, MagentaData magentaData, string sampleCode)
        {
            Queue <KeyValuePair <string, string> > checkQ       = new Queue <KeyValuePair <string, string> >(srcQueue);
            Queue <KeyValuePair <string, string> > tempMatchQ   = new Queue <KeyValuePair <string, string> >(srcQueue);
            Queue <KeyValuePair <string, string> > magentaQueue = magentaData.Queue;
            Queue <KeyValuePair <string, string> > tempMagentaQ = DequeueOneLine(magentaQueue);
            Queue <string> codeQueue = magentaData.SampleCodeQ;
            string         code      = codeQueue.Dequeue();

            /* check destination plate version */
            if (!CheckDataValid(checkQ))
            {
                FileProcessor.GiveLog("Export File Version Error");
                return(false);
            }
            foreach (KeyValuePair <string, string> pair in tempMatchQ)
            {
                FileProcessor.GiveLog("Comparing  " + pair.Key + "    " + pair.Value);
            }
            bool result = MatchOneLine(CloneQueue(tempMatchQ), tempMagentaQ, code, sampleCode);

            if (!result)
            {
                while (!result)     //compare until all data used.
                {
                    if (magentaQueue.Count == 0)
                    {
                        FileProcessor.GiveLog("No more magenta data");
                        break;
                    }
                    else
                    {
                        tempMagentaQ = DequeueOneLine(magentaQueue);
                        code         = codeQueue.Dequeue();
                        result       = MatchOneLine(CloneQueue(tempMatchQ), tempMagentaQ, code, sampleCode);
                    }
                }
            }

            if (result == false)
            {
                FileProcessor.GiveLog("Match Unsuccessfully  ");
            }
            return(result);
        }
예제 #2
0
        public MagentaData Read_Magenta(string expCode, string markerString, string magentaFileDir)
        {
            MagentaData          magentaData = null;
            DirectoryInfo        mfdInfo     = new DirectoryInfo(magentaFileDir);
            List <DirectoryInfo> subDirs     = mfdInfo.GetDirectories().ToList();

            subDirs = subDirs.OrderByDescending(p => p.CreationTime).ToList();
            foreach (DirectoryInfo dInfo in subDirs)
            {
                if (expCode.Equals(FileProcessor.GetMagentaFileCode(dInfo.Name)))
                {
                    magentaData = new MagentaData();
                    FileInfo[] files    = dInfo.GetFiles("*.txt");
                    FileInfo   fInfo    = files.First();
                    string[]   texts    = File.ReadAllText(fInfo.FullName).Split('\t');
                    int        strPlace = texts.FindFirst(markerString);
                    while (strPlace != -1)
                    {
                        //get source1, destination 1, add 6 and 5 according to format
                        string[] src = (texts[strPlace + 5]).Split(Constant.Magenta_File_Delimiter).ToArray();
                        string[] des = (texts[strPlace + 4]).Split(Constant.Magenta_File_Delimiter).ToArray();
                        foreach (string strSrc in src)
                        {
                            KeyValuePair <string, string> pair = new KeyValuePair <string, string>(Constant.StrSrc.ToLower(), strSrc.Trim());
                            magentaData.Queue.Enqueue(pair);
                        }
                        foreach (string strDes in des)
                        {
                            KeyValuePair <string, string> pair = new KeyValuePair <string, string>(Constant.StrDes.ToLower(), strDes.Trim());
                            magentaData.Queue.Enqueue(pair);
                        }
                        string sampleCode = texts[strPlace + 1].Trim();
                        magentaData.SampleCodeQ.Enqueue(sampleCode);
                        strPlace = texts.FindNext(markerString, strPlace);
                    }
                    break;
                }
            }
            return(magentaData);
        }
예제 #3
0
        public void ProcessFile(string[] exportLines, string markerStr, string sampleCode)
        {
            #region [3]. read export file
            MatchData   fileData    = new MatchData();
            MagentaData magentaData = new MagentaData();
            string      errorMsg    = string.Empty;
            /* flag to mark whether the match is already failed */
            switch (sampleCode)
            {
            case "96to96":
                fileData.ProcessName = Constant.Extrac_96w_96w_ProcessName;
                break;

            case "48to96":
                fileData.ProcessName = Constant.Extrac_48w_96w_ProcessName;
                break;

            case "384":
                fileData.ProcessName = Constant.Daug_Mplx1_ProcessName;
                break;

            case "192":
                fileData.ProcessName = Constant.Daug_Mplx2_ProcessName;
                break;

            case "96":
                fileData.ProcessName = Constant.Daug_Mplx4_ProcessName;
                break;

            default:
                break;
            }
            /*---- get ExprtFile Data ----*/
            if (markerStr.Equals(Constant.Extraction96_MarkerString))
            {
                FileProcessor.GiveLog("Reading Export File");
                reader.Read_96w_to_96w(exportLines, ref fileData);
                ValidateEmpty(fileData);
            }
            else if (markerStr.Equals(Constant.Extraction48_MarkerString))
            {
                FileProcessor.GiveLog("Reading Export File");
                reader.Read_48w_to_96w(exportLines, ref fileData);
                ValidateEmpty(fileData);
            }
            else
            {
                FileProcessor.GiveLog("Reading Daug Export File");
                reader.Read_Daug(exportLines, ref fileData);
                ValidateEmpty(fileData);
                ValidateDesDuplication(fileData);
                ValidateVersionNumber(fileData);
                ValidateDaugPlatesNum(fileData);
            }
            #endregion


            FileProcessor.GiveLog("Reading Magenta File");
            /* loop dictionary, compare values*/
            // Dictionary<string, Queue<KeyValuePair<string, string>>> dict = new Dictionary<string, Queue<KeyValuePair<string, string>>>(fileData.ExpDict);
            /* set successful at first*/
            foreach (MatchItem item in fileData.MatchQueue)
            {
                if (item.itemResult.Equals(Constant.MatchSucces))
                {
                    string expCode = item.itemQueue.First().Value.GetExpCode();
                    FileProcessor.GiveLog("Comparing   " + expCode);
                    magentaData = reader.Read_Magenta(expCode, markerStr, magentaFileDir);
                    /* new queue by remove version number, original one not affected */
                    Queue <KeyValuePair <string, string> > queue = compare.RemoveVersionNum(item.itemQueue);
                    queue = compare.RemoveDuplicateDestination(queue);
                    if (magentaData != null)
                    {
                        if (!(compare.CompareSrcDes(queue, magentaData, sampleCode)))
                        {
                            item.itemResult = Constant.MatchingFail;
                        }
                    }
                    else
                    {
                        FileProcessor.GiveLog("Can not find Magenta file");
                        item.itemResult = Constant.MagentaNotFound;
                    }
                }
            }

            FileProcessor.GiveLog("Generating Result File  ");
            FileProcessor.GenerateResult(fileData, markerStr, resultFileDir, outputFileDir);
        }