示例#1
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);
            }
        }
示例#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);
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
        {
            try
            {


                StringBuilder tmp;
                values.TryGetValue("Resource", out tmp);
                var serializer = new Dev2JsonSerializer();

                if (tmp != null)
                {
                    var res = serializer.Deserialize<IScheduledResource>(tmp);
                    Dev2Logger.Log.Info("Get Scheduled History. " +tmp);
                    IList<IResourceHistory> resources;
                    using (var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
                    {
                        resources = model.CreateHistory(res);
                    }
                    return serializer.SerializeToBuilder(resources);
                }
                Dev2Logger.Log.Debug("No resource Provided");
                return serializer.SerializeToBuilder(new List<IResourceHistory>());
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                throw;
            }
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string type = null;
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            StringBuilder tmp;
            values.TryGetValue("ResourceID", out tmp);
            Guid resourceId = Guid.Empty;
            if(tmp != null)
            {
                if(!Guid.TryParse(tmp.ToString(), out resourceId))
                {
                    Dev2Logger.Log.Info("Delete Resource Service. Invalid Parameter Guid:");
                    var failureResult = new ExecuteMessage { HasError = true };
                    failureResult.SetMessage("Invalid guid passed for ResourceID");
                    return serializer.SerializeToBuilder(failureResult);
                }
            }
            values.TryGetValue("ResourceType", out tmp);
            if(tmp != null)
            {
                type = tmp.ToString();
            }

            Dev2Logger.Log.Info("Delete Resource Service. Resource:" + resourceId);
            // BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor
            var msg = ResourceCatalog.Instance.DeleteResource(theWorkspace.ID, resourceId, type);

            var result = new ExecuteMessage { HasError = false };
            result.SetMessage(msg.Message);
            result.HasError = msg.Status != ExecStatus.Success;
            return serializer.SerializeToBuilder(result);
        }
        /// <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);
            }
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            IExplorerRepositoryResult item;
            var serializer = new Dev2JsonSerializer();
            try
            {
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                StringBuilder itemToBeRenamed;
                StringBuilder newPath;
                if (!values.TryGetValue("itemToMove", out itemToBeRenamed))
                {
                    throw new ArgumentException("itemToMove value not supplied.");
                }
                if (!values.TryGetValue("newPath", out newPath))
                {
                    throw new ArgumentException("newName value not supplied.");
                }

                var itemToMove = serializer.Deserialize<ServerExplorerItem>(itemToBeRenamed);
                Dev2Logger.Log.Info(String.Format("Move Item. Path:{0} NewPath:{1}", itemToBeRenamed, newPath));
                item = ServerExplorerRepo.MoveItem(itemToMove, newPath.ToString(), GlobalConstants.ServerWorkspaceID);
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
            }
            return serializer.SerializeToBuilder(item);
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {

                Dev2Logger.Log.Info("Fetch Server Log Started");
                var result = new ExecuteMessage { HasError = false };
                if (File.Exists(_serverLogPath))
                {
                    var fileStream = File.Open(_serverLogPath, FileMode.Open, FileAccess.Read,FileShare.Read);
                    using (var streamReader = new StreamReader(fileStream))
                    {
                        while(!streamReader.EndOfStream)
                        {
                            result.Message.Append(streamReader.ReadLine());    
                        }
                    }
                }
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                return serializer.SerializeToBuilder(result);
            }
            catch (Exception err)
            {
                Dev2Logger.Log.Error("Fetch Server Log Error", err);
                throw;
            }
        }
 public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
 {
     IExplorerRepositoryResult item;
     try
     {
         if(values == null)
         {
             throw new ArgumentNullException("values");
         }
         if(theWorkspace == null)
         {
             throw new ArgumentNullException("theWorkspace");
         }
         StringBuilder path;
         if(!values.TryGetValue("path", out path))
         {
             throw new ArgumentException("path value not supplied.");
         }
         StringBuilder newPath;
         if(!values.TryGetValue("newPath", out newPath))
         {
             throw new ArgumentException("newPath value not supplied.");
         }
         Dev2Logger.Log.Info(String.Format("Reanme Folder. Path:{0} NewPath:{1}",path,newPath));
         item = ServerExplorerRepository.Instance.RenameFolder(path.ToString(), newPath.ToString(), theWorkspace.ID);
     }
     catch(Exception e)
     {
         Dev2Logger.Log.Error(e);
         item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
     }
     var serializer = new Dev2JsonSerializer();
     return serializer.SerializeToBuilder(item);
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if(values == null)
            {
                throw new InvalidDataException("Empty values passed.");
            }

            StringBuilder settingsJson;
            values.TryGetValue("Settings", out settingsJson);
            if(settingsJson == null || settingsJson.Length == 0)
            {
                throw new InvalidDataException("Error: Unable to parse values.");
            }
            var serializer = new Dev2JsonSerializer();
            var result = new ExecuteMessage { HasError = false, Message = new StringBuilder() };
            try
            {
                var settings = serializer.Deserialize<Settings>(settingsJson.ToString());
                WriteSecuritySettings(theWorkspace, settings, result);
                WriteLoggingSettings(theWorkspace, settings, result);
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error("Error writing settings.", ex);
                result.HasError = true;
                result.Message.AppendLine("Error writing settings.");
            }
            return serializer.SerializeToBuilder(result);
        }
        public SharepointServerSourceViewModel(SharepointServerSource serverSource, IEnvironmentModel environment)
        {
            IsLoading = false;
            TestComplete = false;
            _environment = environment;
            ServerName = "";
            AuthenticationType = AuthenticationType.Windows;
            IsWindows = true;
            SaveCommand = new RelayCommand(o =>
            {
                serverSource.DialogResult = true;
                serverSource.Close();
            }, o => TestComplete);

            CancelCommand = new RelayCommand(o =>
            {
                serverSource.DialogResult = false;
                serverSource.Close();
            });
            TestCommand = new RelayCommand(o =>
            {
                IsLoading = true;
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                var source = CreateSharepointServerSource();
                var comsController = new CommunicationController { ServiceName = "TestSharepointServerService" };
                comsController.AddPayloadArgument("SharepointServer", serializer.SerializeToBuilder(source));
                TestResult = comsController.ExecuteCommand<string>(environment.Connection, GlobalConstants.ServerWorkspaceID);
                IsLoading = false;
            }, o => !TestComplete);
        }
