Exemplo n.º 1
0
        public IDbConnection CreateConnection(string connectionString)
        {
            VerifyArgument.IsNotNull("connectionString", connectionString);
            if (connectionString.CanBeDecrypted())
            {
                connectionString = DpapiWrapper.Decrypt(connectionString);
            }
            _sqlConnection = new SqlConnection(connectionString);
            _sqlConnection.FireInfoMessageEventOnUserErrors = true;
            _sqlConnection.StatisticsEnabled = true;
            _sqlConnection.InfoMessage      += (sender, args) =>
            {
                Dev2Logger.Debug("SQL Server:" + args.Message + " Source:" + args.Source);
                foreach (SqlError error in args.Errors)
                {
                    var errorMessages = new StringBuilder();
                    errorMessages.Append("Index #" + error.Number + Environment.NewLine +
                                         "Message: " + error.Message + Environment.NewLine +
                                         "LineNumber: " + error.LineNumber + Environment.NewLine +
                                         "Source: " + error.Source + Environment.NewLine +
                                         "Procedure: " + error.Procedure + Environment.NewLine);

                    Dev2Logger.Error("SQL Error:" + errorMessages.ToString());
                }
            };
            return(_sqlConnection);
        }
Exemplo n.º 2
0
        public WebSource(XElement xml)
            : base(xml)
        {
            ResourceType       = "WebSource";
            AuthenticationType = AuthenticationType.Anonymous;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Address", string.Empty },
                { "DefaultQuery", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            connectionString = connectionString.UnescapeString();
            ParseProperties(connectionString, properties);
            Address      = properties["Address"];
            DefaultQuery = properties["DefaultQuery"];
            UserName     = properties["UserName"];
            Password     = properties["Password"];

            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
        public void EncryptDecryptFailsIfAlreadyPerformedTest()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            string encrypted         = DpapiWrapper.Encrypt(message);
            char   x                 = encrypted.Where(o => encrypted.Where(u => u == o).Count() > 1).First(); // find first char that appears more than once
            char   y                 = encrypted.Where(o => o != x).First();                                   // find the first char not equal to x
            string tamperedEncrypted = encrypted.Replace(x, y);

            try
            {
                string decrypted = DpapiWrapper.Decrypt(tamperedEncrypted);
            }
            catch (Exception e)
            {
                e.GetType().Should().Be(typeof(System.Security.Cryptography.CryptographicException));
            }
            try
            {
                DpapiWrapper.Decrypt(message);
            }
            catch (Exception e)
            {
                e.GetType().Should().Be(typeof(ArgumentException));
            }
        }
Exemplo n.º 4
0
        public RabbitMQSource(XElement xml)
            : base(xml)
        {
            ResourceType = "RabbitMQSource";
            Port         = DefaultPort;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "HostName", string.Empty },
                { "Port", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "VirtualHost", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            HostName = properties["HostName"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            int port;

            Port        = Int32.TryParse(properties["Port"], out port) ? port : DefaultPort;
            VirtualHost = !string.IsNullOrWhiteSpace(properties["VirtualHost"]) ? properties["VirtualHost"] : DefaultVirtualHost;
        }
Exemplo n.º 5
0
        public ExchangeSource(XElement xml)
            : base(xml)
        {
            ResourceType = "ExchangeSource";
            Timeout      = DefaultTimeout;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "AutoDiscoverUrl", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "Timeout", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            AutoDiscoverUrl = properties["AutoDiscoverUrl"];
            UserName        = properties["UserName"];
            Password        = properties["Password"];

            int timeout;

            Timeout = Int32.TryParse(properties["Timeout"], out timeout) ? timeout : DefaultTimeout;
        }
Exemplo n.º 6
0
        public SharepointSource(XElement xml)
            : base(xml)
        {
            ResourceType       = ResourceType.SharepointServerSource;
            AuthenticationType = AuthenticationType.Windows;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Server", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            Server   = properties["Server"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            AuthenticationType authType;

            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out authType) ? authType : AuthenticationType.Windows;
        }
Exemplo n.º 7
0
        public EmailSource(XElement xml)
            : base(xml)
        {
            ResourceType = "EmailSource";
            Timeout      = DefaultTimeout;
            Port         = DefaultPort;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Host", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty },
                { "Port", string.Empty },
                { "EnableSsl", string.Empty },
                { "Timeout", string.Empty },
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);

            Host     = properties["Host"];
            UserName = properties["UserName"];
            Password = properties["Password"];

            Port = Int32.TryParse(properties["Port"], out int port) ? port : DefaultPort;

            EnableSsl = bool.TryParse(properties["EnableSsl"], out bool enableSsl) && enableSsl;

            Timeout = Int32.TryParse(properties["Timeout"], out int timeout) ? timeout : DefaultTimeout;
        }
