コード例 #1
0
ファイル: bom.asmx.cs プロジェクト: yhltd/YH_jinxiaocun_PC
        public string save(bom_info bomInfo)
        {
            try
            {
                UserInfoService us             = new UserInfoService();
                string          quanxian_save1 = us.new_quanxian("add", "BOM");
                if (quanxian_save1 != null && quanxian_save1.Length > 0 && quanxian_save1 == "是")
                {
                }
                else
                {
                    return(ResultUtil.error("没有权限!"));
                }

                bs = new BomService();
                if (bs.save(bomInfo))
                {
                    return(ResultUtil.success("保存成功"));
                }
                else
                {
                    return(ResultUtil.error("保存失败"));
                }
            }
            catch (ErrorUtil err)
            {
                return(ResultUtil.fail(401, err.Message));
            }
            catch
            {
                return(ResultUtil.error("查询失败"));
            }
        }
コード例 #2
0
        public async Task ShouldGetTemperatureDataFromEndpoint()
        {
            const string url  = "http://good.uri";
            const string json = @"{
			""observations"": {
				""data"": [
							{""air_temp"": 10.3},
							{""air_temp"": 3},
							{""air_temp"": -3},
							{""air_temp"": 23.6},
							{""air_temp"": 13.9}
						]}}"                        ;

            var httpClientFactoryMock  = Substitute.For <IHttpClientFactory>();
            var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(json, Encoding.UTF8, "application/json")
            });
            var expected = new List <double> {
                10.3, 3, -3, 23.6, 13.9
            };
            var fakeHttpClient = new HttpClient(fakeHttpMessageHandler)
            {
                BaseAddress = new Uri(url)
            };

            httpClientFactoryMock.CreateClient().Returns(fakeHttpClient);

            var sut = new BomService(fakeHttpClient);

            var actual = await sut.GetTemperatureDataAsync();

            actual.Should().BeEquivalentTo(expected);
        }
コード例 #3
0
ファイル: bom.asmx.cs プロジェクト: yhltd/YH_jinxiaocun_PC
        public string list()
        {
            try
            {
                UserInfoService us             = new UserInfoService();
                string          quanxian_save1 = us.new_quanxian("sel", "BOM");
                if (quanxian_save1 != null && quanxian_save1.Length > 0 && quanxian_save1 == "是")
                {
                }
                else
                {
                    return(ResultUtil.error("没有权限!"));
                }

                bs = new BomService();
                return(ResultUtil.success(bs.list(), "查询成功"));
            }
            catch (ErrorUtil err)
            {
                return(ResultUtil.fail(401, err.Message));
            }
            catch
            {
                return(ResultUtil.error("查询失败"));
            }
        }
コード例 #4
0
ファイル: bom.asmx.cs プロジェクト: yhltd/YH_jinxiaocun_PC
        public string page(int nowPage, int pageCount, string code, string name, string type)
        {
            try
            {
                UserInfoService us             = new UserInfoService();
                string          quanxian_save1 = us.new_quanxian("sel", "BOM");
                if (quanxian_save1 != null && quanxian_save1.Length > 0 && quanxian_save1 == "是")
                {
                }
                else
                {
                    return(ResultUtil.error("没有权限!"));
                }

                bs = new BomService();
                return(ResultUtil.success(bs.page(nowPage, pageCount, code, name, type), "查询成功"));
            }
            catch (ErrorUtil err)
            {
                return(ResultUtil.fail(401, err.Message));
            }
            catch
            {
                return(ResultUtil.error("查询失败"));
            }
        }
