//设备授时 private void button7_Click(object sender, EventArgs e) { for (int i = 0; i < ManualRec.userIDList.Count; i++) { bool temp_bool = TimingSet.TimingSetByAuto(ManualRec.userIDList.ElementAt(i).Value); } }
//设备授时 private void button7_Click(object sender, EventArgs e) { for (int i = 0; i < ManualRec.userIDList.Count; i++) { bool temp_bool = TimingSet.TimingSetByAuto(ManualRec.userIDList.ElementAt(i).Value); if (temp_bool) { MessageBox.Show("授时成功"); } else { MessageBox.Show("授时失败"); } } }
/// <summary> /// Creates a ViewModel for the given ProcessReport with given row and column /// </summary> /// <param name="model">if null, it automatically assign unreported process space</param> public ProcessReportVm(Model.ProcessReport model, Dal.SoheilEdmContext uow) { Model = model; Message = new EmbeddedException(); try { ActivityName = model.Process.StateStationActivity.Activity.Name; ProductName = model.Process.StateStationActivity.StateStation.State.FPC.Product.Name; ProductColor = model.Process.StateStationActivity.StateStation.State.FPC.Product.Color; } catch { } //uow UOW = uow; _processReportDataService = new DataServices.ProcessReportDataService(UOW); _taskReportDataService = new DataServices.TaskReportDataService(UOW); //properties //Model.ProducedG1 = Model.OperatorProcessReports.Sum(x => x.OperatorProducedG1);//??? can be different than sum ProducedG1 = Model.ProducedG1; Timing = new TimingSet(this); Timing.Saved += () => Save(); Timing.DurationChanged += v => Model.DurationSeconds = v; Timing.StartChanged += v => Model.StartDateTime = v; Timing.EndChanged += v => Model.EndDateTime = v; Timing.TargetPointChanged += tp => { TargetPointForOperator = Model.OperatorProcessReports.Any() ? string.Format("{0:F2}", (float)tp / Model.OperatorProcessReports.Count) : "---"; Model.ProcessReportTargetPoint = tp; updateEmptyCount(tp: tp); }; TargetPointForOperator = Model.OperatorProcessReports.Any() ? string.Format("{0:F2}", (float)Model.ProcessReportTargetPoint / Model.OperatorProcessReports.Count) : "---"; //reports OperatorReports = new OperatorReportCollection(this); DefectionReports = new DefectionReportCollection(this); DefectionCount = (int)Model.DefectionReports.Sum(x => x.CountEquivalence); StoppageReports = new StoppageReportCollection(this); StoppageCount = (int)Model.StoppageReports.Sum(x => x.CountEquivalence); IsUserDrag = false; _isInInitializingPhase = false; initializeCommands(); }
/// <summary> /// Creates an instance of PPEditorProcess with given model within the given PPEditorTask /// <para>Updates its choices and operators and machines as well</para> /// </summary> /// <param name="model"></param> public ProcessEditorVm(Model.Process model, Model.Activity activityModel, Dal.SoheilEdmContext uow) { _isInitializing = true; #region Basic _uow = uow; Model = model; ActivityModel = activityModel; HasReport = Model.ProcessReports.Any(); Message = new Common.SoheilException.EmbeddedException(); Timing = new TimingSet(this); Timing.DurationChanged += v => Model.DurationSeconds = v; Timing.StartChanged += v => Model.StartDateTime = v; Timing.EndChanged += v => Model.EndDateTime = v; Timing.TargetPointChanged += tp => Model.TargetCount = tp; Timing.TimesChanged += (start, end) => { if (TimesChanged != null) TimesChanged(this, start, end); }; #endregion #region Machines //SelectedMachines foreach (var sm in model.SelectedMachines) { var machineVm = new MachineEditorVm(sm); SelectedMachines.Add(machineVm); } NoSelectedMachines = !SelectedMachines.Any(); //MachineFamilyList ShowAllMachinesCommand = new Commands.Command(o => { if (Model.StateStationActivity == null) { Message.AddEmbeddedException("فعالیت یا نفرساعت آن نامعتبر است"); return; } IsSelected = true; if (ShowAllMachines) return; ShowAllMachines = true; MachineFamilyList.Clear(); //Load Model var ssams = new List<Model.StateStationActivityMachine>(); foreach (var ssa in Model.StateStationActivity.StateStation.StateStationActivities) { ssams.AddRange(ssa.StateStationActivityMachines); } var machines = ssams.GroupBy(x => x.Machine); var machineFamilies = machines.GroupBy(x => x.Key.MachineFamily); //Create ViewModel foreach (var machineFamily in machineFamilies) { var machineFamilyVm = new MachineFamilyEditorVm(machineFamily); machineFamilyVm.SelectionChanged += (vm, val) => { //add/remove SelectedMachines var sm = SelectedMachines.FirstOrDefault(x => x.MachineId == vm.MachineId); if (val && sm == null) { SelectedMachines.Add(vm); } else if (!val) { SelectedMachines.Remove(sm); } NoSelectedMachines = !SelectedMachines.Any(); }; //revalidate foreach (var machineVm in machineFamilyVm.MachineList) { machineVm.Revalidate(model); machineVm.IsUsed = SelectedMachines.Any(x => x.MachineId == machineVm.MachineId); } MachineFamilyList.Add(machineFamilyVm); } }); #endregion //set operators after those 2, because when choice is selected we expect to have valid information in this vm #region Operators //select the right choice based on ManHour foreach (var oper in model.ProcessOperators) { SelectedOperators.Add(new OperatorVm(oper.Operator)); } SelectedOperatorsCount = model.ProcessOperators.Count; SelectedOperators.CollectionChanged += (s, e) => { SelectedOperatorsCount = SelectedOperators.Count; if (SelectedOperatorsCountChanged != null) SelectedOperatorsCountChanged(this, SelectedOperators.Count); }; #endregion //command SelectCommand = new Commands.Command(o => IsSelected = true); DeleteCommand = new Commands.Command(o => { var succeed = new DataServices.TaskDataService(uow).DeleteModel(Model, (bool)o); if (succeed) { //uow.Commit(); if (Deleted != null) Deleted(this); } else Message.AddEmbeddedException("Activity has reports"); }); _isInitializing = false; }