/// <summary>上行数据</summary> /// <param name="data"></param> protected virtual void PushData(Packet data) { var str = data.ToStr(); var js = new JsonParser(str).Decode() as IDictionary <String, Object>; //var st = JsonHelper.Convert<StatModel>(js[\"stat\"]); var st = StatModel.Read(js["stat"]); if (st != null) { Console.WriteLine(st.ToJson(true)); } var rxs = RxPacket.Read(js["rxpk"]); if (rxs.Length > 0) { OnPushPacket(rxs, js); } //var tx = TxPacket.Read(js["txpk"]); //if (tx != null) Console.WriteLine(tx.ToJson(true)); }
public StatModel SetLists(DateTime start, DateTime end, StatModel stat, int factoryId) { while (end.Date != start.Date) { if (ShiftManager.CheckShiftsOnDay(start, factoryId)) { var row = new ExelRow() { Date = start.ToShortDateString(), TotalDayWeight = ShiftManager.GetShiftTotalWeightByDay(start, factoryId), TotalProduction = ShiftManager.GetShiftProductionByDay(start, factoryId), IncidentCount = IncidentManager.GetByDay(start, factoryId).Count }; stat.ExelTable.Add(row); foreach (var e in IncidentManager.GetByDay(start, factoryId)) { var i = stat.IncidentTable.FirstOrDefault(I => I.Cause == e.Cause.Name); if (i != null) { i.IncidentCount++; } else { stat.IncidentTable.Add(new IncidentRow() { Cause = e.Cause.Name, IncidentCount = 1 }); } } } start = start.AddDays(1); } return(stat); }
public StatModel ByPeriod(string Start, string End, int factoryId) { var factoryList = FactoryManager.GetAll(); var stat = new StatModel(factoryList); var start = StringToDate(Start); var end = StringToDate(End); stat.Date = Start + " - " + End; stat = SetLists(start, end, stat, factoryId); stat.FactoryId = factoryId; stat.Factory = db.Factory.Find(factoryId); var shifts = ShiftManager.GetByTimeInterval(start, end, factoryId); if (shifts.Count != 0) { foreach (var s in shifts) { stat.TotalWeight += s.TotalShiftWeight; stat.DownTime += s.DownTime; stat.ProductionPct += s.ProductionPct; } stat.ProductionPct /= shifts.Count; return(stat); } return(null); }
public void EditStat(StatModel model) { _dao.EditStat(Convert(model)); }
public void CreateStat(StatModel model) { _dao.CreateStat(Convert(model)); }
public ActionResult Update(StatModel stat) { statRepo.EditStat(stat); return(RedirectToAction("Details", stat.EntityType.ToString(), new { ID = stat.EntityId })); }
public static Stat ToEntity(this StatModel model) { return(new Stat(new StatName(model.Name), new StatValue(model.Value), new StatWeighting(model.Weighting))); }
private void OnStatAdded(object sender, StatModel e) { _viewmodel.SelectedItem.AddStat(e); _select(e); }
public HttpResponseMessage getStampaByUserMail(FormDataCollection collection) { StatModel model = new StatModel(); DateTime datainzio = System.DateTime.Parse(collection["dt"]); DateTime datafine = System.DateTime.Parse(collection["df"]); string utente = collection["utente"]; string mail = collection["mail"]; if (utente.ToUpper().Contains("SELEZIONARE")) { utente = string.Empty; } try { BackendUserService bus = new BackendUserService(); int starti = 1; int recordPagina = 100; int tot = 0; List <UserResultItem> list = bus.GetStatsInBox(mail, utente, datainzio, datafine, starti, recordPagina, ref tot); if (list.Count > 0) { byte[] response = null; response = PrintWrapperITEXT.StampaStat(list); model.success = "true"; string filename = "StatisticheLavorazioni" + System.DateTime.Now.ToString("dd/MM/yyyy HH:MI:ss") + ".pdf"; var server = VirtualPathUtility.ToAbsolute("~/"); var auth = Request.RequestUri.Authority; model.Url = "http://" + auth + server + "api/StatServiceController/getFile"; SessionManager <byte[]> .set(SessionKeys.STAMPA_STATISTICA, response); //MemoryStream output = new MemoryStream(); //output.Write(response, 0, response.Length); //output.Position = 0; //HttpResponseMessage result = this.Request.CreateResponse(HttpStatusCode.OK); //result.Content = new StreamContent(output); //result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); //result.Content.Headers.ContentDisposition.FileName = "StatisticheLavorazioni.pdf"; //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); //result.Content.Headers.ContentLength = output.Length; //return result; return(this.Request.CreateResponse <StatModel>(HttpStatusCode.OK, model)); } else { model.Totale = "0"; model.success = "false"; model.message = "Nessuna ritrovamento per la stampa"; return(this.Request.CreateResponse <StatModel>(HttpStatusCode.OK, model)); } } catch (Exception ex) { ErrorLogInfo error = new ErrorLogInfo(); error.freeTextDetails = ex.Message + " " + "Parameteri: " + utente + " " + mail + " " + datainzio.ToString() + " " + datafine.ToString(); error.logCode = "ERR_S02"; error.loggingAppCode = "PEC"; error.loggingTime = System.DateTime.Now; error.uniqueLogID = System.DateTime.Now.Ticks.ToString(); log.Error(error); model.message = ex.Message; model.success = "false"; return(this.Request.CreateResponse <StatModel>(HttpStatusCode.OK, model)); } }
public StatViewModel CreateStat(StatModel statModel) { return(new StatViewModel(statModel, _statTranslater)); }
private void DrawGraph(Artist artist) { StatModel.Series.Clear(); StatModel.Axes.Clear(); var categoryAxis = new OxyPlot.Axes.CategoryAxis { Position = AxisPosition.Bottom }; var s1 = new OxyPlot.Series.ColumnSeries { Title = $"Творчество художника ({artist.full_name})", StrokeColor = OxyColors.Black, StrokeThickness = 1 }; var paintings = context.Paintings.Where(x => x.artist_id == artist.id && x.year_of_creation != null) .OrderBy(x => x.year_of_creation) .ToArray(); if (paintings.Any()) { var min = artist.date_of_birth.Value.Year; var max = artist.date_of_death?.Year != null ? artist.date_of_death.Value.Year : artist.date_of_birth.Value.AddYears(120).Year; int currIndex = 0; for (int i = min; ; i += 5) { var nextBound = i + 5; if (nextBound > max) { nextBound = max; } int count = 0; while (currIndex < paintings.Length && paintings[currIndex].year_of_creation <= nextBound) { count++; currIndex++; } s1.Items.Add(new ColumnItem(count)); categoryAxis.Labels.Add(i + Environment.NewLine + nextBound); if (nextBound == max) { break; } } var valueAxis = new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0 }; StatModel.Series.Add(s1); StatModel.Axes.Add(categoryAxis); StatModel.Axes.Add(valueAxis); StatModel.InvalidatePlot(true); } }