Ejemplo n.º 1
0
        public void EditSource(IDbSource selectedSource, enSourceType type)
        {
            switch (type)
            {
            case enSourceType.SqlDatabase:
                _shell.EditSqlServerResource(selectedSource);
                break;

            case enSourceType.MySqlDatabase:
                _shell.EditMySqlResource(selectedSource);
                break;

            case enSourceType.PostgreSQL:
                _shell.EditPostgreSqlResource(selectedSource);
                break;

            case enSourceType.Oracle:
                _shell.EditOracleResource(selectedSource);
                break;

            case enSourceType.ODBC:
                _shell.EditOdbcResource(selectedSource);
                break;

            default:
                throw new ArgumentException("Unrecognized Source Type: " + type.ToString());
            }
        }
        public void EditSource(IDbSource selectedSource, enSourceType type)
        {
            switch (type)
            {
            case enSourceType.SqlDatabase:
                _shell.EditSqlServerResource(selectedSource);
                break;

            case enSourceType.MySqlDatabase:
                _shell.EditMySqlResource(selectedSource);
                break;

            case enSourceType.PostgreSQL:
                _shell.EditPostgreSqlResource(selectedSource);
                break;

            case enSourceType.Oracle:
                _shell.EditOracleResource(selectedSource);
                break;

            case enSourceType.ODBC:
                _shell.EditOdbcResource(selectedSource);
                break;
            }
        }
Ejemplo n.º 3
0
        public void SetDbSource(string activityName, IDbSource dbSource)
        {
            var activities = _commonSteps.GetActivityList();

            if (activityName.Contains("MySql"))
            {
                var activity = activities[activityName] as DsfMySqlDatabaseActivity;
                activity.SourceId = dbSource.Id;
            }
            if (activityName.Contains("SqlServer"))
            {
                var activity = activities[activityName] as DsfSqlServerDatabaseActivity;
                activity.SourceId = dbSource.Id;
            }
            if (activityName.Contains("Oracle"))
            {
                var activity = activities[activityName] as DsfOracleDatabaseActivity;
                activity.SourceId = dbSource.Id;
            }
            if (activityName.Contains("Postgre"))
            {
                var activity = activities[activityName] as DsfPostgreSqlActivity;
                activity.SourceId = dbSource.Id;
            }
        }
Ejemplo n.º 4
0
 public void Write(DataBase <T> pDataBase, IDbSource pTarget)
 {
     lock (_syncLock)
     {
         var stream = pTarget.GetStream();
         _serializer.Write(pDataBase, stream);
         StreamUtils.CloseStream(stream);
     }
 }
