Beispiel #1
0
        public void PushResponseIntoEnvironment(string input, int update, IDSFDataObject dataObj, bool formatResult)
        {
            if (dataObj == null)
            {
                throw new ArgumentNullException(nameof(dataObj));
            }

            try
            {
                if (!IsObject && (Outputs == null || Outputs.Count == 0))
                {
                    return;
                }
                if (!IsObject && OutputDescription != null && OutputDescription.DataSourceShapes.Count == 1 && OutputDescription.DataSourceShapes[0].Paths.All(a => a is StringPath))
                {
                    var serviceOutputMapping = Outputs.First();
                    if (serviceOutputMapping != null)
                    {
                        dataObj.Environment.Assign(serviceOutputMapping.MappedTo, input, update);
                    }
                    return;
                }
                if (IsObject)
                {
                    AssignObject(input, update, dataObj);
                }
                else
                {
                    TryFormatOutput(input, update, dataObj, formatResult);
                }
            }
            catch (Exception e)
            {
                dataObj.Environment.AddError(e.Message);
                Dev2Logger.Error(e.Message, e, GlobalConstants.WarewolfError);
            }
        }
Beispiel #2
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Auditing Settings Service", GlobalConstants.WarewolfInfo);
                values.TryGetValue(Warewolf.Service.SaveAuditingSettings.AuditingSettings, out StringBuilder settings);
                values.TryGetValue(Warewolf.Service.SaveAuditingSettings.SinkType, out StringBuilder sinkType);

                if (sinkType.ToString() == "AuditingSettingsData")
                {
                    var updatedAuditingSettings = serializer.Deserialize <AuditingSettingsData>(settings);
                    Config.Auditing.LoggingDataSource = updatedAuditingSettings.LoggingDataSource;
                    Config.Auditing.EncryptDataSource = updatedAuditingSettings.EncryptDataSource;
                    Config.Server.Sink = nameof(AuditingSettingsData);
                }
                else
                {
                    var updatedLegacySettings = serializer.Deserialize <LegacySettingsData>(settings);
                    var auditsFilePath        = updatedLegacySettings.AuditFilePath;
                    Config.Legacy.SaveLoggingPath(auditsFilePath);
                    Config.Server.Sink = nameof(LegacySettingsData);
                }
                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));
        }
Beispiel #3
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

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

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

                var src = serializer.Deserialize <IEmailServiceSource>(resourceDefinition);
                var con = new EmailSource
                {
                    Host         = src.HostName,
                    UserName     = src.UserName,
                    Password     = src.Password,
                    Port         = src.Port,
                    EnableSsl    = src.EnableSsl,
                    Timeout      = src.Timeout,
                    ResourceName = src.ResourceName,
                    ResourceID   = src.Id
                };
                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, con, src.Path);
                ServerExplorerRepo.UpdateItem(con);

                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 IOutputDescription Test(PluginInvokeArgs setupInfo, out string serializedResult)
        {
            try
            {
                serializedResult  = null;
                _assemblyLocation = setupInfo.AssemblyLocation;
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
                if (!_assemblyLoader.TryLoadAssembly(setupInfo.AssemblyLocation, setupInfo.AssemblyName, out Assembly loadedAssembly))
                {
                    return(null);
                }
                var methodToRun = TryExecutePlugin(setupInfo, loadedAssembly, out object pluginResult);

                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
                // do formating here to avoid object serialization issues ;)
                var dataBrowser     = DataBrowserFactory.CreateDataBrowser();
                var dataSourceShape = DataSourceShapeFactory.CreateDataSourceShape();

                if (pluginResult != null)
                {
                    serializedResult = JsonConvert.SerializeObject(pluginResult);
                    pluginResult     = AdjustPluginResult(pluginResult, methodToRun);
                    var tmpData = dataBrowser.Map(pluginResult);
                    dataSourceShape.Paths.AddRange(tmpData);
                }

                var result = OutputDescriptionFactory.CreateOutputDescription(OutputFormats.ShapedXML);
                result.DataSourceShapes.Add(dataSourceShape);
                return(result);
            }
            catch (Exception e)
            {
                Dev2Logger.Error("IOutputDescription Test(PluginInvokeArgs setupInfo)", e, GlobalConstants.WarewolfError);
                serializedResult = null;
                return(null);
            }
        }
