private void PollingCountPieces() { // Aggiorno a mano i valori di tre tag int maxAge = 0; ItemIdentifier[] OPCItems = new ItemIdentifier[2]; ItemValue[] OPCItemValues = null; OPCItems[0] = new ItemIdentifier(); OPCItems[0].ItemName = "its-iot-device.Device1.PieceCounter"; OPCItems[0].ClientHandle = 1; OPCItems[1] = new ItemIdentifier(); OPCItems[1].ItemName = "its-iot-device.Device1.DefectedPiecesCounter"; OPCItems[1].ClientHandle = 2; // ab edit: corretto gli indici Console.WriteLine(OPCItems[0].ItemName + "--PIECE COUNTER"); Console.WriteLine(OPCItems[1].ItemName + "--DEFECTED PIECES\n"); try { daServerMgt.Read(maxAge, ref OPCItems, out OPCItemValues); if (OPCItems[0].ResultID.Succeeded && OPCItemValues[0].Quality.IsGood && OPCItems[1].ResultID.Succeeded && OPCItemValues[1].Quality.IsGood) { int num; int numDefected; Console.WriteLine(OPCItemValues[0].Value.ToString() + "\n"); Console.WriteLine(OPCItemValues[1].Value.ToString() + "\n"); int.TryParse(OPCItemValues[0].Value.ToString(), out num); int.TryParse(OPCItemValues[1].Value.ToString(), out numDefected); DailyProduction dailyProduction = new DailyProduction() { // ab edit: mancava Timestamp TimeStamp = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59), NumPieces = num, NumPiecesRejected = numDefected }; SavePlantDailyProductionToDb(dailyProduction); } else { // ab edit: aggiungiamo ilcontesto per capire l'errore Console.WriteLine($"ResultID 0: {OPCItems[0].ResultID.Description}\n"); Console.WriteLine($"ResultID 1: {OPCItems[1].ResultID.Description}\n"); } } catch (Exception ex) { // ab edit: aggiungiamo ilcontesto per capire l'errore Console.WriteLine($"PollingCountPieces exeception: {ex.ToString()}"); } }
public virtual int _GetUniqueIdentifier() { var hashCode = 399326290; hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (DateOfStockUpdate?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (DailyProduction?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Stock?.GetHashCode() ?? 0); return(hashCode); }
public JsonResult Edit(DailyProduction dprod) { DateTime sdate = dprod.CDate; DateTime edate = dprod.CDate.AddDays(1); List <DailyProduction> dailyprod = db.DailyProductions .Where(x => x.CDate >= sdate && x.CDate <= edate) .OrderByDescending(x => x.CDate).ToList(); return(Json(dailyprod, JsonRequestBehavior.AllowGet)); }
public JsonResult Index(DailyProduction objdailyproduct) { if (ModelState.IsValid) { string [] datepart = GetCalendarYearData(objdailyproduct.PDate); objdailyproduct.DpDay = datepart[0]; objdailyproduct.DpMonth = datepart[1]; objdailyproduct.DpYear = datepart[2]; objdailyproduct.DpWeek = datepart[3]; objdailyproduct.DpQuarter = datepart[4]; objdailyproduct.CDate = DateTime.Now; db.DailyProductions.Add(objdailyproduct); db.SaveChanges(); } //return Content("success"); //return "succes"; return(Json(objdailyproduct, JsonRequestBehavior.AllowGet)); }
public ActionResult EditEmp(DailyProduction objdaily) { try { if (ModelState.IsValid) { string[] datepart = GetCalendarYearData(objdaily.PDate); objdaily.DpDay = datepart[0]; objdaily.DpMonth = datepart[1]; objdaily.DpYear = datepart[2]; objdaily.DpWeek = datepart[3]; objdaily.DpQuarter = datepart[4]; objdaily.CDate = DateTime.Now; db.Entry(objdaily).State = EntityState.Modified; db.SaveChanges(); } return(Json(objdaily, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public static DailyProduction GetDailyProduction(this DailyProduction s) { try { if (s == null) { return(null); } return(new DailyProduction() { id = s.id, id_daily_intake = s.id_daily_intake, id_directory_production = s.id_directory_production, value = s.value, change = s.change, change_user = s.change_user, }); } catch (Exception e) { return(null); } }
private void SavePlantDailyProductionToDb(DailyProduction dailyProduction) { dailyProductionDataAccess.Insert(dailyProduction); }