コード例 #5
0
ファイル: BomServiceTests.cs プロジェクト: engo63/WeatherApi
        public async Task ShouldGetWeatherDataForElementByWmoFromEndpoint()
        {
            const string returnData = @"[
						
							{""Time"": ""12.30pm"", ""air_temp"": 10.3},
							{""Time"": ""12.30pm"", ""air_temp"": 3},
							{""Time"": ""12.30pm"", ""air_temp"": -3},
							{""Time"": ""12.30pm"", ""air_temp"": 23.6},
							{""Time"": ""12.30pm"", ""air_temp"": 13.9}
						]"                        ;

            var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(_json, Encoding.UTF8, "application/json")
            });

            var fakeHttpClient = new HttpClient(fakeHttpMessageHandler)
            {
                BaseAddress = new Uri(_url)
            };

            _httpClientFactoryMock.CreateClient().Returns(fakeHttpClient);

            var sut = new BomService(fakeHttpClient);

            var actual = await sut.GetWeatherDataElementAsync(123, "air_temp");

            var expected = JsonConvert.DeserializeObject <IEnumerable <JToken> >(returnData);

            actual.Should().BeEquivalentTo(expected);
        }
コード例 #6
0
 public delegateController(IManageRepository _manageRepository, IBomRepository _bomrepository, IPurchaseRepository _bomRepository, IStockInRepository _stockinrepository, IStockOutRepository _stockoutrepository)
 {
     manageService   = new ManageService(_manageRepository);
     bomService      = new BomService(_bomrepository);
     stockoutService = new StockOutService(_stockoutrepository);
     stockinService  = new StockInService(_stockinrepository);
     purchaseService = new PurchaseService(_bomRepository);
 }
コード例 #7
0
 private void deleteBomById(decimal id)
 {
     if (id < 1)
     {
         throw new Exception(MessageHelper.component_nothing_deleted);
     }
     BomService.getInstance().deleteBomById(id);
 }
コード例 #8
0
ファイル: mainController.cs プロジェクト: mkbiltek2019/dlerp
 public mainController(IAccountRepository _accountRepository, IManageRepository _manageRepository, IPurchaseRepository _purchaseRepository, IStockInRepository _stockinrepository, IStockOutRepository _stockoutrepository, IBomRepository _bomrepository)
 {
     accountService  = new AccountService(_accountRepository);
     purchaseService = new PurchaseService(_purchaseRepository);
     stockinService  = new StockInService(_stockinrepository);
     stockoutService = new StockOutService(_stockoutrepository);
     manageService   = new ManageService(_manageRepository);
     bomService      = new BomService(_bomrepository);
 }
コード例 #9
0
        async Task updateBom(BOM_Model model)
        {
            string message = "Update bom successfully";

            try
            {
                BomService.getInstance().updateBom(model);
                await reloadBomAsync();
            }catch (Exception e)
            {
                message = e.Message;
            }
            MessageBox.Show(message);
        }
コード例 #10
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            BomSearchModel q = new BomSearchModel();

            IBomService bs = new BomService(Settings.Default.db);

            IPagedList <BOM> boms = bs.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View(boms));
        }
コード例 #11
0
        public ActionResult Search([Bind(Include = "ID, PartNr, VFFrom, VFTo, VTFrom, VTTo")] BomSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IBomService bs = new BomService(Settings.Default.db);

            IPagedList <BOM> boms = bs.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View("Index", boms));
        }
コード例 #12
0
        private async Task  saveAndReloadBom()
        {
            string    message = MessageHelper.saveComponentSuccess;
            BOM_Model model   = getBomModel();

            try
            {
                BomService.getInstance().save(model);
                reloadBom();
            }
            catch (Exception e)
            {
                message = e.Message;
            }
            MessageBox.Show(message);
        }