Beispiel #5
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            _indexCounter = 1;
            var allErrors = new ErrorResultTO();

            try
            {
                var sharepointReadListTos = SharepointUtils.GetValidReadListItems(ReadListItems).ToList();
                if (sharepointReadListTos.Any())
                {
                    TryExecute(dataObject, update, sharepointReadListTos);
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Error("SharepointCreateListItemActivity", e, GlobalConstants.WarewolfError);
                allErrors.AddError(e.Message);
            }
            finally
            {
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    dataObject.Environment.Assign(Result, "Failed", update);
                    DisplayAndWriteError("SharepointCreateListItemActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test connection Service");
                StringBuilder resourceDefinition;
                var           workspaceIdString = string.Empty;

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

                IServerSource src    = serializer.Deserialize <ServerSource>(resourceDefinition);
                Connections   tester = new Connections();

                var result = tester.CanConnectToServer(new Connection
                {
                    Address            = src.Address,
                    AuthenticationType = src.AuthenticationType,
                    UserName           = src.UserName,
                    Password           = src.Password
                });

                msg.HasError = false;
                msg.Message  = new StringBuilder(result.IsValid ? "" : result.ErrorMessage);
                msg.HasError = !result.IsValid;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

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

            try
            {
                string serviceId            = null;
                var    prepairForDeployment = false;
                values.TryGetValue(@"ResourceID", out StringBuilder tmp);

                if (tmp != null)
                {
                    serviceId = tmp.ToString();
                }

                values.TryGetValue(@"PrepairForDeployment", out tmp);

                if (tmp != null)
                {
                    prepairForDeployment = bool.Parse(tmp.ToString());
                }

                Guid.TryParse(serviceId, out Guid resourceId);

                Dev2Logger.Info($"Fetch Resource definition. ResourceId: {resourceId}", GlobalConstants.WarewolfInfo);
                var result             = ResourceCat.GetResourceContents(theWorkspace.ID, resourceId);
                var resourceDefinition = Cleaner.GetResourceDefinition(prepairForDeployment, resourceId, result);

                return(resourceDefinition);
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                throw;
            }
        }
Beispiel #8
0
        public Stream Get(IActivityIOPath path, List <string> filesToCleanup)
        {
            Stream result = null;

            try
            {
                if (_implementation.IsStandardFtp(path))
                {
                    _implementation.ReadFromFtp(path, ref result);
                }
                else
                {
                    Dev2Logger.Debug($"SFTP_GET:{path.Path}", GlobalConstants.WarewolfDebug);
                    _implementation.ReadFromSftp(path, ref result, filesToCleanup);
                }
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(this, ex, GlobalConstants.WarewolfError);
                var message = $"{ex.Message} ,  [{path.Path}]";
                throw new Exception(message, ex);
            }
            return(result);
        }
        protected override void Save(IServer server, dynamic jsonArgs)
        {
            try
            {
                string resName           = jsonArgs.resourceName;
                bool   loadingFromServer = jsonArgs.resourceLoadingFromServer;
                string originalPath      = jsonArgs.OriginalPath;
                var    resCat            = HelperUtils.SanitizePath((string)jsonArgs.resourcePath, resName);
                if (_resourceModel != null)
                {
                    EventPublisher.Publish(new SaveUnsavedWorkflowMessage(_resourceModel, resName, resCat, AddToTabManager, loadingFromServer, originalPath));
                }

                Close();
            }
            catch (Exception e)
            {
                var e1 = new Exception("There was a problem saving. Please try again.", e);

                Dev2Logger.Info(e.Message + Environment.NewLine + " Stacktrace : " + e.StackTrace + Environment.NewLine + " jsonObj: " + jsonArgs.ToString(), "Warewolf Info");

                throw e1;
            }
        }
Beispiel #10
0
 void CreateSourceFileWithSomeDummyData(int numberOfGuids = 1)
 {
     try
     {
         Dev2Logger.Debug(string.Format("Source File: {0}", _scenarioContext.Get <string>(ActualSourceHolder)), "Warewolf Debug");
         var broker = ActivityIOFactory.CreateOperationsBroker();
         var source = ActivityIOFactory.CreatePathFromString(_scenarioContext.Get <string>(ActualSourceHolder),
                                                             _scenarioContext.Get <string>(SourceUsernameHolder),
                                                             _scenarioContext.Get <string>(SourcePasswordHolder),
                                                             true, "");
         var sb = new StringBuilder();
         Enumerable.Range(1, numberOfGuids).ToList().ForEach(x => sb.Append(Guid.NewGuid().ToString()));
         var ops            = ActivityIOFactory.CreatePutRawOperationTO(WriteType.Overwrite, sb.ToString());
         var sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
         if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
         {
             var result = broker.PutRaw(sourceEndPoint, ops);
             if (result != "Success")
             {
                 result = broker.PutRaw(sourceEndPoint, ops);
                 if (result != "Success")
                 {
                     Dev2Logger.Debug("Create Source File for file op test error", "Warewolf Debug");
                 }
             }
         }
         else if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.Directory && source.Path.Contains("emptydir"))
         {
             broker.Create(sourceEndPoint, new Dev2CRUDOperationTO(true, false), false);
         }
     }
     catch (Exception e)
     {
         Dev2Logger.Debug("Create Source File for file op test error", e, "Warewolf Debug");
     }
 }
