コード例 #1
0
        public void AddWorkspaceItem(IContextualResourceModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == model.ID && wi.EnvironmentID == model.Environment.EnvironmentID);

            if (workspaceItem != null)
            {
                return;
            }

            var context = model.Environment.Connection;

            WorkspaceItems.Add(new WorkspaceItem(context.WorkspaceID, context.ServerID, model.Environment.EnvironmentID, model.ID)
            {
                ServiceName     = model.ResourceName,
                IsWorkflowSaved = model.IsWorkflowSaved,
                ServiceType     =
                    model.ResourceType == ResourceType.Source
                        ? WorkspaceItem.SourceServiceType
                        : WorkspaceItem.ServiceServiceType,
            });
            Write();
            model.OnResourceSaved += UpdateWorkspaceItemIsWorkflowSaved;
        }
コード例 #2
0
        public void UpdateWorkspaceItemIsWorkflowSaved(IContextualResourceModel resourceModel)
        {
            if (resourceModel == null)
            {
                throw new ArgumentNullException("resourceModel");
            }
            var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == resourceModel.ID && wi.EnvironmentID == resourceModel.Environment.EnvironmentID);

            if (workspaceItem == null)
            {
                return;
            }
            workspaceItem.IsWorkflowSaved = resourceModel.IsWorkflowSaved;
        }
コード例 #3
0
        public void Remove(IContextualResourceModel resourceModel)
        {
            if (resourceModel == null)
            {
                return;
            }
            var itemToRemove = WorkspaceItems.FirstOrDefault(c => c.ServiceName == resourceModel.ResourceName);

            if (itemToRemove == null)
            {
                return;
            }

            WorkspaceItems.Remove(itemToRemove);
            Write();
            resourceModel.Environment.ResourceRepository.DeleteResourceFromWorkspaceAsync(resourceModel);
        }
コード例 #4
0
        public void Remove(IContextualResourceModel resourceModel)
        {
            // BUG 9492 - 2013.06.08 - TWR : added null check
            if (resourceModel == null)
            {
                return;
            }
            var itemToRemove = WorkspaceItems.FirstOrDefault(c => c.ServiceName == resourceModel.ResourceName);

            if (itemToRemove == null)
            {
                return;
            }

            WorkspaceItems.Remove(itemToRemove);
            Write();
            resourceModel.Environment.ResourceRepository.DeleteResourceFromWorkspace(resourceModel);
        }
コード例 #5
0
        public ExecuteMessage UpdateWorkspaceItem(IContextualResourceModel resource, bool isLocalSave)
        {
            // BUG 9492 - 2013.06.08 - TWR : added null check
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }
            var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == resource.ID && wi.EnvironmentID == resource.Environment.ID);

            if (workspaceItem == null)
            {
                var msg = new ExecuteMessage {
                    HasError = false
                };
                msg.SetMessage(string.Empty);
                return(msg);
            }


            workspaceItem.Action = WorkspaceItemAction.Commit;

            var comsController = new CommunicationController {
                ServiceName = "UpdateWorkspaceItemService"
            };

            comsController.AddPayloadArgument("Roles", String.Join(",", "Test"));
            var xml = workspaceItem.ToXml();

            comsController.AddPayloadArgument("ItemXml", xml.ToString(SaveOptions.DisableFormatting));
            comsController.AddPayloadArgument("IsLocalSave", isLocalSave.ToString());

            var con = resource.Environment.Connection;

            var result = comsController.ExecuteCommand <ExecuteMessage>(con, con.WorkspaceID);

            return(result);
        }