public ToolVM(WorkOrderDetailVM workOrderDetailVM, MaximoToolTrans toolTrans = null) { WorkOrderDetailVM = workOrderDetailVM; CancelCommand = new Command.CancelCommand <ToolVM>(this); SaveCommand = new Command.SaveCommand <ToolVM>(this); ToolTrans = toolTrans; ToolList = MaximoServiceLibrary.AppContext.inventoryRepository.findAll().ToList(); if (ToolTrans != null) { Quantity = ToolTrans.toolqty.ToString(); Duration = new DateTime(1900, 1, 1).AddHours(ToolTrans.toolhrs); Tool = ToolTrans.itemnum; } else { Quantity = "1"; Tool = MaximoServiceLibrary.AppContext.synchronizationService.mxuser?.userPreferences?.setting?.vehiclenum; } }
public void Save() { if (ToolTrans == null) { MaximoToolTrans tool = new MaximoToolTrans(); tool.transdate = DateTime.Now; tool.toolrate = 0; tool.toolqty = Convert.ToInt32(Quantity); tool.toolhrs = Duration.TimeOfDay.TotalHours; tool.itemnum = Tool; tool.itemsetid = "IDC_WASA"; tool.enterdate = DateTime.Now; tool.enterby = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId; tool.langcode = "EN"; tool.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED; WorkOrderDetailVM.ToolTrans.Add(tool); } else { Index = WorkOrderDetailVM.ToolTrans.IndexOf(ToolTrans); ToolTrans.toolqty = Convert.ToInt32(Quantity); ToolTrans.toolhrs = Duration.TimeOfDay.TotalHours; ToolTrans.itemnum = Tool; ToolTrans.enterdate = DateTime.Now; ToolTrans.enterby = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId; if (ToolTrans.syncronizationStatus != LocalDBLibrary.model.SyncronizationStatus.CREATED) { ToolTrans.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED; } WorkOrderDetailVM.ToolTrans[Index] = ToolTrans; } Close(); }
public void Execute(object parameter) { if (parameter == null) { return; } if (((MaximoWorkOrder)parameter).status != "DISPTCHD") { return; } var values = MaximoServiceLibrary.AppContext.workOrderRepository.findNot("startTimerDate", null).ToList(); if (values.Count > 0) { if (values[0].Id == ((MaximoWorkOrder)parameter).Id) { } else { MessageBox.Show($"Wonum : {values[0].wonum} is still start timer"); var woo = WorkOrderListVM.WorkOrders.Where(w => w.Id == values[0].Id).FirstOrDefault(); if (woo != null) { WorkOrderListVM.listView.ScrollIntoView(woo); } return; } } else { } MaximoWorkOrder wo = ((MaximoWorkOrder)parameter); if (wo.startTimerDate == null) { wo.startTimerDate = DateTime.Now; wo.timerImageUri = "pack://application:,,,/CatchBasin;component/Resources/Images/startWatch.png"; MaximoServiceLibrary.AppContext.workOrderRepository.upsert(wo); WorkOrderListVM.Update(); } else { DateTime stopTimerDate = DateTime.Now; DateTime startTimerDate = Convert.ToDateTime(wo.startTimerDate); TimeSpan?time = stopTimerDate - wo.startTimerDate; MaximoServiceLibrary.AppContext.Log.Warn($"time :{time}"); var mxuser = MaximoServiceLibrary.AppContext.synchronizationService.mxuser; MaximoLabTrans labTrans = new MaximoLabTrans(); MaximoLabTrans secondlabTrans = new MaximoLabTrans(); labTrans.startdateentered = startTimerDate - startTimerDate.TimeOfDay; labTrans.starttimeentered = new DateTime(1900, 1, 1) + startTimerDate.TimeOfDay; labTrans.finishdateentered = stopTimerDate - stopTimerDate.TimeOfDay; labTrans.finishtimeentered = new DateTime(1900, 1, 1) + stopTimerDate.TimeOfDay; labTrans.transdate = DateTime.Now; if (wo.worktype == "EM" || wo.worktype == "INV" || wo.worktype == "EMERG") { labTrans.transtype = "TRAV"; } else { labTrans.transtype = "WORK"; } var _labors = MaximoServiceLibrary.AppContext.laborRepository.Find("person[*].personid", mxuser.userPreferences.setting?.leadMan).ToList(); try { labTrans.craft = _labors?[0].laborcraftrate?[0].craft; } catch (Exception e) { labTrans.craft = null; } labTrans.siteid = "DWS_DSS"; labTrans.orgid = "DC_WASA"; labTrans.dcw_truckdriver = mxuser.userPreferences.setting?.leadMan == mxuser.userPreferences.setting?.driverMan; labTrans.dcw_trucksecond = false; labTrans.dcw_trucklead = true; labTrans.dcw_trucknum = mxuser.userPreferences.setting.vehiclenum; labTrans.enterdate = DateTime.Now; labTrans.laborcode = mxuser.userPreferences.setting?.leadMan; labTrans.enterby = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId; labTrans.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED; if (((App)Application.Current).AppType == "PM") { secondlabTrans.startdateentered = startTimerDate - startTimerDate.TimeOfDay; secondlabTrans.starttimeentered = new DateTime(1900, 1, 1) + startTimerDate.TimeOfDay; secondlabTrans.finishdateentered = stopTimerDate - stopTimerDate.TimeOfDay; secondlabTrans.finishtimeentered = new DateTime(1900, 1, 1) + stopTimerDate.TimeOfDay; secondlabTrans.transdate = DateTime.Now; if (wo.worktype == "EM" || wo.worktype == "INV" || wo.worktype == "EMERG") { secondlabTrans.transtype = "TRAV"; } else { secondlabTrans.transtype = "WORK"; } _labors = MaximoServiceLibrary.AppContext.laborRepository.Find("person[*].personid", mxuser.userPreferences.setting?.secondMan).ToList(); try { secondlabTrans.craft = _labors?[0].laborcraftrate?[0].craft; } catch (Exception e) { secondlabTrans.craft = null; } secondlabTrans.siteid = "DWS_DSS"; secondlabTrans.orgid = "DC_WASA"; secondlabTrans.dcw_truckdriver = mxuser.userPreferences.setting?.secondMan == mxuser.userPreferences.setting?.driverMan; secondlabTrans.dcw_trucksecond = true; secondlabTrans.dcw_trucklead = false; secondlabTrans.dcw_trucknum = mxuser.userPreferences.setting.vehiclenum; secondlabTrans.enterdate = DateTime.Now; secondlabTrans.laborcode = mxuser.userPreferences.setting?.secondMan; secondlabTrans.enterby = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId; secondlabTrans.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED; } MaximoToolTrans tool = new MaximoToolTrans(); tool.transdate = DateTime.Now; tool.toolrate = 0; tool.toolqty = 1; if (time.HasValue) { tool.toolhrs = time.Value.TotalHours; } tool.itemnum = mxuser.userPreferences.setting.vehiclenum; tool.itemsetid = "IDC_WASA"; tool.enterdate = DateTime.Now; tool.enterby = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId; tool.langcode = "EN"; tool.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED; if (WorkOrderListVM.MapVM.WorkOrderDetailIsVisible && wo?.Id == WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder?.Id) { WorkOrderListVM.MapVM.WorkOrderDetailVM.LabTrans.Add(labTrans); if (((App)Application.Current).AppType == "PM") { WorkOrderListVM.MapVM.WorkOrderDetailVM.LabTrans.Add(secondlabTrans); } WorkOrderListVM.MapVM.WorkOrderDetailVM.ToolTrans.Add(tool); WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder.startTimerDate = null; WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder.timerImageUri = "pack://application:,,,/CatchBasin;component/Resources/Images/stopWatch.png"; } else { if (wo.labtrans == null) { wo.labtrans = new List <MaximoLabTrans>(); } wo.labtrans.Add(labTrans); if (((App)Application.Current).AppType == "PM") { wo.labtrans.Add(secondlabTrans); } if (wo.tooltrans == null) { wo.tooltrans = new List <MaximoToolTrans>(); } wo.tooltrans.Add(tool); } wo.startTimerDate = null; wo.timerImageUri = "pack://application:,,,/CatchBasin;component/Resources/Images/stopWatch.png"; wo = MaximoServiceLibrary.AppContext.workOrderRepository.upsert(wo); WorkOrderListVM.Update(); if (!WorkOrderListVM.MapVM.WorkOrderDetailIsVisible) { WorkOrderListVM.showWorkOrder(wo); } } }