コード例 #13
0
        public void Export([Bind(Include = "ID, PartNr, VFFrom, VFTo, VTFrom, VTTo")] BomSearchModel q)
        {
            IBomService bs = new BomService(Settings.Default.db);

            List <BOM> boms = bs.Search(q).ToList();

            ViewBag.Query = q;

            MemoryStream ms = new MemoryStream();

            using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8))
            {
                List <string> head = new List <string> {
                    " No.", "ID", "PartNr", "ValidFrom", "ValidTo", "VersionId", "BomDesc", "Action"
                };
                sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head));
                for (var i = 0; i < boms.Count; i++)
                {
                    List <string> ii = new List <string>();
                    ii.Add((i + 1).ToString());
                    ii.Add(boms[i].id.ToString());
                    ii.Add(boms[i].partNr);
                    ii.Add(boms[i].validFrom.ToString());
                    ii.Add(boms[i].validTo.ToString());
                    ii.Add(boms[i].versionId);
                    ii.Add(boms[i].bomDesc);
                    ii.Add("");
                    sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray()));
                }
                //sw.WriteLine(max);
            }
            var filename    = "Bom" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
            var contenttype = "text/csv";

            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = contenttype;
            Response.AddHeader("content-disposition", "attachment;filename=" + filename);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.BinaryWrite(ms.ToArray());
            Response.End();
        }