Ejemplo n.º 5
0
        public void DbSourceDefinition_Equals_DbSource_Null_Expected_False()
        {
            var dbSourceDefinition = new DbSourceDefinition();

            const IDbSource dbSource = null;

            var isEqual = dbSourceDefinition.Equals(dbSource);

            Assert.IsFalse(isEqual);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="pSource"></param>
        /// <returns></returns>
        /// <exception cref="InvalidSourceException"></exception>
        internal static DataBase <Transaction> GetTransactionDataBase(IDbSource pSource)
        {
            if (pSource == null)
            {
                throw new InvalidSourceException("No such source");
            }

            var helper = new DbHelper <Transaction>();

            return(helper.Read(pSource));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// </summary>
        /// <param name="pSource"></param>
        /// <returns></returns>
        /// <exception cref="InvalidSourceException"></exception>
        internal static DataBase <Models.User.User> GetUserDataBase(IDbSource pSource)
        {
            if (pSource == null)
            {
                throw new InvalidSourceException("No such source");
            }

            var helper = new DbHelper <Models.User.User>();

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

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

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

                IDbSource src = serializer.Deserialize <DbSourceDefinition>(resourceDefinition);
                if (src.Path.EndsWith("\\"))
                {
                    src.Path = src.Path.Substring(0, src.Path.LastIndexOf("\\", StringComparison.Ordinal));
                }
                var res = new DbSource
                {
                    AuthenticationType = src.AuthenticationType,
                    Server             = src.ServerName,
                    Password           = src.Password,
                    ServerType         = src.Type,
                    UserID             = src.UserName,
                    ResourceID         = src.Id,
                    DatabaseName       = src.DbName,
                    ResourceName       = src.Name,
                    ResourceType       = src.Type.ToString()
                };
                var con    = new DbSources();
                var result = con.DoDatabaseValidation(res);

                if (result.IsValid)
                {
                    ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, res, src.Path);
                    ServerExplorerRepo.UpdateItem(res);

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

            return(serializer.SerializeToBuilder(msg));
        }
 public override void FromModel(IDbSource service)
 {
     ResourceName = service.Name;
     ServerName   = ComputerNames.FirstOrDefault(name => string.Equals(service.ServerName, name.Name, StringComparison.CurrentCultureIgnoreCase));
     if (ServerName != null)
     {
         EmptyServerName = ServerName.Name ?? service.ServerName;
     }
     AuthenticationType = service.AuthenticationType;
     Path = service.Path;
     TestConnection();
     DatabaseName = service.DbName;
 }
Ejemplo n.º 10
0
        public void SaveDbSource(IDbSource toDbSource, Guid serverWorkspaceID)
        {
            var con            = Connection;
            var comsController = CommunicationControllerFactory.CreateController("SaveDbSourceService");
            var serialiser     = new Dev2JsonSerializer();

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

            if (output.HasError)
            {
                throw new WarewolfSaveException(output.Message.ToString(), null);
            }
        }
Ejemplo n.º 11
0
        public DataBase <T> Read(IDbSource pSource)
        {
            DataBase <T> dataBase;

            lock (_syncLock)
            {
                var stream = pSource.GetStream();
                dataBase = _serializer.Read(stream);
                StreamUtils.CloseStream(stream);

                dataBase.DbSource = pSource;
            }

            return(dataBase);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Tests if a valid connection to a server can be made returns 'Success' on a successful connection
        /// </summary>
        /// <param name="resource"></param>
        /// <returns></returns>
        /// <exception cref="WarewolfTestException">Unable to contact Server</exception>
        public IList <string> TestDbConnection(IDbSource resource)
        {
            var con                       = Connection;
            var comsController            = CommunicationControllerFactory.CreateController("TestDbSourceService");
            Dev2JsonSerializer serialiser = new Dev2JsonSerializer();

            comsController.AddPayloadArgument("DbSource", serialiser.SerializeToBuilder(resource));
            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(serialiser.Deserialize <List <string> >(output.Message));
        }
Ejemplo n.º 13
0
 void SetupActions(IDbSource selectedSource)
 {
     if (selectedSource != null)
     {
         _someAction = new DbAction
         {
             Name   = "someAction",
             Inputs = new List <IServiceInput> {
                 new ServiceInput("SomeInput", "")
             }
         };
         var serviceModel = GetServiceModel();
         serviceModel.Setup(model => model.GetActions(It.IsAny <IDbSource>())).Returns(new List <IDbAction> {
             _someAction
         });
     }
     if (GetViewModel().ActionRegion.SelectedAction == null)
     {
         GetViewModel().ActionRegion.SelectedAction = _someAction;
     }
 }
Ejemplo n.º 14
0
        public bool Equals(IDbSource other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            var equals = true;

            equals &= string.Equals(ServerName, other.ServerName);
            equals &= Type == other.Type;
            equals &= string.Equals(UserName, other.UserName);
            equals &= string.Equals(Password, other.Password);
            equals &= AuthenticationType == other.AuthenticationType;
            equals &= Id == other.Id;
            equals &= string.Equals(DbName, other.DbName);
            equals &= ConnectionTimeout == other.ConnectionTimeout;
            return(equals);
        }
Ejemplo n.º 15
0
        public IList <IDbAction> FetchDbActions(IDbSource source)
        {
            var serializer     = new Dev2JsonSerializer();
            var comsController = CommunicationControllerFactory.CreateController(nameof(FetchDbActions));

            comsController.AddPayloadArgument(nameof(source), serializer.SerializeToBuilder(source));
            var workspaceId = Connection.WorkspaceID;
            var payload     = comsController.ExecuteCommand <ExecuteMessage>(Connection, workspaceId);

            if (payload == null || payload.HasError)
            {
                if (!Connection.IsConnected)
                {
                    ShowServerDisconnectedPopup();
                    return(new List <IDbAction>());
                }
                if (payload != null)
                {
                    throw new WarewolfSupportServiceException(payload.Message.ToString(), null);
                }
                throw new WarewolfSupportServiceException(ErrorResource.ServiceDoesNotExist, null);
            }
            return(serializer.Deserialize <IList <IDbAction> >(payload.Message));
        }
Ejemplo n.º 16
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));
        }
 public void Save(IDbSource toDbSource) => UpdateManagerProxy.SaveDbSource(toDbSource, GlobalConstants.ServerWorkspaceID);
 public IList <string> TestDbConnection(IDbSource serverSource) => UpdateManagerProxy.TestDbConnection(serverSource);
Ejemplo n.º 19
0
 public void EditSource(IDbSource selectedSource, enSourceType type)
 {
 }
 private void CreateDbActionRegion()
 {
     _selectedSource        = _source.Sources.Single(a => a.Id == _sqlActivity.SourceId);
     _source.SelectedSource = _selectedSource;
     _dbActionRegion        = new DbActionRegion(_dbServiceModel, _modelItem, _source, new SynchronousAsyncWorker());
 }
Ejemplo n.º 21
0
 public ICollection <IDbAction> RefreshActions(IDbSource source)
 {
     return(RefreshActionsList);
 }
Ejemplo n.º 22
0
 public void Save(IDbSource toDbSource)
 {
     _updateRepository.Save(toDbSource);
 }
Ejemplo n.º 23
0
 public ManageMySqlSourceViewModel(IManageDatabaseSourceModel updateManager, IEventAggregator aggregator, IDbSource dbSource, IAsyncWorker asyncWorker)
     : base(updateManager, aggregator, dbSource, asyncWorker, "MySqlDatabase")
 {
     VerifyArgument.IsNotNull("mySqlSource", dbSource);
 }
Ejemplo n.º 24
0
 public ICollection <IDbAction> GetActions(IDbSource source) => _queryProxy.FetchDbActions(source);
 public ICollection <IDbAction> GetActions(IDbSource source)
 {
     return(_queryProxy.FetchDbActions(source));
 }
Ejemplo n.º 26
0
 public ICollection <IDbAction> GetActions(IDbSource source)
 {
     return(Actions);
 }
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public bool Equals(IDbSource other)
 {
     return(Equals(other as DbSourceDefinition));
 }
 public IList <string> TestDbConnection(IDbSource resource) => _updateRepository.TestDbConnection(resource);
 public ManageOracleSourceViewModel(IManageDatabaseSourceModel updateManager, IEventAggregator aggregator, IDbSource dbSource, IAsyncWorker asyncWorker)
     : base(updateManager, aggregator, dbSource, asyncWorker, "Oracle")
 {
     VerifyArgument.IsNotNull("oracleSource", dbSource);
     InitializeViewModel();
 }
Ejemplo n.º 30
0
 public IList <string> TestDbConnection(IDbSource resource)
 {
     return(_updateRepository.TestDbConnection(resource));
 }