/// <summary> /// 附件列表 /// </summary> /// <param name="Id"></param> /// <returns></returns> public Result_List <Result_AttachmentInfo> GetObjectList_ById_Web(long Id) { Result_List <Result_AttachmentInfo> res = new Result_List <Result_AttachmentInfo>() { Msg = new Result_Msg() { IsSuccess = true } }; try { List <AttachmentInfo> list = (from p in context.AttachmentInfo where p.ParentId == Id && p.Type == 2 select p).ToList(); res.List = list.Select(x => new Result_AttachmentInfo() { Id = x.Id, AttachmentName = x.AttachmentName, ParentId = x.ParentId, Type = x.Type, UserId = x.UserId }).ToList(); } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = ex.Message }; } return(res); }
/// <summary> /// 加载首页Banner /// </summary> /// <returns></returns> public Result_List <Result_BannersIndex> GetBannerList_IndexPage(int languageType) { var listHash = hashSet.Get_DictionariesList(); Result_List <Result_BannersIndex> resList = new Result_List <Result_BannersIndex>() { Msg = new Result_Msg() { IsSuccess = true } }; try { var total = (from p in context.BannersIndex where p.Url != null && p.LanguageType == languageType select p).ToList(); resList.List = total.Select(x => new Result_BannersIndex() { Id = x.Id, ShopId = x.ShopId, BannerTitle = x.BannerTitle, BannerDes = x.BannerDes, Url = x.Url, ManagerId = x.ManagerId, TargetName = x.TargetName, LanguageType = x.LanguageType == 1 ? listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == x.LanguageType.ToString()).FirstOrDefault().DKey : listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == x.LanguageType.ToString()).FirstOrDefault().Remarks, }).ToList(); } catch (Exception ex) { resList.Msg = new Result_Msg() { IsSuccess = false, Message = ex.Message }; } return(resList); }
/*热销产品*/ public Result_List <OrderSynthesis_Index> GetHotSelling() { Result_List <OrderSynthesis_Index> resList = new Result_List <OrderSynthesis_Index>(); var topCountList = (from p in context.OrderItemInfo where p.ProductName != "" && p.ProductName != null && (from q in context.ProductInfo select q.Id).ToList().Contains(p.ProductId) group p by p.ProductId into g select new { ProductId = g.Key, Quantity = g.Sum(p => p.Quantity) } ).ToList(); ProductService _ProductService = new ProductService(); resList.List = topCountList.Take(10).Select(p => new OrderSynthesis_Index() { ProductName = _ProductService.GetProduct(p.ProductId) == null ? "" : _ProductService.GetProduct(p.ProductId).CASNo, SellNum = p.Quantity }).OrderByDescending(x => x.SellNum).ToList(); resList.List = (from p in resList.List where p.ProductName != "" && p.ProductName != null select new OrderSynthesis_Index { ProductName = p.ProductName.Length > 18 ? (p.ProductName.Substring(0, 18) + "...") : p.ProductName, SellNum = p.SellNum }).ToList(); return(resList); }
/// <summary> /// 下拉框赋值 /// </summary> /// <returns></returns> public string GetSelectOptionList() { Result_List <ChemCloud_Dictionaries> res = new Result_List <ChemCloud_Dictionaries>() { List = hashSet.Get_DictionariesList(), Msg = new Result_Msg() { IsSuccess = true } }; return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); }
public Result_List <OrderSynthesis_Index> GetTopNumOrderSynthesis(int count) { Result_List <OrderSynthesis_Index> resList = new Result_List <OrderSynthesis_Index>(); var topCountList = (from p in context.OrderItemInfo where p.ProductName != "" && p.ProductName != null orderby p.Id descending select p).ToList().Take(count); resList.List = topCountList.Select(x => new OrderSynthesis_Index() { ProductName = x.ProductName.Length > 18 ? (x.ProductName.Substring(0, 18) + "...") : x.ProductName, ProductCount = x.Quantity.ToString(), PackingUnit = x.PackingUnit, OrderTime = Convert.ToDateTime((from p in context.OrderInfo where p.Id == x.OrderId select p.OrderDate).FirstOrDefault()), Status = GetStatusNameByValue(Convert.ToInt32((from p in context.OrderInfo where p.Id == x.OrderId select p.OrderStatus).FirstOrDefault())) }).OrderByDescending(x => x.OrderTime).ToList(); return(resList); }
public Result_List <Result_Model <MeetingInfo> > Get_PreNext_ById_Web(long Id) { Result_List <Result_Model <MeetingInfo> > res = new Result_List <Result_Model <MeetingInfo> >(); try { IMeetInfoService jobsService = ServiceHelper.Create <IMeetInfoService>(); res = jobsService.Get_PreNext_ById_Web(Id); } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = "读取失败,失败原因:" + ex.Message }; } return(res); }
public Result_List <Result_Model <TechnicalInfo> > Get_PreNext_ById_Web(long Id) { Result_List <Result_Model <TechnicalInfo> > res = new Result_List <Result_Model <TechnicalInfo> >(); try { ITechnicalInfoService jobsService = ServiceHelper.Create <ITechnicalInfoService>(); res = jobsService.Get_PreNext_ById_Web(Id); } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = "Failed to read, cause of failure :" + ex.Message }; } return(res); }
public Result_List <Result_AttachmentInfo> GetObjectList_ById_Web(long Id) { Result_List <Result_AttachmentInfo> res = new Result_List <Result_AttachmentInfo>(); try { ILawInfoService jobsService = ServiceHelper.Create <ILawInfoService>(); res = jobsService.GetObjectList_ById_Web(Id); //res.List.Select(x => x.FileName == System.IO.Path.GetFileName(x.AttachmentName)); } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = "读取失败,失败原因:" + ex.Message }; } return(res); }
/// <summary> /// /// </summary> /// <param name="iWantToBuyId"></param> /// <returns></returns> public Result_List <Result_IWantToSupply> GetObjectById_Web_SupplyList(long iWantToBuyId) { Result_List <Result_IWantToSupply> res = new Result_List <Result_IWantToSupply>() { Msg = new Result_Msg() { IsSuccess = true }, List = new List <Result_IWantToSupply>() }; Result_List <IWantToSupply> list = iWantToBuyService.GetObjectById_Web_SupplyList(iWantToBuyId); if (list.Msg.IsSuccess) { var listHash = hashSet.Get_DictionariesList(); res.List = list.List.Select(x => new Result_IWantToSupply() { Id = x.Id, PurchaseNum = x.PurchaseNum.ToString(), IWantToBuyID = x.IWantToBuyID, UnitPrice = x.UnitPrice, Quantity = x.Quantity, Unit = x.Unit, TotalPrice = x.TotalPrice, SupplierID = x.SupplierID, TypeOfCurrency = listHash.Where(y => y.DictionaryTypeId == 1 && y.DValue == x.TypeOfCurrency.ToString()).FirstOrDefault().Remarks, ShopName = jobsService.GetCompanyInfo_ByUserIdAndUserType(x.SupplierID), CreateDate = x.CreateDate.ToString("yyyy-MM-dd hh:mm"), BidDate = x.BidDate.ToString("yyyy-MM-dd hh:mm"), LatestDeliveryTime = x.LatestDeliveryTime.ToString("yyyy-MM-dd hh:mm"), UpdateDate = x.UpdateDate.ToString("yyyy-MM-dd hh:mm"), Status = x.Status, StatusStr = listHash.Where(y => y.DictionaryTypeId == 108 && y.DKey == x.Status.ToString()).FirstOrDefault().DValue }).ToList(); } return(res); }
/// <summary> /// 加载首页Banner /// </summary> /// <returns></returns> public Result_List <Result_WhatBusy> Get_WhatBusy_Top(int count) { JobsService jobsService = new JobsService(); Result_List <Result_WhatBusy> resList = new Result_List <Result_WhatBusy>(); try { var list1 = (from p in context.WhatBusy select p).OrderByDescending(x => x.CreateDate).Take(count).ToList(); resList.List = list1.Select(x => new Result_WhatBusy() { Id = x.Id, BusyCotent = hashSet.Get_DictionariesList_ByTypeID(19).Where(y => y.DKey == x.BusyType.ToString()).FirstOrDefault().Remarks.Replace("#BusyContent#", x.BusyCotent.Length > 6 ? x.BusyCotent.Substring(0, 6) + "..." : x.BusyCotent), BusyType = x.BusyType, UserName = jobsService.GetCompanyInfo_ByUserIdAndUserType(x.UserId).Length > 6 ? jobsService.GetCompanyInfo_ByUserIdAndUserType(x.UserId).Substring(0, 6) + "..." : jobsService.GetCompanyInfo_ByUserIdAndUserType(x.UserId), BusyTypeName = hashSet.Get_DictionariesList_ByTypeID(19).Where(y => y.DKey == x.BusyType.ToString()).FirstOrDefault().DValue, IsShow = x.IsShow, UserId = x.UserId, TargetUrl = x.TargetUrl, CreateDate = x.CreateDate.ToString("MM-dd") }).ToList(); resList.List.Select(x => x.UserName.Length > 7 ? x.UserName.Substring(0, 7) + "**" : x.UserName); resList.Msg = new Result_Msg() { IsSuccess = true }; } catch (Exception ex) { resList.Msg = new Result_Msg() { IsSuccess = false, Message = "查询交易记录失败,失败原因:" + ex.Message }; } return(resList); }
public ActionResult Index() { string str; string[] strArrays; if (!IsInstalled()) { return(RedirectToAction("Agreement", "Installer")); } ServiceHelper.Create <IMemberService>(); ViewBag.OAuthValidateContents = GetOAuthValidateContents(); ViewBag.SiteName = base.CurrentSiteSetting.SiteName; dynamic viewBag = base.ViewBag; strArrays = (!string.IsNullOrWhiteSpace(base.CurrentSiteSetting.Hotkeywords) ? base.CurrentSiteSetting.Hotkeywords.Split(new char[] { ',' }) : new string[0]); viewBag.HotKeyWords = strArrays; str = (string.IsNullOrWhiteSpace(base.CurrentSiteSetting.Site_SEOTitle) ? "ChemCloud" : base.CurrentSiteSetting.Site_SEOTitle); ViewBag.Title = str; ViewEngines.Engines.FindView(base.ControllerContext, "Index", null); ViewBag.handImage = ServiceHelper.Create <ISlideAdsService>().GetHandSlidAds().ToList(); List <SlideAdInfo> list = ServiceHelper.Create <ISlideAdsService>().GetSlidAds(0, SlideAdInfo.SlideAdType.PlatformHome).ToList(); ViewBag.slideImage = list; //banner列表(轮播图) Result_List <Result_BannersIndex> bannerList = ServiceHelper.Create <IBannersIndexService>().GetBannerList_IndexPage(1); ViewBag.Banners = bannerList; //交易动态 Result_List <OrderSynthesis_Index> dynamicTrading = ServiceHelper.Create <IOrderSynthesisService>().GetTopNumOrderSynthesis(26); ViewBag.DynamicTrading = dynamicTrading; //最近动态报价 Result_List <ProductInfoSpec> latestPrice = ServiceHelper.Create <IProductService>().Get_Products_Top(30); ViewBag.LatestPrice = latestPrice; //大家都在忙什么 Result_List <Result_WhatBusy> whatBusy = ServiceHelper.Create <IWhatBusyService>().Get_WhatBusy_Top(26); ViewBag.WhatBusyList = whatBusy; //热销产品 Result_List <OrderSynthesis_Index> HotSelling = ServiceHelper.Create <IOrderSynthesisService>().GetHotSelling(); ViewBag.HotSelling = HotSelling; IEnumerable <ImageAdInfo> imageAds = ServiceHelper.Create <ISlideAdsService>().GetImageAds(0); ViewBag.imageAds = imageAds.Where((ImageAdInfo p) => { if (p.Id <= 0) { return(false); } return(p.Id <= 4); }).ToList(); dynamic viewBag1 = base.ViewBag; IEnumerable <ImageAdInfo> imageAdInfos = ServiceHelper.Create <ISlideAdsService>().GetImageAds(0); ViewBag.imageAdsTop = imageAdInfos.Where((ImageAdInfo p) => { if (p.Id == 14) { return(true); } return(p.Id == 15); }).ToList(); ChemCloud.Service.SiteSettingService a = new ChemCloud.Service.SiteSettingService(); ViewBag.FirstAmount = int.Parse(a.GetSiteValue("FirstAmount")); ViewBag.SecondAmount = int.Parse(a.GetSiteValue("SecondAmount")); ViewBag.leijiFirstAmount = int.Parse(a.GetSiteValue("leijiFirstAmount")); ViewBag.leijiSecondAmount = int.Parse(a.GetSiteValue("leijiSecondAmount")); DateTime Runtime = DateTime.Parse(a.GetSiteValue("Runtime")); DateTime Now = DateTime.Now.Date; System.TimeSpan ts = Now - Runtime; int OperationDays = ts.Days + 1; if (OperationDays <= 0) { OperationDays = 1; } ViewBag.OperationDays = OperationDays; ViewBag.Operationreport = a.GetSiteValue("Operationreport"); if (string.IsNullOrEmpty(ViewBag.Operationreport)) { ViewBag.Operationreport = "http://47.90.8.156:9100/album/yybg.pdf"; } //List<ProductInfo> productInfo = ServiceHelper.Create<IProductService>().RecommendProductList().ToList<ProductInfo>(); //ViewBag.Products = productInfo; List <RecommendInfo> model = ServiceHelper.Create <IRecommendInfoService>().GetRecommendByStatus(); ViewBag.Products = model; int typeid = Convert.ToInt32(ServiceHelper.Create <ISiteSettingService>().GetSiteValue("RecommandIndexImg")); List <RecFloorImg> rfiList = ServiceHelper.Create <IRecFloorImgService>().GetAll(4); ViewBag.typeid = typeid; ViewBag.rfiList = rfiList; List <ArticleInfo> articles = ServiceHelper.Create <IArticleService>().GetArticleByArticleCategoryId(21).ToList <ArticleInfo>(); foreach (ArticleInfo item in articles) { item.Content = NoHTML(item.Content); if (item.Content.Length > 100) { item.Content = item.Content.Substring(0, 100) + ".."; } } ViewBag.news = articles; return(View()); }
public string IWantToSupply_UpdateStatus7(QueryCommon <IWantToSupplyQuery> query) { DateTime dtNow = DateTime.Now; QueryCommon <IWantToSupplyQuery> query1 = new QueryCommon <IWantToSupplyQuery>() { ParamInfo = new IWantToSupplyQuery() }; query1.ParamInfo.Id = query.ParamInfo.Id; query1.ParamInfo.UpdateDate = dtNow; query1.ParamInfo.BidDate = dtNow; QueryCommon <IWantToBuyQuery> query2 = new QueryCommon <IWantToBuyQuery>() { ParamInfo = new IWantToBuyQuery() }; query2.ParamInfo.UpdateDate = dtNow; query2.ParamInfo.Id = query.ParamInfo.IWantToBuyID; QueryCommon <IWantToBuy_Orders> query3 = new QueryCommon <IWantToBuy_Orders>() { ParamInfo = new IWantToBuy_Orders() }; query3.ParamInfo.IWantToSupplyID = query.ParamInfo.Id; Result_Msg res = new Result_Msg() { IsSuccess = true }; Result_List <Result_IWantToSupply> list = GetObjectById_Web_SupplyList(query.ParamInfo.IWantToBuyID); try { if (list.Msg.IsSuccess) { Result_Model <IWantToSupply> max = iWantToBuyService.MaxStatusSupply_By_Num(Convert.ToInt64(list.List.FirstOrDefault().PurchaseNum)); if (max.Msg.IsSuccess && max.Model.Status != 6) { res.Message = "当前订单异常(报价状态异常)"; res.IsSuccess = false; return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); } query2.ParamInfo.Status = 7; iWantToBuyService.UpdateBuy_Status(query2);//签收采购单 query1.ParamInfo.Status = 7; iWantToBuyService.UpdateSupply_Status(query1);//签收竞价单 query3.ParamInfo.Status = 7; iWantToBuyService.UpdateOrders_Status(query3);//签收订单 } } catch (Exception ex) { res.IsSuccess = false; res.Message = ex.Message; } return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); }
public string IWantToSupply_UpdateStatus(QueryCommon <IWantToSupplyQuery> query) { DateTime dtNow = DateTime.Now; QueryCommon <IWantToSupplyQuery> query1 = new QueryCommon <IWantToSupplyQuery>() { ParamInfo = new IWantToSupplyQuery() }; query1.ParamInfo.UpdateDate = dtNow; query1.ParamInfo.BidDate = dtNow; int status = query.ParamInfo.Status; QueryCommon <IWantToBuyQuery> query2 = new QueryCommon <IWantToBuyQuery>() { ParamInfo = new IWantToBuyQuery() }; query2.ParamInfo.UpdateDate = dtNow; query2.ParamInfo.Id = query.ParamInfo.IWantToBuyID; Result_Msg res = new Result_Msg() { IsSuccess = true }; Result_List <Result_IWantToSupply> list = GetObjectById_Web_SupplyList(query.ParamInfo.IWantToBuyID); try { if (list.Msg.IsSuccess) { Result_Model <IWantToSupply> max = iWantToBuyService.MaxStatusSupply_By_Num(Convert.ToInt64(list.List.FirstOrDefault().PurchaseNum)); if (max.Msg.IsSuccess) { switch (max.Model.Status) { case 4: res.Message = "已下单,无法修改中标状态"; break; case 5: res.Message = "已支付,无法修改中标状态"; break; case 6: res.Message = "已发货,无法修改中标状态"; break; case 7: res.Message = "已签收,无法修改中标状态"; break; default: break; } res.IsSuccess = false; return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); } foreach (var item in list.List) { query1.ParamInfo.Id = item.Id; if (query.ParamInfo.Id == item.Id) { #region 修改当前操作信息 switch (status) { case 0: //设为:竞价成功 query1.ParamInfo.Status = 1; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 3; iWantToBuyService.UpdateBuy_Status(query2); break; case 1: //设为:竞价失败 query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 0; iWantToBuyService.UpdateBuy_Status(query2); break; case 2: //设为:竞价成功 query1.ParamInfo.Status = 1; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 3; iWantToBuyService.UpdateBuy_Status(query2); break; case 3: //—————— break; default: break; } #endregion } else { #region 修改其他信息 switch (status) { case 0: //设为:竞价失败 if (item.Status != 3) { query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); } else { } break; case 1: //—————— break; case 2: //设为:竞价失败 if (item.Status != 3) { query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); } else { } break; case 3: //—————— break; default: break; } #endregion } } } } catch (Exception ex) { res.IsSuccess = false; res.Message = ex.Message; } return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); }
public Result_List <Result_Model <Result_IWantToBuy> > Get_PreNext_ById_Web(long Id) { Result_List <Result_Model <Result_IWantToBuy> > res = new Result_List <Result_Model <Result_IWantToBuy> >() { Msg = new Result_Msg() { IsSuccess = true }, List = new List <Result_Model <Result_IWantToBuy> >() }; try { var listHash = hashSet.Get_DictionariesList(); Result_List <Result_Model <IWantToBuy> > resIWantToBuy = iWantToBuyService.Get_PreNext_ById_Web(Id); res.Msg = resIWantToBuy.Msg; if (resIWantToBuy != null && resIWantToBuy.Msg.IsSuccess) { foreach (var item in resIWantToBuy.List) { if (item.Msg.IsSuccess) { res.List.Add(new Result_Model <Result_IWantToBuy>() { Model = new Result_IWantToBuy() { Id = item.Model.Id, //EndDate = item.Model.EndDate.ToString("yyyy-MM-dd HH;mm"), //CreateDate = item.Model.CreateDate.ToString("yyyy-MM-dd HH;mm"), //StartDate = item.Model.StartDate.ToString("yyyy-MM-dd HH;mm"), //UpdateDate = item.Model.UpdateDate.ToString("yyyy-MM-dd HH;mm") //UserId = item.Model.UserId, //LanguageType = item.Model.LanguageType == 1 ? listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == item.Model.LanguageType.ToString()).FirstOrDefault().DKey : listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == item.Model.LanguageType.ToString()).FirstOrDefault().Remarks, }, Msg = item.Msg }); } else { res.List.Add(new Result_Model <Result_IWantToBuy>() { Model = new Result_IWantToBuy(), Msg = item.Msg }); } } } else { res.Msg = resIWantToBuy.Msg; } } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = ex.Message }; } return(res); }
public Result_List <Result_Model <Result_Jobs> > Get_PreNext_ById_Web(long Id, int workType, int languageType) { Result_List <Result_Model <Result_Jobs> > res = new Result_List <Result_Model <Result_Jobs> >() { Msg = new Result_Msg() { IsSuccess = true }, List = new List <Result_Model <Result_Jobs> >() }; try { var listHash = hashSet.Get_DictionariesList(); Result_List <Result_Model <Jobs> > resJobs = jobsService.Get_PreNext_ById_Web(Id, workType, languageType); res.Msg = resJobs.Msg; if (resJobs != null && resJobs.Msg.IsSuccess) { foreach (var item in resJobs.List) { if (item.Msg.IsSuccess) { res.List.Add(new Result_Model <Result_Jobs>() { Model = new Result_Jobs() { Id = item.Model.Id, JobTitle = item.Model.JobTitle, EndDate = item.Model.EndDate.ToString("yyyy-MM-dd HH;mm"), CreateDate = item.Model.CreateDate.ToString("yyyy-MM-dd HH;mm"), JobContent = item.Model.JobContent, ApprovalStatus = listHash.Where(y => y.DictionaryTypeId == 14 && y.DKey == item.Model.ApprovalStatus.ToString()).FirstOrDefault().DValue, Reviewer = item.Model.Reviewer, StartDate = item.Model.StartDate.ToString("yyyy-MM-dd HH;mm"), UpdateDate = item.Model.UpdateDate.ToString("yyyy-MM-dd HH;mm"), //UserId = item.Model.UserId, UserType = listHash.Where(y => y.DictionaryTypeId == 15 && y.DKey == item.Model.UserType.ToString()).FirstOrDefault().DValue, LanguageType = item.Model.LanguageType == 1 ? listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == item.Model.LanguageType.ToString()).FirstOrDefault().DKey : listHash.Where(y => y.DictionaryTypeId == 10 && y.DValue == item.Model.LanguageType.ToString()).FirstOrDefault().Remarks, }, Msg = item.Msg }); } else { res.List.Add(new Result_Model <Result_Jobs>() { Model = new Result_Jobs(), Msg = item.Msg }); } } } else { res.Msg = resJobs.Msg; } } catch (Exception ex) { res.Msg = new Result_Msg() { IsSuccess = false, Message = ex.Message }; } return(res); }
public JsonResult Post([FromBody] Search search) { // Data structure to hold names of subfolders to be // examined for files. Stack <string> dirs = new Stack <string>(20); if (!System.IO.Directory.Exists(search.Root)) { throw new ArgumentException(); } Result_Data result_Data; Result_List result_List = new Result_List(); List <Result_Data> results = new List <Result_Data>(); List <string> listFile = new List <string>(); int amount = 0; dirs.Push(search.Root); while (dirs.Count > 0) { string currentDir = dirs.Pop(); string[] subDirs; try { subDirs = System.IO.Directory.GetDirectories(currentDir); } // An UnauthorizedAccessException exception will be thrown if we do not have // discovery permission on a folder or file. It may or may not be acceptable // to ignore the exception and continue enumerating the remaining files and // folders. It is also possible (but unlikely) that a DirectoryNotFound exception // will be raised. This will happen if currentDir has been deleted by // another application or thread after our call to Directory.Exists. The // choice of which exceptions to catch depends entirely on the specific task // you are intending to perform and also on how much you know with certainty // about the systems on which this code will run. catch (UnauthorizedAccessException e) { Console.WriteLine(e.Message); continue; } catch (System.IO.DirectoryNotFoundException e) { Console.WriteLine(e.Message); continue; } string[] files = null; try { files = System.IO.Directory.GetFiles(currentDir); } catch (UnauthorizedAccessException e) { //Console.WriteLine(e.Message); continue; } catch (System.IO.DirectoryNotFoundException e) { //Console.WriteLine(e.Message); continue; } // Perform the required action on each file here. // Modify this block to perform your required task. foreach (string file in files) { try { // Perform whatever action is required in your scenario. System.IO.FileInfo fi = new System.IO.FileInfo(file); if (fi.Extension == ".json") { //Console.WriteLine("****************{0}: {1}, {2} файл № {3}", fi.Name, fi.Length, fi.CreationTimeUtc, amount); FileStream fs = new FileStream(file, FileMode.Open); StreamReader sr = new StreamReader(fs); //Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.Linq.JObject.Parse(); string json = sr.ReadToEnd(); ////Console.WriteLine("***********json************"); ////Console.WriteLine(json); //foreach (var searchContentInFile in search.Contents) //{ // if (json.Contains(searchContentInFile.ContentField)) // { // Console.WriteLine(fi.FullName); // listFile.Add(file); // } //} try { JObject jo = JObject.Parse(json); foreach (var searchContent in search.Contents) { string s = "$.." + searchContent.NameField; IEnumerable <JToken> findFilds = jo.SelectTokens(s); foreach (var contentField in findFilds) { if (searchContent.ContentField == contentField.ToString()) { result_Data = new Result_Data() { Path = file, Field = searchContent.NameField, Value = contentField.ToString() }; results.Add(result_Data); amount++; } } } } catch (Exception e) { // Console.WriteLine(e.Message); continue; } try { JArray jj = JArray.Parse(json); foreach (var searchContent in search.Contents) { string s = "$.." + searchContent.NameField; IEnumerable <JToken> findFilds = jj.SelectTokens(s); foreach (var contentField in findFilds) { if (searchContent.ContentField == contentField.ToString()) { result_Data = new Result_Data() { Path = file, Field = searchContent.NameField, Value = contentField.ToString() }; results.Add(result_Data); amount++; } } } } catch (Exception e) { //Console.WriteLine(e.Message); continue; } //JsonTextReader jsonTextReader = new JsonTextReader(@sr) //{ // MaxDepth = 3 //}; //while (jsonTextReader.Read()) //{ // if (jsonTextReader.Value != null) // { // // Console.WriteLine("Token: {0}, Value: {1} Depth {2}", jsonTextReader.TokenType, jsonTextReader.Value, jsonTextReader.Depth); // foreach (var searchContent in search.Contents) // { // if (jsonTextReader.TokenType.ToString() == "PropertyName") // { // if (jsonTextReader.Value.ToString() == searchContent.NameField) // { // // Console.Write("Field = {0} ======>>>>>>> ", jsonTextReader.Value); // jsonTextReader.ReadAsString(); // if (jsonTextReader.Value.ToString() == searchContent.ContentField) // { // // Console.WriteLine("Field Value = {0}", jsonTextReader.Value); // // Console.WriteLine("Token: {0}, Value: {1} Depth {2}" , jsonTextReader.TokenType, jsonTextReader.Value, jsonTextReader.Depth); // result_Data = new Result_Data() { Path = file, Field = searchContent.NameField+ " Depth " + jsonTextReader.Depth, Value = jsonTextReader.Value.ToString() }; // results.Add(result_Data); // amount++; // } // } // } // } // } // else // { // // Console.WriteLine("Token: {0}", jsonTextReader.TokenType); // } //} /* JObject jo = (JObject)JToken.ReadFrom(jsonTextReader); * Console.WriteLine(jo); * foreach (var searchContent in search.Contents) * { * Console.WriteLine("searchContent.NameField {0}",searchContent.NameField); * string nameField = ".." + searchContent.NameField; * var namesField = jo.SelectTokens(nameField); * var contentFields = namesField.Select(x => (x as JValue).Value); * foreach (var contentField in contentFields) * { * Console.WriteLine("nameField {0} contentField {1}",nameField, contentField); * if (searchContent.ContentField == contentField.ToString()) * { * result_Data = new Result_Data() { Path = file, Field = nameField, Value = contentField.ToString() }; * results.Add(result_Data); * amount++; * } * } * } */ fs.Close(); // Console.ReadKey(); } } catch (System.IO.FileNotFoundException e) { // If file was deleted by a separate application // or thread since the call to TraverseTree() // then just continue. Console.WriteLine(e.Message); continue; } } // Push the subdirectories onto the stack for traversal. // This could also be done before handing the files. foreach (string str in subDirs) { dirs.Push(str); } result_List = new Result_List() { Amount = amount, Results = results }; } return(new JsonResult(result_List)); }
/// <summary> /// 前后两条记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public Result_List <Result_Model <LawInfo> > Get_PreNext_ById_Web(long id) { Result_List <Result_Model <LawInfo> > res = new Result_List <Result_Model <LawInfo> >() { List = new List <Result_Model <LawInfo> >(), Msg = new Result_Msg() { IsSuccess = true } }; try { var linqList = (from listMeet in context.LawInfo select listMeet).OrderBy(p => p.CreateTime).OrderByDescending(p => p.Id).ToList(); int indexNo = linqList.IndexOf(linqList.First(x => x.Id == id)); if (indexNo > 0) { LawInfo pre = linqList.Skip(indexNo - 1).Take(1).First(); if (pre != null) { res.List.Add(new Result_Model <LawInfo>() { Model = pre, Msg = new Result_Msg() { IsSuccess = true } }); } else { res.List.Add(new Result_Model <LawInfo>() { Msg = new Result_Msg() { IsSuccess = false, Message = "获取上一条信息失败" } }); } } else { res.List.Add(new Result_Model <LawInfo>() { Msg = new Result_Msg() { IsSuccess = false, Message = "上一条没有了" } }); } if (indexNo < (linqList.Count - 1)) { LawInfo next = linqList.Skip(indexNo + 1).Take(1).First(); if (next != null) { res.List.Add(new Result_Model <LawInfo>() { Model = next, Msg = new Result_Msg() { IsSuccess = true } }); } else { res.List.Add(new Result_Model <LawInfo>() { Msg = new Result_Msg() { IsSuccess = false, Message = "获取下一条信息失败" } }); } } else { res.List.Add(new Result_Model <LawInfo>() { Msg = new Result_Msg() { IsSuccess = false, Message = "下一条没有了" } }); } } catch (Exception ex) { res.Msg.IsSuccess = false; res.Msg.Message = "查询失败,失败原因:" + ex.Message; } return(res); }
public string IWantToBuy_UpdateStatus(QueryCommon <IWantToSupplyQuery> query) { DateTime dtNow = DateTime.Now; QueryCommon <IWantToSupplyQuery> query1 = new QueryCommon <IWantToSupplyQuery>() { ParamInfo = new IWantToSupplyQuery() }; query1.ParamInfo.UpdateDate = dtNow; query1.ParamInfo.BidDate = dtNow; int status = query.ParamInfo.Status; QueryCommon <IWantToBuyQuery> query2 = new QueryCommon <IWantToBuyQuery>() { ParamInfo = new IWantToBuyQuery() }; query2.ParamInfo.UpdateDate = dtNow; query2.ParamInfo.Id = query.ParamInfo.IWantToBuyID; Result_Msg res = new Result_Msg() { IsSuccess = true }; Result_List <Result_IWantToSupply> list = Get_SupplyList_ByIWantToBuyId(query.ParamInfo.IWantToBuyID); try { if (list.Msg.IsSuccess) { foreach (var item in list.List) { query1.ParamInfo.Id = item.Id; if (query.ParamInfo.Id == item.Id) { switch (status) { case 0: //设为:竞价成功 query1.ParamInfo.Status = 1; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 3; iWantToBuyService.UpdateBuy_Status(query2); break; case 1: //设为:竞价失败 query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 0; iWantToBuyService.UpdateBuy_Status(query2); break; case 2: //设为:竞价成功 query1.ParamInfo.Status = 1; iWantToBuyService.UpdateSupply_Status(query1); query2.ParamInfo.Status = 3; iWantToBuyService.UpdateBuy_Status(query2); break; case 3: //—————— break; default: break; } } else { switch (status) { case 0: //设为:竞价失败 if (item.Status != 3) { query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); } else { } break; case 1: //—————— break; case 2: //设为:竞价失败 if (item.Status != 3) { query1.ParamInfo.Status = 2; iWantToBuyService.UpdateSupply_Status(query1); } else { } break; case 3: //—————— break; default: break; } } } } } catch (Exception ex) { res.IsSuccess = false; res.Message = ex.Message; } return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); }
public Result_List <OrderSynthesis_Index> GetTopNumOrderSynthesis(int count) { Result_List <OrderSynthesis_Index> list = ServiceHelper.Create <IOrderSynthesisService>().GetTopNumOrderSynthesis(count); return(list); }
public JsonResult Post([FromBody] Search search) { int fileCount = 0; var sw = Stopwatch.StartNew(); Result_Data result_Data; Result_List result_List = new Result_List(); List <Result_Data> results = new List <Result_Data>(); List <string> listFile = new List <string>(); int amountFind = 0; var files = Directory.EnumerateFiles(search.Root, "*.json", SearchOption.AllDirectories); Parallel.ForEach(files, (file) => { StreamReader sr = new StreamReader(file); string json = sr.ReadToEnd(); try { JObject jo = JObject.Parse(json); foreach (var searchContent in search.Contents) { string s = "$.." + searchContent.NameField; IEnumerable <JToken> findFilds = jo.SelectTokens(s); Parallel.ForEach(findFilds, (contentField) => { if (searchContent.ContentField == contentField.ToString()) { result_Data = new Result_Data() { Path = file, Field = searchContent.NameField, Value = contentField.ToString() }; results.Add(result_Data); amountFind++; } }); } } catch (Exception) { } try { JArray jj = JArray.Parse(json); foreach (var searchContent in search.Contents) { string s = "$.." + searchContent.NameField; IEnumerable <JToken> findFilds = jj.SelectTokens(s); Parallel.ForEach(findFilds, (contentField) => { if (searchContent.ContentField == contentField.ToString()) { result_Data = new Result_Data() { Path = file, Field = searchContent.NameField, Value = contentField.ToString() }; results.Add(result_Data); amountFind++; } }); } } catch (Exception) { } fileCount++; }); Console.WriteLine("Processed {0} files in {1} milliseconds", fileCount, sw.ElapsedMilliseconds); return(new JsonResult(results)); }
/// <summary> /// 前后两条记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public Result_List <Result_Model <Jobs> > Get_PreNext_ById_Web(long id, int workType, int languageType) { Result_List <Result_Model <Jobs> > res = new Result_List <Result_Model <Jobs> >() { List = new List <Result_Model <Jobs> >(), Msg = new Result_Msg() { IsSuccess = true } }; List <Jobs> linqList = new List <Jobs>(); try { if (workType == 3)//所有 { linqList = (from listMeet in context.Jobs where listMeet.ApprovalStatus == 3 && listMeet.LanguageType == languageType select listMeet).OrderBy(p => p.EndDate).OrderByDescending(p => p.Id).ToList(); } else { linqList = (from listMeet in context.Jobs where listMeet.ApprovalStatus == 3 && listMeet.LanguageType == languageType && listMeet.WorkType == workType select listMeet).OrderBy(p => p.EndDate).OrderByDescending(p => p.Id).ToList(); } int indexNo = linqList.IndexOf(linqList.First(x => x.Id == id)); if (indexNo > 0) { Jobs pre = linqList.Skip(indexNo - 1).Take(1).First(); if (pre != null) { res.List.Add(new Result_Model <Jobs>() { Model = pre, Msg = new Result_Msg() { IsSuccess = true } }); } else { res.List.Add(new Result_Model <Jobs>() { Msg = new Result_Msg() { IsSuccess = false, Message = "获取上一条信息失败" } }); } } else { res.List.Add(new Result_Model <Jobs>() { Msg = new Result_Msg() { IsSuccess = false, Message = "上一条没有了" } }); } if (indexNo < (linqList.Count - 1)) { Jobs next = linqList.Skip(indexNo + 1).Take(1).First(); //Jobs next = linqList.Skip(indexNo + 1).Take(1).First(); if (next != null) { res.List.Add(new Result_Model <Jobs>() { Model = next, Msg = new Result_Msg() { IsSuccess = true } }); } else { res.List.Add(new Result_Model <Jobs>() { Msg = new Result_Msg() { IsSuccess = false, Message = "获取下一条信息失败" } }); } } else { res.List.Add(new Result_Model <Jobs>() { Msg = new Result_Msg() { IsSuccess = false, Message = "下一条没有了" } }); } } catch (Exception ex) { res.Msg.IsSuccess = false; res.Msg.Message = ex.Message; } return(res); }