public void OnSaved(ESyncProcessEdit model, ProcessEdit parentModel)
        {
            Model = model;
            ParentModel = parentModel;

            if (Model != null)
            {
                EndpointsViewModel.OnSaved(Model.Endpoints);
                SchedulerViewModel.OnSaved(Model.Scheduler);
            }
            else
            {
                ThePopupFactory.NotifyFailure("Model is null after saving sync process");
                Logger.Log(LogSeverity.Error, GetType().ToString(), "Model is null after saving sync process");
            }
        }
        /// <summary>
        /// Loads the expression items.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="syncProcess">The synchronize process.</param>
        private void LoadExpressionItems(ProcessEdit process, ESyncProcessEdit syncProcess)
        {
            WindowManager.Value.ShowStatus(new Status { IsBusy = true });

            var expressions = new List<IExpressionObjectBase>();
            var newExpressions = new List<IExpressionObjectBase>();

            var syncContext = new NotifyClientAction(
                () =>
                    {
                        _expressionDesigner.LoadFromExpressionObjects(expressions);
                        WindowManager.Value.ShowStatus(new Status());
                    });

            syncContext.OperationStarted();

            var source = new SourceFieldList { ExpressionName = "Source", Top = 10, Left = 10 };

            foreach (var providerField in syncProcess.Endpoints.Source.ProviderFields)
            {
                var sourceField = CreateSourceField(providerField, source);

                if (sourceField != null)
                    source.Fields.Add(sourceField);
            }

            newExpressions.Add(source);

            var destination = new DestinationFieldList { ExpressionName = process.Name, Top = 10, Left = 600 };

            AddIdFields(destination);
            AddStateFields(process, destination);
            AddVersionFields(process, destination);

            foreach (var field in process.GetAllFields().Where(CanBeDestinationField))
            {
                var destinationField = CreateDestinationField(field, destination);

                if (destinationField != null)
                    destination.Fields.Add(destinationField);
            }

            newExpressions.Add(destination);

            if (!string.IsNullOrWhiteSpace(syncProcess.Map.Designer))
            {
                try
                {
                    var expressionsContainer = ExpressionsSerializer.Deserialize(syncProcess.Map.Designer);
                    ExpressionNodeFactory.RestoreConnections(expressionsContainer.Expressions);
                    expressions.AddRange(expressionsContainer.Expressions);
                }
                catch
                {
                    // Do nothing, new expressions will be used.
                }
            }

            UpdateStateList(process);

            UpdateStoredExpressions(expressions, newExpressions, syncContext);

            syncContext.OperationCompleted();
        }
        public void Initialize(ESyncProcessEdit process, ProcessEdit parentModel, ITopLevelWindow parentWindow)
        {
            if (process == null) throw new ArgumentNullException("process");

            Model = process;
            ParentModel = parentModel;
            ParentWindow = parentWindow;
            
            EndpointsViewModel.Initialize(process.Endpoints, parentWindow);
            SchedulerViewModel.Initialize(process.Scheduler);

            JobStatus = ESyncJobStatus.Unknown;
        }
        /// <summary>
        /// Edits the expression.
        /// </summary>
        /// <param name="parentWindow">The parent window.</param>
        /// <param name="process">The process.</param>
        /// <param name="syncProcess">The synchronize process.</param>
        /// <param name="saveAction">The save action.</param>
        /// <param name="cancelAction">The cancel action.</param>
        /// <param name="removeAction">The remove action.</param>
        public void EditExpression(
            ITopLevelWindow parentWindow,
            ProcessEdit process,
            ESyncProcessEdit syncProcess,
            Action saveAction,
            Action cancelAction,
            Action removeAction)
        {
            _saveAction = saveAction;
            _cancelAction = cancelAction;
            _removeAction = removeAction;

            _expressionDesigner.LoadFromExpressionObjects(new List<IExpressionObjectBase>());

            LoadExpressionItems(process, syncProcess);
            WindowManager.Value.ShowChildWindow(parentWindow, this);
        }