Example #1
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                if (values == null)
                {
                    throw new ArgumentNullException(nameof(values));
                }
                if (!values.ContainsKey("resourceId"))
                {
                    throw new ArgumentNullException(ErrorResource.NoResourceIdInTheIncomingData);
                }
                var id = Guid.Parse(values["resourceId"].ToString());
                Dev2Logger.Info("Get Versions. " + id, GlobalConstants.WarewolfInfo);
                var item = ServerVersionRepo.GetVersions(id);
                return(serializer.SerializeToBuilder(item));
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return(serializer.SerializeToBuilder(error));
            }
        }
Example #2
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.ContainsKey("resourceId"))
                {
// ReSharper disable NotResolvedInText
                    throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
                }
                var id = Guid.Parse(values["resourceId"].ToString());
                Dev2Logger.Log.Info("Get Versions. " + id);
                var item = ServerVersionRepo.GetVersions(id);
                return(serializer.SerializeToBuilder(item));
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return(serializer.SerializeToBuilder(error));
            }
        }
Example #3
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)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var res = new ExecuteMessage {
                    HasError = false
                };
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.ContainsKey("versionInfo"))
                {
// ReSharper disable NotResolvedInText
                    throw new ArgumentNullException(ErrorResource.NoResourceIdInTheIncomingData);
// ReSharper restore NotResolvedInText
                }

                var version = serializer.Deserialize <IVersionInfo>(values["versionInfo"]);
                Dev2Logger.Info("Get Version. " + version);
                StringBuilder tmp;
                Guid          resourceId = Guid.Empty;
                values.TryGetValue("resourceId", out tmp);
                if (tmp != null)
                {
                    resourceId = Guid.Parse(tmp.ToString());
                }
                var resourcePath = ResourceCatalog.GetResourcePath(theWorkspace.ID, resourceId);
                var result       = ServerVersionRepo.GetVersion(version, resourcePath);
                res.Message.Append(result);
                Dev2XamlCleaner dev2XamlCleaner = new Dev2XamlCleaner();
                res.Message = dev2XamlCleaner.StripNaughtyNamespaces(res.Message);


                return(serializer.SerializeToBuilder(res));
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return(serializer.SerializeToBuilder(error));
            }
        }
Example #4
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));
        }
Example #5
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer  = new Dev2JsonSerializer();
            var execMessage = new ExecuteMessage {
                HasError = false
            };

            if (!values.ContainsKey("resourceId"))
            {
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder(ErrorResource.NoResourceIdSentToServer);
                Dev2Logger.Debug(ErrorResource.NoResourceIdSentToServer, GlobalConstants.WarewolfDebug);
            }
            else if (!values.ContainsKey("versionNumber"))
            {
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder(ErrorResource.NoVersionNumberSentToServer);
                Dev2Logger.Debug(ErrorResource.NoVersionNumberSentToServer, GlobalConstants.WarewolfDebug);
            }
            else
            {
                try
                {
                    var guid    = Guid.Parse(values["resourceId"].ToString());
                    var version = values["versionNumber"].ToString();
                    Dev2Logger.Info($"Rollback to. ResourceId:{guid} Version:{version}", GlobalConstants.WarewolfInfo);
                    var res = ServerVersionRepo.RollbackTo(guid, version);
                    execMessage.Message = serializer.SerializeToBuilder(res);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                    execMessage.HasError = true;
                    execMessage.Message  = new StringBuilder(e.Message);
                }
            }
            return(serializer.SerializeToBuilder(execMessage));
        }
Example #6
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));
        }
Example #7
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)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var res = new ExecuteMessage {
                    HasError = false
                };
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.ContainsKey("versionInfo"))
                {
// ReSharper disable NotResolvedInText
                    throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
                }

                var version = serializer.Deserialize <IVersionInfo>(values["versionInfo"]);
                Dev2Logger.Log.Info("Get Version. " + version);
                var result = ServerVersionRepo.GetVersion(version);
                res.Message.Append(result);
                Dev2XamlCleaner dev2XamlCleaner = new Dev2XamlCleaner();
                res.Message = dev2XamlCleaner.StripNaughtyNamespaces(res.Message);


                return(serializer.SerializeToBuilder(res));
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return(serializer.SerializeToBuilder(error));
            }
        }
        /// <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)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var res = new ExecuteMessage {
                    HasError = false
                };
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.ContainsKey("versionInfo"))
                {
// ReSharper disable NotResolvedInText
                    throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
                }

                var version = serializer.Deserialize <IVersionInfo>(values["versionInfo"]);
                Dev2Logger.Log.Info("Get Version. " + version);
                var result   = ServerVersionRepo.GetVersion(version);
                var resource = Resources.GetResource(theWorkspace.ID, version.ResourceId);
                if (resource != null && resource.ResourceType == ResourceType.DbSource)
                {
                    res.Message.Append(result);
                }
                else
                {
                    var startIdx = result.IndexOf(PayloadStart, 0, false);

                    if (startIdx >= 0)
                    {
                        // remove beginning junk
                        startIdx += PayloadStart.Length;
                        result    = result.Remove(0, startIdx);

                        startIdx = result.IndexOf(PayloadEnd, 0, false);

                        if (startIdx > 0)
                        {
                            var len = result.Length - startIdx;
                            result = result.Remove(startIdx, len);

                            res.Message.Append(result.Unescape());
                        }
                    }
                    else
                    {
                        // handle services ;)
                        startIdx = result.IndexOf(AltPayloadStart, 0, false);
                        if (startIdx >= 0)
                        {
                            // remove begging junk
                            startIdx += AltPayloadStart.Length;
                            result    = result.Remove(0, startIdx);

                            startIdx = result.IndexOf(AltPayloadEnd, 0, false);

                            if (startIdx > 0)
                            {
                                var len = result.Length - startIdx;
                                result = result.Remove(startIdx, len);

                                res.Message.Append(result.Unescape());
                            }
                        }
                        else
                        {
                            // send the entire thing ;)
                            res.Message.Append(result);
                        }
                    }
                }

                Dev2XamlCleaner dev2XamlCleaner = new Dev2XamlCleaner();
                res.Message = dev2XamlCleaner.StripNaughtyNamespaces(res.Message);


                return(serializer.SerializeToBuilder(res));
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return(serializer.SerializeToBuilder(error));
            }
        }