Exemplo n.º 8
0
        public DbSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.DbSource;

            // Setup type include default port
            switch (xml.AttributeSafe("ServerType"))
            {
            case "SqlDatabase":
                ServerType = enSourceType.SqlDatabase;
                Port       = 1433;
                break;

            case "MySqlDatabase":
                ServerType = enSourceType.MySqlDatabase;
                break;

            default:
                ServerType = enSourceType.Unknown;
                break;
            }
            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ConnectionString = connectionString;
        }
Exemplo n.º 9
0
        public ElasticsearchSource(XElement xml) : base(xml)
        {
            ResourceType       = nameof(ElasticsearchSource);
            AuthenticationType = AuthenticationType.Anonymous;
            Port        = DefaultPort;
            SearchIndex = DefaultSearchIndex;
            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "HostName", string.Empty },
                { "Port", string.Empty },
                { "AuthenticationType", string.Empty },
                { "Password", string.Empty },
                { "Username", string.Empty },
                { "SearchIndex", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            connectionString = connectionString.UnescapeString();
            ParseProperties(connectionString, properties);
            HostName           = properties["HostName"];
            Port               = properties["Port"];
            Username           = properties["Username"];
            Password           = properties["Password"];
            SearchIndex        = properties["SearchIndex"];
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
Exemplo n.º 10
0
        public SharepointSource(XElement xml, ISharepointHelperFactory sharepointHelperFactory)
            : base(xml)
        {
            _sharepointHelperFactory = sharepointHelperFactory;
            ResourceType             = "SharepointServerSource";
            AuthenticationType       = AuthenticationType.Windows;

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Server", string.Empty },
                { "AuthenticationType", string.Empty },
                { "UserName", string.Empty },
                { "Password", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            Server   = properties["Server"];
            UserName = properties["UserName"];
            Password = properties["Password"];
            var isSharepointSourceValue = xml.AttributeSafe("IsSharepointOnline");

            if (bool.TryParse(isSharepointSourceValue, out bool isSharepointSource))
            {
                IsSharepointOnline = isSharepointSource;
            }
            AuthenticationType = Enum.TryParse(properties["AuthenticationType"], true, out AuthenticationType authType) ? authType : AuthenticationType.Windows;
        }
Exemplo n.º 11
0
        public ITriggerQueue LoadQueueTriggerFromFile(string filename)
        {
            var fileData         = _fileWrapper.ReadAllText(filename);
            var decryptedTrigger = DpapiWrapper.Decrypt(fileData);
            var triggerQueue     = _serializer.Deserialize <ITriggerQueue>(decryptedTrigger);

            return(triggerQueue);
        }
Exemplo n.º 12
0
 public IDbConnection CreateConnection(string connectionString)
 {
     VerifyArgument.IsNotNull("connectionString", connectionString);
     if (connectionString.CanBeDecrypted())
     {
         connectionString = DpapiWrapper.Decrypt(connectionString);
     }
     return(new OracleConnection(connectionString));
 }
Exemplo n.º 13
0
        public IDbConnection CreateConnection(string connectionString)
        {
            var connectionStr = connectionString;

            VerifyArgument.IsNotNull("connectionString", connectionStr);
            if (connectionStr.CanBeDecrypted())
            {
                connectionStr = DpapiWrapper.Decrypt(connectionStr);
            }
            return(new SQLiteConnection(connectionStr));
        }
Exemplo n.º 14
0
        public void EncryptDecryptTest()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            string encrypted = DpapiWrapper.Encrypt(message);

            encrypted.Should().NotBeNullOrEmpty();
            encrypted.Should().NotBeNullOrWhiteSpace();
            encrypted.Should().NotBeSameAs(message);
            encrypted.Should().NotContain(message);
            DpapiWrapper.Decrypt(encrypted).Should().Be(message);
        }
Exemplo n.º 15
0
 private IAuditQueryable GetAuditQueryable()
 {
     if (Config.Server.Sink == nameof(AuditingSettingsData))
     {
         var payload             = Config.Auditing.LoggingDataSource.Payload;
         var decryptedPayload    = payload.CanBeDecrypted() ? DpapiWrapper.Decrypt(payload) : payload;
         var elasticsearchSource = new Dev2JsonSerializer().Deserialize <ElasticsearchSource>(decryptedPayload);
         return(new AuditQueryableElastic(elasticsearchSource.HostName, elasticsearchSource.Port, elasticsearchSource.SearchIndex, elasticsearchSource.AuthenticationType, elasticsearchSource.Username, elasticsearchSource.Password));
     }
     else
     {
         return(new AuditQueryableSqlite());
     }
 }
Exemplo n.º 16
0
        public WcfSource(XElement xml)
            : base(xml)
        {
            ResourceType = "WcfSource";
            ProxyService = new WcfProxyService();
            var properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "EndpointUrl", string.Empty },
            };

            var conString = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;
            ParseProperties(connectionString, properties);

            EndpointUrl = properties["EndpointUrl"];
        }