コード例 #14
0
        public ActionResult ImportBomRecord(HttpPostedFileBase bomFile)
        {
            if (bomFile == null)
            {
                //TODO: Bom Import 优化上传失败界面
                throw new Exception("No file is uploaded to system");
            }

            var appData  = Server.MapPath("~/TmpFile/");
            var filename = Path.Combine(appData,
                                        DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Path.GetFileName(bomFile.FileName));

            bomFile.SaveAs(filename);
            string ex = Path.GetExtension(filename);

            List <BomImportModel> records = new List <BomImportModel>();

            if (ex.Equals(".csv"))
            {
                CsvConfiguration configuration = new CsvConfiguration();
                configuration.Delimiter        = Settings.Default.csvDelimiter;
                configuration.HasHeaderRecord  = true;
                configuration.SkipEmptyRecords = true;
                configuration.RegisterClassMap <BomCsvModelMap>();
                configuration.TrimHeaders = true;
                configuration.TrimFields  = true;

                try
                {
                    using (TextReader treader = System.IO.File.OpenText(filename))
                    {
                        CsvReader csvReader = new CsvReader(treader, configuration);
                        records = csvReader.GetRecords <BomImportModel>().ToList();
                    }
                }
                catch (Exception e)
                {
                    //ViewBag.TextExpMsg = "<-------------Read Csv File Exception!,Please Check.------------->" + e;
                    ViewBag.TextExpMsg = "<-------------读取CSV文件异常,请查看原因:------------->" + e;
                }

                List <Dictionary <string, string> > CreateErrorDic     = new List <Dictionary <string, string> >();
                List <Dictionary <string, string> > UpdateErrorDic     = new List <Dictionary <string, string> >();
                List <Dictionary <string, string> > DeleteErrorDic     = new List <Dictionary <string, string> >();
                List <Dictionary <string, string> > ActionNullErrorDic = new List <Dictionary <string, string> >();
                List <Dictionary <string, string> > OtherErrorDic      = new List <Dictionary <string, string> >();

                if (records.Count > 0)
                {
                    int AllQty           = records.Count;
                    int CreateSuccessQty = 0;
                    int CreateFailureQty = 0;
                    int UpdateSuccessQty = 0;
                    int UpdateFailureQty = 0;
                    int DeleteSuccessQty = 0;
                    int DeleteFailureQty = 0;
                    int ActionNullQty    = 0;
                    int OtherQty         = 0;

                    IBomService ps = new BomService(Settings.Default.db);

                    foreach (BomImportModel record in records)
                    {
                        if (string.IsNullOrWhiteSpace(record.Action))
                        {
                            ActionNullQty++;

                            Dictionary <string, string> ActionNullErrorList = new Dictionary <string, string>();

                            ActionNullErrorList.Add("ID", record.ID);
                            ActionNullErrorList.Add("PartNr", record.PartNr);
                            ActionNullErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                            ActionNullErrorList.Add("ValidTo", record.ValidTo.ToString());
                            ActionNullErrorList.Add("VersionId", record.VersionId);
                            ActionNullErrorList.Add("BomDesc", record.BomDesc);
                            ActionNullErrorList.Add("Action", record.Action);

                            ActionNullErrorDic.Add(ActionNullErrorList);
                            ViewData["actionNullErrorDic"] = ActionNullErrorDic;
                        }
                        else
                        {
                            //新建
                            BOM bom = new BOM()
                            {
                                id        = record.ID,
                                partNr    = record.PartNr,
                                validFrom = record.ValidFrom,
                                validTo   = record.ValidTo,
                                versionId = record.VersionId,
                                bomDesc   = record.BomDesc
                            };

                            if (record.Action.Trim().ToLower().Equals("create"))
                            {
                                try
                                {
                                    ps.Create(bom);
                                    CreateSuccessQty++;
                                }
                                catch (Exception)
                                {
                                    CreateFailureQty++;

                                    Dictionary <string, string> CreateErrorList = new Dictionary <string, string>();

                                    CreateErrorList.Add("ID", record.ID);
                                    CreateErrorList.Add("PartNr", record.PartNr);
                                    CreateErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                    CreateErrorList.Add("ValidTo", record.ValidTo.ToString());
                                    CreateErrorList.Add("VersionId", record.VersionId);
                                    CreateErrorList.Add("BomDesc", record.BomDesc);
                                    CreateErrorList.Add("Action", record.Action);

                                    CreateErrorDic.Add(CreateErrorList);
                                    ViewData["createErrorDic"] = CreateErrorDic;
                                }
                            }
                            else if (record.Action.Trim().ToLower().Equals("update"))
                            {
                                //更新
                                try
                                {
                                    bool result = ps.Update(bom);
                                    if (result)
                                    {
                                        UpdateSuccessQty++;
                                    }
                                    else
                                    {
                                        UpdateFailureQty++;

                                        Dictionary <string, string> UpdateErrorList = new Dictionary <string, string>();

                                        UpdateErrorList.Add("ID", record.ID);
                                        UpdateErrorList.Add("PartNr", record.PartNr);
                                        UpdateErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                        UpdateErrorList.Add("ValidTo", record.ValidTo.ToString());
                                        UpdateErrorList.Add("VersionId", record.VersionId);
                                        UpdateErrorList.Add("BomDesc", record.BomDesc);
                                        UpdateErrorList.Add("Action", record.Action);

                                        UpdateErrorDic.Add(UpdateErrorList);
                                        ViewData["updateErrorDic"] = UpdateErrorDic;
                                    }
                                }
                                catch (Exception)
                                {
                                    UpdateFailureQty++;

                                    Dictionary <string, string> UpdateErrorList = new Dictionary <string, string>();

                                    UpdateErrorList.Add("ID", record.ID);
                                    UpdateErrorList.Add("PartNr", record.PartNr);
                                    UpdateErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                    UpdateErrorList.Add("ValidTo", record.ValidTo.ToString());
                                    UpdateErrorList.Add("VersionId", record.VersionId);
                                    UpdateErrorList.Add("BomDesc", record.BomDesc);
                                    UpdateErrorList.Add("Action", record.Action);

                                    UpdateErrorDic.Add(UpdateErrorList);
                                    ViewData["updateErrorDic"] = UpdateErrorDic;
                                }
                            }
                            else if (record.Action.Trim().ToLower().Equals("delete"))
                            {
                                try
                                {
                                    //删除
                                    bool result = ps.Delete(bom);

                                    if (result)
                                    {
                                        DeleteSuccessQty++;
                                    }
                                    else
                                    {
                                        DeleteFailureQty++;

                                        Dictionary <string, string> DeleteErrorList = new Dictionary <string, string>();

                                        DeleteErrorList.Add("ID", record.ID);
                                        DeleteErrorList.Add("PartNr", record.PartNr);
                                        DeleteErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                        DeleteErrorList.Add("ValidTo", record.ValidTo.ToString());
                                        DeleteErrorList.Add("VersionId", record.VersionId);
                                        DeleteErrorList.Add("BomDesc", record.BomDesc);
                                        DeleteErrorList.Add("Action", record.Action);

                                        DeleteErrorDic.Add(DeleteErrorList);
                                        ViewData["deleteErrorDic"] = DeleteErrorDic;
                                    }
                                }
                                catch (Exception)
                                {
                                    DeleteFailureQty++;
                                    Dictionary <string, string> DeleteErrorList = new Dictionary <string, string>();

                                    DeleteErrorList.Add("ID", record.ID);
                                    DeleteErrorList.Add("PartNr", record.PartNr);
                                    DeleteErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                    DeleteErrorList.Add("ValidTo", record.ValidTo.ToString());
                                    DeleteErrorList.Add("VersionId", record.VersionId);
                                    DeleteErrorList.Add("BomDesc", record.BomDesc);
                                    DeleteErrorList.Add("Action", record.Action);

                                    DeleteErrorDic.Add(DeleteErrorList);
                                    ViewData["deleteErrorDic"] = DeleteErrorDic;
                                }
                            }
                            else
                            {
                                //错误 忽略
                                Dictionary <string, string> OtherErrorList = new Dictionary <string, string>();

                                OtherErrorList.Add("ID", record.ID);
                                OtherErrorList.Add("PartNr", record.PartNr);
                                OtherErrorList.Add("ValidFrom", record.ValidFrom.ToString());
                                OtherErrorList.Add("ValidTo", record.ValidTo.ToString());
                                OtherErrorList.Add("VersionId", record.VersionId);
                                OtherErrorList.Add("BomDesc", record.BomDesc);
                                OtherErrorList.Add("Action", record.Action);

                                OtherErrorDic.Add(OtherErrorList);
                                ViewData["otherErrorDic"] = OtherErrorDic;
                            }
                        }
                    }

                    OtherQty = AllQty - CreateSuccessQty - CreateFailureQty - UpdateSuccessQty - UpdateFailureQty - DeleteSuccessQty - DeleteFailureQty - ActionNullQty;
                    Dictionary <string, int> Qty = new Dictionary <string, int>();
                    Qty.Add("AllQty", AllQty);
                    Qty.Add("CreateSuccessQty", CreateSuccessQty);
                    Qty.Add("CreateFailureQty", CreateFailureQty);
                    Qty.Add("UpdateSuccessQty", UpdateSuccessQty);
                    Qty.Add("UpdateFailureQty", UpdateFailureQty);
                    Qty.Add("DeleteSuccessQty", DeleteSuccessQty);
                    Qty.Add("DeleteFailureQty", DeleteFailureQty);
                    Qty.Add("ActionNullQty", ActionNullQty);
                    Qty.Add("OtherQty", OtherQty);
                    ViewData["Qty"] = Qty;
                }
                else
                {
                    //ViewBag.NotCheckedData = "No Data Checked. Please Check Delimiter or Column Name.";
                    ViewBag.NotCheckedData = "没有检测到数据。请检查分隔符和列名。";
                }
            }
            else
            {
                //ViewBag.NotCsv = "Your File is not .Csv File, Please Check FileName.";
                ViewBag.NotCsv = "你上传的文件不是.CSV格式。请检查文件名。";
            }

            if (ViewBag.NotCsv == null)
            {
                //ViewBag.NotCsv = "CSV File is OK.";
                ViewBag.NotCsv = "上传CSV文件正确!";
            }

            if (ViewBag.NotCheckedData == null)
            {
                //ViewBag.NotCheckedData = "Check Data is OK.";
                ViewBag.NotCheckedData = "检查数据完成!";
            }

            return(View());
        }
コード例 #15
0
 public BomController()
 {
     Service = new BomService(this);
 }
コード例 #16
0
 public costController(IManageRepository _manageRepository, IBomRepository _bomrepository)
 {
     manageService = new ManageService(_manageRepository);
     bomService    = new BomService(_bomrepository);
 }