public static List<TagProcessResult> ProcessTagSet(List<TagSimple> tagSet) { var resultList = new List<TagProcessResult>(); // Spellcheck tagSet.ForEach(t => resultList.Add( new TagProcessResult { TagId = t.TagId, TagValue = t.TagValue, WordProcessResultList = t.TagValue.Split(' ').ToList().Select(w => ProcessWord(w, t.TagId)).ToList() })); var correctlySpelledTagList = resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList(); resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetTest(correctlySpelledTagList, tpr)); //// Check all tags that are 100% spelled correctly for a duplicate in provided set. //resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetForDuplicates(correctlySpelledTagList, tpr)); //// Check all tags that are unique in the provided set of tags and are 100% spelled correctly for a duplicate in the media tag repository. //resultList.Where(t => !t.DuplicateTagId.HasValue && t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(CheckRepositoryForDuplicates); //resultList.Where(t => !t.MediaTagId.HasValue).ToList().ForEach(t => CheckTagSetForSynonyms(correctlySpelledTagList, t)); return resultList; }
public IList<Model.DJ_GroupConsumRecord> GetByDate(int year, int month, string code, int djsid, bool? IsVerified_City, bool? IsVerified_Country) { List<DJ_GroupConsumRecord> ListRecord = IDjgroup.GetByDate(year, month, code, djsid, IsVerified_City, IsVerified_Country).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0) { //加入省市县的判断 //省 if (code.Substring(2) == "0000") { } else if (code.Substring(4, 2) == "00") { if (item.Enterprise.Area.Code.Substring(0,4) == code.Substring(0,4)) { List.Add(item); } } else { if (item.Enterprise.Area.Code == code) { List.Add(item); } } } } return List; }
public static IEnumerable<RecordStatistic> GetStatistics(IEnumerable<RecordData> recordDatas) { IList<RecordStatistic> Statistics = new List<RecordStatistic>(); RecordStatistic statistic; foreach (var record in recordDatas) { statistic = Statistics.Where(s => s.ResourceType == record.ResourceType && s.ResourceName == record.ResourceName).FirstOrDefault(); TimeSpan duration = record.EndTime - record.StartTime; if (statistic == null) //尚未统计该条record { statistic = new RecordStatistic(); statistic.ResourceName = record.ResourceName; statistic.ResourceType = record.ResourceType; statistic.ResourceType = record.ResourceType; statistic.TotalHours = duration.TotalHours; statistic.TotalMinutes = duration.TotalMinutes; Statistics.Add(statistic); } else { statistic.TotalHours += duration.TotalHours; statistic.TotalMinutes += duration.TotalMinutes; } } return Statistics; }
public List<DJ_GroupConsumRecord> GetByDate(int year, int month, int entid, int djsid, bool? IsVerified_City, bool? IsVerified_Country) { List<DJ_GroupConsumRecord> ListRecord = IDjgroup.GetByDate(year, month, entid, djsid, IsVerified_City, IsVerified_Country).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0) { List.Add(item); } } return List; }
public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes) { if (!guideProgram.PreviouslyAiredTime.HasValue) { return false; } this.MatchAttempts++; var match = episodes.Where(e => e.FirstAired == guideProgram.PreviouslyAiredTime).FirstOrDefault(); if (match != null) { return this.Matched(guideProgram, match); } return this.Unmatched(guideProgram); }
private static string BuildFailureMessage(List<Build> builds) { var failedBuilds = builds.Where(b => !IsSuccesfullBuild(b)).ToList(); var build = builds.First(); var stringBuilder = new StringBuilder(); stringBuilder .AppendFormat( //todo externalize this in settings @"<img src='http://ci.innoveo.com/img/buildStates/buildFailed.png' height='16' width='16'/><strong>Failed</strong> to build {0} branch {1} with build number <a href=""{2}""><strong>{3}</strong></a>. Failed build(s) ", build.projectName, build.branchName, build.buildStatusUrl, build.buildNumber); stringBuilder.Append( string.Join(", ", failedBuilds.Select(fb => string.Format(@"<a href=""{0}""><strong>{1}</strong></a>", fb.buildStatusUrl, fb.buildName)))); return stringBuilder.ToString(); }
public void CalculateAbsoluteNumbers(List<TvdbEpisode> episodes) { int absoluteNumber = 0; var actualEpisodes = episodes.Where(x => x.IsSpecial == false).ToList(); actualEpisodes.Sort(new TvEpisodeComparer()); foreach (var episode in actualEpisodes) { if (episode.AbsoluteNumber != -99) { absoluteNumber = episode.AbsoluteNumber; } else { absoluteNumber++; episode.AbsoluteNumber = absoluteNumber; } } }
public List<Pro_details_entity> Load_search_result(string _txt,int type,int _idcat) { List<Pro_details_entity> l = new List<Pro_details_entity>(); string[] arr = _txt.Split(' '); for (int s = 0; s < arr.Length; s++) { if (s == 0) { var list = (from c in db.ESHOP_NEWS_CATs join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID where (SqlMethods.Like(a.NEWS_KEYWORD_ASCII, ClearUnicode("%" + arr[s] + "%"))) && a.NEWS_TYPE == type && (_idcat != 0 ? (b.CAT_ID == _idcat || b.CAT_PARENT_PATH.Contains(_idcat.ToString())) : _idcat == 0) select new { a.NEWS_ID, a.NEWS_TITLE, a.NEWS_IMAGE3, a.NEWS_PRICE1, a.NEWS_PRICE2, a.NEWS_DESC, a.NEWS_SEO_URL, a.NEWS_URL, a.NEWS_ORDER, a.NEWS_ORDER_PERIOD, a.NEWS_PUBLISHDATE, a.NEWS_FIELD3 }).Distinct().OrderByDescending(n => n.NEWS_ID).OrderByDescending(n => n.NEWS_ORDER); foreach (var i in list) { Pro_details_entity pro = new Pro_details_entity(); pro.NEWS_ID = i.NEWS_ID; pro.NEWS_TITLE = i.NEWS_TITLE; pro.NEWS_IMAGE3 = i.NEWS_IMAGE3; pro.NEWS_DESC = i.NEWS_DESC; pro.NEWS_SEO_URL = i.NEWS_SEO_URL; pro.NEWS_URL = i.NEWS_URL; pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER); pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD); pro.NEWS_PRICE1 = Utils.CDecDef(i.NEWS_PRICE1); pro.NEWS_PRICE2 = Utils.CDecDef(i.NEWS_PRICE2); pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now); pro.NEWS_FIELD3 = i.NEWS_FIELD3; pro.CAT_SEO_URL = ""; l.Add(pro); } } else { var list = l.Where(n => n.NEWS_TITLE.ToLower().Contains(arr[s].ToLower())).ToList(); if (list != null && list.Count > 0) l = list; } } return l; }
public List<DJ_GovManageDepartment> GetDptRecord(string beginTime, string endTime, string dptname, int entid, bool? IsVerified_City, bool? IsVerified_Country) { List<Model.DJ_GroupConsumRecord> ListRecord = IDjgroup.GetDptRecordByCondition(beginTime, endTime, dptname, entid, IsVerified_City, IsVerified_Country).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0) { List.Add(item); } } List<DJ_GovManageDepartment> ListGovDpt = new BLLDJ_GovManageDepartment().GetGovDptByName(dptname).ToList(); List<DJ_GovManageDepartment> ListGovWdpt = new List<DJ_GovManageDepartment>(); foreach (DJ_GovManageDepartment item in ListGovDpt) { foreach (DJ_GroupConsumRecord record in List) { //省 if (item.Area.Code.Substring(2) == "0000") { //省的暂时不做处理 } //市 else if (item.Area.Code.Substring(4,2) == "00") { if (item.Area.Code.Substring(0, 4) == record.Enterprise.Area.Code.Substring(0, 4)) { ListGovWdpt.Add(item); break; } } //县 else { if (item.Area.Code.Substring(0, 6) == record.Enterprise.Area.Code.Substring(0, 6)) { ListGovWdpt.Add(item); break; } } } } return ListGovWdpt; }
/// <summary> /// 地接社其他企业统计信息 /// </summary> /// <param name="dateyear">查询年份</param> /// <param name="EntName">查询企业名称</param> /// <param name="EntId">所在地接社id</param> /// <returns>查询出的企业列表</returns> public IList<DJ_TourEnterprise> GetDJStaticsEnt(string bengintime, string endtime, string EntName, int type, int EntId, bool? IsVerified_City, bool? IsVerified_Country) { List<DJ_GroupConsumRecord> ListRecord = GetRecordByCondition(bengintime, endtime, EntName, type, EntId, IsVerified_City, IsVerified_Country).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x=>x.Enterprise.Id==item.Enterprise.Id).Count() == 0) { List.Add(item); } } List<DJ_TourEnterprise> ListTE = new List<DJ_TourEnterprise>(); foreach (IGrouping<DJ_TourEnterprise, DJ_GroupConsumRecord> item in List.GroupBy(x => x.Enterprise).ToList()) { ListTE.Add(item.Key); } return ListTE; }
public void GetDetailDptCount(string beginTime, string endTime, string code, int entid, out int people, out int room, out int appendbed, out int visited, bool? IsVerified_City, bool? IsVerified_Country) { people = room = appendbed = visited = 0; List<Model.DJ_GroupConsumRecord> ListRecord = IDjgroup.GetDptRecordByCondition(beginTime, endTime, "", entid,IsVerified_City,IsVerified_Country).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0) { List.Add(item); } } if (code.Substring(2) == "0000") { //省的不会出现 } else if (code.Substring(4, 2) == "00") { foreach (DJ_GroupConsumRecord item in List.Where(x => x.Enterprise.Area.Code.Substring(0, 4) == code.Substring(0, 4))) { if (item.Enterprise.Type==EnterpriseType.宾馆) { people += (item.AdultsAmount + item.ChildrenAmount) * (item.LiveDay); room += item.RoomNum; appendbed += item.AppendBed; } else if (item.Enterprise.Type == EnterpriseType.景点) { visited += item.AdultsAmount + item.ChildrenAmount; } } } else { foreach (DJ_GroupConsumRecord item in List.Where(x => x.Enterprise.Area.Code.Substring(0, 6) == code.Substring(0, 6))) { if (item.Enterprise.Type == EnterpriseType.宾馆) { people += (item.AdultsAmount + item.ChildrenAmount) * (item.LiveDay); room += item.RoomNum; appendbed += item.AppendBed; } else if (item.Enterprise.Type == EnterpriseType.景点) { visited += item.AdultsAmount + item.ChildrenAmount; } } } }
public void GetCountByStatics(string begintime, string endtime, string EntName, int type, int EntId, int Enttype, int Wentid,out int people,out int room,out int appendbed) { people = room = appendbed = 0; List<DJ_GroupConsumRecord> ListRecord = GetRecordByCondition(begintime, endtime, EntName, type, EntId,null,null).ToList(); //过滤掉有相同团队的记录 List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0) { List.Add(item); } } List = List.Where(x => x.Enterprise.Id == Wentid).ToList(); if (Enttype == 1) { foreach (DJ_GroupConsumRecord item in List) { people += item.AdultsAmount + item.ChildrenAmount; } } if (Enttype == 4) { foreach (DJ_GroupConsumRecord item in List) { people += (item.AdultsAmount + item.ChildrenAmount)*item.LiveDay; room += item.RoomNum; appendbed += item.AppendBed; } } }
/// <summary> /// GeneratePo /// </summary> /// <param name="proposePoList">proposePoList(EmpID, EstDate, ItemID, supplier1Qty, supplier2Qty, supplier3Qty)</param> /// <returns></returns> public bool generatePo(List<ProposePo> proposePoList) { bool result = true; //filter the proposePoList by supplier List<ProposePo> supplier1 = proposePoList.Where(x => x.supplier1Qty != 0).ToList(); List<ProposePo> supplier2 = proposePoList.Where(x => x.supplier2Qty != 0).ToList(); List<ProposePo> supplier3 = proposePoList.Where(x => x.supplier3Qty != 0).ToList(); //obtain supplier1 ID string supplier1ID = ctx.Supplier.Where(x => x.Rank == 1).First().SupplierID; //obtain supplier2 ID string supplier2ID = ctx.Supplier.Where(x => x.Rank == 2).First().SupplierID; //obtain supplier3 ID string supplier3ID = ctx.Supplier.Where(x => x.Rank == 3).First().SupplierID; //generate po for supplier 1 if (supplier1.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier1ID; po.EmpID = supplier1.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier1.First().EstDate).Date; po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier1.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x=> x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier1) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier1Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 2 if (supplier2.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier2ID; po.EmpID = supplier2.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier2.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier2.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier2) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier2Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 3 if (supplier3.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier3ID; po.EmpID = supplier3.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier3.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier3.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier3) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier3Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } try { ctx.SaveChanges(); } catch { result = false; } return result; }
private List<SelectListItem> GetMarketList(string selected, bool allOption = false) { List<SelectListItem> listeMarket = new List<SelectListItem>(); SelectListItem mAll = new SelectListItem(); SelectListItem mHealth = new SelectListItem(); SelectListItem mAdvertising = new SelectListItem(); SelectListItem mFinance = new SelectListItem(); SelectListItem mICT = new SelectListItem(); if (allOption) { mAll.Value = ""; mAll.Text = "All"; listeMarket.Add(mAll); mAll.Selected = true; } // mAll.Selected = true; mHealth.Value = "Health"; mHealth.Text = "Health"; mAdvertising.Value = "Advertising"; mAdvertising.Text = "Advertising"; mFinance.Value = "Finance"; mFinance.Text = "Finance"; mICT.Value = "ICT"; mICT.Text = "ICT"; listeMarket.Add(mAdvertising); listeMarket.Add(mHealth); listeMarket.Add(mFinance); listeMarket.Add(mICT); if (!string.IsNullOrEmpty(selected)) { var selecteditem = listeMarket.Where(m => m.Value.ToLower().Equals(selected.ToLower())).FirstOrDefault(); if (selecteditem != null) { selecteditem.Selected = true; } } return listeMarket; }
/// <summary> /// Gets all series that match with the provided name. /// </summary> /// <param name="name">Name of the series.</param> /// <param name="languageAbbreviation">Abbreviation of the language to search the series.</param> /// <param name="mirror">The mirror to use.</param> /// <returns>List of series that matches the provided name.</returns> /// <example>Shows how to get a series by name. /// <code> /// namespace Docunamespace /// { /// /// <summary> /// /// Class for the docu. /// /// </summary> /// class DocuClass /// { /// /// <summary> /// /// Gets series by name. /// /// </summary> /// public List<Series> GetSeries(string name, Mirror mirror, Language language) /// { /// string apiKey = "ABCD12345"; /// TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey); /// List<Series> series = await instance.GetSeriesByName(name, language.Abbreviation, mirror); /// /// return series; /// } /// } /// } /// </code> /// </example> public async Task<List<Series>> GetSeriesByName(string name, string languageAbbreviation, Mirror mirror) { if (string.IsNullOrEmpty(name)) { return null; } if (mirror == null) { return null; } if (string.IsNullOrEmpty(languageAbbreviation)) { return null; } string url = "{0}/api/GetSeries.php?seriesname={1}&language={2}"; byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, name, languageAbbreviation)).ConfigureAwait(continueOnCapturedContext: false); MemoryStream resultStream = new MemoryStream(result); XmlDocument doc = new XmlDocument(); doc.Load(resultStream); XmlNode dataNode = doc.ChildNodes[1]; List<Series> series = new List<Series>(); foreach (XmlNode currentNode in dataNode.ChildNodes) { Series deserialized = new Series(); deserialized.Deserialize(currentNode); series.Add(deserialized); } return series.Where(x => x.Language.Equals(languageAbbreviation)).ToList<Series>(); }
private static void CheckTagSetForDuplicates(List<TagProcessResult> tagList, TagProcessResult tpr) { var duplicateTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.DuplicateTagId.HasValue) .Where(t => t.TagValue.ToLower() == tpr.TagValue.ToLower()) .Select(t => t.TagId).FirstOrDefault(); if (duplicateTagId != default(int)) { tpr.DuplicateTagId = duplicateTagId; } }
/// <summary> /// 获取该供应商下所关联的所有联系人信息 /// </summary> /// <param name="suppId"></param> /// <returns></returns> private void GetAllContacts(string suppId) { //string conId = string.Empty; //DataTable dt_contacts = new DataTable(); //DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "cont_id", " relation_object_id='" + suppId + "'", "", ""); //if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0) //{ // foreach (DataRow dr in dt_base_contacts.Rows) // { // conId += "'" + dr["cont_id"] + "',"; // } // conId = conId.Trim(','); // gvUserInfoList.DataSource = DBHelper.GetTable("查询关联的联系人信息", "tb_contacts", "*", " cont_id in (" + conId + ")", "", ""); //} string conId = string.Empty; DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "*", " relation_object_id='" + suppId + "'", "", ""); if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0) { isdefault defaultModel = new isdefault(); List<isdefault> list_default = new List<isdefault>(); foreach (DataRow dr in dt_base_contacts.Rows) { conId += "'" + dr["cont_id"] + "',"; defaultModel = new isdefault(); defaultModel.cont_id = dr["cont_id"].ToString(); defaultModel.is_default = dr["is_default"] == null || dr["is_default"].ToString() == "" ? "0" : dr["is_default"].ToString(); list_default.Add(defaultModel); } conId = conId.Trim(','); string TableName = string.Format(@"(select dic_name as con_post_name,tb_contacts.* from tb_contacts left join sys_dictionaries on tb_contacts.cont_post=sys_dictionaries.dic_id) as tb_contacts"); DataTable dt_contacts = DBHelper.GetTable("查询关联的联系人信息", TableName, string.Format("*,{0} phone,{1} tel", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel")), " cont_id in (" + conId + ")", "", ""); foreach (DataRow dr in dt_contacts.Rows) { DataGridViewRow dgvr = gvUserInfoList.Rows[gvUserInfoList.Rows.Add()]; dgvr.Cells["colcont_id"].Value = dr["cont_id"]; dgvr.Cells["colcont_name"].Value = dr["cont_name"]; dgvr.Cells["colcont_post"].Value = dr["con_post_name"]; dgvr.Cells["colcont_phone"].Value = dr["phone"]; dgvr.Cells["colcont_tel"].Value = dr["tel"]; dgvr.Cells["colremark"].Value = dr["remark"]; dgvr.Cells["colcont_email"].Value = dr["cont_email"]; if (list_default.Count > 0) { dgvr.Cells["colis_default"].Value = list_default.Where(p => p.cont_id == dr["cont_id"].ToString()).First().is_default; } string createTime = CommonCtrl.IsNullToString(dr["cont_birthday"]); if (createTime.Length > 0) { dgvr.Cells["colcont_birthday"].Value = DateTime.MinValue.AddTicks(Convert.ToInt64(createTime)).ToLocalTime(); } } } }
/// <summary> /// 获取该企业的奖励情况 /// </summary> /// <param name="entid">企业id</param> /// <param name="day">天数</param> public void GetDJSRewordEnt(string entid, int day, out int groupcount, out int peocount) { peocount = 0; groupcount = 0; List<DJ_Route> ListRoute = new DAL.DALDJ_Route().GetRouteByentid(int.Parse(entid)).ToList(); List<DJ_TourGroup> ListGroup = new List<DJ_TourGroup>(); foreach (DJ_Route route in ListRoute) { Model.DJ_GroupConsumRecord record = new BLLDJConsumRecord().GetGroupConsumRecordByRouteId(route.Id); if (record != null && DateTime.Parse(record.ConsumeTime.AddDays(day).ToShortDateString()) >= DateTime.Parse(DateTime.Now.ToShortDateString())) { peocount += record.AdultsAmount + record.ChildrenAmount; if (ListGroup.Where(x => x.Id == route.DJ_TourGroup.Id).Count() == 0) { ListGroup.Add(route.DJ_TourGroup); } } } groupcount = ListGroup.Count; }
public List<CategoryEntityComplete> searchComplete(string searchitem) { string[] arr = searchitem.Split(' '); List<CategoryEntityComplete> l = new List<CategoryEntityComplete>(); for (int s = 0; s < arr.Length; s++) { if (s == 0) { var list = (from a in db.ESHOP_NEWs join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID where (SqlMethods.Like(a.NEWS_KEYWORD_ASCII, ClearUnicode("%" + arr[s] + "%"))) && a.NEWS_TYPE == 1 select new { a.NEWS_TITLE, a.NEWS_PUBLISHDATE, b.ESHOP_CATEGORy.CAT_NAME }).Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.CAT_NAME); foreach (var i in list) { CategoryEntityComplete enti = new CategoryEntityComplete(); enti.catname = i.CAT_NAME; enti.title = i.NEWS_TITLE; l.Add(enti); } } else { var list = l.Where(n=>n.title.ToLower().Contains(arr[s].ToLower())).ToList(); if (list != null && list.Count > 0) l = list; } } return l; }
static void Main(string[] args) { //Business.SMS.Instance.SendSMS("Mensagem de teste!!", "+5511965579593"); Console.WriteLine("Olá!! Vamos começar =)"); Console.WriteLine("Começando pelo começo, importar o CSV? S/N"); var csv = Console.ReadLine(); #region importar dados if (csv != null && csv.ToLower() == "s") { var list = new List<Models.Lentidao>(); var reader = new StreamReader(File.OpenRead(@"Content\Lentidao.csv"), Encoding.Default); reader.ReadLine(); while (!reader.EndOfStream) { var line = reader.ReadLine(); if (!String.IsNullOrWhiteSpace(line)) { string[] values = line.Split(';'); if (values.Length >= 12) { list.Add(new Models.Lentidao { DataHora = Convert.ToDateTime(values[1]), IdCorredor = Convert.ToInt32(values[2]), Corredor = values[3], Sentido = values[4], Pista = values[5], ExtensaoPista = Convert.ToInt32(values[6]), InicioLentidao = values[7], TerminoLentidao = values[8], ReferenciaNumericaInicioLentidao = Convert.ToInt32(values[9]), ExensaoLentidao = Convert.ToInt32(values[10]), Regiao = values[11] }); } } } using (var context = new DatabaseContext()) { context.BulkInsert(list); } Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Uffa!! Terminamos, vamos pro próximo =)"); Console.ResetColor(); } #endregion Console.WriteLine("Vamos fazer a query... (sem view, vai demorar)"); using (var context = new DatabaseContext()) { context.Database.Log = Console.WriteLine; Console.WriteLine("Inserir Lentidão Consolidada? S/N"); var s = Console.ReadLine(); var todos = new List<Models.LentidaoConsolidado>(); if (s != null && s.ToLower() == "s") { todos = context.Lentidoes .GroupBy(a => new { a.InicioLentidao, a.TerminoLentidao, a.ReferenciaNumericaInicioLentidao, a.Regiao}) .Select(a=> new { Total = a.Count(), TerminoLentidao = a.Key.TerminoLentidao, InicioLentidao = a.Key.InicioLentidao, ReferenciaNumericaInicioLentidao = a.Key.ReferenciaNumericaInicioLentidao, Regiao = a.Key.Regiao }) .OrderByDescending(a => a.Total).Skip(1).ToList().Select(a => new Models.LentidaoConsolidado { Total = a.Total, TerminoLentidao = a.TerminoLentidao, InicioLentidao = a.InicioLentidao, ReferenciaNumericaInicioLentidao = a.ReferenciaNumericaInicioLentidao, Regiao = a.Regiao }).ToList(); context.BulkInsert(todos); } todos = context.LentidaoConsolidados.Where(a=>!a.Steps.Any()).ToList(); var stps = new List<Models.Step>(); var count = 0; foreach(var todo in todos) { count++; var directionsRequest = new DirectionsRequest() { Origin = String.Format("{0} {1}, São Paulo - SP, Brasil", TratarEndereco(todo.InicioLentidao), todo.ReferenciaNumericaInicioLentidao), Destination = String.Format("{0}, São Paulo - SP, Brasil", todo.TerminoLentidao), SigningKey = "AIzaSyAl8V3SnsqpCWA1SmyMH0g-PaOkfN5J5LA", }; var directions = GoogleMaps.Directions.Query(directionsRequest); if (directions.Status == DirectionsStatusCodes.OK) { var legs = directions.Routes.First().Legs; foreach (var leg in legs) { if (leg.Distance.Value > 20000) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine( String.Format("Xiiii, mais do que 20 quilômetros? Tá suspeito esse registro..."), new object {}); Console.WriteLine(todo); Console.ResetColor(); } else { var steps = leg.Steps; stps.AddRange(steps.Select(step => new Models.Step { PosicaoGeografica = DbGeography.FromText(Business.Ocorrencia.Instance.GetGeographyTextFromLatlng(step.StartLocation.Latitude, step.StartLocation.Longitude)), FkLentidaoConsolidado = todo.Id })); count = count + stps.Count; } } } if (count > 500) { if (count > 500) { using (var context2 = new DatabaseContext()) { try { context2.Steps.AddRange(stps.Where(a => a.PosicaoGeografica != null)); } catch (Exception) { } context2.SaveChanges(); stps = new List<Models.Step>(); count = 0; } } } Console.WriteLine(directions); }; context.SaveChanges(); } }
public List<Model.DJ_GroupConsumRecord> GetRecordByAllCondition(string groupname, string EntName, string BeginTime, string EndTime, int enterid) { List<Model.DJ_GroupConsumRecord> ListRecord = IDjgroup.GetRecordByAllCondition(groupname, EntName, BeginTime, EndTime, enterid); List<Model.DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>(); foreach (Model.DJ_GroupConsumRecord item in ListRecord) { if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Count() == 0) { List.Add(item); } } return List; }
public JsonState UpdateData(int id, DateTime updateStart, DateTime updateEnd) { JsonState jsonState = new JsonState(); string formula = ""; jsonState.state = 0; if (id > 0) { Sql sql = new Sql(); sql.Select("*").From("tn_FormulaSetting").Where("Id=@0", id); FormulaSetting formulaSetting = db.Fetch<FormulaSetting>(sql).FirstOrDefault(); if (formulaSetting != null) { formula = formulaSetting.Formula; List<string> pipoints = GetPiPoints(formulaSetting.Formula); List<FormulaPoint> formulaPoints = new List<FormulaPoint>(); formulaPoints = db.Fetch<FormulaPoint>("select * from tn_FormulaPoint"); IDictionary<string, List<PIAvgRecords>> piAvgRecords = new Dictionary<string, List<PIAvgRecords>>(); foreach (string pipoint in pipoints) { string pointName = pipoint.Replace("_MONTHAVG", "").Replace("_MONTH", ""); FormulaPoint formulaPoint = formulaPoints.Where(n => n.PointName == pointName).FirstOrDefault(); if (formulaPoint != null) sql = new Sql("select * from " + formulaPoint.TableName + " where pname=@0 and timestamps<=@1 and timestamps>=@2", pointName, updateEnd, updateStart); else sql = new Sql("select * from PIAvgRecords where pname=@0 and timestamps<=@1 and timestamps>=@2", pointName, updateEnd, updateStart); piAvgRecords[pipoint] = db.Fetch<PIAvgRecords>(sql); } Expre(pipoints, piAvgRecords, formulaSetting, updateStart, updateEnd); jsonState.state = 1; } } return jsonState; }
private static void CheckTagSetForSynonyms(List<TagProcessResult> tagList, TagProcessResult tpr) { var synonymTagId = 0; foreach (var wpr in tpr.WordProcessResultList) { var wordSynonyms = Synonyms(wpr.Word); if (wordSynonyms.Any()) { synonymTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.SynonymTagId.HasValue) .Where(t => t.WordProcessResultList.Any(x => wordSynonyms.Contains(x.Word))) .Select(x => x.TagId) .FirstOrDefault(); } } if (synonymTagId != default(int)) { tpr.SynonymTagId = synonymTagId; } }
/// <summary> 提交成功时,对引用的前置单据的状态进行更新 /// </summary> /// <param name="orderid"></param> bool SetOrderStatus(string saleorderid) { bool ret = false; try { #region 设置前置单据的状态和完成数量 List<OrderImportStatus> list_order = new List<OrderImportStatus>(); List<OrderFinishInfo> list_orderinfo = new List<OrderFinishInfo>(); OrderImportStatus orderimport_model = new OrderImportStatus(); OrderFinishInfo orderfinish_info = new OrderFinishInfo(); DataTable dt_Business = GetBusinessCount(saleorderid); DataTable dt_Finish = GetFinishCount(saleorderid); string sale_plan_id = string.Empty; string order_num = string.Empty; string parts_code = string.Empty; if (dt_Business.Rows.Count > 0) { for (int i = 0; i < dt_Business.Rows.Count; i++) { bool isfinish = true; int BusinessCount = int.Parse(dt_Business.Rows[i]["business_count"].ToString()); sale_plan_id = dt_Business.Rows[i]["sale_plan_id"].ToString(); order_num = dt_Business.Rows[i]["order_num"].ToString(); parts_code = dt_Business.Rows[i]["parts_code"].ToString(); DataRow[] dr = dt_Finish.Select(" order_num='" + order_num + "' and parts_code='" + parts_code + "'"); if (dr != null && dr.Count() > 0) { orderfinish_info = new OrderFinishInfo(); orderfinish_info.sale_plan_id = sale_plan_id; orderfinish_info.parts_code = parts_code; orderfinish_info.finish_num = dr[0]["relation_count"].ToString(); list_orderinfo.Add(orderfinish_info); if (int.Parse(dr[0]["relation_count"].ToString()) < BusinessCount) { isfinish = false; } } else { orderfinish_info = new OrderFinishInfo(); orderfinish_info.sale_plan_id = sale_plan_id; orderfinish_info.parts_code = parts_code; orderfinish_info.finish_num = "0"; list_orderinfo.Add(orderfinish_info); isfinish = false; } orderimport_model = new OrderImportStatus(); orderimport_model.order_num = order_num; orderimport_model.isfinish = isfinish; if (list_order.Count > 0) { if (list_order.Where(p => p.order_num == order_num).Count() > 0) { if (!isfinish) { for (int a = 0; a < list_order.Count; a++) { if (list_order[a].order_num == order_num && list_order[a].isfinish) { list_order[a].isfinish = isfinish; } } } } else { list_order.Add(orderimport_model); } } else { list_order.Add(orderimport_model); } } } ret = ImportPurchasePlanStatus(list_order, list_orderinfo); #endregion } catch (Exception ex) { } return ret; }
/// <summary> /// Gets the resume field. /// </summary> protected List<ResumeField> GetResumeField() { var result = new List<ResumeField>(); foreach (RepeaterItem filed in fieldRepeater.Items) { var lbl = (Label)filed.FindControl("field"); var listView = (ListView)filed.FindControl("themeListView"); var item = new ResumeField { FieldName = lbl.Text, Theme = new List<ResumeTheme>() }; foreach (var theme in listView.Items) { var skill = (DropDownList)theme.FindControl("themeSkils"); if (skill.SelectedIndex == 0) continue; var themeId = (Label)theme.FindControl("themeId"); var themeName = (Label)theme.FindControl("theme"); item.Theme.Add(new ResumeTheme { SkillId = Convert.ToInt32(skill.SelectedValue), SkillName = skill.SelectedItem.Text, ThemeId = Convert.ToInt32(themeId.Text), ThemeName = themeName.Text }); } result.Add(item); } foreach (var item in result.Where(item => item.Theme.Count == 0)) { result.Remove(item); } return result; }
/// <summary> /// Finds the by age. /// </summary> /// <param name="list">The list.</param> /// <param name="startAge">The start age.</param> /// <param name="endAge">The end age.</param> public static List<Resume> FindByAge(List<Resume> list, int startAge, int endAge) { if (endAge == 0) endAge = 99; if ((startAge < 1 && endAge > 65)||startAge>=endAge) return list; var now = DateTime.Now.Year; return list.Where(x => startAge <= (now - x.Client.BirthDay.Year) && (now - x.Client.BirthDay.Year) <= endAge) .ToList(); }
/// <summary> /// Handler for <see cref="Page.OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs)" />. /// </summary> /// <param name="parameter"><see cref="Windows.UI.Xaml.Navigation.NavigationEventArgs.Parameter" />.</param> public async void Activate(object parameter) { string lsActivityID = parameter as string; MSHealthActivities loActivities = null; MSHealthSplitDistanceType loDistanceType = MSHealthSplitDistanceType.None; MSHealthActivityInclude loInclude = MSHealthActivityInclude.Details | MSHealthActivityInclude.MapPoints; IsLoaded = false; Activity = null; TotalDistance = null; DistanceUnitShort = null; Pace = null; Splits = null; HeartRateZones = null; MapPath = null; ElevationGain = null; ElevationLoss = null; MaxElevation = null; MinElevation = null; IsElevationAvailable = false; IsHeartRateZonesAvailable = false; IsNikePlusAvailable = false; List<HeartRateZoneItem> loHeartRateZones = null; // Set back button visible (for Windows app) SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; // Check parameter (Activity ID) if (!string.IsNullOrEmpty(lsActivityID)) { IsRunningRequest = true; // Determine Distance Unit switch (Settings.MSHealthFilterDistance) { case DistanceUnit.DISTANCE_MILE: loDistanceType = MSHealthSplitDistanceType.Mile; DistanceUnitShort = Resources.Strings.TextDistanceUnitShortMileText; break; case DistanceUnit.DISTANCE_KILOMETER: loDistanceType = MSHealthSplitDistanceType.Kilometer; DistanceUnitShort = Resources.Strings.TextDistanceUnitShortKilometerText; break; } try { // Get Activity details loActivities = await moMSHealthClient.ListActivities(ids: lsActivityID, include: loInclude, splitDistanceType: loDistanceType); // Check Activity details returned if (loActivities.ItemCount > 0) { // Map from derivated activities to single instance activity if (loActivities.FreePlayActivities != null && loActivities.FreePlayActivities.Any()) Activity = loActivities.FreePlayActivities.FirstOrDefault(); else if (loActivities.RunActivities != null && loActivities.RunActivities.Any()) Activity = loActivities.RunActivities.FirstOrDefault(); else if (loActivities.BikeActivities != null && loActivities.BikeActivities.Any()) Activity = loActivities.BikeActivities.FirstOrDefault(); else if (loActivities.GolfActivities != null && loActivities.GolfActivities.Any()) Activity = loActivities.GolfActivities.FirstOrDefault(); else if (loActivities.GuidedWorkoutActivities != null && loActivities.GuidedWorkoutActivities.Any()) Activity = loActivities.GuidedWorkoutActivities.FirstOrDefault(); else if (loActivities.SleepActivities != null && loActivities.SleepActivities.Any()) Activity = loActivities.SleepActivities.FirstOrDefault(); else if (loActivities.HikeActivities != null && loActivities.HikeActivities.Any()) Activity = loActivities.HikeActivities.FirstOrDefault(); } // Check current activity instance if (Activity != null) { // Calculate Total Distance if (Activity.SplitDistance != null && Activity.SplitDistance.HasValue && Activity.SplitDistance.Value > 0 && Activity.DistanceSummary != null && Activity.DistanceSummary.TotalDistance != null && Activity.DistanceSummary.TotalDistance.HasValue) { TotalDistance = (decimal)Activity.DistanceSummary.TotalDistance / (decimal)Activity.SplitDistance; } // Calculate Pace if (Activity.DistanceSummary != null && Activity.DistanceSummary.Pace != null && Activity.DistanceSummary.Pace.HasValue) { Pace = TimeSpan.FromMilliseconds((double)Activity.DistanceSummary.Pace); } // Calculate Elevation if (Activity.DistanceSummary != null) { // Elevation Gain if (Activity.DistanceSummary.ElevationGain != null) { ElevationGain = (double)Activity.DistanceSummary.ElevationGain / MSHealthDistanceSummary.ELEVATION_FACTOR; IsElevationAvailable = true; } // Elevation Loss if (Activity.DistanceSummary.ElevationLoss != null) { ElevationLoss = (double)Activity.DistanceSummary.ElevationLoss / MSHealthDistanceSummary.ELEVATION_FACTOR; IsElevationAvailable = true; } // Max Elevation if (Activity.DistanceSummary.MaxElevation != null) { MaxElevation = (double)Activity.DistanceSummary.MaxElevation / MSHealthDistanceSummary.ELEVATION_FACTOR; IsElevationAvailable = true; } // Min Elevation if (Activity.DistanceSummary.MinElevation != null) { MinElevation = (double)Activity.DistanceSummary.MinElevation / MSHealthDistanceSummary.ELEVATION_FACTOR; IsElevationAvailable = true; } } // Heart Rate Zones if (Activity.PerformanceSummary != null && Activity.PerformanceSummary.HeartRateZones != null) { loHeartRateZones = new List<HeartRateZoneItem>(); // Underhealthy loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_UNDER_HEALTHY, Name = Resources.Strings.TextHeartRateZoneUnderHealthyText, Value = Activity.PerformanceSummary.HeartRateZones.UnderHealthyHeart ?? 0, }); // Healthy loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_HEALTHY, Name = Resources.Strings.TextHeartRateZoneHealthyText, Value = Activity.PerformanceSummary.HeartRateZones.HealthyHeart ?? 0, }); // Fitness loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_FITNESS, Name = Resources.Strings.TextHeartRateZoneFitnessText, Value = Activity.PerformanceSummary.HeartRateZones.FitnessZone ?? 0, }); // Aerobic loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_AEROBIC, Name = Resources.Strings.TextHeartRateZoneAerobicText, Value = Activity.PerformanceSummary.HeartRateZones.Aerobic ?? 0, }); // Anaerobic loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_ANAEROBIC, Name = Resources.Strings.TextHeartRateZoneAnaerobicText, Value = Activity.PerformanceSummary.HeartRateZones.Anaerobic ?? 0, }); // Redline loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_REDLINE, Name = Resources.Strings.TextHeartRateZoneRedlineText, Value = Activity.PerformanceSummary.HeartRateZones.Redline ?? 0, }); // OverRedline loHeartRateZones.Add(new HeartRateZoneItem() { Key = HeartRateZoneItem.HRZONE_OVER_REDLINE, Name = Resources.Strings.TextHeartRateZoneOverRedlineText, Value = Activity.PerformanceSummary.HeartRateZones.OverRedline ?? 0, }); HeartRateZones = new ObservableCollection<HeartRateZoneItem>(loHeartRateZones); IsHeartRateZonesAvailable = true; } // Segments (splits) if (Activity.ActivitySegments != null && Activity.ActivitySegments.Any() && TotalDistance != null) { // ActivitySegment to Split double ldSplitValue = 0; List<SplitItem> loSplits = new List<SplitItem>(); foreach (MSHealthActivitySegment loSegment in Activity.ActivitySegments.OrderBy(loSeg => loSeg.StartTime)) { ldSplitValue++; loSplits.Add(new SplitItem() { Value = ldSplitValue > (double)TotalDistance.Value ? (double)TotalDistance.Value : ldSplitValue, Duration = loSegment.Duration.Value, AvgHeartRate = loSegment.HeartRateSummary != null ? loSegment.HeartRateSummary.AverageHeartRate.Value : 0, }); } // Get Max/Min Duration/HR, for complete splits only try { loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.Duration).First().DurationMark = "↓"; loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.Duration).First().DurationMark = "↑"; loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.AvgHeartRate).First().HRMark = "↓"; loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.AvgHeartRate).First().HRMark = "↑"; } catch { /* Do nothing */ } // Sort by value and assign to instance loSplits = loSplits.OrderBy(loSplit => loSplit.Value).ToList(); Splits = new ObservableCollection<SplitItem>(loSplits); } // MapPoints to MapPath if (Activity.MapPoints != null && Activity.MapPoints.Any()) { List<BasicGeoposition> loGeopositions = new List<BasicGeoposition>(); loGeopositions = (from loMapPoint in Activity.MapPoints .Where(loPoint => loPoint.Location != null && loPoint.Location.Latitude != null && loPoint.Location.Longitude != null) .OrderBy(loPoint => loPoint.Ordinal) select new BasicGeoposition() { Latitude = (double)loMapPoint.Location.Latitude / MSHealthGPSPoint.LATITUDE_FACTOR, Longitude = (double)loMapPoint.Location.Longitude / MSHealthGPSPoint.LONGITUDE_FACTOR, Altitude = loMapPoint.Location.ElevationFromMeanSeaLevel != null ? ((double)loMapPoint.Location.ElevationFromMeanSeaLevel / MSHealthGPSPoint.ELEVATION_FACTOR) : 0d, }).ToList(); //foreach (var loMapPoint in Activity.MapPoints) //{ // if (loMapPoint.Location != null && // loMapPoint.Location.Latitude != null && // loMapPoint.Location.Longitude != null) // { // loGeopositions.Add(new BasicGeoposition() // { // Latitude = (double)loMapPoint.Location.Latitude / 10000000d, // Longitude = (double)loMapPoint.Location.Longitude / 10000000d, // }); // } //} if (loGeopositions.Any()) { MapPath = new Geopath(loGeopositions); } } } } catch (Exception loException) { // Handle exceptions (just for debugging purposes) if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debug.WriteLine(loException.StackTrace); await moDialogService.ShowError(Resources.Strings.MessageContentErrorOperation, Resources.Strings.MessageTitleError, Resources.Strings.MessageButtonOK, null); // Return to main page moNavigationService.GoBack(); } finally { Messenger.Default.Send<Geopath>(MapPath); IsRunningRequest = false; } // Check for Nike+ Credentials if (Settings.NikePlusCredential != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(Settings.NikePlusCredential.Password, "[\"&`'<>]")) { try { // Check for GPS data if (Activity.MapPoints == null || !Activity.MapPoints.Any()) { // Get Minute Summaries loActivities = await moMSHealthClient.ListActivities(ids: lsActivityID, include: MSHealthActivityInclude.MinuteSummaries, splitDistanceType: loDistanceType); // Check Activity details returned if (loActivities.ItemCount > 0) { // Map from derivated activities to single instance activity if (loActivities.FreePlayActivities != null && loActivities.FreePlayActivities.Any()) Activity.MinuteSummaries = loActivities.FreePlayActivities.FirstOrDefault().MinuteSummaries; else if (loActivities.RunActivities != null && loActivities.RunActivities.Any()) Activity.MinuteSummaries = loActivities.RunActivities.FirstOrDefault().MinuteSummaries; else if (loActivities.BikeActivities != null && loActivities.BikeActivities.Any()) Activity.MinuteSummaries = loActivities.BikeActivities.FirstOrDefault().MinuteSummaries; else if (loActivities.GolfActivities != null && loActivities.GolfActivities.Any()) Activity.MinuteSummaries = loActivities.GolfActivities.FirstOrDefault().MinuteSummaries; else if (loActivities.GuidedWorkoutActivities != null && loActivities.GuidedWorkoutActivities.Any()) Activity.MinuteSummaries = loActivities.GuidedWorkoutActivities.FirstOrDefault().MinuteSummaries; else if (loActivities.SleepActivities != null && loActivities.SleepActivities.Any()) Activity.MinuteSummaries = loActivities.SleepActivities.FirstOrDefault().MinuteSummaries; } } } catch (Exception loException) { // Handle exceptions (just for debugging purposes) if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debug.WriteLine(loException.StackTrace); } // Ensure Activity either has GPS or MinuteSummaries data if ((Activity.MapPoints != null && Activity.MapPoints.Any()) || (Activity.MinuteSummaries != null && Activity.MinuteSummaries.Any())) { moNikePlusClient.SetCredentials(Settings.NikePlusCredential.UserName, Settings.NikePlusCredential.Password); IsNikePlusAvailable = true; } } } IsLoaded = true; } }
/// <summary> 提交成功时,对引用的前置单据的状态进行更新 /// </summary> /// <param name="orderid"></param> void SetOrderStatus(string orderid) { //前置单据中的配件信息是否在后置单据中全部导入完成(完成数量>=计划数量) List<OrderImportStatus> list_order = new List<OrderImportStatus>(); List<OrderFinishInfo> list_orderinfo = new List<OrderFinishInfo>(); OrderImportStatus orderimport_model = new OrderImportStatus(); OrderFinishInfo orderfinish_info = new OrderFinishInfo(); DataTable dt_Business = GetBusinessCount(orderid); DataTable dt_Finish = GetFinishCount(); string plan_id = string.Empty; string order_num = string.Empty; string parts_code = string.Empty; string importtype = string.Empty; if (dt_Business.Rows.Count > 0) { for (int i = 0; i < dt_Business.Rows.Count; i++) { bool isfinish = true; decimal BusinessCount = decimal.Parse(dt_Business.Rows[i]["business_counts"].ToString()); plan_id = dt_Business.Rows[i]["plan_id"].ToString(); order_num = dt_Business.Rows[i]["order_num"].ToString(); parts_code = dt_Business.Rows[i]["parts_code"].ToString(); DataRow[] dr = dt_Finish.Select(" order_num='" + order_num + "' and parts_code='" + parts_code + "'"); if (dr != null && dr.Count() > 0) { importtype = dr[0]["ImportType"].ToString(); orderfinish_info = new OrderFinishInfo(); orderfinish_info.plan_id = plan_id; orderfinish_info.parts_code = parts_code; orderfinish_info.finish_num = dr[0]["relation_count"].ToString(); orderfinish_info.importtype = importtype; list_orderinfo.Add(orderfinish_info); if (decimal.Parse(dr[0]["relation_count"].ToString()) < BusinessCount) { isfinish = false; } } else { orderfinish_info = new OrderFinishInfo(); orderfinish_info.plan_id = plan_id; orderfinish_info.parts_code = parts_code; orderfinish_info.finish_num = "0"; orderfinish_info.importtype = importtype; list_orderinfo.Add(orderfinish_info); isfinish = false; } orderimport_model = new OrderImportStatus(); orderimport_model.order_num = order_num; orderimport_model.importtype = importtype; orderimport_model.isfinish = isfinish; if (list_order.Count > 0) { if (list_order.Where(p => p.order_num == order_num).Count() > 0) { if (!isfinish) { for (int a = 0; a < list_order.Count; a++) { if (list_order[a].order_num == order_num && list_order[a].isfinish) { list_order[a].isfinish = isfinish; } } } } else { list_order.Add(orderimport_model); } } else { list_order.Add(orderimport_model); } } } ImportPurchasePlanStatus(list_order, list_orderinfo); }
public void Execute(IEnumerable<ICommandLineElement> args) { if(args.Count() == 0) { RunAsService(_settings.FullServiceName); return; } var subcommand = args.Take(1) .Where(x => x is IArgumentElement) .Select(x => x as IArgumentElement) .Select(x => x.Id) .DefaultIfEmpty("") .FirstOrDefault(); _log.DebugFormat("Subcommand: '{0}'", subcommand); //processing out the instance argument var instance = args .Where(x => x is IDefinitionElement) .Select(x => x as IDefinitionElement) .Where(x => x.Key == "instance") .Select(x => x.Value) .DefaultIfEmpty(null) .FirstOrDefault(); //instance override _settings.InstanceName = instance; var subcommands = new List<Command> { new InstallService(_settings), new UninstallService(_settings) }; var oa = subcommands .Where(x => x.Name == subcommand) .SingleOrDefault(); if (oa == null) { RunAsService(_settings.FullServiceName); return; } //need to skip two now. ? oa.Execute(args.Skip(1).ToList()); }