Ejemplo n.º 1
0
        public void GetSerialNoTest()
        {
            //IFormatSerialNoPersistent persisten=
            var persistent = MockRepository.GenerateStub<IFormatSerialNoPersistent>();
            Dictionary<string, int> dict = new Dictionary<string, int>();
            dict.Add("1", 4);
            persistent.Stub(x => x.GetAll()).Return(dict);

            persistent = new NDAL.DALFormatSerialNo() as IFormatSerialNoPersistent;

            NLibrary.FormatSerialNoUnit fu = new NLibrary.FormatSerialNoUnit(persistent);

               //Assert.AreEqual("100001", fu.GetFormatedSerialNo("1"));
               //Assert.AreEqual("100002", fu.GetFormatedSerialNo("1"));
               //Assert.AreEqual("200001", fu.GetFormatedSerialNo("2"));
            fu.GetFormatedSerialNo("01.032.00003");
            fu.GetFormatedSerialNo("1");
        }
Ejemplo n.º 2
0
        public void GetSerialNoTest()
        {
            //IFormatSerialNoPersistent persisten=
            var persistent = MockRepository.GenerateStub <IFormatSerialNoPersistent>();
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict.Add("1", 4);
            persistent.Stub(x => x.GetAll()).Return(dict);

            persistent = new NDAL.DALFormatSerialNo() as IFormatSerialNoPersistent;

            NLibrary.FormatSerialNoUnit fu = new NLibrary.FormatSerialNoUnit(persistent);

            //Assert.AreEqual("100001", fu.GetFormatedSerialNo("1"));
            //Assert.AreEqual("100002", fu.GetFormatedSerialNo("1"));
            //Assert.AreEqual("200001", fu.GetFormatedSerialNo("2"));
            fu.GetFormatedSerialNo("01.032.00003");
            fu.GetFormatedSerialNo("1");
            fu.Save();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 导入总方法
        /// </summary>
        public void Import(BizProduct bizProduct, BizSupplier bizSupplier,IFormatSerialNoPersistent formatSerialnoPersisitent)
        {
            //1 读取Excel列表
            IList<Product> ProductsInExcel = ReadProductsFromExcel(CheckExcelFile());
            //2 检查图片是否存在
            CheckProductImages(ProductsInExcel);
            //检查数据库
            if (NeedCheckWithDB)
            {
                //1 检查 供应商是否存在
                IList<string> supplierCodeList = GetSupplierCodeList(ProductsInExcel,bizSupplier);
                IList<string> supplierCodeList_NotExists;
                IList<Supplier> supplierList = bizSupplier.GetListByCodeList(supplierCodeList, out supplierCodeList_NotExists);

                if (supplierCodeList_NotExists.Count > 0)
                {
                    foreach (string supplierCode in supplierCodeList_NotExists)
                    {
                        sbImportMsg.AppendLine("不存在该供应商:" + supplierCode);
                    }
                    return;
                }

                //2 检查数据是否已经导入  && 更新产品的供应商信息
                IList<Product> productsExisted;
                ProductsPassedDBCheck = bizProduct.CheckSupplierExisted(ProductsHasImage, out productsExisted);
                ProductsExistedInDB = productsExisted;
                foreach (Product productExist in ProductsExistedInDB)
                {
                    sbImportMsg.AppendLine("已存在该产品.供应商/型号:"+bizSupplier.GetByCode(productExist. SupplierCode).Name+"/"+productExist.ModelNumber);
                }
            }
            //数据保存到数据库-- 分配NTS编码
            FormatSerialNoUnit serialNoMgr=new FormatSerialNoUnit(formatSerialnoPersisitent);

            foreach(Product p in ProductsPassedDBCheck)
            {
                 p.NTSCode=serialNoMgr.GetFormatedSerialNo(p.CategoryCode+"."+p.SupplierCode );
            }

            bizProduct.SaveList(ProductsPassedDBCheck);
            serialNoMgr.Save();

            //图片复制至web的虚拟路径,  不合格数据拷贝
        }