当前位置: 首页>>代码示例>>C#>>正文


C# IWorkspace.Update方法代码示例

本文整理汇总了C#中IWorkspace.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkspace.Update方法的具体用法?C# IWorkspace.Update怎么用?C# IWorkspace.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWorkspace的用法示例。


在下文中一共展示了IWorkspace.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {

            StringBuilder itemXml;
            string isLocal = string.Empty;

            StringBuilder tmp;
            values.TryGetValue("ItemXml", out itemXml);
            values.TryGetValue("IsLocalSave", out tmp);
            if (tmp != null)
            {
                isLocal = tmp.ToString();
            }

            bool isLocalSave;

            bool.TryParse(isLocal, out isLocalSave);

            var res = new ExecuteMessage { HasError = false};

            if(itemXml == null || itemXml.Length == 0)
            {
                res.SetMessage("Invalid workspace item definition " + DateTime.Now);
                res.HasError = true;
            }
            else
            {
                try
                {
                    XElement xe = itemXml.ToXElement();

                    var workspaceItem = new WorkspaceItem(xe);
                    if (workspaceItem.WorkspaceID != theWorkspace.ID)
                    {
                        res.SetMessage("Cannot update a workspace item from another workspace " + DateTime.Now);
                        res.HasError = true;
                    }
                    else
                    {
                        theWorkspace.Update(workspaceItem, isLocalSave);
                        res.SetMessage("Workspace item updated " + DateTime.Now);
                    }
                }
                catch(Exception ex)
                {
                    res.SetMessage("Error updating workspace item " + DateTime.Now);
                    res.SetMessage(ex.Message);
                    res.SetMessage(ex.StackTrace);
                    res.HasError = true;
                }
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(res);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:55,代码来源:UpdateWorkspaceItem.cs

示例2: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {

            ExecuteMessage result = new ExecuteMessage { HasError = false };

            string resourceID = null;
            string resourceType = null;

            StringBuilder tmp;
            values.TryGetValue("ResourceID", out tmp);
            if(tmp != null)
            {
                resourceID = tmp.ToString();
            }

            values.TryGetValue("ResourceType", out tmp);
            if(tmp != null)
            {
                resourceType = tmp.ToString();
            }
            Dev2Logger.Log.Info(String.Format("Reload Resource. Id:{0} Type:{1}",resourceID,resourceType));
            try
            {
                // 2012.10.01: TWR - 5392 - Server does not dynamically reload resources 
                if(resourceID == "*")
                {
                    ResourceCatalog.Instance.LoadWorkspace(theWorkspace.ID);
                }
                else
                {
                    //
                    // Ugly conversion between studio resource type and server resource type
                    //
                    enDynamicServiceObjectType serviceType;
                    switch(resourceType)
                    {
                        case "HumanInterfaceProcess":
                        case "Website":
                        case "WorkflowService":
                            serviceType = enDynamicServiceObjectType.WorkflowActivity;
                            break;
                        case "Service":
                            serviceType = enDynamicServiceObjectType.DynamicService;
                            break;
                        case "Source":
                            serviceType = enDynamicServiceObjectType.Source;
                            break;
                        case "Server":
                            serviceType = enDynamicServiceObjectType.Source;
                            break;
                        default:
                            throw new Exception("Unexpected resource type '" + resourceType + "'.");
                    }
                    Guid getID;
                    if(resourceID != null && Guid.TryParse(resourceID, out getID))
                    {
                        //
                        // Copy the file from the server workspace into the current workspace
                        //
                        theWorkspace.Update(
                            new WorkspaceItem(theWorkspace.ID, HostSecurityProvider.Instance.ServerID, Guid.Empty, getID)
                            {
                                Action = WorkspaceItemAction.Edit,
                                IsWorkflowSaved = true,
                                ServiceType = serviceType.ToString()
                            }, false);

                    }
                    else
                    {
                        theWorkspace.Update(
                            new WorkspaceItem(theWorkspace.ID, HostSecurityProvider.Instance.ServerID, Guid.Empty, Guid.Empty)
                            {
                                Action = WorkspaceItemAction.Edit,
                                ServiceName = resourceID,
                                IsWorkflowSaved = true,
                                ServiceType = serviceType.ToString()
                            }, false);
                    }
                    //
                    // Reload resources
                    //
                    ResourceCatalog.Instance.LoadWorkspace(theWorkspace.ID);
                    result.SetMessage(string.Concat("'", resourceID, "' Reloaded..."));
                }
            }
            catch(Exception ex)
            {
                result.SetMessage(string.Concat("Error reloading '", resourceID, "'..."));
                Dev2Logger.Log.Error(ex);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(result);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:95,代码来源:ReloadResource.cs


注:本文中的IWorkspace.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。