Beispiel #11
0
        public QueueWorkerMonitor(IProcessFactory processFactory, IQueueConfigLoader queueConfigLoader, ITriggersCatalog triggersCatalog, IChildProcessTracker childProcessTracker)
        {
            _childProcessTracker = childProcessTracker;
            _processFactory      = processFactory;
            _queueConfigLoader   = queueConfigLoader;

            triggersCatalog.OnChanged += (triggerId) =>
            {
                try
                {
                    var configs = _queueConfigLoader.Configs;
                    var config  = configs.First(o => o.Id == triggerId);
                    WorkerDeleted(config.Id);
                    WorkerCreated(config.Id);
                }
                catch (Exception e)
                {
                    Dev2Logger.Warn(e.Message, "");
                }
            };

            triggersCatalog.OnDeleted += WorkerDeleted;
            triggersCatalog.OnCreated += WorkerCreated;
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test WebserviceSource", GlobalConstants.WarewolfInfo);

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

                var src    = serializer.Deserialize <WebServiceSourceDefinition>(resourceDefinition);
                var con    = new WebSources();
                var result = con.Test(new WebSource
                {
                    Address            = src.HostName,
                    DefaultQuery       = src.DefaultQuery,
                    AuthenticationType = src.AuthenticationType,
                    UserName           = src.UserName,
                    Password           = src.Password
                });


                msg.HasError = false;
                msg.Message  = new StringBuilder(result.IsValid ? serializer.Serialize(result.Result) : result.ErrorMessage);
                msg.HasError = !result.IsValid;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }

            return(serializer.SerializeToBuilder(msg));
        }
        public SecuritySettingsTO ReadSettingsFile(IResourceNameProvider resourceNameProvider)
        {
            var serverSecuritySettingsFile = EnvironmentVariables.ServerSecuritySettingsFile;

            if (!File.Exists(serverSecuritySettingsFile))
            {
                return(new SecuritySettingsTO(DefaultPermissions, DefaultOverrideResource, DefaultSecretKey)
                {
                    CacheTimeout = CacheTimeout
                });
            }

            string encryptedData;

            using (var inStream = new FileStream(serverSecuritySettingsFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var reader = new StreamReader(inStream))
                {
                    encryptedData = reader.ReadToEnd();
                }
            }

            Dev2Logger.Debug("Security Data Read", GlobalConstants.WarewolfDebug);
            try
            {
                return(ProcessSettingsFile(resourceNameProvider, encryptedData));
            }
            catch (Exception e)
            {
                Dev2Logger.Error("SecurityRead", e, GlobalConstants.WarewolfError);
                return(new SecuritySettingsTO(DefaultPermissions, DefaultOverrideResource, DefaultSecretKey)
                {
                    CacheTimeout = CacheTimeout
                });
            }
        }