Exemplo n.º 17
0
        public DbSource(XElement xml)
            : base(xml)
        {
            // Setup type include default port
            var attributeSafe = xml.AttributeSafe("ServerType");

            switch (attributeSafe.ToLowerInvariant())
            {
            case "sqldatabase":
                ServerType = enSourceType.SqlDatabase;
                Port       = 1433;
                break;

            case "mysqldatabase":
                ServerType = enSourceType.MySqlDatabase;
                break;

            case "oracle":
                ServerType = enSourceType.Oracle;
                Port       = 1521;
                break;

            case "odbc":
                ServerType = enSourceType.ODBC;
                break;

            case "postgresql":
                ServerType = enSourceType.PostgreSQL;
                break;

            case "sqlite":
                ServerType = enSourceType.SQLiteDatabase;
                break;

            default:
                ResourceType = "DbSource";
                ServerType   = enSourceType.Unknown;
                break;
            }

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ResourceType     = ServerType.ToString();
            ConnectionString = connectionString;
        }
Exemplo n.º 18
0
            private string ConnectionString()
            {
                var payload = _persistence.PersistenceDataSource.Payload;

                if (string.IsNullOrEmpty(payload))
                {
                    return(string.Empty);
                }

                if (_persistence.EncryptDataSource)
                {
                    payload = payload.CanBeDecrypted() ? DpapiWrapper.Decrypt(payload) : payload;
                }

                var source = _deserializer.Deserialize <DbSource>(payload);

                return(source.ConnectionString);
            }
Exemplo n.º 19
0
        public OauthSource(XElement xml)
            : base(xml)
        {
            ResourceType = ResourceType.OauthSource;


            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "Secret", string.Empty },
                { "Key", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            Secret = properties["Secret"];
            Key    = properties["Key"];
        }
Exemplo n.º 20
0
            public int Run()
            {
                var sourceFileName      = _options.FileName;
                var sourceData          = File.ReadAllText(sourceFileName);
                var destinationFileName = _options.OutputFileName;

                if (_options.ShouldEncrypt)
                {
                    var data = DpapiWrapper.Encrypt(sourceData);
                    File.WriteAllText(destinationFileName, data);
                }
                else
                {
                    var data = DpapiWrapper.Decrypt(sourceData);
                    File.WriteAllText(destinationFileName, data);
                }

                return(0);
            }
Exemplo n.º 21
0
        public DropBoxSource(XElement xml)
            : base(xml)
        {
            ResourceType = "DropBoxSource";

            var properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { "AccessToken", string.Empty },
                { "AppKey", string.Empty }
            };

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString) : conString;

            ParseProperties(connectionString, properties);
            AccessToken  = properties["AccessToken"];
            AppKey       = properties["AppKey"];
            ResourcePath = GetSavePath();
        }
