예제 #1
0
파일: OPFiles.cs 프로젝트: tempbottle/INCC6
        /// <summary>
        /// Create a list of Isotopics instances from each CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateIsotopics(CSVFile csv)
        {
            List<Isotopics> l = NOPIsotopics;  // local alias
            foreach (string[] sa in csv.Lines)
            {
                Isotopics i = new Isotopics();
                String s = String.Empty;
                double v = 0, err = 0;
                foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                            case NOPCol.AmDate:
                                Match amd = yyyymmdd.Match(s);
                                if (amd.Success)
                                    i.am_date = GenFromYYYYMMDD(s);
                                break;
                            case NOPCol.PuDate:
                                Match pud = yyyymmdd.Match(s);
                                if (pud.Success)
                                    i.pu_date = GenFromYYYYMMDD(s);
                                break;
                            case NOPCol.IsoSourceCode:
                                System.Enum.TryParse<Isotopics.SourceCode>(s, out i.source_code);
                                break;
                            case NOPCol.IsoId:
                                i.id = String.Copy(s);
                                break;
                            case NOPCol.Pu238:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu238, v);
                                break;
                            case NOPCol.Pu239:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu239, v);
                                break;
                            case NOPCol.Pu240:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu240, v);
                                break;
                            case NOPCol.Pu241:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu241, v);
                                break;
                            case NOPCol.Pu242:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu242, v);
                                break;
                            case NOPCol.Am241:
                                Double.TryParse(s, out v); i.SetVal(Isotope.am241, v);
                                break;
                            case NOPCol.Pu238err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu238, err);
                                break;
                            case NOPCol.Pu239err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu239, err);
                                break;
                            case NOPCol.Pu240err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu240, err);
                                break;
                            case NOPCol.Pu241err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu241, err);
                                break;
                            case NOPCol.Pu242err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu242, err);
                                break;
                            case NOPCol.Am241err:
                                Double.TryParse(s, out err); i.SetVal(Isotope.am241, err);
                                break;
                            case NOPCol.Norm:
                                // todo: the values in this field are related to COP file usage, bu I don't quite understand this yet, appears it should be looking for "Cf" in this field according to the documentation
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as isotopics element " + op.ToString() + " " + ex.Message);
                    }
                }

                l.Add(i);
            }
        }
예제 #2
0
파일: OPFiles.cs 프로젝트: tempbottle/INCC6
 /// <summary>
 /// Create a list of Item Id instances from each CSV parsed line set
 /// </summary>
 /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
 void GenerateItemIds(CSVFile csv)
 {
     List<ItemId> l = NOPItemIds;  // local alias
     String s = String.Empty;
     foreach (string[] sa in csv.Lines)
     {
         ItemId iid = new ItemId();
         foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
         {
             try
             {
                 s = String.Empty;
                 s = sa[(int)op];  // might blow here when file was badly created
                 switch (op)
                 {
                     case NOPCol.MBA:
                         iid.mba = String.Copy(s);
                         break;
                     case NOPCol.MatType:
                         iid.material = String.Copy(s);
                         break;
                     case NOPCol.ItemId:
                         iid.item = String.Copy(s);
                         break;
                     case NOPCol.StratumId:
                         iid.stratum = String.Copy(s);
                         break;
                     case NOPCol.InvChangeCode:
                         iid.inventoryChangeCode = String.Copy(s);
                         break;
                     case NOPCol.IOCode:
                         iid.IOCode = String.Copy(s);
                         break;
                     case NOPCol.IsoId:
                         iid.isotopics = String.Copy(s);
                         break;
                     case NOPCol.DecPuMassGr:
                         Double.TryParse(s, out iid.declaredMass);
                         break;
                     case NOPCol.AmDate:
                         Match amd = yyyymmdd.Match(s);
                         if (amd.Success)
                             iid.am_date = GenFromYYYYMMDD(s);
                         break;
                     case NOPCol.PuDate:
                         Match pud = yyyymmdd.Match(s);
                         if (pud.Success)
                             iid.pu_date = GenFromYYYYMMDD(s);
                         break;
                 }
             }
             catch (Exception ex)
             {
                 mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as item element " + op.ToString() + " " + ex.Message);
             }
         }
         l.Add(iid);
     }
 }