示例#11
0
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {


            string guidCsv = string.Empty;
            string type = null;

            StringBuilder tmp;
            values.TryGetValue("GuidCsv", out tmp);
            if(tmp != null)
            {
                guidCsv = tmp.ToString();
            }
            values.TryGetValue("ResourceType", out tmp);
            if(tmp != null)
            {
                type = tmp.ToString();
            }
            Dev2Logger.Log.Info("Find Resource By Id. "+guidCsv);
            // BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor
            var resources = ResourceCatalog.Instance.GetResourceList(theWorkspace.ID, guidCsv, type);

            IList<SerializableResource> resourceList = resources.Select(new FindResourceHelper().SerializeResourceForStudio).ToList();

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(resourceList);
            }
            catch (Exception err)
            {
                Dev2Logger.Log.Error(err);
                throw;
            }
        }
示例#12
0
 public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
 {
     IExplorerRepositoryResult item;
     var serializer = new Dev2JsonSerializer();
     try
     {
         if(values == null)
         {
             throw new ArgumentNullException("values");
         }               
         StringBuilder itemBeingDeleted;
         if(!values.TryGetValue("itemToDelete", out itemBeingDeleted))
         {
             throw new ArgumentException("itemToDelete value not supplied.");
         }
         var itemToDelete = serializer.Deserialize<ServerExplorerItem>(itemBeingDeleted);
         Dev2Logger.Log.Info("Delete Item Service."+itemToDelete);
         item = ServerExplorerRepo.DeleteItem(itemToDelete, GlobalConstants.ServerWorkspaceID);
     }
     catch(Exception e)
     {
         Dev2Logger.Log.Error("Delete Item Error" ,e);
         item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
     }
     return serializer.SerializeToBuilder(item);
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var result = new ExecuteMessage { HasError = false };

            Dev2Logger.Log.Info("Find Log Directory");
            try
            {
                var logdir = WorkflowLoggger.GetDirectoryPath(SettingsProvider.Instance.Configuration.Logging);
                var cleanedDir = CleanUp(logdir);
                result.Message.Append("<JSON>");
                result.Message.Append(@"{""PathToSerialize"":""");
                result.Message.Append(cleanedDir);
                result.Message.Append(@"""}");
                result.Message.Append("</JSON>");    
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error(ex);
                result.Message.Append(ex.Message);
                result.HasError = true;
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(result);
        }
示例#14
0
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var result = new ExecuteMessage { HasError = false };
            Dev2Logger.Log.Info("Delete Scheduled Resource Service");
            StringBuilder tmp;
            values.TryGetValue("Resource", out tmp);
            var serializer = new Dev2JsonSerializer();

            if (tmp != null)
            {
                var res = serializer.Deserialize<IScheduledResource>(tmp);
                Dev2Logger.Log.Info("Delete Scheduled Resource Service." +res);
                using(var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
                {
                    model.DeleteSchedule(res);
                }
            }
            else
            {
                Dev2Logger.Log.Info("Delete Scheduled Resource Service. No Resource Selected");
                result.Message.Append("No Resource Selected");
                result.HasError = true;
            }
            return serializer.SerializeToBuilder(result);
        }
 public IExplorerRepositoryResult DeleteItem(IExplorerItem itemToRename, Guid workSpaceId)
 {
     var controller = CommunicationControllerFactory.CreateController("DeleteItemService");
     var serializer = new Dev2JsonSerializer();
     controller.AddPayloadArgument("itemToDelete", serializer.SerializeToBuilder(itemToRename).ToString());
     return controller.ExecuteCommand<IExplorerRepositoryResult>(Connection, workSpaceId);
 }
示例#16
0
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {

     
            Dev2Logger.Log.Info("Find Dependencies");
            var result = new ExecuteMessage { HasError = false };

            string resourceId = null;
            string dependsOnMeString = null;
            bool dependsOnMe = false;
            StringBuilder tmp;
            values.TryGetValue("ResourceId", out tmp);
            if(tmp != null)
            {
                resourceId = tmp.ToString();
            }
            values.TryGetValue("GetDependsOnMe", out tmp);
            if(tmp != null)
            {
                dependsOnMeString = tmp.ToString();
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw new InvalidDataContractException("ResourceName is empty or null");
            }
            var resource= ResourceCatalog.Instance.GetResource(theWorkspace.ID, Guid.Parse(resourceId));
            var resourceName = resource.ResourcePath;
            if(!string.IsNullOrEmpty(dependsOnMeString))
            {
                if(!bool.TryParse(dependsOnMeString, out dependsOnMe))
                {
                    dependsOnMe = false;
                }
            }

            if(dependsOnMe)
            {
                result.Message.Append(string.Format("<graph title=\"Local Dependants Graph: {0}\">", resourceName));
                result.Message.Append(FindWhatDependsOnMe(resource, theWorkspace.ID));
                result.Message.Append("</graph>");
            }
            else
            {
                result.Message.Append(string.Format("<graph title=\"Dependency Graph Of {0}\">", resourceName));
                result.Message.Append(FindDependenciesRecursive(resource.ResourceID, theWorkspace.ID));
                result.Message.Append("</graph>");
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(result);
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                throw;
            }
        }
 public void DeleteSchedule(IScheduledResource resource)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "DeleteScheduledResourceService" };
     controller.AddPayloadArgument("Resource", builder);
     controller.ExecuteCommand<string>(_model.Connection, _model.Connection.WorkspaceID);
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string serviceId = null;
            string workspaceId = null;

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            var result = new ExecuteMessage { HasError = false };

            StringBuilder tmp;
            values.TryGetValue("ServiceID", out tmp);
            if(tmp != null)
            {
                serviceId = tmp.ToString();
            }
            values.TryGetValue("WorkspaceID", out tmp);
            if(tmp != null)
            {
                workspaceId = tmp.ToString();
            }
            values.TryGetValue("FilterList", out tmp);
            if(tmp != null)
            {
            }

            if(string.IsNullOrEmpty(serviceId) || string.IsNullOrEmpty(workspaceId))
            {
                throw new InvalidDataContractException("Null or empty ServiceID or WorkspaceID");
            }

            Guid wGuid;
            Guid sGuid;

            Guid.TryParse(workspaceId, out wGuid);
            Guid.TryParse(serviceId, out sGuid);


            var thisService = ResourceCatalog.Instance.GetResource(wGuid, sGuid);

            if(thisService != null)
            {
                var deps = thisService.Dependencies;

                CompileMessageType[] filters = null; // TODO : Convert string list to enum array ;)

                // ReSharper disable ExpressionIsAlwaysNull
                CompileMessageList msgs = CompileMessageRepo.Instance.FetchMessages(wGuid, sGuid, deps, filters);
                // ReSharper restore ExpressionIsAlwaysNull

                result.Message.Append(serializer.SerializeToBuilder(msgs));
            }
            else
            {
                result.Message.Append("Could not locate service with ID [ " + sGuid + " ]");
                result.HasError = true;
            }

            return serializer.SerializeToBuilder(result);
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();
            var folderToDelete = values["folderToDelete"].ToString();
            var deleteContents = bool.Parse(values["deleteContents"].ToString());
            var item = ServerExplorerRepository.DeleteItem(folderToDelete, deleteContents, theWorkspace.ID);
            return serializer.SerializeToBuilder(item);

        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage msg = new ExecuteMessage { HasError = false };

            msg.SetMessage(values["payload"].ToString());

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return serializer.SerializeToBuilder(msg);
        }
示例#21
0
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage msg = new ExecuteMessage {HasError = false};

            msg.SetMessage("Pong @ " + Now.Invoke().ToString("yyyy-MM-dd hh:mm:ss.fff"));

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return serializer.SerializeToBuilder(msg);
        }
        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);
        }
        /// <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)
        {
            if(values == null)
            {
                throw new InvalidDataContractException("No parameter values provided.");
            }
            string serializedSource = null;
            StringBuilder tmp;
            values.TryGetValue("SharepointServer", out tmp);
            if(tmp != null)
            {
                serializedSource = tmp.ToString();
            }
            
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            if(string.IsNullOrEmpty(serializedSource))
            {
                var res = new ExecuteMessage();
                res.HasError = true;
                res.SetMessage("No sharepoint server set");
                Dev2Logger.Log.Debug("No sharepoint server set.");
                return serializer.SerializeToBuilder(res);
            }
            try
            {
                var sharepointSource = serializer.Deserialize<SharepointSource>(serializedSource);
                var result = sharepointSource.TestConnection();
                var sharepointSourceTo = new SharepointSourceTo
                {
                    TestMessage = result,
                    IsSharepointOnline = sharepointSource.IsSharepointOnline
                };
                return serializer.SerializeToBuilder(sharepointSourceTo);
            }
            catch(Exception ex)
            {
                Dev2Logger.Log.Error(ex);
                var res = new DbColumnList(ex);
                return serializer.SerializeToBuilder(res);
            }
        }
 public void Save(IScheduledResource resource, string userName, string password)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "SaveScheduledResourceService" };
     controller.AddPayloadArgument("Resource", builder);
     controller.AddPayloadArgument("UserName", userName);
     controller.AddPayloadArgument("Password", password);
     controller.ExecuteCommand<string>(_model.Connection, _model.Connection.WorkspaceID);
     resource.IsDirty = false;
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            Dev2Logger.Log.Info("Fetch Explorer Items");

            var serializer = new Dev2JsonSerializer();
            try
            {
                if(values == null)
                {
                    throw new ArgumentNullException("values");
                }
                var item = ServerExplorerRepo.Load(GlobalConstants.ServerWorkspaceID);
                return serializer.SerializeToBuilder(item);
            }
            catch(Exception e)
            {
                Dev2Logger.Log.Info("Fetch Explorer Items Error",e);
                IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
                return serializer.SerializeToBuilder(error);
            }
        }
 public IExplorerRepositoryResult RenameItem(IExplorerItem itemToRename, string newName, Guid workSpaceId)
 {
     var controller = CommunicationControllerFactory.CreateController("RenameItemService");
     if(itemToRename.Children != null)
     {
         var any = itemToRename.Children.Where(a => a.ResourceType == ResourceType.Version);
         itemToRename.Children = itemToRename.Children.Except(any).ToList();
     }
     var serializer = new Dev2JsonSerializer();
     controller.AddPayloadArgument("itemToRename", serializer.SerializeToBuilder(itemToRename).ToString());
     controller.AddPayloadArgument("newName", newName);
     return controller.ExecuteCommand<IExplorerRepositoryResult>(Connection, workSpaceId);
 }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {

            Dev2Logger.Log.Info("Fetch Debug Item File Started");
            try
            {

        
            var result = new ExecuteMessage { HasError = false };

            if(values == null)
            {
                Dev2Logger.Log.Debug("values are missing");
                throw new InvalidDataContractException("values are missing");
            }

            StringBuilder tmp;
            values.TryGetValue("DebugItemFilePath", out tmp);
            if(tmp == null || tmp.Length == 0)
            {
                Dev2Logger.Log.Debug("DebugItemFilePath is missing");
                throw new InvalidDataContractException("DebugItemFilePath is missing");
            }

            string debugItemFilePath = tmp.ToString();

            if(File.Exists(debugItemFilePath))
            {
                Dev2Logger.Log.Debug("DebugItemFilePath found");

                var lines = File.ReadLines(debugItemFilePath);
                foreach(var line in lines)
                {
                    result.Message.AppendLine(line);
                }

                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                return serializer.SerializeToBuilder(result);
            }
            Dev2Logger.Log.Debug("DebugItemFilePath not found, throwing an exception");
            throw new InvalidDataContractException(string.Format("DebugItemFilePath {0} not found", debugItemFilePath));
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                throw;
            }

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

            
            string oldCategory = null;
            string newCategory = null;
            string resourceType = null;
            if(values == null)
            {
                throw new InvalidDataContractException("No parameter values provided.");
            }
            StringBuilder tmp;
            values.TryGetValue("OldCategory", out tmp);
            if(tmp != null)
            {
                oldCategory = tmp.ToString();
            }
            values.TryGetValue("NewCategory", out tmp);
            if(tmp != null)
            {
                newCategory = tmp.ToString();
            }
            values.TryGetValue("ResourceType", out tmp);
            if(tmp != null)
            {
                resourceType = tmp.ToString();
            }

            if(oldCategory == null)
            {
                
                throw new InvalidDataContractException("No value provided for OldCategory parameter.");
            }
            if(String.IsNullOrEmpty(newCategory))
            {
                throw new InvalidDataContractException("No value provided for NewCategory parameter.");
            }
            if(String.IsNullOrEmpty(resourceType))
            {
                throw new InvalidDataContractException("No value provided for ResourceType parameter.");
            }
            Dev2Logger.Log.Info(String.Format( "Rename Category. Old {0} New {1} Type{2}",oldCategory,newCategory,resourceType));
            var saveResult = ResourceCatalog.Instance.RenameCategory(Guid.Empty, oldCategory, newCategory);

            ExecuteMessage msg = new ExecuteMessage { HasError = false };
            msg.SetMessage(saveResult.Message);
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(msg);
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
           
            var serializer = new Dev2JsonSerializer();
            var itemToAdd = serializer.Deserialize<ServerExplorerItem>(values["itemToAdd"]);
            Dev2Logger.Log.Info("Add Folder Service." +itemToAdd);
            itemToAdd.Permissions = Permissions.Contribute;
            if(itemToAdd.ResourcePath.ToLower().StartsWith("root\\"))
            {
                itemToAdd.ResourcePath = itemToAdd.ResourcePath.Remove(0, 5);
            }

            var item = ServerExplorerRepo.AddItem(itemToAdd, theWorkspace.ID);
            return serializer.SerializeToBuilder(item);
        }
        public StringBuilder GetVersion(IVersionInfo versionInfo)
        {
            var workSpaceId = Guid.NewGuid();
            var controller = CommunicationControllerFactory.CreateController("GetVersion");
            var serializer = new Dev2JsonSerializer();
            controller.AddPayloadArgument("versionInfo", serializer.SerializeToBuilder(versionInfo).ToString());
            var executeMessage = controller.ExecuteCommand<ExecuteMessage>(Connection, workSpaceId);

            if(executeMessage == null || executeMessage.HasError)
            {
                return null;
            }

            return executeMessage.Message;
        }
示例#31
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var result = new ExecuteMessage {
                HasError = false
            };

            values.TryGetValue("Resource", out StringBuilder tmp);
            var serializer = new Dev2JsonSerializer();

            try
            {
                TryExecute(values, result, tmp, serializer);
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                result.Message.Append($"Error while saving: {e.Message.Remove(e.Message.IndexOf('.'))}");
                result.HasError = true;
            }
            return(serializer.SerializeToBuilder(result));
        }
        public void Dev2JsonSerializer_SerializeToBuffer_WhenEsbExecuteRequest_ValidObjectStringBuffer()
        {
            //------------Setup for test--------------------------
            var js      = new Dev2JsonSerializer();
            var request = new EsbExecuteRequest {
                ServiceName = "Foobar"
            };

            request.AddArgument("key1", new StringBuilder("value1"));
            request.AddArgument("key2", new StringBuilder("value2"));

            //------------Execute Test---------------------------
            var result = js.SerializeToBuilder(request);

            //------------Assert Results-------------------------
            var resultObj = js.Deserialize <EsbExecuteRequest>(result);

            Assert.AreEqual(request.ServiceName, resultObj.ServiceName);
            Assert.AreEqual(request.Args["key1"].ToString(), resultObj.Args["key1"].ToString());
            Assert.AreEqual(request.Args["key2"].ToString(), resultObj.Args["key2"].ToString());
        }
示例#33
0
        public StringBuilder ProcessRequest(EsbExecuteRequest request, Guid workspaceId, Guid dataListId, string connectionId)
        {
            var channel = new EsbServicesEndpoint();

            var isManagementResource = ProcessDsfDataObject(request, workspaceId, dataListId, connectionId, channel);

            if (!DsfDataObject.Environment.HasErrors())
            {
                return(ProcessRequest(request, workspaceId, channel, DsfDataObject, isManagementResource));
            }

            var msg = new ExecuteMessage {
                HasError = true
            };

            msg.SetMessage(string.Join(Environment.NewLine, DsfDataObject.Environment.Errors));

            var serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(msg));
        }
示例#34
0
        public string TestWcfServiceSource(IWcfServerSource wcfServerSource)
        {
            var con            = Connection;
            var comsController = CommunicationControllerFactory.CreateController("TestWcfServiceSource");
            var serialiser     = new Dev2JsonSerializer();

            comsController.AddPayloadArgument("WcfSource", serialiser.SerializeToBuilder(wcfServerSource));
            var output = comsController.ExecuteCommand <IExecuteMessage>(con, GlobalConstants.ServerWorkspaceID);

            if (output == null)
            {
                throw new WarewolfTestException(ErrorResource.UnableToContactServer, null);
            }

            if (output.HasError)
            {
                throw new WarewolfTestException(output.Message.ToString(), null);
            }

            return(output.Message.ToString());
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                var fileLogLevel  = Dev2Logger.GetFileLogLevel();
                var eventLogLevel = Dev2Logger.GetEventLogLevel();
                var logMaxSize    = Dev2Logger.GetLogMaxSize();

                var loggingSettings = new LoggingSettingsTo {
                    FileLoggerLogLevel = fileLogLevel, EventLogLoggerLogLevel = eventLogLevel, FileLoggerLogSize = logMaxSize
                };
                var serializer         = new Dev2JsonSerializer();
                var serializeToBuilder = serializer.SerializeToBuilder(loggingSettings);
                return(serializeToBuilder);
            }
            catch (Exception e)
            {
                Dev2Logger.Error("LoggingSettingsRead", e);
            }
            return(null);
        }
        public void QueryManagerProxy_FetchConstructors_GivenEnvHasObjectVariablesAddsvariables()
        {
            var ser  = new Dev2JsonSerializer();
            var res  = ser.SerializeToBuilder(new List <IPluginConstructor>());
            var aggr = new Mock <IEventAggregator>();
            var dataListViewModel = new DataListViewModel(aggr.Object);

            dataListViewModel.Add(new ComplexObjectItemModel("Name", null, enDev2ColumnArgumentDirection.Both));
            DataListSingleton.SetDataList(dataListViewModel);
            var ns = new Mock <INamespaceItem>();

            RunTest("FetchPluginConstructors", new ExecuteMessage
            {
                HasError = false,
                Message  = res
            }
                    , new List <Tuple <string, object> >
            {
                new Tuple <string, object>("source", new PluginSourceDefinition())
            }, a => Assert.AreEqual(1, a.Count), a => a.PluginConstructors(new PluginSourceDefinition(), ns.Object));
        }
示例#37
0
        public void SaveServerSettings_Execute_SaveServerSettingsData()
        {
            //------------Setup for test--------------------------
            var serializer    = new Dev2JsonSerializer();
            var workspaceMock = new Mock <IWorkspace>();
            var settingsData  = new ServerSettingsData()
            {
                ExecutionLogLevel = LogLevel.DEBUG.ToString()
            };
            var requestArgs = new Dictionary <string, StringBuilder>();

            requestArgs.Add("ServerSettings", new StringBuilder(serializer.SerializeToBuilder(settingsData).ToString()));

            var saveServerSettings = new SaveServerSettings();
            //------------Execute Test---------------------------
            var jsonResult = saveServerSettings.Execute(requestArgs, workspaceMock.Object);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsFalse(result.HasError);
        }
示例#38
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Webservice Source", GlobalConstants.WarewolfInfo);

                values.TryGetValue("WebserviceSource", out StringBuilder resourceDefinition);

                var src = serializer.Deserialize <WebServiceSourceDefinition>(resourceDefinition);
                if (src.Path.EndsWith("\\"))
                {
                    src.Path = src.Path.Substring(0, src.Path.LastIndexOf("\\", StringComparison.Ordinal));
                }

                var res = new WebSource
                {
                    AuthenticationType = src.AuthenticationType,
                    Address            = src.HostName,
                    Password           = src.Password,
                    UserName           = src.UserName,
                    ResourceID         = src.Id,
                    DefaultQuery       = src.DefaultQuery,
                    ResourceName       = src.Name
                };
                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, res, src.Path);
                ServerExplorerRepo.UpdateItem(res);
                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }

            return(serializer.SerializeToBuilder(msg));
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save RabbitMQ Service Source", GlobalConstants.WarewolfInfo);
                msg.HasError = false;

                values.TryGetValue("RabbitMQServiceSource", out StringBuilder resourceDefinition);

                var rabbitMQServiceSourceDefinition = serializer.Deserialize <RabbitMQServiceSourceDefinition>(resourceDefinition);
                if (rabbitMQServiceSourceDefinition.ResourcePath.EndsWith("\\"))
                {
                    rabbitMQServiceSourceDefinition.ResourcePath = rabbitMQServiceSourceDefinition.ResourcePath.Substring(0, rabbitMQServiceSourceDefinition.ResourcePath.LastIndexOf("\\", StringComparison.Ordinal));
                }

                var rabbitMQSource = new RabbitMQSource
                {
                    ResourceID   = rabbitMQServiceSourceDefinition.ResourceID,
                    ResourceName = rabbitMQServiceSourceDefinition.ResourceName,
                    HostName     = rabbitMQServiceSourceDefinition.HostName,
                    Port         = rabbitMQServiceSourceDefinition.Port,
                    UserName     = rabbitMQServiceSourceDefinition.UserName,
                    Password     = rabbitMQServiceSourceDefinition.Password,
                    VirtualHost  = rabbitMQServiceSourceDefinition.VirtualHost
                };

                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, rabbitMQSource, rabbitMQServiceSourceDefinition.ResourcePath);
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error("Save RabbitMQ Service Source Failed: " + err.Message, GlobalConstants.WarewolfError);
            }

            return(serializer.SerializeToBuilder(msg));
        }
示例#40
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage res = new ExecuteMessage {
                HasError = false
            };

            string editedItemsXml = null;

            StringBuilder tmp;

            values.TryGetValue("EditedItemsXml", out tmp);
            if (tmp != null)
            {
                editedItemsXml = tmp.ToString();
            }

            try
            {
                var editedItems = new List <string>();

                if (!string.IsNullOrWhiteSpace(editedItemsXml))
                {
                    editedItems.AddRange(XElement.Parse(editedItemsXml)
                                         .Elements()
                                         .Select(x => x.Attribute("ServiceName").Value));
                }

                WorkspaceRepository.Instance.GetLatest(theWorkspace, editedItems);
                res.SetMessage("Workspace updated " + DateTime.Now);
            }
            catch (Exception ex)
            {
                res.SetMessage("Error updating workspace " + DateTime.Now);
                Dev2Logger.Log.Error(ex);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(res));
        }
示例#41
0
        public T ExecuteCommand <T>(IEnvironmentConnection connection, Guid workspaceId) where T : class
        {
            var serializer      = new Dev2JsonSerializer();
            var popupController = CustomContainer.Get <IPopupController>();

            if (connection == null || !connection.IsConnected)
            {
                IsConnectionValid(connection, popupController);
            }
            else
            {
                if (ServicePayload == null)
                {
                    ServicePayload = new EsbExecuteRequest();
                }

                ServicePayload.ServiceName = ServiceName;
                var toSend  = serializer.SerializeToBuilder(ServicePayload);
                var payload = connection.ExecuteCommand(toSend, workspaceId);
                ValidatePayload(connection, payload, popupController);
                var executeCommand = serializer.Deserialize <T>(payload);
                if (executeCommand == null)
                {
                    var execMessage = serializer.Deserialize <ExecuteMessage>(payload);
                    if (execMessage != null)
                    {
                        return(CheckAuthorization <T>(execMessage));
                    }
                }
                else
                {
                    if (typeof(T) == typeof(ExecuteMessage))
                    {
                        return(CheckAuthorization <T>(executeCommand as ExecuteMessage));
                    }
                    return(executeCommand);
                }
            }
            return(default(T));
        }
示例#42
0
        public async Task <T> ExecuteCompressedCommandAsync <T>(IEnvironmentConnection connection, Guid workspaceId) where T : class
        {
            // build the service request payload ;)
            var serializer = new Dev2JsonSerializer();

            if (connection == null || !connection.IsConnected)
            {
                if (connection != null && !connection.IsConnecting)
                {
                    var popupController = CustomContainer.Get <IPopupController>();
                    popupController?.Show(string.Format(ErrorResource.ServerDisconnected, connection.DisplayName) + Environment.NewLine +
                                          ErrorResource.ServerReconnectForActions, ErrorResource.ServerDisconnectedHeader, MessageBoxButton.OK,
                                          MessageBoxImage.Information, "", false, false, true, false, false, false);
                }
            }
            else
            {
                if (ServicePayload == null)
                {
                    ServicePayload = new EsbExecuteRequest();
                }

                ServicePayload.ServiceName = ServiceName;
                var toSend  = serializer.SerializeToBuilder(ServicePayload);
                var payload = await connection.ExecuteCommandAsync(toSend, workspaceId).ConfigureAwait(true);

                try
                {
                    var message = serializer.Deserialize <CompressedExecuteMessage>(payload).GetDecompressedMessage();
                    return(serializer.Deserialize <T>(message));
                }
                catch (NullReferenceException e)
                {
                    Dev2Logger.Debug("fallback to non compressed", e, "Warewolf Debug");
                    var val = serializer.Deserialize <T>(payload);
                    return(val);
                }
            }
            return(default(T));
        }
示例#43
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test RabbitMQ Service Source");
                StringBuilder resourceDefinition;
                msg.HasError = false;

                values.TryGetValue("RabbitMQServiceSource", out resourceDefinition);

                RabbitMQServiceSourceDefinition rabbitMQServiceSourceDefinition = serializer.Deserialize <RabbitMQServiceSourceDefinition>(resourceDefinition);
                RabbitMQSources  rabbitMQSources = new RabbitMQSources();
                ValidationResult result          = rabbitMQSources.Test(new RabbitMQSource
                {
                    ResourceID   = rabbitMQServiceSourceDefinition.ResourceID,
                    ResourceName = rabbitMQServiceSourceDefinition.ResourceName,
                    HostName     = rabbitMQServiceSourceDefinition.HostName,
                    Port         = rabbitMQServiceSourceDefinition.Port,
                    UserName     = rabbitMQServiceSourceDefinition.UserName,
                    Password     = rabbitMQServiceSourceDefinition.Password,
                    VirtualHost  = rabbitMQServiceSourceDefinition.VirtualHost
                });

                if (!result.IsValid)
                {
                    msg.HasError = true;
                    msg.Message  = new StringBuilder(result.ErrorMessage);
                }
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }
            return(serializer.SerializeToBuilder(msg));
        }
示例#44
0
        public void Execute_GivenNullResource_ShouldReturnResourceDeletedMsg()
        {
            //------------Setup for test--------------------------
            var serializer = new Dev2JsonSerializer();
            var inputs     = new Dictionary <string, StringBuilder>();
            var resourceID = Guid.NewGuid();
            var saveTests  = new SaveTests();

            var listOfTests = new List <ServiceTestModelTO>
            {
                new ServiceTestModelTO
                {
                    AuthenticationType = AuthenticationType.Public,
                    Enabled            = true,
                    TestName           = "Test MyWF"
                }
            };
            var testCatalogMock = new Mock <ITestCatalog>();
            var resourceCatalog = new Mock <IResourceCatalog>();

            resourceCatalog.Setup(catalog => catalog.GetResource(GlobalConstants.ServerWorkspaceID, resourceID)).Returns(default(IResource));
            var ws = new Mock <IWorkspace>();

            inputs.Add("resourceID", new StringBuilder(resourceID.ToString()));
            var compressedExecuteMessage = new CompressedExecuteMessage();

            compressedExecuteMessage.SetMessage(serializer.Serialize(listOfTests));
            inputs.Add("testDefinitions", serializer.SerializeToBuilder(compressedExecuteMessage));
            inputs.Add("resourcePath", "Home".ToStringBuilder());
            saveTests.TestCatalog     = testCatalogMock.Object;
            saveTests.ResourceCatalog = resourceCatalog.Object;
            //------------Execute Test---------------------------
            var stringBuilder = saveTests.Execute(inputs, ws.Object);
            //------------Assert Results-------------------------
            var msg            = serializer.Deserialize <ExecuteMessage>(stringBuilder);
            var testSaveResult = serializer.Deserialize <TestSaveResult>(msg.Message);

            Assert.AreEqual(SaveResult.ResourceDeleted, testSaveResult.Result);
            Assert.AreEqual("Resource Home has been deleted. No Tests can be saved for this resource.", testSaveResult.Message);
        }
示例#45
0
        public void DeleteItem_Execute_ExpectName()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();

            ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable();

            var serializer = new Dev2JsonSerializer();
            var inputs     = new Dictionary <string, StringBuilder>();

            inputs.Add("itemToDelete", serializer.SerializeToBuilder(item));
            ws.Setup(a => a.ID).Returns(Guid.Empty);
            deleteItem.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            deleteItem.Execute(inputs, ws.Object);
            //------------Assert Results-------------------------
            repo.Verify(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>()));
        }
示例#46
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var result = new CompressedExecuteMessage {
                HasError = false
            };

            try
            {
                TestCatalog.Load();
                result.SetMessage("Test reload succesful");
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.SetMessage("Error reloading tests...");
                Dev2Logger.Error(ex, GlobalConstants.WarewolfError);
            }

            var serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(result));
        }
        ExecuteMessage RunOutput(bool expectCorrectInput)
        {
            var esbMethod = new DeleteScheduledResource();
            var factory   = new Mock <IServerSchedulerFactory>();
            var model     = new Mock <IScheduledResourceModel>();
            var ws        = new Mock <IWorkspace>();
            var trigger   = new ScheduleTrigger(TaskState.Disabled,
                                                new Dev2DailyTrigger(new TaskServiceConvertorFactory(), new DailyTrigger(21)),
                                                new Dev2TaskService(new TaskServiceConvertorFactory()),
                                                new TaskServiceConvertorFactory());
            var res      = new ScheduledResource("a", SchedulerStatus.Enabled, DateTime.Now, trigger, "dave", Guid.NewGuid().ToString());
            var security = new Mock <ISecurityWrapper>();

            esbMethod.SecurityWrapper = security.Object;

            var inp = new Dictionary <string, StringBuilder>();

            factory.Setup(
                a =>
                a.CreateModel(GlobalConstants.SchedulerFolderId, It.IsAny <ISecurityWrapper>())).Returns(model.Object);
            var serialiser = new Dev2JsonSerializer();

            if (expectCorrectInput)
            {
                model.Setup(a => a.DeleteSchedule(It.IsAny <ScheduledResource>())).Verifiable();
                inp.Add("Resource", serialiser.SerializeToBuilder(res));
            }

            esbMethod.SchedulerFactory = factory.Object;

            var output = esbMethod.Execute(inp, ws.Object);

            if (expectCorrectInput)
            {
                model.Verify(a => a.DeleteSchedule(It.IsAny <ScheduledResource>()));
            }

            return(serialiser.Deserialize <ExecuteMessage>(output));
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Sharepoint Source");
                StringBuilder resourceDefinition;

                values.TryGetValue("SharepointServer", out resourceDefinition);

                var src = serializer.Deserialize <SharePointServiceSourceDefinition>(resourceDefinition);
                if (src.Path.EndsWith("\\"))
                {
                    src.Path = src.Path.Substring(0, src.Path.LastIndexOf("\\", StringComparison.Ordinal));
                }
                var res = new SharepointSource
                {
                    AuthenticationType = src.AuthenticationType,
                    Server             = src.Server,
                    Password           = src.Password,
                    UserName           = src.UserName,
                    ResourceID         = src.Id,
                    ResourceName       = src.Name,
                    IsSharepointOnline = src.IsSharepointOnline,
                };
                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, res, src.Path);
                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
示例#49
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                values.TryGetValue(Warewolf.Service.GetResourceById.ResourceId, out StringBuilder tmpResourceId);
                var resourceId = Guid.Empty;
                if (tmpResourceId != null)
                {
                    Guid.TryParse(tmpResourceId.ToString(), out resourceId);
                }

                if (resourceId == Guid.Empty)
                {
                    throw new ArgumentNullException("resourceid");
                }
                values.TryGetValue(Warewolf.Service.GetResourceById.WorkspaceId, out StringBuilder tmpWorkspaceId);
                var workspaceId = Guid.Empty;
                if (tmpWorkspaceId != null)
                {
                    Guid.TryParse(tmpWorkspaceId.ToString(), out workspaceId);
                }

                Dev2Logger.Info($"Get Resource By Id. workspaceId:{workspaceId} resourceId:{resourceId}", GlobalConstants.WarewolfInfo);

                var result = _resourceCatalog.Value.GetResource(workspaceId, resourceId);
                if (result != null)
                {
                    var serializer = new Dev2JsonSerializer();
                    return(serializer.SerializeToBuilder(result));
                }

                return(new StringBuilder());
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                throw;
            }
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            IExplorerRepositoryResult item;
            var serializer = new Dev2JsonSerializer();

            try
            {
                StringBuilder itemToBeRenamedPath;
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                StringBuilder itemToBeRenamed;
                StringBuilder newPath;
                if (!values.TryGetValue("itemToMove", out itemToBeRenamed))
                {
                    throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "itemToMove"));
                }
                if (!values.TryGetValue("newPath", out newPath))
                {
                    throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "newName"));
                }
                if (!values.TryGetValue("itemToBeRenamedPath", out itemToBeRenamedPath))
                {
                    throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "newName"));
                }


                var itemToMove = ServerExplorerRepo.Find(Guid.Parse(itemToBeRenamed.ToString())) ?? ServerExplorerRepo.Find(a => a.ResourcePath == itemToBeRenamedPath.ToString());
                Dev2Logger.Info($"Move Item. Path:{itemToBeRenamed} NewPath:{newPath}");
                item = ServerExplorerRepo.MoveItem(itemToMove, newPath.ToString(), GlobalConstants.ServerWorkspaceID);
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e);
                item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
            }
            return(serializer.SerializeToBuilder(item));
        }
示例#51
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                string typeName = null;
                values.TryGetValue("SelectedSource", out StringBuilder tmp);
                if (tmp != null)
                {
                    typeName = tmp.ToString();
                }

                if (string.IsNullOrEmpty(typeName))
                {
                    throw new ArgumentNullException("SelectedSource");
                }
                Dev2Logger.Info("Find Autocomplete Options. " + typeName, GlobalConstants.WarewolfInfo);

                string[] tempValues = new string[3];
                tempValues[0] = "value1";
                tempValues[1] = "value2";
                tempValues[2] = "value3";

                var result = new Dictionary <string, string[]>();
                result.Add("QueueNames", tempValues);

                if (result != null)
                {
                    var serializer = new Dev2JsonSerializer();
                    return(serializer.SerializeToBuilder(result));
                }

                return(new StringBuilder());
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                throw;
            }
        }
示例#52
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Resource Service", GlobalConstants.WarewolfInfo);

                values.TryGetValue("ServerSettings", out StringBuilder resourceDefinition);

                msg.Message  = new StringBuilder();
                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }
            return(serializer.SerializeToBuilder(msg));
        }
示例#53
0
        private static void CreateDebugState(string result, string workflowName, string taskName)
        {
            string user  = Thread.CurrentPrincipal.Identity.Name.Replace("\\", "-");
            var    state = new DebugState
            {
                HasError     = true,
                ID           = Guid.NewGuid(),
                Message      = string.Format("{0}", result),
                StartTime    = DateTime.Now,
                EndTime      = DateTime.Now,
                ErrorMessage = string.Format("{0}", result),
                DisplayName  = workflowName
            };

            var debug = new DebugItem();

            debug.Add(new DebugItemResult
            {
                Type     = DebugItemResultType.Label,
                Value    = "Warewolf Execution Error:",
                Label    = "Scheduler Execution Error",
                Variable = result
            });
            var js = new Dev2JsonSerializer();

            Thread.Sleep(5000);
            string correlation = GetCorrelationId(WarewolfTaskSchedulerPath + taskName);

            if (!Directory.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }
            File.WriteAllText(
                string.Format("{0}DebugItems_{1}_{2}_{3}_{4}.txt", OutputPath, workflowName.Replace("\\", "_"),
                              DateTime.Now.ToString("yyyy-MM-dd"), correlation, user),
                js.SerializeToBuilder(new List <DebugState> {
                state
            }).ToString());
        }
示例#54
0
        private void SetMessage(ErrorResultTO errors, IEsbManagementEndpoint eme)
        {
            var serializer = new Dev2JsonSerializer();
            var msg        = new ExecuteMessage {
                HasError = true
            };

            switch (eme.GetAuthorizationContextForService())
            {
            case AuthorizationContext.View:
                msg.SetMessage(ErrorResource.NotAuthorizedToViewException);
                break;

            case AuthorizationContext.Execute:
                msg.SetMessage(ErrorResource.NotAuthorizedToExecuteException);
                break;

            case AuthorizationContext.Contribute:
                msg.SetMessage(ErrorResource.NotAuthorizedToContributeException);
                break;

            case AuthorizationContext.DeployTo:
                msg.SetMessage(ErrorResource.NotAuthorizedToDeployToException);
                break;

            case AuthorizationContext.DeployFrom:
                msg.SetMessage(ErrorResource.NotAuthorizedToDeployFromException);
                break;

            case AuthorizationContext.Administrator:
                msg.SetMessage(ErrorResource.NotAuthorizedToAdministratorException);
                break;

            default:
                Request.ExecuteResult = serializer.SerializeToBuilder(msg);
                errors.AddError(ErrorResource.NotAuthorizedToExecuteException);
                break;
            }
        }
示例#55
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var settings = new Settings();

            try
            {
                var securityRead    = CreateSecurityReadEndPoint();
                var jsonPermissions = securityRead.Execute(values, theWorkspace);
                settings.Security = JsonConvert.DeserializeObject <SecuritySettingsTO>(jsonPermissions.ToString());
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error(ex);
                settings.HasError = true;
                settings.Error    = "Error reading settings configuration : " + ex.Message;
                settings.Security = new SecuritySettingsTO(SecurityRead.DefaultPermissions);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(settings));
        }
示例#56
0
        public bool Save(IScheduledResource resource, out string errorMessage)
        {
            Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
            var builder    = jsonSerializer.SerializeToBuilder(resource);
            var controller = new CommunicationController {
                ServiceName = "SaveScheduledResourceService"
            };

            controller.AddPayloadArgument("Resource", builder);
            controller.AddPayloadArgument("PreviousResource", resource.OldName);
            controller.AddPayloadArgument("UserName", resource.UserName);
            controller.AddPayloadArgument("Password", resource.Password);
            var executeCommand = controller.ExecuteCommand <ExecuteMessage>(_model.Connection, _model.Connection.WorkspaceID);

            errorMessage = "";
            if (executeCommand != null)
            {
                errorMessage = executeCommand.Message.ToString();
                return(!executeCommand.HasError);
            }
            return(true);
        }
示例#57
0
        public void SaveAuditingSettings_Execute_LegacySettingsData()
        {
            //------------Setup for test--------------------------
            var serializer    = new Dev2JsonSerializer();
            var workspaceMock = new Mock <IWorkspace>();
            var settingsData  = new LegacySettingsData()
            {
                AuditFilePath = @"C:\ProgramData\Warewolf\Audits",
            };
            var requestArgs = new Dictionary <string, StringBuilder>();

            requestArgs.Add("AuditingSettings", new StringBuilder(serializer.SerializeToBuilder(settingsData).ToString()));
            requestArgs.Add("SinkType", new StringBuilder("LegacySettingsData"));

            var saveAuditingSettings = new SaveAuditingSettings();
            //------------Execute Test---------------------------
            var jsonResult = saveAuditingSettings.Execute(requestArgs, workspaceMock.Object);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsFalse(result.HasError);
        }
        public void AddFolder(string path, string name, Guid id)
        {
            var controller        = CommunicationControllerFactory.CreateController("AddFolderService");
            var resourcePath      = String.IsNullOrEmpty(path) ? name : $"{path}\\{name}";
            var serialiser        = new Dev2JsonSerializer();
            var explorerItemModel = new ServerExplorerItem
            {
                DisplayName  = name,
                ResourceType = "Folder",
                ResourcePath = resourcePath,
                ResourceId   = id,
                IsFolder     = true
            };

            controller.AddPayloadArgument("itemToAdd", serialiser.SerializeToBuilder(explorerItemModel));
            var result = controller.ExecuteCommand <IExplorerRepositoryResult>(Connection, GlobalConstants.ServerWorkspaceID);

            if (result.Status != ExecStatus.Success)
            {
                throw new WarewolfSaveException(result.Message, null);
            }
        }
示例#59
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if (values == null)
            {
                throw new InvalidDataException(ErrorResource.EmptyValuesPassed);
            }

            values.TryGetValue("LoggingSettings", out StringBuilder loggingSettingsBuilder);

            if (loggingSettingsBuilder == null || loggingSettingsBuilder.Length == 0)
            {
                throw new InvalidDataException(ErrorResource.EmptyLoggingSettingsPassed);
            }

            var serializer = new Dev2JsonSerializer();

            try
            {
                var loggingSettingsTo = serializer.Deserialize <LoggingSettingsTo>(loggingSettingsBuilder);
                if (loggingSettingsTo == null)
                {
                    throw new InvalidDataException(ErrorResource.InvalidSecuritySettings);
                }

                Write(loggingSettingsTo);
            }
            catch (Exception e)
            {
                throw new InvalidDataException(ErrorResource.InvalidSecuritySettings + $" Error: {e.Message}");
            }

            var msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage("Success");

            return(serializer.SerializeToBuilder(msg));
        }
示例#60
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                Dev2Logger.Log.Info("Fetch Remote Debug Messages");
                string             invokerId  = null;
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();

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

                if (string.IsNullOrEmpty(invokerId))
                {
                    throw new InvalidDataContractException("Null or empty ServiceID or WorkspaceID");
                }

                Guid iGuid;
                // RemoteDebugMessageRepo
                Guid.TryParse(invokerId, out iGuid);

                if (iGuid != Guid.Empty)
                {
                    var items = RemoteDebugMessageRepo.Instance.FetchDebugItems(iGuid);

                    return(serializer.SerializeToBuilder(items));
                }

                return(new StringBuilder());
            }
            catch (Exception err)
            {
                Dev2Logger.Log.Error("Fetch Remote Debug Messages Error", err);
                throw;
            }
        }