Beispiel #14
0
        public bool EnsureSsl(IFile fileWrapper, string certPath, IPEndPoint endPoint)
        {
            var result = false;

            if (!fileWrapper.Exists(certPath))
            {
                try
                {
                    var certificateBuilder = new SslCertificateBuilder();
                    certificateBuilder.EnsureSslCertificate(certPath, endPoint);
                    result = fileWrapper.Exists(certPath);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                }
            }
            else
            {
                result = SslCertificateBuilder.BindSslCertToPorts(endPoint, certPath);
            }

            return(result);
        }
Beispiel #15
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

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

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

                var src = serializer.Deserialize <WcfServiceSourceDefinition>(resourceDefinition);
                var con = new WcfSource
                {
                    EndpointUrl  = src.EndpointUrl,
                    ResourceName = src.Name,
                    Name         = src.Name,
                    ResourceID   = src.Id,
                    Type         = enSourceType.WcfSource,
                    ResourceType = "WcfSource"
                };
                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, con, src.Path);
                ServerExplorerRepo.UpdateItem(con);

                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

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

            try
            {
                Dev2Logger.Info("Fetch All Tests Service", GlobalConstants.WarewolfInfo);

                var tests   = TestCatalog.FetchAllTests();
                var message = new CompressedExecuteMessage();
                message.SetMessage(serializer.Serialize(tests));
                message.HasError = false;

                return(serializer.SerializeToBuilder(message));
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                var res = new CompressedExecuteMessage {
                    HasError = true, Message = new StringBuilder(err.Message)
                };
                return(serializer.SerializeToBuilder(res));
            }
        }
Beispiel #17
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            IExplorerRepositoryResult item;
            var serializer = new Dev2JsonSerializer();

            try
            {
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }
                if (!values.TryGetValue("itemToMove", out StringBuilder itemToBeRenamed))
                {
                    throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "itemToMove"));
                }
                if (!values.TryGetValue("newPath", out StringBuilder newPath))
                {
                    throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "newName"));
                }
                if (!values.TryGetValue("itemToBeRenamedPath", out StringBuilder 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}", GlobalConstants.WarewolfInfo);
                item = ServerExplorerRepo.MoveItem(itemToMove, newPath.ToString(), GlobalConstants.ServerWorkspaceID);
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
            }
            return(serializer.SerializeToBuilder(item));
        }
Beispiel #18
0
 public ResourceCatalogResult DeleteResource(Guid workspaceID, Guid resourceID, string type, bool deleteVersions)
 {
     try
     {
         if (workspaceID != GlobalConstants.ServerWorkspaceID)
         {
             return(DeleteFromWorkspace(workspaceID, resourceID, type, deleteVersions));
         }
         foreach (var wid in _resourceCatalog.WorkspaceResources.Keys)
         {
             var result = DeleteFromWorkspace(wid, resourceID, type, deleteVersions);
             if (wid == GlobalConstants.ServerWorkspaceID && result.Status != ExecStatus.Success)
             {
                 return(result);
             }
         }
         return(ResourceCatalogResultBuilder.CreateSuccessResult("Success"));
     }
     catch (Exception err)
     {
         Dev2Logger.Error("Delete Error", err, GlobalConstants.WarewolfError);
         throw;
     }
 }
