Exemplo n.º 1
0
        public IDataSource CreateLocalDataSourceConnection(ConnectionProperties dataConnection, string pdatasourcename, string ClassDBHandlerName)
        {
            ErrorObject.Flag = Errors.Ok;
            IDataSource             ds      = null;
            ConnectionDriversConfig package = null;

            if (ConfigEditor.DataDriversClasses.Where(x => x.classHandler == ClassDBHandlerName).Any())
            {
                package = ConfigEditor.DataDriversClasses.Where(x => x.classHandler == ClassDBHandlerName).FirstOrDefault();
                string packagename = ConfigEditor.DataSourcesClasses.Where(x => x.className == package.classHandler).FirstOrDefault().PackageName;

                Type            adc  = assemblyHandler.GetType(packagename);
                ConstructorInfo ctor = adc.GetConstructors().First();
                ObjectActivator <IDataSource> createdActivator = GetActivator <IDataSource>(ctor);

                //create an instance:
                ds = createdActivator(dataConnection.ConnectionName, Logger, this, dataConnection.DatabaseType, ErrorObject);
            }


            try
            {
                if (ds != null)
                {
                    ds.Dataconnection.ConnectionProp   = dataConnection;
                    ds.Dataconnection.DataSourceDriver = package;
                    ds.Dataconnection.ReplaceValueFromConnectionString();
                    ILocalDB dB = (ILocalDB)ds;
                    DataSources.Add(ds);

                    AddLogMessage("Fail", $"Success Created Local Database  {pdatasourcename}", DateTime.Now, -1, "", Errors.Failed);
                    return(ds);
                }
                else
                {
                    AddLogMessage("Fail", "Could Find DataSource Drivers", DateTime.Now, 0, pdatasourcename, Errors.Failed);
                    return(null);
                }

                //     bool ok= dB.CreateDB();
                //      if (ok)
                //      {
                //  ds.ConnectionStatus = ds.Dataconnection.OpenConnection();
                //if (ds.ConnectionStatus == ConnectionState.Open)
                //{
                // ConfigEditor.DataConnections.Add(dataConnection);


                //}else
                //{
                //    return null;
                //}
            }
            catch (Exception ex)
            {
                AddLogMessage("Fail", $"Error in Opening Connection (Check DLL for Connection drivers,connect string, Datasource down,Firewall, .. etc)({ex.Message})", DateTime.Now, -1, "", Errors.Failed);
                return(null);
            }
        }
        private void CreateDBbutton_Click(object sender, EventArgs e)
        {
            try

            {
                if (!DMEEditor.ConfigEditor.DataConnectionExist(databaseTextBox.Text))
                {
                    ConnectionProperties cn = CreateConn();
                    IDataSource          ds = DMEEditor.CreateLocalDataSourceConnection(cn, databaseTextBox.Text, EmbeddedDatabaseTypecomboBox.Text);

                    if (ds != null)
                    {
                        ILocalDB dB = (ILocalDB)ds;
                        bool     ok = dB.CreateDB();
                        if (ok)
                        {
                            //ds.ConnectionStatus = ds.Dataconnection.OpenConnection();
                            DMEEditor.OpenDataSource(cn.ConnectionName);
                        }
                        DMEEditor.ConfigEditor.AddDataConnection(cn);
                        DMEEditor.ConfigEditor.SaveDataconnectionsValues();
                        if (Passedarg.ObjectType == "COMPOSITEDB")
                        {
                        }
                        branch.CreateChildNodes();
                        MessageBox.Show("Local/Embedded Database Created successfully", "Beep");
                    }
                    else
                    {
                        MessageBox.Show("Coudl not Create Local/Embedded Database ", "Beep");
                    }
                }
                else
                {
                    MessageBox.Show("Database Already Exist by this name please try another name ", "Beep");
                }
            }
            catch (Exception ex)
            {
                ErrorObject.Flag = Errors.Failed;
                string errmsg = "Error creating Database";
                MessageBox.Show(errmsg, "Beep");
                ErrorObject.Message = $"{errmsg}:{ex.Message}";
                Logger.WriteLog($" {errmsg} :{ex.Message}");
            }
        }
Exemplo n.º 3
0
 public UserRepo(LocalDB localDB)
 {
     _localDb = localDB;
 }
Exemplo n.º 4
0
 public MovieREpo(ILocalDB db)
 {
     _db = db;
 }
Exemplo n.º 5
0
 public OrderRepo(LocalDB localDb)
 {
     _localDb = localDb;
 }
