//public ToolInventoriesController(CsmForAsml2Context context, // IHubContext<CsmHub> hubcontext, // ICreateExcelFile<ToolInventory> crExcel) { public ToolInventoriesController(CsmForAsml2Context context, ICreateExcelFile <ToolInventory> crExcel) { _context = context; _toolRepo = context.ToolInventoryRepository; //_hubContext = hubcontext; _crExcel = crExcel; }
public async Task <ActionResult> SavePInfo([FromBody] PInfo PInfoData) { string clientId = PInfoData.connectionId; if (PInfoData.ChangedP) { MaterialNeedCalRepository matrep = _context.MaterialNeedCalRepository; var materialEntry = matrep.GetRecord(PInfoData.Material); materialEntry.PMaker = PInfoData.PMaker; materialEntry.PModel = PInfoData.PModel; materialEntry.PName = PInfoData.PName; matrep.UpdateRecord(materialEntry); } if (PInfoData.ChangedS) { ToolInventoryRepository toolrep = _context.ToolInventoryRepository; ToolInventory toolInvEntry = toolrep.GetRecord(PInfoData.Serial); toolInvEntry.PSN = PInfoData.PSerial; toolrep.UpdateRecord(toolInvEntry); } await _hubContext.Clients.Client(clientId).SendAsync("PInfoSaved"); return(new EmptyResult()); }
public ActionResult MoveToIncal([FromBody] SerialAndFlagList serial) { const double warningLevel = 0.5; const double daysInYear = 365.25; ToolInventoryRepository tir = _context.ToolInventoryRepository; MaterialNeedCalRepository mncr = _context.MaterialNeedCalRepository; CalInProcessRepository cipr = _context.CalInProcessRepository; CalDateRepository cdr = _context.CalDateRepository; List <CalStat> calstatlist = new List <CalStat>(); for (int i = 0; i < serial.SerialNums.Count; ++i) { //foreach (var num in serial.SerialNums) { CalStat stat = new CalStat(); stat.SerialNumber = serial.SerialNums[i]; calstatlist.Add(stat); if (serial.NoCheckFlags[i]) { // RegistorToInCal(stat.SerialNumber); stat.MoveToIncal = true; continue; } var cip = cipr.GetLatestRecords(ci => ci.SerialNumber == stat.SerialNumber); if (cip != null && (cip.CalDate == null || cip.VenShipDate == null)) { stat.MoveToIncal = false; stat.InInCal = true; stat.CommentToUser = "******"; continue; } var inventory = tir.GetRecord(stat.SerialNumber); var material = mncr.GetRecord(inventory.Material); int calInterval = material.CalInterval ?? 12; // calInterval is in months int calIntervalInDays = (int)(daysInYear / 12.0) * calInterval; DateTime?LatestCalDate = cdr.GetLatestCalDate(stat.SerialNumber); if (LatestCalDate != null) { int days = AppResources.JSTNow.Subtract((DateTime)LatestCalDate).Days; double percentdays = (double)days / (double)calIntervalInDays; if (percentdays < warningLevel) { stat.MoveToIncal = false; stat.CommentToUser = $"この Material {inventory.Material} の校正周期は {calInterval} ヵ月です。この Serial の 最新校正日は{LatestCalDate:d}でそこから {days} 日、校正周期の {percentdays:p1} しか経っていません。再度校正のため In-Cal に移動しますか?"; continue; } } // RegistorToInCal(stat.SerialNumber); //disabled for debugging front end (2020/10/01) stat.MoveToIncal = true; } var serializeOptions = new JsonSerializerOptions { // PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNamingPolicy = null, WriteIndented = true }; return(Json(calstatlist, serializeOptions)); }