Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public void EditStat(StatModel model)
 {
     _dao.EditStat(Convert(model));
 }
Esempio n. 5
0
 public void CreateStat(StatModel model)
 {
     _dao.CreateStat(Convert(model));
 }
Esempio n. 6
0
        public ActionResult Update(StatModel stat)
        {
            statRepo.EditStat(stat);

            return(RedirectToAction("Details", stat.EntityType.ToString(), new { ID = stat.EntityId }));
        }
Esempio n. 7
0
 public static Stat ToEntity(this StatModel model)
 {
     return(new Stat(new StatName(model.Name), new StatValue(model.Value), new StatWeighting(model.Weighting)));
 }
Esempio n. 8
0
 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));
            }
        }
Esempio n. 10
0
 public StatViewModel CreateStat(StatModel statModel)
 {
     return(new StatViewModel(statModel, _statTranslater));
 }
Esempio n. 11
0
        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);
            }
        }