Beispiel #1
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));
        }
Beispiel #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"))
            {
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No resourceId sent to server");
                Dev2Logger.Log.Debug("No resourceId sent to server");
            }
            else if (!values.ContainsKey("versionNumber"))
            {
                execMessage.HasError = true;
                execMessage.Message  = new StringBuilder("No versionNumber sent to server");
                Dev2Logger.Log.Debug("No versionNumber sent to server");
            }
            else
            {
                try
                {
                    var guid    = Guid.Parse(values["resourceId"].ToString());
                    var version = values["versionNumber"].ToString();
                    Dev2Logger.Log.Info(String.Format("Rollback to. ResourceId:{0} Version:{1}", guid, version));
                    var res = ServerVersionRepo.RollbackTo(guid, version);
                    execMessage.Message = serializer.SerializeToBuilder(res);
                }
                catch (Exception e)
                {
                    Dev2Logger.Log.Error(e);
                    execMessage.HasError = true;
                    execMessage.Message  = new StringBuilder(e.Message);
                }
            }
            return(serializer.SerializeToBuilder(execMessage));
        }