Exemplo n.º 6
0
        private void Createbutton_Click(object sender, EventArgs e)
        {
            try

            {
                if (string.IsNullOrEmpty(this.layerNameTextBox.Text) || string.IsNullOrEmpty(this.localDBDriverVersionComboBox.Text) || string.IsNullOrEmpty(this.layerNameTextBox.Text))
                {
                    MessageBox.Show("Error, Please Fill all missing Fields");
                    throw new InvalidOperationException("Error, Please Fill all missing Fields");
                }
                if (DMEEditor.ConfigEditor.DataConnectionExist(layerNameTextBox.Text))
                {
                    MessageBox.Show("Error, Already there is a Data connection the Same name");
                    throw new InvalidOperationException("Error, Already there is a Data connection the Same name");
                }

                ConnectionProperties    cn      = new ConnectionProperties();
                ConnectionDriversConfig package = DMEEditor.ConfigEditor.DataDriversClasses.Where(x => x.classHandler == localDBDriverComboBox.Text).OrderByDescending(o => o.version).FirstOrDefault();
                Layer                 = (CompositeLayer)compositeQueryLayersBindingSource.Current;
                cn.CompositeLayer     = true;
                cn.ConnectionName     = layerNameTextBox.Text;
                cn.CompositeLayerName = layerNameTextBox.Text;
                cn.ConnectionName     = layerNameTextBox.Text;
                cn.DatabaseType       = package.DatasourceType;
                cn.Category           = package.DatasourceCategory;
                if (!string.IsNullOrEmpty(FileNametextBox.Text) || !string.IsNullOrEmpty(FolderSavelocationlabel.Text))
                {
                    cn.FilePath = FolderSavelocationlabel.Text;
                    cn.FileName = FileNametextBox.Text;
                }
                else
                {
                    cn.FilePath = DMEEditor.ConfigEditor.Config.Folders.Where(x => x.FolderFilesType == FolderFileTypes.DataFiles).FirstOrDefault().FolderPath;
                    cn.FileName = layerNameTextBox.Text;
                }
                if (cn.FilePath.Contains(DMEEditor.ConfigEditor.ExePath))
                {
                    cn.FilePath.Replace(DMEEditor.ConfigEditor.ExePath, ".");
                }
                cn.DriverName                = package.PackageName;
                cn.DriverVersion             = package.version;
                cn.ID                        = DMEEditor.ConfigEditor.DataConnections.Max(p => p.ID) + 1;
                cn.Category                  = DatasourceCategory.RDBMS;
                Layer.DataSourceName         = this.layerNameTextBox.Text;
                Layer.DataViewDataSourceName = this.dataViewDataSourceNameComboBox.Text;
                Layer.Entities               = new List <EntityStructure>();
                compositeQueryLayersBindingSource.EndEdit();
                DMEEditor.ConfigEditor.RemoveDataSourceEntitiesValues(Layer.DataSourceName);
                ILocalDB db = (ILocalDB)DMEEditor.CreateLocalDataSourceConnection(cn, cn.ConnectionName, package.classHandler);
                db.CreateDB();

                DMEEditor.ConfigEditor.AddDataConnection(cn);
                DMEEditor.ConfigEditor.SaveDataconnectionsValues();
                //  DMEEditor.ConfigEditor.SaveCompositeLayersValues();
                //--------------------
                try
                {
                    //  waitForm = new WaitFormFunc();
                    //  waitForm.Show(this.ParentForm);
                    CompositeLayerDataSource compositeLayerDataSource = new CompositeLayerDataSource(cn.ConnectionName, DMEEditor.Logger, DMEEditor, cn.DatabaseType, DMEEditor.ErrorObject);
                    ConnectionDriversConfig  driversConfig            = DMEEditor.Utilfunction.LinkConnection2Drivers(cn);
                    compositeLayerDataSource.Dataconnection.ConnectionProp   = cn;
                    compositeLayerDataSource.Dataconnection.DataSourceDriver = driversConfig;
                    compositeLayerDataSource.LocalDB = db;
                    // compositeLayerDataSource.Dataconnection.OpenConnection();
                    DMEEditor.OpenDataSource(cn.ConnectionName);
                    compositeLayerDataSource.Openconnection();
                    //   Visutil.treeEditor.ShowWaiting();
                    //   Visutil.treeEditor.ChangeWaitingCaption($"Getting  Composed Layer Entities Total:{compositeLayerDataSource.Entities.Count}");
                    compositeLayerDataSource.GetAllEntitiesFromDataView();
                    //    Visutil.treeEditor.HideWaiting();
                    DMEEditor.ConfigEditor.SaveCompositeLayersValues();
                    RootCompositeLayerBranch.CreateChildNodes();
                    //   waitForm.Close();
                }
                catch (Exception ex1)
                {
                    string errmsg = $"Error Creating Composite Layer for view";
                    //   waitForm.Close();
                    DMEEditor.AddLogMessage("Fail", $"{errmsg}:{ex1.Message}", DateTime.Now, 0, null, Errors.Failed);
                }

                MessageBox.Show($"Creating Composite Layer for view {branch.BranchText}");
                DMEEditor.AddLogMessage("Success", $"Creating Composite Layer for view {branch.BranchText}", DateTime.Now, 0, null, Errors.Ok);
                this.ParentForm.Close();
            }
            catch (Exception ex)
            {
                string errmsg = $"Error Creating Composite Layer for view {branch.BranchText}";

                DMEEditor.AddLogMessage("Fail", $"{errmsg}:{ex.Message}", DateTime.Now, 0, null, Errors.Failed);
                MessageBox.Show(errmsg);
            }
        }
Exemplo n.º 7
0
 public VehiclesRepo(ILocalDB localDb)
 {
     _localDb = localDb;
 }
Exemplo n.º 8
0
 public UserRepo(LocalDB localDb)
 {
     _db = localDb;
 }