Exemplo n.º 22
0
        public Connection(XElement xml)
            : base(xml)
        {
            ResourceType = enSourceType.Dev2Server.ToString();

            var conString        = xml.AttributeSafe("ConnectionString");
            var connectionString = conString.CanBeDecrypted() ? DpapiWrapper.Decrypt(conString):conString;
            var props            = connectionString.Split(';');

            foreach (var p in props.Select(prop => prop.Split('=')).Where(p => p.Length >= 1))
            {
                switch (p[0].ToLowerInvariant())
                {
                case "appserveruri":
                    Address = p[1];
                    break;

                case "webserverport":
                    int port;
                    WebServerPort = Int32.TryParse(p[1], out port) ? port : DefaultWebServerPort;
                    break;

                case "authenticationtype":
                    AuthenticationType authType;
                    AuthenticationType = Enum.TryParse(p[1], true, out authType) ? authType : AuthenticationType.Windows;
                    break;

                case "username":
                    UserName = p[1];
                    break;

                case "password":
                    Password = p[1];
                    break;

                default:
                    break;
                }
            }
        }
        // ReSharper disable InconsistentNaming
        public void EncryptionResourceUpgrader_Upgrade_CanDecrypt()
        {
            //------------Setup for test--------------------------
            var   upgrader = new EncryptionResourceUpgrader();
            Regex cs       = new Regex(@"ConnectionString=""([^""]+)""");

            //------------Execute Test---------------------------
            //------------Assert Results-------------------------
            string output = upgrader.EncryptSourceConnectionStrings(_beforeContainingSource);

            output.Should().NotBeNullOrEmpty();
            output.Should().NotBe(_beforeContainingSource);
            output.Should().NotContain(_connectionString);
            Match m = cs.Match(output);

            m.Success.Should().BeTrue();
            m.Groups.Count.Should().BeGreaterOrEqualTo(1);
            m.Groups[1].Success.Should().BeTrue();
            string x = m.Groups[1].Value;

            DpapiWrapper.Decrypt(x).Should().Be(_connectionString);
        }
Exemplo n.º 24
0
        public void TriggersCatalog_SaveTriggerQueue_WhenHasTriggerId_ShouldSave_NotUpdateTriggerId()
        {
            var queueTriggersPath = QueueTriggersPath;

            var source       = "TestResource";
            var queue        = "TestQueueName";
            var workflowName = "TestWorkflow";
            var triggerId    = Guid.NewGuid();

            var mockResource = new Mock <IResource>();

            mockResource.Setup(resource => resource.ResourceName).Returns(source);
            mockResource.Setup(resource => resource.ResourceID).Returns(Guid.NewGuid());

            var triggerQueueEvent = new TriggerQueue
            {
                QueueSourceId = mockResource.Object.ResourceID,
                QueueName     = queue,
                WorkflowName  = workflowName,
                TriggerId     = triggerId
            };
            var serializer = new Dev2.Common.Serializers.Dev2JsonSerializer();

            var mockSerializer = new Mock <IBuilderSerializer>();

            mockSerializer.Setup(o => o.Serialize(It.IsAny <ITriggerQueue>())).Returns(serializer.Serialize(triggerQueueEvent));
            var serializerInstance = mockSerializer.Object;

            var path = queueTriggersPath + "\\" + triggerId + ".bite";

            var directory = new Mock <IDirectory>().Object;
            var mockFile  = new Mock <IFile>();
            var savedData = string.Empty;

            mockFile.Setup(o => o.WriteAllText(It.IsAny <string>(), It.IsAny <string>())).Callback <string, string>((filename, data) => {
                savedData = data;
            });

            var file = mockFile.Object;
            var fileSystemWatcherWrapper = new Mock <IFileSystemWatcher>().Object;

            var triggerCatalog = GetTriggersCatalog(directory, file, queueTriggersPath, serializerInstance, fileSystemWatcherWrapper);

            triggerCatalog.SaveTriggerQueue(triggerQueueEvent);


            mockFile.Verify(o => o.WriteAllText(It.IsAny <string>(), It.IsAny <string>()), Times.Once);

            var isEncrypted = DpapiWrapper.CanBeDecrypted(savedData);

            Assert.IsTrue(isEncrypted);

            var decryptedTrigger = DpapiWrapper.Decrypt(savedData);

            var theSavedTrigger = serializer.Deserialize <ITriggerQueue>(decryptedTrigger);

            Assert.IsNotNull(theSavedTrigger);
            Assert.AreEqual(workflowName, theSavedTrigger.WorkflowName);

            Assert.AreEqual(triggerId, theSavedTrigger.TriggerId);

            mockFile.Setup(o => o.Exists(path)).Returns(() => savedData != string.Empty);
            triggerCatalog.DeleteTriggerQueue(triggerQueueEvent);

            mockFile.Verify(o => o.Delete(path), Times.Once);

            Assert.AreEqual(0, triggerCatalog.Queues.Count);
        }