예제 #3
0
파일: OPFiles.cs 프로젝트: tempbottle/INCC6
        /// <summary>
        /// Create a list of CmPu ratio record instances from a CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateCmPuRatioRecs(CSVFile csv)
        {
            List<INCCAnalysisParams.cm_pu_ratio_rec> l = COPRatioRecs;  // local alias

            INCCAnalysisParams.cm_pu_ratio_rec cpr = new INCCAnalysisParams.cm_pu_ratio_rec();
            String s = String.Empty;
            foreach (string[] sa in csv.Lines)
            {
                foreach (COPCol op in System.Enum.GetValues(typeof(COPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                            case COPCol.ItemId:
                                //cpr.cm_id = String.Copy(s);
                                break;
                            case COPCol.DecPuMassGr:
                                //Double.TryParse(s, out cpr.cm_dcl_u235_mass);
                                break;
                            case COPCol.InputBatchId:
                                cpr.cm_input_batch_id = String.Copy(s);
                                break;
                            case COPCol.LabelId:
                                cpr.cm_id_label = String.Copy(s);
                                break;
                            case COPCol.Id:
                                cpr.cm_id = String.Copy(s);
                                break;
                            case COPCol.DecU235MassGr:
                                Double.TryParse(s, out cpr.cm_dcl_u235_mass);
                                break;
                            case COPCol.DecUMassGr:
                                Double.TryParse(s, out cpr.cm_dcl_u_mass);
                                break;
                            case COPCol.CmPuDate:
                                Match cmd = yyyymmdd.Match(s);
                                if (cmd.Success)
                                    cpr.cm_pu_ratio_date = GenFromYYYYMMDD(s);
                                break;
                            case COPCol.CmUDate:
                                Match ud = yyyymmdd.Match(s);
                                if (ud.Success)
                                    cpr.cm_u_ratio_date = GenFromYYYYMMDD(s);
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as CmPu ratio element " + op.ToString() + " " + ex.Message);
                    }
                }
                l.Add(cpr);
            }
        }
예제 #4
0
        /// <summary>
        /// Scan a set of iso and comp iso files.
        /// Creates a list of Isotopics from the iso files.
        /// Creates a list of CompositeIsotopics from the comp files.
        /// </summary>
        /// <param name="files">List of nop and cop files to process</param>
        public void Process(List<string> files)
        {
            if (files == null)
                return;
            foreach (string l in files)
            try
                {
                    CSVFile csv = new CSVFile();
                    string name = l.Substring(l.LastIndexOf("\\") + 1); // Remove path information from string
                    csv.Log = NC.App.Loggers.Logger(LMLoggers.AppSection.Data);
                    csv.Filename = l;
                    csv.ExtractDateFromFilename();
                    if (name.IndexOf('.') >= 0)
                        csv.ThisSuffix = name.Substring(name.IndexOf('.'));
                    csv.ProcessFile();  // split lines with scanner
                    bool isofile = false;
                    CompositeIsotopics ciso = null;
                    Isotopics iso = null;
                    iso = GenIso(csv.Lines[0]);
                    if (isofile = (iso != null))
                    {
                        Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "got an iso file, process all the lines " + System.IO.Path.GetFileName(l));
                        Results.mlogger.TraceEvent(LogLevels.Info, 34100, "Processed " + iso.id + " from " + System.IO.Path.GetFileName(csv.Filename));
                        Results.IsoIsotopics.Add(iso);
                    }
                    else
                    {
                        ciso = (CompositeIsotopics)CompositeIsotopics(csv.Lines[0], headtest: true);
                        if (ciso != null)  // got a header of a comp iso file, process the rest of the lines
                        {
                            Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "got a header of a comp iso file, process the rest of the lines " + System.IO.Path.GetFileName(l));
                            Results.CompIsoIsotopics.Add(ciso);
                        }
                    }
                    for (int i = 1; i < csv.Lines.Count; i++)
                    {
                        string[] entry = csv.Lines[i];
                        if (isofile)
                        {
                            iso = GenIso(entry);
                            if (iso != null)
                            {
                                Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "got an iso file, process all the lines " + System.IO.Path.GetFileName(l));
                                Results.mlogger.TraceEvent(LogLevels.Info, 34100, "Processed " + iso.id + " from " + System.IO.Path.GetFileName(csv.Filename));
                                Results.IsoIsotopics.Add(iso);
                            }
                            else Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "Skipped non-iso token entry");
                        }
                        else
                        {
                            CompositeIsotopic ci = (CompositeIsotopic)CompositeIsotopics(entry, headtest: false);
                            if (ci != null)  // got a header of a comp iso file, process the rest of the lines
                            {
                                ciso.isotopicComponents.Add(ci);
                            }

                        }
                    }
                }
                catch (MalformedLineException )  // not a CSV file
                {
                    Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "Skipped " + System.IO.Path.GetFileName(l));
                }
        }
