コード例 #1
0
        private void AddInstrumentEquipmentButtonHandler(object parameter)
        {
            AddIssueInstrumentDialog addIssueInstrumentDialog = new AddIssueInstrumentDialog();
            addIssueInstrumentDialog.Show();
            addIssueInstrumentDialog.Closed +=
                (s1, e1) =>
                {
                    if (addIssueInstrumentDialog.DialogResult.HasValue && addIssueInstrumentDialog.DialogResult.Value)
                    {
                        List<QuickInstrument> equipmentsToAdd = addIssueInstrumentDialog.SelectedEquipments.ToList();

                        List<int> ids = (from x in equipmentsToAdd select x.Id).ToList();

                        CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                        cmsWebServiceClient.GetInstrumentsByIdsCompleted +=
                            (s2, e2) =>
                            {
                                foreach (Instrument instrument in e2.Result)
                                {
                                    IssueRelatedInstrument existingEquipments = (from x in mIssue.IssueRelatedInstruments where x.InstrumentId == instrument.Id select x).FirstOrDefault();
                                    if (existingEquipments == null)
                                    {
                                        mIssue.IssueRelatedInstruments.Add(new IssueRelatedInstrument
                                                                                        {
                                                                                            IssueId = mIssue.Id,
                                                                                            InstrumentId = instrument.Id,
                                                                                            Instrument = instrument
                                                                                        });
                                    }
                                }

                                RaiseChangeEvent();

                                RaisePropertyChanged("IssueRelatedInstruments");

                                OnCollectionChanged();
                            };

                        cmsWebServiceClient.GetInstrumentsByIdsAsync(ids);
                    }
                };
        }
コード例 #2
0
        private void MoveComponentHandler(object parameter)
        {
            if (SelectedComponent != null)
            {
                AddIssueInstrumentDialog dialog = new AddIssueInstrumentDialog("Select Destination Tag", true, SelectedComponent.InstrumentId);
                dialog.Show();

                //Select the component as user might have changed the component type
                //and this needs to reload the component type properties
                dialog.Closed += (s1, e1) =>
                                     {
                                         if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                                         {
                                             if (dialog.SelectedEquipment != null)
                                             {
                                                 SelectedComponent.InstrumentId = dialog.SelectedEquipment.Id;

                                                 //need to CLONE due to the line "RaisePropertyChanged("Components");"
                                                 var movedInstrumentComponent = CloneComponent(SelectedComponent);
                                                 movedInstrumentComponent.Instrument = new Instrument
                                                                                           {
                                                                                               Id = dialog.SelectedEquipment.Id,
                                                                                               Name = dialog.SelectedEquipment.Name
                                                                                           };

                                                 MovedComponents.Add(movedInstrumentComponent);

                                                 //remove
                                                 mInstrument.InstrumentComponents.Remove(SelectedComponent);
                                                 RaiseChangeEvent();
                                                 OnCollectionChanged();
                                                 mSelectedComponent = null;

                                                 RaisePropertyChanged("Components");
                                             }
                                         }
                                     };
            }
        }