示例#1
0
        void SetupLazyComs()
        {
            if (_explorerItemViewModel.IsFolder)
            {
                _lazyComs = new CommunicationController {
                    ServiceName = "DuplicateFolderService"
                };
                _lazyComs.AddPayloadArgument("FixRefs", FixReferences.ToString());
            }
            _lazyComs.AddPayloadArgument("NewResourceName", Name);

            if (!_explorerItemViewModel.IsFolder)
            {
                _lazyComs.AddPayloadArgument("ResourceID", _explorerItemViewModel.ResourceId.ToString());
            }

            _lazyComs.AddPayloadArgument("sourcePath", _explorerItemViewModel.ResourcePath);
            _lazyComs.AddPayloadArgument("destinationPath", Path);
        }
示例#2
0
        private void CallDuplicateService()
        {
            ObservableCollection <IExplorerItemViewModel> childItems = null;

            try
            {
                IsDuplicating = true;

                if (_explorerItemViewModel.IsFolder)
                {
                    _lazyComs = new CommunicationController {
                        ServiceName = "DuplicateFolderService"
                    };
                    _lazyComs.AddPayloadArgument("FixRefs", FixReferences.ToString());
                }
                _lazyComs.AddPayloadArgument("NewResourceName", Name);

                if (!_explorerItemViewModel.IsFolder)
                {
                    _lazyComs.AddPayloadArgument("ResourceID", _explorerItemViewModel.ResourceId.ToString());
                }

                _lazyComs.AddPayloadArgument("sourcePath", _explorerItemViewModel.ResourcePath);
                _lazyComs.AddPayloadArgument("destinationPath", Path);

                var executeCommand = _lazyComs.ExecuteCommand <ResourceCatalogDuplicateResult>(_lazyCon ?? ServerRepository.Instance.ActiveServer?.Connection, GlobalConstants.ServerWorkspaceID);
                if (executeCommand == null)
                {
                    var environmentViewModel = SingleEnvironmentExplorerViewModel.Environments.FirstOrDefault();
                    environmentViewModel?.RefreshCommand.Execute(null);
                    CloseView();
                    ViewResult = MessageBoxResult.OK;
                }
                else
                {
                    if (executeCommand.Status == ExecStatus.Success)
                    {
                        var duplicatedItems      = executeCommand.DuplicatedItems;
                        var environmentViewModel = SingleEnvironmentExplorerViewModel.Environments.FirstOrDefault();
                        var parentItem           = SelectedItem ?? _explorerItemViewModel.Parent;
                        childItems = environmentViewModel?.CreateExplorerItemModels(duplicatedItems, _explorerItemViewModel.Server, parentItem, false, false);
                        var explorerItemViewModels = parentItem.Children;
                        explorerItemViewModels.AddRange(childItems);
                        parentItem.Children = explorerItemViewModels;
                        CloseView();
                        ViewResult = MessageBoxResult.OK;
                    }
                    else
                    {
                        ErrorMessage = executeCommand.Message;
                    }
                }
            }
            catch (Exception)
            {
                //
            }
            finally
            {
                ConnectControlSingleton.Instance.ReloadServer();

                if (childItems != null)
                {
                    foreach (var childItem in childItems.Where(model => model.ResourceType == "Dev2Server"))
                    {
                        FireServerSaved(childItem.ResourceId);
                    }
                }

                IsDuplicating = false;
            }
        }