コード例 #1
0
        /// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            var execMessage = new ExecuteMessage {
                HasError = false
            };

            if (!values.ContainsKey("resourceId"))
            {
                Dev2Logger.Info("Delete Version. Invalid Resource Id");
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No resourceId sent to server");
            }
            else if (!values.ContainsKey("versionNumber"))
            {
                Dev2Logger.Info("Delete Version. Invalid Version number");
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No versionNumber sent to server");
            }
            else
            {
                try
                {
                    var guid    = Guid.Parse(values["resourceId"].ToString());
                    var version = values["versionNumber"].ToString();
                    Dev2Logger.Info($"Delete Version. ResourceId:{guid} VersionNumber{version}");
                    StringBuilder tmp;
                    string        resourcePath = "";
                    values.TryGetValue("resourcePath", out tmp);
                    if (tmp != null)
                    {
                        resourcePath = tmp.ToString();
                    }
                    var res = ServerVersionRepo.DeleteVersion(guid, version, resourcePath);
                    execMessage.Message = serializer.SerializeToBuilder(res);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error("Delete Version Error.", e);
                    execMessage.HasError = true;
                    execMessage.Message  = new StringBuilder(e.Message);
                }
            }
            return(serializer.SerializeToBuilder(execMessage));
        }
コード例 #2
0
        /// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            var execMessage = new ExecuteMessage {
                HasError = false
            };

            if (!values.ContainsKey("resourceId"))
            {
                Dev2Logger.Log.Info("Delete Version. Invalid Resource Id");
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No resourceId sent to server");
            }
            else if (!values.ContainsKey("versionNumber"))
            {
                Dev2Logger.Log.Info("Delete Version. Invalid Version number");
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No versionNumber sent to server");
            }
            else
            {
                try
                {
                    var guid    = Guid.Parse(values["resourceId"].ToString());
                    var version = values["versionNumber"].ToString();
                    Dev2Logger.Log.Info(String.Format("Delete Version. ResourceId:{0} VersionNumber{1}", guid, version));
                    var res = ServerVersionRepo.DeleteVersion(guid, version);
                    execMessage.Message = serializer.SerializeToBuilder(res);
                }
                catch (Exception e)
                {
                    Dev2Logger.Log.Error(String.Format("Delete Version Error."), e);
                    execMessage.HasError = true;
                    execMessage.Message  = new StringBuilder(e.Message);
                }
            }
            return(serializer.SerializeToBuilder(execMessage));
        }