예제 #5
0
        /// <summary>
        /// Scan a dmr file.
        /// </summary>
        /// <param name="files">dmr file to process</param>
        public void Process(string file)
        {
            if (string.IsNullOrEmpty(file))
                return;
            try
            {
                CSVFile csv = new CSVFile();
                string name = file.Substring(file.LastIndexOf("\\") + 1); // Remove path information from string
                csv.Log = NC.App.Loggers.Logger(LMLoggers.AppSection.Data);
                csv.Filename = file;
                csv.ExtractDateFromFilename();
                if (name.IndexOf('.') >= 0)
                    csv.ThisSuffix = name.Substring(name.IndexOf('.'));
                csv.ProcessFile();  // split lines with scanner
                if (csv.Lines.Count < 3)
                {
                    NC.App.Loggers.Logger(LMLoggers.AppSection.Data).TraceEvent(LogLevels.Warning, 34100, "Skipped incomplete " + System.IO.Path.GetFileName(file));
                    return;
                }
                // line 1
                int coeffnum = csv.Lines[0].Length; // 1 -> 3 lines, 2 -> 4 lines, 3 -> 5 lines, 4 -> 6 lines
                int lines = coeffnum + 2;
                if (csv.Lines.Count != lines)
                {
                    NC.App.Loggers.Logger(LMLoggers.AppSection.Data).TraceEvent(LogLevels.Warning, 34100, "Expecting {0} lines, found {1}, skipping {2}", lines, csv.Lines.Count, System.IO.Path.GetFileName(file));
                    return;
                }
                Coefficients.a = GetDouble(csv.Lines[0][0]);
                if (coeffnum > 1)
                    Coefficients.b = GetDouble(csv.Lines[0][1]);
                if (coeffnum > 2)
                    Coefficients.c = GetDouble(csv.Lines[0][2]);
                if (coeffnum > 3)
                    Coefficients.d = GetDouble(csv.Lines[0][3]);

                // line 2 (skipped?)  // URGENT: check if this is used in INCC5
                //Coefficients.var_a = GetDouble(csv.Lines[1][0]);
                //if (coeffnum > 1)
                //	Coefficients.var_b = GetDouble(csv.Lines[2][1]);
                //if (coeffnum > 2)
                //	Coefficients.var_c = GetDouble(csv.Lines[3][2]);
                //if (coeffnum > 3)
                //	Coefficients.var_d = GetDouble(csv.Lines[4][3]);

                // line 3
                Coefficients.var_a = GetDouble(csv.Lines[2][0]);

                // line 4
                if (csv.Lines.Count > 3)
                {
                    if (csv.Lines[4].Length < 2)
                        throw new Exception("Not enough entries on the b coefficient line " + csv.Lines[3].Length.ToString());
                    Coefficients.setcovar(Coeff.a, Coeff.b, GetDouble(csv.Lines[3][0]));
                    Coefficients.var_b = GetDouble(csv.Lines[3][1]);
                }
                if (csv.Lines.Count > 4)
                {
                    if (csv.Lines[4].Length < 3)
                        throw new Exception("Not enough entries on the c coefficient line " + csv.Lines[4].Length.ToString());
                    Coefficients.setcovar(Coeff.a, Coeff.c, GetDouble(csv.Lines[4][0]));
                    Coefficients.setcovar(Coeff.a, Coeff.c, GetDouble(csv.Lines[4][1]));
                    Coefficients.var_c = GetDouble(csv.Lines[4][2]);
                }
                if (csv.Lines.Count > 5)
                {
                    if (csv.Lines[5].Length < 4)
                        throw new Exception("Not enough entries on the d coefficient line " + csv.Lines[5].Length.ToString());
                    Coefficients.setcovar(Coeff.b, Coeff.c, GetDouble(csv.Lines[5][0]));
                    Coefficients.setcovar(Coeff.b, Coeff.d, GetDouble(csv.Lines[5][1]));
                    Coefficients.setcovar(Coeff.c, Coeff.d, GetDouble(csv.Lines[5][2]));
                    Coefficients.var_d = GetDouble(csv.Lines[5][3]);
                }
            } catch (MalformedLineException)  // not a CSV file
            {
                NC.App.Loggers.Logger(LMLoggers.AppSection.Data).TraceEvent(LogLevels.Verbose, 34100, "Skipped " + System.IO.Path.GetFileName(file));
            } catch (Exception e)  // not good
            {
                NC.App.Loggers.Logger(LMLoggers.AppSection.Data).TraceEvent(LogLevels.Verbose, 34100, e.Message + " - Wrongness experienced " + System.IO.Path.GetFileName(file));
            }
        }
