Exemplo n.º 1
0
        private void ReadFile(string posNumberFiles)
        {
            this.posNumbers.Clear();

            if (!string.IsNullOrWhiteSpace(posNumberFiles))
            {
                foreach (var pnFileUnpatched in posNumberFiles.Split(';'))
                {
                    var pnFile = Utils.PatchFilePath(pnFileUnpatched);
                    if (!string.IsNullOrWhiteSpace(pnFile) && File.Exists(pnFile))
                    {
                        var allPnLines = File.ReadAllLines(pnFile, Encoding.Default);
                        foreach (string line in allPnLines.Skip(1))
                        {
                            try
                            {
                                var pn = new PositionNumber();
                                if (pn.TryParse(line))
                                {
                                    this.posNumbers.Add(pn);
                                }
                                else
                                {
                                    if (pn.Exception != null)
                                    {
                                        logger.Warn(pn.Exception, $"Could not parse position number line: {line} :");
                                    }
                                    else
                                    {
                                        logger.Warn($"Could not parse position number line: {line}");
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                logger.Warn(e, $"Could not parse position number line: {line} :");
                            }
                        }
                        // break after first file worked
                        break;
                    }
                }
            }

            this.Search();

            this.pnHash = this.posNumbers.ToDictionary(pnum => pnum.Number, pnum => pnum.Description);
        }
Exemplo n.º 2
0
 private void ReadPNFile(string posNumberFiles)
 {
     if (!string.IsNullOrWhiteSpace(posNumberFiles))
     {
         foreach (var pnFileUnpatched in posNumberFiles.Split(';'))
         {
             var pnFile = Utils.PatchFilePath(pnFileUnpatched);
             if (!string.IsNullOrWhiteSpace(pnFile) && File.Exists(pnFile))
             {
                 var allPnLines = File.ReadAllLines(pnFile, Encoding.Default);
                 foreach (string line in allPnLines.Skip(1))
                 {
                     try
                     {
                         var pn = new PositionNumber();
                         string[] columns = line.Split(';');
                         pn.Number = columns[0];
                         pn.Description = columns[1];
                         pn.Customer = columns[2];
                         this.posNumbers.Add(pn);
                     }
                     catch (Exception e)
                     {
                         logger.Warn(e, "Could not read as projectnumber info: {0}", line);
                     }
                 }
                 // break after first file worked
                 break;
             }
         }
     }
     this.pnHash = this.posNumbers.ToDictionary(pnum => pnum.Number, pnum => pnum.Description);
 }