/// <summary> /// 解析方法 /// </summary> /// <returns></returns> public string Analysis() { string result = Enums.成功; UrlList.Clear();//清空解析的Url列表 for (int i = 0; i < Page; i++) { string html; string res = reptile.GetHtml($"{Url}{(i > 0 ? $"&page={i + 1}" : string.Empty)}", HeadDic, out html); if (res != Enums.成功) { result += $"\r\n获取第{i}页HTML失败\r\n原因:{res}"; continue; } res = GetUrlIDByZz(html); if (res != Enums.成功) { result += $"\r\n获取第{i}页UrlID失败\r\n原因:{res}"; continue; } if (i < 1) { string countZz = "共([\\s\\S]*?)条数据"; DataCount = reptile.Analysis(countZz, "$1", html)[0]; int intCount = int.Parse(DataCount.Replace("+", string.Empty)); AllPage = intCount % 20 > 0 ? (intCount / 20 + 1).ToString() : (intCount / 20).ToString(); if (DataCount.IndexOf('+') > -1) { AllPage += "+"; } } } LoadDataCount = 0;//清空已下载的数据条数 return(result); }
public async Task <IResult> ListProductAttributeValue(int id, DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var attributeValues = _productRepository.GetProductAttributeValuesList(id); if (attributeValues.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "Attributes do not exist for the product."; return(result); } var list = attributeValues; list = DataSortExtention.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); var pdtAttrValue = new List <ProductAttributeValueViewModel>(); pdtAttrValue = resultList.Select(p => { var pdtAttrValueView = new ProductAttributeValueViewModel(); pdtAttrValueView.MapFromModel(p); return(pdtAttrValueView); }).ToList(); ResultModel resultModel = new ResultModel(); resultModel.ProductAttributeValueResult = pdtAttrValue; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(result); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(result); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
public async Task <IResult> ListAttributes(DataHelperModel dataHelper, bool getAll) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var listAttr = _productAttributeRepository.ListAttributes(dataHelper.Search, getAll); if (!getAll) { var list = DataSortExtention.SortBy(listAttr, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); var pdtAttrViewModels = new List <ProductAttributeViewModel>(); pdtAttrViewModels = resultList.Select(p => { var pdtAttrViewModel = new ProductAttributeViewModel(); pdtAttrViewModel.MapFromModel(p); return(pdtAttrViewModel); }).ToList(); ResultModel resultModel = new ResultModel(); resultModel.ProductAttributeResult = pdtAttrViewModels; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(result); } result.Body = resultModel; } else { var attributeList = await listAttr.ToListAsync(); result.Body = attributeList; } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; return(result); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
private void Init() { lsvPay.Items.Clear(); lsvPayList.Items.Clear(); lsvContractList.Items.Clear(); Dictionary <string, DataCount> dataList = new Dictionary <string, DataCount>(); string query = "select obmanager, resultcontent from precontract where obmanager is not null and obpay is null"; DataSet ds = new DataSet(); OleDbDataAdapter adp = new OleDbDataAdapter(query, Main.conn); adp.Fill(ds); foreach (DataRow row in ds.Tables[0].Rows) { object[] itemArry = row.ItemArray; string obManager = itemArry[0].ToString(); if (string.IsNullOrEmpty(obManager)) { continue; } if (obManager[obManager.Length - 1] != '1') { continue; } if (dataList.ContainsKey(obManager) == false) { dataList.Add(obManager, new DataCount()); } DataCount dat = dataList[obManager]; dat.meetingCount++; string result = itemArry[1].ToString().Replace(" ", "").Trim(); if (result == "계약완료") { dat.contractCount++; } } foreach (string key in dataList.Keys.ToArray()) { DataCount data = dataList[key]; ListViewItem lsvItem = lsvPay.Items.Add(key); lsvItem.SubItems.Add(data.meetingCount.ToString()); lsvItem.SubItems.Add(data.contractCount.ToString()); lsvItem.SubItems.Add(String.Format("{0:#,0}", (data.meetingCount * mettingValue.Value + data.contractCount * contractValue.Value))); } }
private void Init() { lsvPay.Items.Clear(); lsvPayList.Items.Clear(); lsvFailList.Items.Clear(); Dictionary <string, DataCount> dataList = new Dictionary <string, DataCount>(); string query = "select contract.salerpersion, contract.offerdb from contract, paytable where contract.storeid = paytable.storeid and contract.salerpay is null and paytable.avablecalc = 'O'"; DataSet ds = new DataSet(); OleDbDataAdapter adp = new OleDbDataAdapter(query, Main.conn); adp.Fill(ds); foreach (DataRow row in ds.Tables[0].Rows) { object[] itemArry = row.ItemArray; string obManager = itemArry[0].ToString(); if (string.IsNullOrEmpty(obManager)) { continue; } if (dataList.ContainsKey(obManager) == false) { dataList.Add(obManager, new DataCount()); } DataCount dat = dataList[obManager]; string result = itemArry[1].ToString().Replace(" ", "").Trim(); if (result.ToLower() == "true") { dat.dbCount++; } else { dat.noneDbCount++; } } foreach (string key in dataList.Keys.ToArray()) { DataCount data = dataList[key]; ListViewItem lsvItem = lsvPay.Items.Add(key); lsvItem.SubItems.Add(data.dbCount.ToString()); lsvItem.SubItems.Add(data.noneDbCount.ToString()); lsvItem.SubItems.Add(String.Format("{0:#,0}", (data.dbCount * dbPay.Value + data.noneDbCount * noneDbPay.Value))); } }
public ActionResult EliminateCountData() { var results = (from r in md.ps_solvetask_main join i in md.ps_solvetask_detail on r.id equals i.taskId join p in md.ps_inspectiontask_detail on i.inspectionTaskDelId equals p.id join d in md.ps_inspectiontask_main on p.taskid equals d.id where r.taskStatus == 5 && r.isCancel == 0 select new { id = r.id, solveTaskCode = r.solveTaskCode, solveTaskName = r.solveTaskName, lineCode = p.lineCode, startPoleCode = d.startPoleCode, endPoleCode = d.endPoleCode, poleCode = p.poleCode, isBug = p.isBug, bugLevel = p.bugLevelName, bugType = p.bugTypeName, issuedTime = r.issuedTime, discoverTime = p.discoverTime, bugDesc = p.bugDesc }); List <DataEliminate> delist = new List <DataEliminate>(); if (results.Count() > 0) { foreach (var f in results) { DataEliminate de = new DataEliminate() { id = f.id, solveTaskCode = f.solveTaskCode, solveTaskName = f.solveTaskName, lineCode = f.lineCode, startPoleCode = f.startPoleCode, endPoleCode = f.endPoleCode, poleCode = f.poleCode, isBug = f.isBug, bugLevelName = f.bugLevel, bugTypeName = f.bugType, issuedTime = f.issuedTime, discoverTime = f.discoverTime, bugDesc = f.bugDesc }; delist.Add(de); } } int pageindex = int.Parse(Request.Params["pageindex"].ToString()); int skip = (pageindex - 1) * 6; DataCount dc = new DataCount(); if (delist.Count() > 0) { dc.plist = delist.Skip(skip).Take(6).ToList(); dc.PageCount = delist.Count(); Session["solvelist"] = dc.plist; } string strs = JsonConvert.SerializeObject(dc); return(Content(strs)); }
public IResult GetProductByCategoryForCustomer(int id, DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var productList = _productRepository.GetProductByCategoryForCustomer(id, dataHelper.Search); var list = productList; if (list.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(result); } list = DataSortExtention.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = pagedList.ToList(); var pdtViewList = new List <ProductViewModel>(); pdtViewList = resultList.Select(p => { var pdtview = new ProductViewModel(); pdtview.MapFromModel(p); return(pdtview); }).ToList(); var resultModel = new ResultModel() { ProductResult = pdtViewList, TotalCount = resultCount, }; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(result); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
public IResult GetUserList(DataHelperModel dataHelper) { var result = new Result() { Operation = Operation.Read, Status = Status.Success }; try { int userId = _specificClaim.GetSpecificClaim("Id"); var userList = _userRepository.GetUserList(userId, dataHelper.Search); if (userList.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "noUserPresent"; return(result); } var list = userList; list = DataSortExtention.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = pagedList.ToList(); var userViewModels = new List <UserViewModel>(); userViewModels = resultList.Select(r => { var userViewModel = new UserViewModel(); userViewModel.MapFromModel(r); userViewModel.Roles = r.Roles.Select(x => x.RoleId).ToArray(); return(userViewModel); }).ToList(); ResultModel resultModel = new ResultModel(); resultModel.UserResult = userViewModels; resultModel.TotalCount = resultCount; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(result); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
public async Task <IResult> GetProductReviewList(int id, DataHelperModel dataHelper) { var result = new Result() { Operation = Operation.Read, Status = Status.Success }; try { var rating = _productRepository.GetReviewList(id); if (rating.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "Ratings do not exist for the product."; return(result); } var list = rating; list = DataSortExtention.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); var ratingViewModel = new List <ProductRatingReviewViewModel>(); ratingViewModel = resultList.Select(r => { var ratingViewObj = new ProductRatingReviewViewModel(); ratingViewObj.MapFromModel(r); return(ratingViewObj); }).ToList(); ResultModel resultModel = new ResultModel(); resultModel.ProductRatingReviewResult = ratingViewModel; resultModel.TotalCount = resultCount; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(result); } catch (Exception e) { result.Status = Status.Success; result.StatusCode = HttpStatusCode.InternalServerError; result.Body = e; result.Message = e.Message; return(result); } }
public IResult GetWishlist(DataHelperModel dataHelper) { var result = new Result() { Operation = Operation.Read, Status = Status.Success }; try { int userDetail = _specificClaim.GetSpecificClaim("Id"); var products = _cartRepository.GetWishlist(userDetail); if (products.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "wishlist-empty"; return(result); } var list = products; var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = pagedList.ToList(); var pdtViewModelList = new List <ProductViewModel>(); pdtViewModelList = resultList.Select(p => { var pdtViewModel = new ProductViewModel(); pdtViewModel.MapFromModel(p); return(pdtViewModel); }).ToList(); var resultModel = new ResultModel() { ProductResult = pdtViewModelList, TotalCount = resultCount }; result.Body = resultModel; result.StatusCode = HttpStatusCode.OK; return(result); } catch (Exception e) { result.Body = e; result.Message = e.Message; result.Status = Status.Error; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
public override string ToString() { return($"{{{nameof(Offset)}={Offset.ToString("X")}, {nameof(HaveNBoneIndex0)}={HaveNBoneIndex0.ToString("X")}, {nameof(HaveNBoneIndex1)}={HaveNBoneIndex1.ToString("X")}, {nameof(ThrowNBoneIndex)}={ThrowNBoneIndex.ToString("X")}, {nameof(DataCount)}={DataCount.ToString("X")}, {nameof(DataOffset)}={DataOffset.ToString("X")}, {nameof(Pad)}={Pad.ToString("X")}, {nameof(EntriesCount)}={EntriesCount.ToString()}, {nameof(Entries)}={string.Join(",", Entries.Select(x => x.ToString()).ToList())}}}"); }
public async Task <IResult> GetCategoryList(DataHelperModel dataHelper, bool getParent, bool getAll) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var categoryList = _categoryRepository.GetCategoryList(dataHelper.Search); if (getAll != true) { var list = categoryList; list = DataSortExtention.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); var categoryViewList = new List <CategoryViewModel>(); categoryViewList = resultList.Select(c => { var categoryView = new CategoryViewModel(); categoryView.MapFromModel(c); return(categoryView); }).ToList(); ResultModel resultModel = new ResultModel(); resultModel.CategoryResult = categoryViewList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(result); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(result); } else { if (getParent) { categoryList = categoryList.Where(x => x.ChildCategory == null).OrderBy(x => x.CategoryName); var categories = await categoryList.ToListAsync(); result.Body = categoryList; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; return(result); } else { categoryList = categoryList.Where(c => c.ParentCategory != true).OrderBy(x => x.CategoryName); var categories = await categoryList.ToListAsync(); result.StatusCode = HttpStatusCode.OK; result.Body = categoryList; result.Status = Status.Success; return(result); } } } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(result); } }
public ActionResult SelectBtn() { string sovercode = ""; string sovername = ""; string isbug = ""; string time1 = ""; string time2 = ""; int pageindex = int.Parse(Request.Params["pageindex"]); SqlConnection con = new SqlConnection("server=.;database=MyElectrCheck_DB;Integrated Security=true;"); if (con.State != ConnectionState.Open) { con.Open(); } string sql = "select a.id,a.solveTaskCode,a.solveTaskName,b.lineCode,b.startPoleCode,b.endPoleCode,c.poleCode,c.isBug,c.bugLevelName,c.bugTypeName,a.issuedTime,c.discoverTime,c.bugDesc from ps_solvetask_main a inner join ps_inspectiontask_main b on a.id=b.id inner join ps_inspectiontask_detail c on b.id=c.taskid where 1=1 and a.taskstatus=5 and a.iscancel=0 "; if (Request.Params["sovercode"] != "") { sovercode = Request.Params["sovercode"]; sql += " and a.solveTaskCode like '%" + sovercode + "%'"; } if (Request.Params["sovername"] != "") { sovername = Request.Params["sovername"]; sql += "and b.lineCode like '%" + sovername + "%'"; } if (Request.Params["isbug"] != "") { isbug = Request.Params["isbug"]; sql += "and c.isBug =" + isbug + ""; } if (Request.Params["time1"] != "") { time1 = Request.Params["time1"]; sql += "and c.discoverTime >= '" + time1 + "' "; } if (Request.Params["time2"] != "") { time2 = Request.Params["time2"]; sql += "and c.discoverTime <= '" + time2 + "' "; } SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); List <DataEliminate> list = new List <DataEliminate>(); while (dr.Read()) { DataEliminate del = new DataEliminate() { id = int.Parse(dr["id"].ToString()), solveTaskCode = dr["solveTaskCode"].ToString(), solveTaskName = dr["solveTaskName"].ToString(), lineCode = dr["lineCode"].ToString(), startPoleCode = dr["startPoleCode"].ToString(), endPoleCode = dr["endPoleCode"].ToString(), poleCode = dr["poleCode"].ToString(), isBug = int.Parse(dr["isBug"].ToString()), bugLevelName = dr["bugLevelName"].ToString(), bugTypeName = dr["bugTypeName"].ToString(), issuedTime = DateTime.Parse(dr["issuedTime"].ToString()), discoverTime = DateTime.Parse(dr["discoverTime"].ToString()), bugDesc = dr["bugDesc"].ToString() }; list.Add(del); } dr.Close(); con.Close(); int skip = (pageindex - 1) * 6; DataCount ds = new DataCount(); ds.plist = list.Skip(skip).Take(6).ToList(); ds.PageCount = list.Count(); Session["solvelist"] = ds.plist; string strs = JsonConvert.SerializeObject(ds);; return(Content(strs)); }
public override string ToString() { return($"{{{nameof(Offset)}={Offset.ToString("X")}, {nameof(DataOffset)}={DataOffset.ToString("X")}, {nameof(DataCount)}={DataCount.ToString("X")}, {nameof(ItemsListOffset)}={ItemsListOffset.ToString("X")}, {nameof(Items)}={string.Join(",", Items.Select(x => x.ToString("X")).ToList())}}}"); }
public override string ToString() { return($"Model Visibility:\n\tOffset: {Offset.ToString("X")}\n\tEntry Offset: {EntryOffset.ToString("X")}\n\tBone Switch Count: {BoneSwitchCount.ToString("X")}\n\t" + $"Data Offset: {DataOffset.ToString("X")}\n\tData Count: {DataCount.ToString("X")}\n\tNumber Of Sections: {Sections.Count}"); }
/// <summary> /// <para>Process Pulse for Walkera WK-2401 PPM</para> /// <para>This is just a permiscuous PPM that does not follow the PPM standard</para> /// <para>This is how it works:</para> /// <para>1. Minimal pulse width is 5</para> /// <para>2. Any pulse of over PPMW_TRIG(=200) is considered as a _sync pulse.</para> /// <para>3. _polarity('input') of the Sync pulse is the polarity of the following _data pulses</para> /// </summary> /// <param name="width"></param> /// <param name="input"></param> /// <param name="filterChannels"></param> /// <param name="filter"></param> protected override void Process(int width, bool input, bool filterChannels, IPropoPlusFilter filter) { if (Monitor.IsEntered(MonitorLock)) { return; } //var tbuffer = new char[9]; if (width < 5) { return; } //if (gDebugLevel >= 2 && gCtrlLogFile && !(_strtime_s(tbuffer, 9))) // fprintf(gCtrlLogFile, "\n%s - ProcessPulseWk2401Ppm(width=%d, input=%d)", tbuffer, width, input); //_sync is detected at the end of a very long pulse (over 4.5mSec) if (width > PpmTrig) { Sync = true; if (!DataCount.Equals(0)) { PosUpdateCounter++; } RawChannelCount = DataCount; DataCount = 0; _polarity = input; return; } if (!Sync) { /* still waiting for _sync */ return; } // If this pulse is a separator - read the next pulse if (_polarity != input) { return; } // Cancel jitter /* Version 3.3.3 */ width = PrevWidth[DataCount].Filter(width, PpmJitter); //var jitterValue = Math.Abs(PrevWidth[DataCount].Value - width); //if (jitterValue < PpmJitter) //{ // width = PrevWidth[DataCount].Value; //} //PrevWidth[DataCount].Value = width; /* convert pulse width in samples to joystick Position values (newdata) * joystick Position of 0 correspond to width over 100 samples (2.25mSec) * joystick Position of 1023 correspond to width under 30 samples (0.68mSec)*/ var newdata = (int)((width - PpmMinPulseWidth) / (PpmMaxPulseWidth - PpmMinPulseWidth) * 1024); /* Trim values into 0-1023 boundries */ if (newdata < 0) { newdata = 0; } else if (newdata > 1023) { newdata = 1023; } /* Update _data - do not allow abrupt change */ if (DataBuffer[DataCount] - newdata > 100) { DataBuffer[DataCount] -= 100; } else if (newdata - DataBuffer[DataCount] > 100) { DataBuffer[DataCount] += 100; } else { DataBuffer[DataCount] = (DataBuffer[DataCount] + newdata) / 2; } //Assign _data to joystick channels ChannelData[DataCount] = DataBuffer[DataCount]; // Send Position and number of channels to the virtual joystick ////SendPPJoy(11, _mPosition); JoystickInteraction.Instance.Send(11, ChannelData, filterChannels, filter); //if (gDebugLevel >= 3 && gCtrlLogFile /*&& !(i++%50)*/) // fprintf(gCtrlLogFile, " _data[%d]=%d", _datacount, _data[_datacount]); //Debug.WriteLine($"data[{DataCount}]={DataBuffer[DataCount]}"); if (DataCount == 11) { Sync = false; /* Reset _sync after channel 12 */ } DataCount++; }
public async Task <ActionResult <IResult> > Listing([FromQuery] DataHelperModel dataHelper, bool getAll) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var listQuery = from attribute in context.ProductAttributes join createdUser in context.Login on attribute.CreatedBy equals createdUser.UserID into createname from createdUsername in createname.DefaultIfEmpty() let createdByUser = createdUsername.Username join modifiedUser in context.Login on attribute.ModifiedBy equals modifiedUser.UserID into modifyname from modifiedUsername in modifyname.DefaultIfEmpty() let modifiedByUser = modifiedUsername.Username join Values in context.ProductAttributeValues on attribute.AttributeID equals Values.AttributeID into attributeValuesCount from attributeValues in attributeValuesCount.DefaultIfEmpty() group new { attributeValues, attribute, createdByUser, modifiedByUser } by new { attribute, createdByUser, modifiedByUser } into valuesCount select new ProductAttributeViewModel { AttributeID = valuesCount.Key.attribute.AttributeID, AttributeName = valuesCount.Key.attribute.AttributeName, CreatedBy = valuesCount.Key.attribute.CreatedBy, AssociatedProductValues = valuesCount.Where(x => x.attributeValues != null ? x.attributeValues.AttributeID == x.attribute.AttributeID : false).Count(), CreatedDate = valuesCount.Key.attribute.CreatedDate, ModifiedBy = valuesCount.Key.attribute.ModifiedBy, ModifiedDate = valuesCount.Key.attribute.ModifiedDate, CreatedUser = valuesCount.Key.createdByUser, ModifiedUser = valuesCount.Key.modifiedByUser }; if (!getAll) { if (dataHelper.Search != null) { listQuery = listQuery.Where(x => x.AttributeName.Contains(dataHelper.Search)); } var list = listQuery; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); ResultModel resultModel = new ResultModel(); resultModel.ProductAttributeResult = resultList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } else { listQuery = listQuery.OrderBy(x => x.AttributeName); var attributeList = await listQuery.ToListAsync(); result.Body = attributeList; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; return(StatusCode((int)result.StatusCode, result)); } } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }
public async Task <ActionResult <IResult> > GetAssociatedProducts(int id, [FromQuery] DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { if (id != 0) { var product = from products in context.Products where products.CategoryID == id && products.IsDeleted != true orderby products.ProductName select new ProductViewModel { ProductName = products.ProductName, ProductID = products.ProductID, ShortDescription = products.ShortDescription, CategoryID = products.CategoryID, CategoryName = "", IsActive = products.IsActive, CreatedBy = products.CreatedBy, CreatedDate = products.CreatedDate, CreatedUser = "", Price = products.Price, QuantityInStock = products.QuantityInStock, VisibleEndDate = products.VisibleEndDate, AllowCustomerReviews = products.AllowCustomerReviews, DiscountPercent = products.DiscountPercent, VisibleStartDate = products.VisibleStartDate, IsDiscounted = products.IsDiscounted, LongDescription = products.LongDescription, MarkNew = products.MarkNew, ModelNumber = products.ModelNumber, ModifiedBy = products.ModifiedBy, ModifiedDate = products.ModifiedDate, ModifiedUser = "", OnHomePage = products.OnHomePage, ShipingEnabled = products.ShipingEnabled, ShippingCharges = products.ShippingCharges, Tax = products.Tax, TaxExempted = products.TaxExempted, QuantityType = products.QuantityType }; if (product.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "Products do not exist for the category."; return(StatusCode((int)result.StatusCode, result)); } var list = product; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); ResultModel resultModel = new ResultModel(); resultModel.ProductResult = resultList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "ID entered is null."; return(StatusCode((int)result.StatusCode, result)); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }
public override string ToString() { return($"{{{nameof(Offset)}={Offset.ToString("X")}, {nameof(HandNBoneIndex0)}={HandNBoneIndex0.ToString("X")}, {nameof(HandNBoneIndex1)}={HandNBoneIndex1.ToString("X")}, {nameof(HandNBoneIndex2)}={HandNBoneIndex2.ToString("X")}, {nameof(HandNBoneIndex3)}={HandNBoneIndex3.ToString("X")}, {nameof(DataCount)}={DataCount.ToString("X")}, {nameof(DataOffset)}={DataOffset.ToString("X")}, {nameof(BonesListDataOffset)}={BonesListDataOffset.ToString("X")}, {nameof(Bones)}={string.Join(",", Bones.Select(x => x.ToString("X")).ToList())}}}"); }
public async Task <ActionResult <IResult> > Listing([FromQuery] DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var listQuery = from product in context.Products join createdUser in context.Login on product.CreatedBy equals createdUser.UserID into createname from createUserName in createname.DefaultIfEmpty() join modifiedUser in context.Login on product.ModifiedBy equals modifiedUser.UserID into modifyname from modifyUserName in modifyname.DefaultIfEmpty() join categoryname in context.Categories on product.CategoryID equals categoryname.CategoryID into namecategory from categoryName in namecategory.DefaultIfEmpty() where product.IsDeleted != true orderby product.CreatedDate descending select new ProductViewModel { ProductName = product.ProductName, ProductID = product.ProductID, ShortDescription = product.ShortDescription, CategoryID = product.CategoryID, CategoryName = categoryName.CategoryName, IsActive = product.IsActive, CreatedBy = product.CreatedBy, CreatedDate = product.CreatedDate, CreatedUser = createUserName.Username, Price = product.Price, QuantityInStock = product.QuantityInStock, VisibleEndDate = product.VisibleEndDate, AllowCustomerReviews = product.AllowCustomerReviews, DiscountPercent = product.DiscountPercent, VisibleStartDate = product.VisibleStartDate, IsDiscounted = product.IsDiscounted, LongDescription = product.LongDescription, MarkNew = product.MarkNew, ModelNumber = product.ModelNumber, ModifiedBy = product.ModifiedBy, ModifiedDate = product.ModifiedDate, ModifiedUser = modifyUserName.Username, OnHomePage = product.OnHomePage, ShipingEnabled = product.ShipingEnabled, ShippingCharges = product.ShippingCharges, Tax = product.Tax, TaxExempted = product.TaxExempted, QuantityType = product.QuantityType }; if (dataHelper.Search != null) { listQuery = listQuery.Where(x => x.ProductName.Contains(dataHelper.Search) || x.ShortDescription.Contains(dataHelper.Search) || x.LongDescription.Contains(dataHelper.Search)); } var list = listQuery; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); ResultModel resultModel = new ResultModel(); resultModel.ProductResult = resultList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }
public async Task <ActionResult <IResult> > GetUserList([FromQuery] DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var userObj = from user in context.Login join role in context.AssignedRolesTable on user.UserID equals role.UserID into assignedRoles from userRole in assignedRoles.DefaultIfEmpty() group new { user } by new { user, assignedRoles } into userDetail select new UserViewModel { UserID = userDetail.Key.user.UserID, EmailID = userDetail.Key.user.EmailID, FirstName = userDetail.Key.user.FirstName, LastName = userDetail.Key.user.LastName, Username = userDetail.Key.user.Username, RoleID = userDetail.Key.assignedRoles.Where(x => x.UserID == userDetail.Key.user.UserID).Select(x => x.RoleID).ToArray(), ImageContent = null }; if (dataHelper.Search != null) { userObj = userObj.Where(x => x.Username.Contains(dataHelper.Search) || x.EmailID.Contains(dataHelper.Search)); } var userList = userObj.Where(x => !x.RoleID.Contains(1)).Select(x => x); if (userObj.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "noUserPresent"; return(StatusCode((int)result.StatusCode, result)); } var list = userList; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = pagedList.ToList(); ResultModel resultModel = new ResultModel(); resultModel.UserResult = resultList; resultModel.TotalCount = resultCount; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }
public async Task <ActionResult <IResult> > GetListProductAttributeValue(int id, [FromQuery] DataHelperModel dataHelper) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { if (!ModelState.IsValid) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; return(StatusCode((int)result.StatusCode, result)); } var attribute = from productAttributeValue in context.ProductAttributeValues join attributeName in context.ProductAttributes on productAttributeValue.AttributeID equals attributeName.AttributeID into attributes from attributeName in attributes.DefaultIfEmpty() where productAttributeValue.ProductID == id orderby productAttributeValue.ID descending select new ProductAttributeValueViewModel { ID = productAttributeValue.ID, AttributeID = productAttributeValue.AttributeID, AttributeName = attributeName.AttributeName, ProductID = productAttributeValue.ProductID, Value = productAttributeValue.Value }; if (attribute.Count() == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "Attributes do not exist for the product."; return(StatusCode((int)result.StatusCode, result)); } var list = attribute; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); ResultModel resultModel = new ResultModel(); resultModel.ProductAttributeValueResult = resultList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }
public override string ToString() { return($"{{{nameof(Offset)}={Offset.ToString()}, {nameof(ActionInterruptsOffset)}={ActionInterruptsOffset.ToString()}, {nameof(DataOffset)}={DataOffset.ToString()}, {nameof(DataCount)}={DataCount.ToString()}, {nameof(ActionInterruptEntries)}={string.Join(",", ActionInterruptEntries.Select(x => x.ToString()).ToList())}}}"); }
/// <summary> /// <para>Process Pulse for Standard PPM</para> /// <para>A long (over 200 samples) leading high, then a short low, then up to six highs followed by short lows.</para> /// <para>The size of a high pulse may vary between 30 to 70 samples, mapped to joystick values of 1024 to 438</para> /// <para>where the mid-point of 50 samples is translated to joystick position of 731.</para> /// </summary> /// <param name="width"></param> /// <param name="input"></param> /// <param name="filterChannels"></param> /// <param name="filter"></param> protected override void Process(int width, bool input, bool filterChannels, IPropoPlusFilter filter) { if (Monitor.IsEntered(MonitorLock)) { return; } if (width < PpmGlitch) { return; } //if (gDebugLevel >= 2 && gCtrlLogFile && !(_strtime_s(tbuffer, 10))/*&& !(i++%50)*/) // fprintf(gCtrlLogFile, "\n%s - ProcessPulsePpm(width=%d, input=%d)", tbuffer, width, input); /* If pulse is a separator then go to the next one */ if (width < PpmSeparator || FormerSync) { _prevSeparator = true; FormerSync = false; return; } // Two separators in a row is an error - resseting if ((width < PpmSeparator) && _prevSeparator) { _prevSeparator = true; RawChannelCount = 0; DataCount = 0; return; } /* sync is detected at the end of a very long pulse (over 200 samples = 4.5mSec) */ if (/*sync == 0 && */ width > PpmTrig) { Sync = true; if (!DataCount.Equals(0)) { PosUpdateCounter++; } RawChannelCount = DataCount; DataCount = 0; FormerSync = true; _prevSeparator = false; return; } if (!Sync) { /* still waiting for sync */ return; } // Two long pulse in a row is an error - resseting if (width > PpmSeparator) { if (!_prevSeparator) { RawChannelCount = 0; DataCount = 0; _prevSeparator = false; return; } _prevSeparator = false; } // Cancel jitter /* Version 3.3.3 */ width = PrevWidth[DataCount].Filter(width, PpmJitter); int newdata; /* * convert pulse width in samples to joystick position values (newdata) * joystick position of 0 correspond to width over 100 samples (2.25mSec) * joystick position of 1023 correspond to width under 30 samples (0.68mSec) */ if (input || JsChPostProc_selected != -1) { newdata = (int)(1024 - (width - PpmMinPulseWidth) / (PpmMaxPulseWidth - PpmMinPulseWidth) * 1024); /* JR */ } else { newdata = (int)((width - PpmMinPulseWidth) / (PpmMaxPulseWidth - PpmMinPulseWidth) * 1024); /* Futaba */ } /* Trim values into 0-1023 boundries */ if (newdata < 0) { newdata = 0; } else if (newdata > 1023) { newdata = 1023; } /* Update _data - do not allow abrupt change */ if (DataBuffer[DataCount] - newdata > 100) { DataBuffer[DataCount] -= 100; } else if (newdata - DataBuffer[DataCount] > 100) { DataBuffer[DataCount] += 100; } else { DataBuffer[DataCount] = (DataBuffer[DataCount] + newdata) / 2; } //if (input|| m_JsChPostProc_selected!=-1) ChannelData[DataCount] = DataBuffer[DataCount]; /* JR - Assign data to joystick channels */ //else // switch (datacount) //{ // Futaba //case 0: m_Position[1] = data[datacount]; break;/* Assign data to joystick channels */ //case 1: m_Position[2] = data[datacount]; break;/* Assign data to joystick channels */ //case 2: m_Position[0] = data[datacount]; break;/* Assign data to joystick channels */ //case 3: m_Position[3] = data[datacount]; break;/* Assign data to joystick channels */ //case 4: m_Position[4] = data[datacount]; break;/* Assign data to joystick channels */ //case 5: m_Position[5] = data[datacount]; break;/* Assign data to joystick channels */ //case 6: m_Position[6] = data[datacount]; break;/* Assign data to joystick channels */ //case 7: m_Position[7] = data[datacount]; break;/* Assign data to joystick channels */ //case 8: m_Position[8] = data[datacount]; break;/* Assign data to joystick channels */ //case 9: m_Position[9] = data[datacount]; break;/* Assign data to joystick channels */ //case 10: m_Position[10] = data[datacount]; break;/* Assign data to joystick channels */ //case 11: m_Position[11] = data[datacount]; break;/* Assign data to joystick channels */ //}; // Send Position and number of channels to the virtual joystick JoystickInteraction.Instance.Send(RawChannelCount, ChannelData, filterChannels, filter); //if (gDebugLevel >= 3 && gCtrlLogFile /*&& !(i++%50)*/) // fprintf(gCtrlLogFile, " data[%d]=%d", datacount, data[datacount]); if (DataCount == 11) { Sync = false; /* Reset _sync after channel 12 */ } DataCount++; }
public async Task <ActionResult <IResult> > Listing([FromQuery] DataHelperModel dataHelper, bool getAllParent, bool getAll) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var listQuery = from category in context.Categories join createdUser in context.Login on category.CreatedBy equals createdUser.UserID into createdUserName from createdUser in createdUserName.DefaultIfEmpty() let createdByUser = createdUser.Username join modifiedUser in context.Login on category.ModifiedBy equals modifiedUser.UserID into modifiedUserName from modifiedUser in modifiedUserName.DefaultIfEmpty() let modifiedByUser = modifiedUser.Username join products in context.Products on category.CategoryID equals products.CategoryID into productCount from productValueCount in productCount.DefaultIfEmpty() where category.IsDeleted != true orderby category.CreatedDate descending group new { category, productValueCount, createdByUser, modifiedByUser } by new { category, createdByUser, modifiedByUser } into categories select new CategoryViewModel { Name = categories.Key.category.CategoryName, CreatedBy = categories.Key.category.CreatedBy, ID = categories.Key.category.CategoryID, IsActive = categories.Key.category.IsActive, CreatedDate = categories.Key.category.CreatedDate, Description = categories.Key.category.CategoryDescription, ModifiedBy = categories.Key.category.ModifiedBy, ModifiedDate = categories.Key.category.ModifiedDate, CreatedUser = categories.Key.createdByUser, ModifiedUser = categories.Key.modifiedByUser, Parent = categories.Key.category.ParentCategory, Child = categories.Key.category.ChildCategory, ImageContent = "", AssociatedProducts = categories.Where(x => x.productValueCount != null ? x.category.CategoryID == x.category.CategoryID : false).Count() }; if (getAllParent != true) { if (dataHelper.Search != null) { listQuery = listQuery.Where(x => x.Name.Contains(dataHelper.Search) || x.Description.Contains(dataHelper.Search)); } var list = listQuery; list = DataSort.SortBy(list, dataHelper.SortColumn, dataHelper.SortOrder); var resultCount = list.Count(); var pagedList = DataCount.Page(list, dataHelper.PageNumber, dataHelper.PageSize); var resultList = await pagedList.ToListAsync(); ResultModel resultModel = new ResultModel(); resultModel.CategoryResult = resultList; resultModel.TotalCount = resultCount; if (resultList.Count == 0) { result.Status = Status.Fail; result.StatusCode = HttpStatusCode.BadRequest; result.Message = "No records present."; return(StatusCode((int)result.StatusCode, result)); } result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; result.Body = resultModel; return(StatusCode((int)result.StatusCode, result)); } else { if (!getAll) { listQuery = listQuery.Where(x => x.Child == null).OrderBy(x => x.Name); var categoryList = await listQuery.ToListAsync(); result.Body = categoryList; result.Status = Status.Success; result.StatusCode = HttpStatusCode.OK; return(StatusCode((int)result.StatusCode, result)); } else { listQuery = listQuery.OrderBy(x => x.Name); var categoryList = await listQuery.ToListAsync(); result.StatusCode = HttpStatusCode.OK; result.Body = categoryList; result.Status = Status.Success; return(StatusCode((int)result.StatusCode, result)); } } } catch (Exception e) { result.Status = Status.Error; result.Message = e.Message; result.StatusCode = HttpStatusCode.InternalServerError; return(StatusCode((int)result.StatusCode, result)); } }