Exemplo n.º 25
0
        public string ResumeJob(IDSFDataObject dsfDataObject, string jobId, bool overrideVariables, string environment)
        {
            try
            {
                var monitoringApi = _jobStorage.GetMonitoringApi();
                var jobDetails    = monitoringApi.JobDetails(jobId);
                var currentState  = jobDetails.History.OrderBy(s => s.CreatedAt).LastOrDefault();

                if (currentState?.StateName != "Scheduled" && currentState?.StateName != "Failed")
                {
                    return(GlobalConstants.Failed);
                }

                var values = jobDetails.Job.Args[0] as Dictionary <string, StringBuilder>;
                values.TryGetValue("environment", out StringBuilder persistedEnvironment);
                var decryptEnvironment = persistedEnvironment.ToString().CanBeDecrypted() ? DpapiWrapper.Decrypt(persistedEnvironment.ToString()) : persistedEnvironment.ToString();
                if (overrideVariables)
                {
                    if (values.ContainsKey("environment"))
                    {
                        values["environment"] = new StringBuilder(environment);
                    }
                }
                else
                {
                    values["environment"] = new StringBuilder(decryptEnvironment);
                }
                values.TryGetValue("currentuserprincipal", out StringBuilder currentUserPrincipal);
                var decryptCurrentUserPrincipal = currentUserPrincipal.ToString().CanBeDecrypted() ? DpapiWrapper.Decrypt(currentUserPrincipal.ToString()) : currentUserPrincipal.ToString();
                if (values.ContainsKey("environment"))
                {
                    values["currentuserprincipal"] = new StringBuilder(decryptCurrentUserPrincipal);
                }
                var workflowResume = new WorkflowResume();
                var result         = workflowResume.Execute(values, null);
                var serializer     = new Dev2JsonSerializer();
                var executeMessage = serializer.Deserialize <ExecuteMessage>(result);
                if (executeMessage.HasError)
                {
                    var failedState = new FailedState(new Exception(executeMessage.Message?.ToString()));
                    _client.ChangeState(jobId, failedState, ScheduledState.StateName);
                    return(GlobalConstants.Failed);
                }

                values.TryGetValue("resourceID", out StringBuilder workflowId);
                values.TryGetValue("environment", out StringBuilder environments);
                values.TryGetValue("startActivityId", out StringBuilder startActivityId);
                values.TryGetValue("versionNumber", out StringBuilder versionNumber);
                values.TryGetValue("currentprincipal", out StringBuilder currentprincipal);

                _stateNotifier = dsfDataObject.StateNotifier;
                var audit = new Audit
                {
                    WorkflowID     = workflowId?.ToString(),
                    Environment    = environments?.ToString(),
                    VersionNumber  = versionNumber?.ToString(),
                    NextActivityId = startActivityId?.ToString(),
                    AuditDate      = DateTime.Now,
                    AuditType      = "LogResumeExecutionState",
                    LogLevel       = LogLevel.Info,
                    User           = currentprincipal?.ToString()
                };

                _stateNotifier?.LogAdditionalDetail(audit, nameof(ResumeJob));
                var manuallyResumedState = new ManuallyResumedState(environments?.ToString());

                _client.ChangeState(jobId, manuallyResumedState, currentState?.StateName);
                return(GlobalConstants.Success);
            }
            catch (Exception ex)
            {
                _stateNotifier?.LogExecuteException(ex, this);
                Dev2Logger.Error(nameof(ResumeJob), ex, GlobalConstants.WarewolfError);
                throw new Exception(ex.Message);
            }
        }