예제 #6
0
 /// <summary>
 /// Create a list of stratum and facilities from a single line set 
 /// </summary>
 /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
 void GenerateStrata(CSVFile csv)
 {
     string s = string.Empty;
     Array ae = System.Enum.GetValues(typeof(SACol));
     foreach (string[] sa in csv.Lines)
     {
         if (sa.Length != ae.Length)
             continue;
         INCCDB.Descriptor desc = null;
         Stratum strat = new Stratum();
         string facname = string.Empty;
         double d = 0;
         foreach (SACol op in ae)
         {
             try
             {
                 s = sa[(int)op];
                 switch (op)
                 {
                     case SACol.Facility:
                        Facilities_.Add(new INCCDB.Descriptor(s,s));
                         break;
                     case SACol.StratumId:
                         facname = string.Copy(s);
                         break;
                     case SACol.StratumDesc:
                         desc = new INCCDB.Descriptor(facname, s);
                         break;
                     case SACol.Bias:
                         double.TryParse(s, out d);
                         strat.bias_uncertainty = d;
                         break;
                     case SACol.Random:
                         double.TryParse(s, out d);
                         strat.random_uncertainty = d;
                         break;
                     case SACol.Systematic:
                         double.TryParse(s, out d);
                         strat.systematic_uncertainty = d;
                         break;
                 }
             }
             catch (Exception)
             {
             }
         }
         Strata.Add(new INCCDB.StratumDescriptor(desc, strat));
     }
 }
예제 #7
0
 void Init()
 {
     IsoIsotopics = new List<Isotopics>();
     CompIsoIsotopics = null;
     mlogger = NC.App.Loggers.Logger(LMLoggers.AppSection.Control);
     Output = new CSVFile();
     Output.Log = mlogger;
 }
예제 #8
0
        /// <summary>
        /// Scan a stratum authority file.
        /// Creates a list of Strata and a list of Facilities from the file.
        /// </summary>
        /// <param name="file">file to process</param>
        public void Process(string path)
        {
            if (string.IsNullOrEmpty(path))
                return;
            CSVFile csv = new CSVFile();
            string name = path.Substring(path.LastIndexOf("\\") + 1); // Remove path information from string
            csv.Log = NC.App.Loggers.Logger(LMLoggers.AppSection.Data);
            csv.Filename = path;
            csv.ExtractDateFromFilename();
            if (name.IndexOf('.') >= 0)
                csv.ThisSuffix = name.Substring(name.IndexOf('.'));
            csv.ProcessFile();  // split lines with scanner
            mlogger.TraceEvent(LogLevels.Info, 34100, "Processed " + System.IO.Path.GetFileName(csv.Filename));

            GenerateStrata(csv);
            DoFacs();
            DoStratumIds();
        }
