internal void Clear()
 {
     uiFactory.StartNew(() => {
         WorkspaceItems.Clear();
         OnPropertyChanged("SourceFiles");
     });
 }
        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;
        }
 public ExampleViewModel(IWorkspaceItemViewModelFactory workspaceItemViewModelFactory)
 {
     AddItemCommand = new ActionCommand(() =>
     {
         var newItem = workspaceItemViewModelFactory.CreateWorkspaceItem();
         WorkspaceItems.Add(newItem);
     });
 }
 public void ClearWorkspaceItems(IContextualResourceModel resourceModel)
 {
     if (resourceModel == null)
     {
         return;
     }
     WorkspaceItems.Clear();
     resourceModel.Environment.ResourceRepository.DeleteResourceFromWorkspace(resourceModel);
 }
 internal void Delete(WorkspaceItem pWorkspaceItem)
 {
     uiFactory.StartNew(() => {
         lock (WorkspaceItems) {
             var objToRemove = WorkspaceItems.ToList().Where(i => i.ID.Equals(pWorkspaceItem.ID)).FirstOrDefault();
             if (objToRemove != null)
             {
                 WorkspaceItems.Remove(objToRemove);
                 OnPropertyChanged("SourceFiles");
             }
         }
     });
 }
        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;
        }
        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);
        }
 internal void Update(WorkspaceItem pWorkspaceItem)
 {
     uiFactory.StartNew(() => {
         lock (WorkspaceItems) {
             for (var i = 0; i < WorkspaceItems.Count; i++)
             {
                 if (WorkspaceItems[i].ID.Equals(pWorkspaceItem.ID))
                 {
                     WorkspaceItems[i].Update(pWorkspaceItem);
                     return;
                 }
             }
             WorkspaceItems.Add(new WorkspaceItemViewModel(pWorkspaceItem));
             OnPropertyChanged("SourceFiles");
         }
     });
 }
        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);
        }
        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);
        }