private void LoadCalibrationComponentTypes(NodeView expandedNode) { CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); EventHandler<GetCalibrationComponentTypesCompletedEventArgs> fetchCompleted = null; fetchCompleted = (s, eventArgs) => { List<CalibrationComponentType> calibrationComponentTypes = eventArgs.Result; foreach (CalibrationComponentType calibrationComponentType in calibrationComponentTypes) { NodeView child = new NodeView(expandedNode) { Id = calibrationComponentType.Id, Name = calibrationComponentType.Name, Description = calibrationComponentType.Description, Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png", Type = NodeType.CalibrationComponentType, HasChildren = true, SortField = calibrationComponentType.Ordinal.ToString() }; expandedNode.Children.Add(child); } cmsWebServiceClient.GetCalibrationComponentTypesCompleted -= fetchCompleted; expandedNode.Sort(); }; cmsWebServiceClient.GetCalibrationComponentTypesCompleted += fetchCompleted; cmsWebServiceClient.GetCalibrationComponentTypesAsync(false); }
private void Initialize() { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetCalibrationComponentTypesCompleted += (s, e) => { Types = e.Result; if (mCalibrationComponent.CalibrationComponentType != null) { SelectedType = (from x in Types where x.Id == mCalibrationComponent.CalibrationComponentTypeId select x).FirstOrDefault(); } cmsWebServiceClient.GetInstrumentVerificationFrequencyCompleted += (s1, e1) => { mVerificationFrequency = e1.Result; if (mVerificationFrequency.Duration > 0) { if (mVerificationFrequency.DurationInDays) { mCalibrationComponent.NextInspectionDate = mCalibrationComponent.LastInspectedDate.Value.AddDays(mVerificationFrequency.Duration); } else { mCalibrationComponent.NextInspectionDate = mCalibrationComponent.LastInspectedDate.Value.AddMonths(mVerificationFrequency.Duration); } } Loaded(); }; cmsWebServiceClient.GetInstrumentVerificationFrequencyAsync(mCalibrationComponent.InstrumentId); }; cmsWebServiceClient.GetCalibrationComponentTypesAsync(); OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); }