예제 #9
0
        /// <summary>
        /// Scan a dat file.
        /// New facilities, MBAs, strata, inventory change codes, I/O codes, material types, isotopics,
        ///     collar data and item ids will automatically be created if necessary. Already existing items will automatically be overwritten.        
        /// </summary>
        /// <param name="files">dat file to process</param>
        public void Process(string file)
        {
            if (string.IsNullOrEmpty(file))
                return;
            try
            {
                CSVFile csv = new CSVFile();
                string name = file.Substring(file.LastIndexOf("\\") + 1); // Remove path information from string
                csv.Log = NC.App.Loggers.Logger(LMLoggers.AppSection.Data);
                csv.Filename = file;
                csv.ExtractDateFromFilename();
                if (name.IndexOf('.') >= 0)
                    csv.ThisSuffix = name.Substring(name.IndexOf('.'));
                csv.ProcessFile();  // split lines with scanner
                int el = System.Enum.GetValues(typeof(ItemCol)).Length;
                foreach (string[] entry in csv.Lines)
                {
                    List<string> ls = new List<string>(entry);
                    if (entry.Length < el)
                    {
                        ls.AddRange(new string[el - ls.Count]);
                    }

                    PopulateSingletons(ls);
                    string code = Results.ItemTypes[Results.ItemTypes.Count - 1];
                    string isoid = ls[(int)ItemCol.IsoId];
                    if (UseDefaultIso(isoid))
                        isoid = Isotopics.DefaultId;
                    if (CompositeCode(code))
                    {
                        // comp isotopics id and item id iso id fields are the same here
                        Results.CompIsoIsotopics.Add(GenCompIso(ls));
                    } else
                    {
                        // isotopics id and item id iso id fields are the same here, Default
                        Results.IsoIsotopics.Add(GenIso(ls));
                    }
                    if (CollarCode(code))
                    {
                        CollarItemId id = GenColl(ls);
                        CollarItems.Add(id);
                        id.item_id = Results.ItemNames[Results.ItemNames.Count - 1];  // the item id for this entry
                    }
                    ItemId iid = GenItemId(ls);
                    Results.ItemIds.Add(iid);
                    // mass was scooped up in one of the three scanners
                }
            } catch (Microsoft.VisualBasic.FileIO.MalformedLineException)  // not a CSV file
            {
                Results.mlogger.TraceEvent(LogLevels.Verbose, 34100, "Skipped " + System.IO.Path.GetFileName(file));
            }
            Results.ApplyContent();
            Results.DoFacs();
            Results.CompIsotopicGen();
            Results.DoSrcCodes();
        }
예제 #10
0
        /// <summary>
        /// Create a list of Isotopics instances from each CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateIsotopics(CSVFile csv)
        {
            List <Isotopics> l = NOPIsotopics;  // local alias

            foreach (string[] sa in csv.Lines)
            {
                Isotopics i = new Isotopics();
                String    s = String.Empty;
                double    v = 0, err = 0;
                foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                        case NOPCol.AmDate:
                            Match amd = yyyymmdd.Match(s);
                            if (amd.Success)
                            {
                                i.am_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case NOPCol.PuDate:
                            Match pud = yyyymmdd.Match(s);
                            if (pud.Success)
                            {
                                i.pu_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case NOPCol.IsoSourceCode:
                            System.Enum.TryParse <Isotopics.SourceCode>(s, out i.source_code);
                            break;

                        case NOPCol.IsoId:
                            i.id = String.Copy(s);
                            break;

                        case NOPCol.Pu238:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu238, v);
                            break;

                        case NOPCol.Pu239:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu239, v);
                            break;

                        case NOPCol.Pu240:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu240, v);
                            break;

                        case NOPCol.Pu241:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu241, v);
                            break;

                        case NOPCol.Pu242:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu242, v);
                            break;

                        case NOPCol.Am241:
                            Double.TryParse(s, out v); i.SetVal(Isotope.am241, v);
                            break;

                        case NOPCol.Pu238err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu238, err);
                            break;

                        case NOPCol.Pu239err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu239, err);
                            break;

                        case NOPCol.Pu240err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu240, err);
                            break;

                        case NOPCol.Pu241err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu241, err);
                            break;

                        case NOPCol.Pu242err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu242, err);
                            break;

                        case NOPCol.Am241err:
                            Double.TryParse(s, out err); i.SetVal(Isotope.am241, err);
                            break;

                        case NOPCol.Norm:
                            // todo: the values in this field are related to COP file usage, bu I don't quite understand this yet, appears it should be looking for "Cf" in this field according to the documentation
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as isotopics element " + op.ToString() + " " + ex.Message);
                    }
                }

                l.Add(i);
            }
        }
