public void FileParse_Parse_Test()
        {
            var df          = personFileParser.Parse(testFilePath);
            var recordCount = df.Items.Count;


            Assert.AreEqual(4, recordCount);
        }
Exemple #2
0
        private object[] GetAllMOBOM()
        {
            string fileName = string.Empty;


            fileName = this.ViewState["UploadedMOBOMFileName"].ToString();

            string configFile = this.getParseConfigFileName();

            DataFileParser parser = new DataFileParser();

            parser.FormatName       = "MOBOM";
            parser.ConfigFile       = configFile;
            parser.CheckValidHandle = new CheckValid(this.MOBOMDownloadCheck);
            moboms = parser.Parse(fileName);



            foreach (MOBOM mobom in moboms)
            {
                mobom.MOCode   = FormatHelper.PKCapitalFormat(mobom.MOCode);
                mobom.ItemCode = FormatHelper.PKCapitalFormat(mobom.ItemCode);

                mobom.MaintainUser = this.GetUserCode();
                mobom.MaintainDate = FormatHelper.TODateInt(DateTime.Today);
                mobom.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
            }

            return(moboms);
        }
Exemple #3
0
 protected override void ProcessData()
 {
     foreach (var file in Files)
     {
         var df = DataFileParser.Parse(file);
         _service.Add(df.Items);
     }
 }
        private object[] GetAllSBOMs()
        {
            string fileName = string.Empty;

            if (this.ViewState["UploadedFileName"] == null)
            {
                ExceptionManager.Raise(this.GetType().BaseType, "$Error_NOExamineFile");
            }

            fileName = this.ViewState["UploadedFileName"].ToString();

            string configFile = this.getParseConfigFileName();

            DataFileParser parser = new DataFileParser();

            parser.FormatName       = "SBOM";
            parser.ConfigFile       = configFile;
            parser.CheckValidHandle = new CheckValid(this.SBOMDownloadCheck);
            sboms = parser.Parse(fileName);

            //added by jessie lee for AM0185(TS35), 2005/10/11,P4.10
            //为了兼顾效率,一次只能导入一个产品的BOM,即按产品导入
            ArrayList aList = new ArrayList();

            for (int i = 0; i < sboms.Length; i++)
            {
                bool repeat = false;
                for (int j = aList.Count; j > 0; j--)
                {
                    if ((string.Compare((sboms[i] as SBOM).ItemCode, aList[j - 1].ToString(), true)) == 0)
                    {
                        repeat = true;
                        break;
                    }
                }
                if (!repeat)
                {
                    aList.Add((sboms[i] as SBOM).ItemCode);
                }
            }

            if (aList.Count > 1)
            {
                ExceptionManager.Raise(this.GetType().BaseType, "$Error_Only_A_ProductBOM_Import_Once");
            }

            foreach (SBOM sbom in sboms)
            {
                sbom.ItemCode           = FormatHelper.PKCapitalFormat(sbom.ItemCode);
                sbom.SBOMItemCode       = FormatHelper.PKCapitalFormat(sbom.SBOMItemCode);
                sbom.SBOMSourceItemCode = FormatHelper.PKCapitalFormat(sbom.SBOMSourceItemCode);
                sbom.MaintainUser       = this.GetUserCode();
                sbom.MaintainDate       = FormatHelper.TODateInt(DateTime.Today);
                sbom.MaintainTime       = FormatHelper.TOTimeInt(DateTime.Now);
            }

            return(sboms);
        }