Beispiel #19
0
        void Debug(IDSFDataObject dataObject, string firstOrDefault, Dev2Switch ds)
        {
            try
            {
                if (dataObject.IsDebugMode())
                {
                    var result      = new List <DebugItem>();
                    var itemToAdd   = new DebugItem();
                    var debugResult = new DebugItemWarewolfAtomResult(firstOrDefault, "", ds.SwitchVariable, "", "Switch on", "", "=");
                    itemToAdd.AddRange(debugResult.GetDebugItemResult());
                    result.Add(itemToAdd);
                    _debugInputs = result;

                    if (Inner != null)
                    {
                        Inner.SetDebugInputs(_debugInputs);
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Warn(e.Message, GlobalConstants.WarewolfWarn);
            }
        }
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                Dev2Logger.Info("Get Scheduled Resources", GlobalConstants.WarewolfInfo);
                ObservableCollection <IScheduledResource> resources;
                using (var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
                {
                    resources = model.GetScheduledResources();
                }

                var sb = new StringBuilder(JsonConvert.SerializeObject(resources, Formatting.Indented, new JsonSerializerSettings
                {
                    TypeNameHandling = TypeNameHandling.Objects,
                    TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
                }));
                return(sb);
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                throw;
            }
        }
Beispiel #21
0
        bool TransferDirectoryContents(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args)
        {
            ValidateSourceAndDestinationContents(src, dst, args);

            if (args.DoRecursiveCopy)
            {
                RecursiveCopy(src, dst, args);
            }

            var srcContents = src.ListFilesInDirectory(src.IOPath);
            var result      = true;
            var origDstPath = Dev2ActivityIOPathUtils.ExtractFullDirectoryPath(dst.IOPath.Path);

            if (!dst.PathExist(dst.IOPath))
            {
                CreateDirectory(dst, args);
            }
            foreach (var p in srcContents)
            {
                result = PerformTransfer(src, dst, args, origDstPath, p, result);
            }
            Dev2Logger.Debug($"Transfered: {src.IOPath.Path}", GlobalConstants.WarewolfDebug);
            return(result);
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test Redis Source", GlobalConstants.WarewolfInfo);
                msg.HasError = false;
                values.TryGetValue(Warewolf.Service.TestRedisSource.RedisSource, out StringBuilder resourceDefinition);

                var redisServiceSourceDefinition = serializer.Deserialize <RedisSourceDefinition>(resourceDefinition);
                var con = new RedisSources();
                using (var redisSource = new RedisSource
                {
                    HostName = redisServiceSourceDefinition.HostName,
                    Port = redisServiceSourceDefinition.Port,
                    AuthenticationType = redisServiceSourceDefinition.AuthenticationType,
                    Password = redisServiceSourceDefinition.Password
                })
                {
                    var result = con.Test(redisSource);
                    msg.HasError = false;
                    msg.Message  = new StringBuilder(result.IsValid ? serializer.Serialize(result.Result) : result.ErrorMessage);
                    msg.HasError = !result.IsValid;
                }
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Beispiel #23
0
        internal void CleanupServer()
        {
            try
            {
                _queueProcessMonitor.Shutdown();
                if (_startWebServer != null)
                {
                    _startWebServer.Dispose();
                    _startWebServer = null;
                }

                if (_ipcClient != null)
                {
                    _ipcClient.Dispose();
                    _ipcClient = null;
                }

                DebugDispatcher.Instance.Shutdown();
            }
            catch (Exception ex)
            {
                Dev2Logger.Error("Dev2.ServerLifecycleManager", ex, GlobalConstants.WarewolfError);
            }
        }
 public void Disconnect()
 {
     // It can take some time to shutdown when permissions have changed ;(
     // Give 5 seconds, then force a dispose ;)
     try
     {
         IsShuttingDown = true;
         IsConnected    = false;
         IsConnecting   = false;
         HubConnection.Stop(new TimeSpan(0, 0, 0, 5));
     }
     catch (AggregateException aex)
     {
         aex.Flatten();
         aex.Handle(ex =>
         {
             Dev2Logger.Error(this, aex);
             var hex = ex as HttpClientException;
             if (hex != null)
             {
                 switch (hex.Response.StatusCode)
                 {
                 case HttpStatusCode.Unauthorized:
                 case HttpStatusCode.Forbidden:
                     UpdateIsAuthorized(false);
                     throw new NotConnectedException();
                 }
             }
             throw new NotConnectedException();
         });
     }
     catch (Exception e)
     {
         Dev2Logger.Error(this, e);
     }
 }
Beispiel #25
0
            string ExtendedDirListSftp(string path, string user, string pass, string privateKeyFile)
            {
                var result         = new StringBuilder();
                var pathFromString = ActivityIOFactory.CreatePathFromString(path, user, pass, privateKeyFile);
                var sftp           = BuildSftpClient(pathFromString);

                try
                {
                    var fromPath = ExtractFileNameFromPath(pathFromString.Path);
                    AddResults(sftp, fromPath, result);
                }
                catch (Exception ex)
                {
                    sftp.Dispose();
                    Dev2Logger.Error(this, ex, GlobalConstants.WarewolfError);
                    throw new Exception(string.Format(ErrorResource.DirectoryNotFound, path));
                }
                finally
                {
                    sftp.Disconnect();
                    sftp.Dispose();
                }
                return(result.ToString());
            }
Beispiel #26
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test DB Connection Service");
                StringBuilder resourceDefinition;

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

                IDbSource src = serializer.Deserialize <DbSourceDefinition>(resourceDefinition);
                var       con = new DbSources();
                DatabaseValidationResult result = con.DoDatabaseValidation(new DbSource
                {
                    AuthenticationType = src.AuthenticationType,
                    Server             = src.ServerName,
                    Password           = src.Password,
                    ServerType         = src.Type,
                    UserID             = src.UserName
                });

                msg.HasError = false;
                msg.Message  = new StringBuilder(result.IsValid ? serializer.Serialize(result.DatabaseList) : result.ErrorMessage);
                msg.HasError = !result.IsValid;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Beispiel #27
0
 /// <summary>
 /// Adds the resource.
 /// </summary>
 /// <param name="res">The res.</param>
 /// <param name="filePath">The file path.</param>
 private void AddResource(IResource res, string filePath)
 {
     if (!filePath.Contains("VersionControl"))
     {
         if (!_addedResources.Contains(res.ResourceID))
         {
             _resources.Add(res);
             _addedResources.Add(res.ResourceID);
         }
         else
         {
             var dupRes = _resources.Find(c => c.ResourceID == res.ResourceID);
             if (dupRes != null)
             {
                 CreateDupResource(dupRes, filePath);
                 Dev2Logger.Debug(string.Format(ErrorResource.ResourceAlreadyLoaded, res.ResourceName, filePath, dupRes.FilePath), GlobalConstants.WarewolfDebug);
             }
             else
             {
                 Dev2Logger.Debug(string.Format("Resource '{0}' from file '{1}' wasn't loaded because a resource with the same name has already been loaded but cannot find its location.", res.ResourceName, filePath), GlobalConstants.WarewolfDebug);
             }
         }
     }
 }
Beispiel #28
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var allErrors = new ErrorResultTO();

            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                TryExecute(dataObject, update, allErrors);
            }
            catch (Exception e)
            {
                Dev2Logger.Error("DSFDateTime", e, GlobalConstants.WarewolfError);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfDateTimeActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }
                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
Beispiel #29
0
        IEnumerable <IExplorerItem> DuplicateAndSaveFolders(string sourceLocation, string destination, string newName, bool fixRefences)
        {
            var    resourcesToMove = GetResourcesToMoveFrom(sourceLocation);
            string destFolderPath  = CalculateDestinationFolderPath(destination, newName, out List <IExplorerItem> items);

            try
            {
                var duplicatedResourcesMap = DuplicateAndSaveResources(sourceLocation, destFolderPath, resourcesToMove);

                DuplicateAndSaveTests(duplicatedResourcesMap);

                if (fixRefences)
                {
                    try
                    {
                        using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew))
                        {
                            FixReferences(duplicatedResourcesMap);
                            tx.Complete();
                        }
                    }
                    catch (TransactionAbortedException e)
                    {
                        Dev2Logger.Error("Failure Fixing references", e, GlobalConstants.WarewolfError);
                        throw new WarewolfThreadAbortException(string.Format(ErrorResource.ErrorDuringDuplicateFolderCallback, e.Message));
                    }
                }
            }
            catch (TransactionAbortedException ex)
            {
                Dev2Logger.Error(ErrorResource.ErrorDuringDuplicateFolderCallback, ex, GlobalConstants.WarewolfError);
                throw new WarewolfThreadAbortException(string.Format(ErrorResource.ErrorDuringDuplicateFolderCallback, ex.Message));
            }

            return(items);
        }
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var allErrors = new ErrorResultTO();
            var errors    = new ErrorResultTO();

            _executionResult = new List <string>();
            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                TryExecute(dataObject, update, allErrors, errors);
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(string.Format("{0} Exception", DisplayName), ex, GlobalConstants.WarewolfError);
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError(DisplayName, allErrors);
                    var errorList = allErrors.MakeDataListReady();
                    dataObject.Environment.AddError(errorList);
                    dataObject.Environment.Assign(Result, DisplayName.ToUpper().Contains("Dropbox".ToUpper()) ? GlobalConstants.DropBoxFailure : null, update);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }