Пример #1
0
        private void ButtonAddImage_Click(object sender, RoutedEventArgs e)
        {
            var step     = (CrmTypeStep)ListTypeSteps.SelectedItem;
            var newImage = new CrmStepImage {
                Step = step
            };

            new Thread(() =>
            {
                try
                {
                    UpdateStatus("Getting attribute list ...", true);
                    newImage.AttributeList = new ObservableCollection <string>(CrmDataHelper
                                                                               .GetEntityFieldNames(step.Entity, context));
                    UpdateStatus("-- Finished getting attribute list.", false);
                }
                catch (Exception exception)
                {
                    PopException(exception);
                }
                finally
                {
                    UpdateStatus("", false);
                }

                StepImage dialogue = null;
                Dispatcher.Invoke(() =>
                {
                    dialogue = new StepImage(newImage, context);
                    dialogue.ShowDialog();
                });

                try
                {
                    if (dialogue.IsUpdate)
                    {
                        assemblyRegistration.CreateStepImage(newImage);
                        Dispatcher.Invoke(() => step.Children.Add(newImage));
                    }
                }
                catch (Exception exception)
                {
                    PopException(exception);
                }
                finally
                {
                    HideBusy();
                }
            }).Start();
        }
Пример #2
0
        private void ButtonEditImage_Click(object sender, RoutedEventArgs e)
        {
            var step  = (CrmTypeStep)ListTypeSteps.SelectedItem;
            var image = (CrmStepImage)ListStepImages.SelectedItem;

            new Thread(() =>
            {
                try
                {
                    UpdateStatus("Getting attribute list ...", true);
                    image.AttributeList = new ObservableCollection <string>(CrmDataHelper
                                                                            .GetEntityFieldNames(step.Entity, context));
                    UpdateStatus("-- Finished getting attribute list.", false);

                    if (!image.IsUpdated)
                    {
                        UpdateStatus("Updating image info ...", true);
                        // only basic info exists in the image when it is loaded through the step class
                        image.UpdateInfo(context);
                        UpdateStatus("-- Finished updating image info.", false);
                    }
                }
                catch (Exception exception)
                {
                    PopException(exception);
                }
                finally
                {
                    UpdateStatus("", false);
                }

                var clone = image.Clone <CrmStepImage>();

                StepImage dialogue = null;
                Dispatcher.Invoke(() =>
                {
                    dialogue = new StepImage(clone, context);
                    dialogue.ShowDialog();
                });

                try
                {
                    if (dialogue.IsUpdate)
                    {
                        assemblyRegistration.UpdateStepImage(clone);
                        Dispatcher.Invoke(() =>
                        {
                            step.Children.Remove(image);
                            step.Children.Add(clone);
                        });
                    }
                }
                catch (Exception exception)
                {
                    PopException(exception);
                }
                finally
                {
                    HideBusy();
                }
            }).Start();
        }