예제 #11
0
        /// <summary>
        /// Create a list of CmPu ratio record instances from a CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateCmPuRatioRecs(CSVFile csv)
        {
            List <INCCAnalysisParams.cm_pu_ratio_rec> l = COPRatioRecs;  // local alias

            INCCAnalysisParams.cm_pu_ratio_rec cpr = new INCCAnalysisParams.cm_pu_ratio_rec();
            String s = String.Empty;

            foreach (string[] sa in csv.Lines)
            {
                foreach (COPCol op in System.Enum.GetValues(typeof(COPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                        case COPCol.ItemId:
                            //cpr.cm_id = String.Copy(s);
                            break;

                        case COPCol.DecPuMassGr:
                            //Double.TryParse(s, out cpr.cm_dcl_u235_mass);
                            break;

                        case COPCol.InputBatchId:
                            cpr.cm_input_batch_id = String.Copy(s);
                            break;

                        case COPCol.LabelId:
                            cpr.cm_id_label = String.Copy(s);
                            break;

                        case COPCol.Id:
                            cpr.cm_id = String.Copy(s);
                            break;

                        case COPCol.DecU235MassGr:
                            Double.TryParse(s, out cpr.cm_dcl_u235_mass);
                            break;

                        case COPCol.DecUMassGr:
                            Double.TryParse(s, out cpr.cm_dcl_u_mass);
                            break;

                        case COPCol.CmPuDate:
                            Match cmd = yyyymmdd.Match(s);
                            if (cmd.Success)
                            {
                                cpr.cm_pu_ratio_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case COPCol.CmUDate:
                            Match ud = yyyymmdd.Match(s);
                            if (ud.Success)
                            {
                                cpr.cm_u_ratio_date = GenFromYYYYMMDD(s);
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as CmPu ratio element " + op.ToString() + " " + ex.Message);
                    }
                }
                l.Add(cpr);
            }
        }
예제 #12
0
        /// <summary>
        /// Create a list of Item Id instances from each CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateItemIds(CSVFile csv)
        {
            List <ItemId> l = NOPItemIds;  // local alias
            String        s = String.Empty;

            foreach (string[] sa in csv.Lines)
            {
                ItemId iid = new ItemId();
                foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                        case NOPCol.MBA:
                            iid.mba = String.Copy(s);
                            break;

                        case NOPCol.MatType:
                            iid.material = String.Copy(s);
                            break;

                        case NOPCol.ItemId:
                            iid.item = String.Copy(s);
                            break;

                        case NOPCol.StratumId:
                            iid.stratum = String.Copy(s);
                            break;

                        case NOPCol.InvChangeCode:
                            iid.inventoryChangeCode = String.Copy(s);
                            break;

                        case NOPCol.IOCode:
                            iid.IOCode = String.Copy(s);
                            break;

                        case NOPCol.IsoId:
                            iid.isotopics = String.Copy(s);
                            break;

                        case NOPCol.DecPuMassGr:
                            Double.TryParse(s, out iid.declaredMass);
                            break;

                        case NOPCol.AmDate:
                            Match amd = yyyymmdd.Match(s);
                            if (amd.Success)
                            {
                                iid.am_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case NOPCol.PuDate:
                            Match pud = yyyymmdd.Match(s);
                            if (pud.Success)
                            {
                                iid.pu_date = GenFromYYYYMMDD(s);
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as item element " + op.ToString() + " " + ex.Message);
                    }
                }
                l.Add(iid);
            }
        }