Beispiel #1
0
        //private void BlockColumnsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    var senderGrid = (DataGridView)sender;

        //    if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
        //        e.RowIndex >= 0)
        //    {
        //        //if ((object)column == (object)color)
        //        //{
        //        //    colorDialog.Color = Color.Blue;
        //        //    colorDialog.ShowDialog();
        //        //}
        //    }

        //}

        //private void BlockColumnsDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    // Ignore clicks that are not in our
        //    if (e.ColumnIndex == blockColumnsDataGridView.Columns["MyButtonColumn"].Index && e.RowIndex >= 0)
        //    {
        //        Console.WriteLine("Button on row {0} clicked", e.RowIndex);
        //    }
        //}

        private void BlocksBindingSource_CurrentChanged(object sender, EventArgs e)
        {
            ReportBlock x = (ReportBlock)blocksBindingSource.Current;

            if (x.BlockColumns.Count() == 0)
            {
                if (!string.IsNullOrEmpty(this.viewIDComboBox.Text))
                {
                    ds = (DataViewDataSource)DMEEditor.GetDataSource(this.viewIDComboBox.Text);
                    EntityStructure           ent = ds.GetEntityStructure(this.entityIDComboBox.Text, true);
                    List <ReportBlockColumns> ls  = new List <ReportBlockColumns>();
                    if (ent != null)
                    {
                        int i = 0;
                        foreach (EntityField item in ent.Fields)
                        {
                            ReportBlockColumns c = new ReportBlockColumns();
                            c.ColumnName  = item.fieldname;
                            c.ColumnSeq   = i;
                            c.DisplayName = item.fieldname;
                            c.Show        = true;
                            i            += 1;

                            ls.Add(c);
                        }
                        x.BlockColumns = ls;
                    }
                }
            }
        }
        private void Entity2DataSourceComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            if (entity2DataSourceComboBox.SelectedItem == null)
            {
            }
            else
            {
                ds2 = DMEEditor.GetDataSource(entity2DataSourceComboBox.SelectedItem.ToString());
                if (ds2 != null)
                {
                    ds2.GetEntitesList();

                    entityName2ComboBox.Items.Clear();

                    foreach (string s in ds2.EntitiesNames)
                    {
                        entityName2ComboBox.Items.Add(s);
                    }
                }
                else
                {
                    MessageBox.Show($"Error Could not Open Datasource {entity2DataSourceComboBox.SelectedValue.ToString()} : {DMEEditor.ErrorObject.Message}");
                }
            }
        }
Beispiel #3
0
        public IMapping_rep CreateMapping(IMapping_rep x)
        {
            DMEEditor.ErrorObject.Flag = Errors.Ok;
            try
            {
                IDataSource ds1 = DMEEditor.GetDataSource(x.Entity1DataSource);
                IDataSource ds2 = DMEEditor.GetDataSource(x.Entity2DataSource);
                if (ds1 == null || ds2 == null)
                {
                    DMEEditor.ErrorObject.Flag    = Errors.Failed;
                    DMEEditor.ErrorObject.Message = "one of the Datasources Dont Exist";
                    DMEEditor.Logger.WriteLog($"one of the Datasources Dont Exist");
                }
                else
                {
                    EntityStructure dt1 = ds1.GetEntityStructure(x.EntityName1, false);
                    EntityStructure dt2 = ds2.GetEntityStructure(x.EntityName2, false);
                    x.Entity1Fields = dt1.Fields;

                    x.Entity2Fields = dt2.Fields;
                    DMEEditor.Logger.WriteLog($"Successful in Creating Mapping");
                }
            }
            catch (System.Exception ex)
            {
                DMEEditor.ErrorObject.Flag = Errors.Failed;
                DMEEditor.ErrorObject.Ex   = ex;
                x = null;
                DMEEditor.Logger.WriteLog($"Error in Creating Mapping({ex.Message})");
            }

            return(x);
        }
        private void ListBox1_DragDrop(object sender, DragEventArgs e)
        {
            string dsnamewithentiy = (string)e.Data.GetData(DataFormats.Text);

            //  ITreeBranch br = (ITreeBranch)e.Data.GetData(typeof(ITreeBranch));

            if (dsnamewithentiy != null)
            {
                string[] splitstring = dsnamewithentiy.Split(',');
                string   dsname      = splitstring[0];
                string   entityname  = splitstring[1];
                // entityname = br.BranchText;
                // dsname = br.ParentNode.Text;

                mappingsBindingSource.AddNew();


                this.mappingNameTextBox.Text           = dsname + "_" + entityname + "_";
                entity1DataSourceComboBox.SelectedText = dsname;
                entityName1ComboBox.SelectedText       = entityname;

                ds1 = DMEEditor.GetDataSource(dsname);
                if (ds1 != null)
                {
                    ds1.GetEntitesList();
                    entityName1ComboBox.Items.Clear();
                    foreach (string s in ds1.EntitiesNames)
                    {
                        entityName1ComboBox.Items.Add(s);
                    }
                }
            }
        }
Beispiel #5
0
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ds = (IDataSource)DMEEditor.DataSources.Where(f => f.DatasourceName == dataSourceIDComboBox.Items[dataSourceIDComboBox.SelectedIndex].ToString()).FirstOrDefault();
            ConnectionProperties cn = DMEEditor.ConfigEditor.DataConnections.Where(f => f.ConnectionName == dataSourceIDComboBox.Items[dataSourceIDComboBox.SelectedIndex].ToString()).FirstOrDefault();

            if (ds == null)
            {
                ds = DMEEditor.GetDataSource(dataSourceIDComboBox.Items[dataSourceIDComboBox.SelectedIndex].ToString());
                try
                {
                    if (ds != null)
                    {
                        // ds.ConnectionStatus = SourceConnection.Dataconnection.OpenConnection();
                        DMEEditor.OpenDataSource(dataSourceIDComboBox.Items[dataSourceIDComboBox.SelectedIndex].ToString());
                        if (ErrorObject.Flag == Errors.Ok)
                        {
                            DMEEditor.DataSources.Add(SourceConnection);
                        }
                        else
                        {
                            MessageBox.Show($"Error in  opening the Database ,{ErrorObject.Message}");
                            Logger.WriteLog($"Error in  opening the Database ,{ErrorObject.Message}");
                        }
                    }
                }
                catch (Exception e1)
                {
                    // Logger.WriteLog($"Error in  opening the Database ,{e1.Message}");
                    MessageBox.Show($"Error in  opening the Database ,{e1.Message}");
                }
            }
        }
        private void CreateDataSources()
        {
            Mapping_rep x = (Mapping_rep)mappingsBindingSource.Current;

            ds1 = DMEEditor.GetDataSource(x.Entity1DataSource);

            ds2 = DMEEditor.GetDataSource(x.Entity2DataSource);
        }
Beispiel #7
0
        private IDMDataView AddViewFile()
        {
            IDMDataView DataView = null;

            try
            {
                string         viewname        = null;
                string         fullname        = null;
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.InitialDirectory = DMEEditor.ConfigEditor.Config.Folders.Where(i => i.FolderFilesType == FolderFileTypes.DataView).FirstOrDefault().FolderPath;
                openFileDialog1.Filter           = "json files (*.json)|*.txt|All files (*.*)|*.*";

                openFileDialog1.DefaultExt       = "json";
                openFileDialog1.FilterIndex      = 2;
                openFileDialog1.RestoreDirectory = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    viewname = Path.GetFileName(openFileDialog1.FileName);
                    if ((viewname != null) && DMEEditor.ConfigEditor.DataConnectionExist(viewname + ".json") == false)
                    {
                        fullname = openFileDialog1.FileName;  //Path.Combine(Path.GetDirectoryName(openFileDialog1.FileName), Path.GetFileName(openFileDialog1.FileName));
                        ConnectionProperties f = new ConnectionProperties
                        {
                            FileName       = Path.GetFileName(fullname),
                            FilePath       = Path.GetDirectoryName(fullname),
                            Ext            = Path.GetExtension(fullname),
                            ConnectionName = Path.GetFileName(fullname)
                        };

                        f.Category      = DatasourceCategory.VIEWS;
                        f.DriverVersion = "1";
                        f.DriverName    = "DataViewReader";

                        DMEEditor.ConfigEditor.DataConnections.Add(f);
                        DMEEditor.ConfigEditor.SaveDataconnectionsValues();

                        DataViewDataSource ds = (DataViewDataSource)DMEEditor.GetDataSource(f.ConnectionName);

                        DataView = ds.DataView;
                    }
                    DMEEditor.AddLogMessage("Success", "Added View", DateTime.Now, 0, null, Errors.Ok);
                }
                else
                {
                    Visutil.controlEditor.MsgBox("DM Engine", "Please Try another name . DataSource Exist");
                }
            }
            catch (Exception ex)
            {
                string mes = "Could not Added View ";
                DMEEditor.AddLogMessage(ex.Message, mes, DateTime.Now, -1, mes, Errors.Failed);
            };
            return(DataView);
        }
Beispiel #8
0
 private IErrorsInfo RunCopyData()
 {
     try
     {
         //----------- Chceck if both Source and Target Exist -----
         if (InParameters.Count > 0)
         {
             if (OutParameters.Count > 0)
             {
                 Inds = DMEEditor.GetDataSource(InParameters[0].DatasourceName);
                 if (Inds == null)
                 {
                     DMEEditor.AddLogMessage("Error", " No DataSource exists ", DateTime.Now, -1, "", Errors.Failed);
                 }
                 else
                 {
                     if (DMEEditor.ErrorObject.Flag == Errors.Ok) //  --- Successful in Getting Data
                     {
                         Outds = DMEEditor.GetDataSource(OutParameters[0].DatasourceName);
                         if (Outds == null)
                         {
                             DMEEditor.AddLogMessage("Error", "Getting Data From Source  ", DateTime.Now, -1, "", Errors.Failed);
                         }
                         else //---- Everything Checks OK we can Procceed with Data Loading
                         {
                             try
                             {
                                 RunCopyDataBackWorker();
                                 DMEEditor.AddLogMessage("Success", $"Copied Data to {OutParameters[0].DatasourceName}", DateTime.Now, -1, "", Errors.Ok);
                             }
                             catch (Exception ex)
                             {
                                 DMEEditor.AddLogMessage("Error", "Getting Destination Table  " + ex.Message, DateTime.Now, -1, "", Errors.Failed);
                             }
                         }
                     }
                 }
             }
             else
             {
                 DMEEditor.AddLogMessage("Error", " No Target Table Data exist ", DateTime.Now, -1, "", Errors.Failed);
             }
         }
         else
         {
             DMEEditor.AddLogMessage("Error", " No Source Table Data exist", DateTime.Now, -1, "", Errors.Failed);
         }
     }
     catch (Exception ex)
     {
         DMEEditor.AddLogMessage("Error", "Loading Data" + ex.Message, DateTime.Now, -1, "", Errors.Failed);
     }
     return(ErrorObject);
 }
Beispiel #9
0
        public IErrorsInfo PerformAction()
        {
            try
            {
                //----------- Chceck if both Source and Target Exist -----
                if (InParameters.Count > 0)
                {
                    if (OutParameters.Count > 0)
                    {
                        Inds = DMEEditor.GetDataSource(InParameters[0].DatasourceName);
                        if (Inds == null)
                        {
                            DMEEditor.AddLogMessage("Fail", $"Error In DataSource does not exists   {InParameters[0].DatasourceName}", DateTime.Now, -1, "", Errors.Failed);
                        }
                        else
                        {
                            Outds = DMEEditor.GetDataSource(OutParameters[0].DatasourceName);
                            if (Outds == null)
                            {
                                DMEEditor.AddLogMessage("Fail", $"Error Out DataSource does not exists   {OutParameters[0].DatasourceName}", DateTime.Now, -1, "", Errors.Failed);
                            }
                            else //---- Everything Checks OK we can Procceed with Copy
                            {
                                string SourceEntityName = InParameters[0].CurrentEntity;
                                if (Outds.CheckEntityExist(SourceEntityName) == false)
                                {
                                    Outds.CreateEntityAs(Inds.GetEntityStructure(SourceEntityName, false));
                                    //   DMEEditor.viewEditor.AddTableToDataView
                                }
                                else
                                {
                                    DMEEditor.AddLogMessage("Fail", $"Entity already Exist at Destination   {SourceEntityName}. in {InParameters[0].DatasourceName}", DateTime.Now, -1, "", Errors.Failed);
                                }
                            }
                        }
                    }
                    else
                    {
                        DMEEditor.AddLogMessage("Fail", $"Error No Target Table Data exist   {OutParameters[0].DatasourceName}", DateTime.Now, -1, "", Errors.Failed);
                    }
                }
                else
                {
                    DMEEditor.AddLogMessage("Fail", $"Error No Source Table Data exist {InParameters[0].CurrentEntity}. in  {InParameters[0].DatasourceName} ", DateTime.Now, -1, "", Errors.Failed);
                }
            }
            catch (Exception ex)
            {
                DMEEditor.AddLogMessage("Fail", $"Error in  Copy {InParameters[0].CurrentEntity}. from   {InParameters[0].DatasourceName} to  {OutParameters[0].DatasourceName}({ex.Message})", DateTime.Now, -1, "", Errors.Failed);
            }

            return(ErrorObject);
        }
Beispiel #10
0
        private IDMDataView CreateViewUsingTable(EntityStructure EntitySource)
        {
            IDMDataView DataView         = null;
            IDataSource DataSource       = null;
            IDataSource EntityDataSource = null;

            try
            {
                string viewname = null;
                string fullname = null;
                if (Visutil.controlEditor.InputBox("Create View", "Please Enter Name of View (Name Should not exist already in Views)", ref viewname) == System.Windows.Forms.DialogResult.OK)
                {
                    if ((viewname != null) && DMEEditor.ConfigEditor.DataConnectionExist(viewname + ".json") == false)
                    {
                        fullname = Path.Combine(DMEEditor.ConfigEditor.Config.Folders.Where(x => x.FolderFilesType == FolderFileTypes.DataView).FirstOrDefault().FolderPath, viewname + ".json");
                        ConnectionProperties f = new ConnectionProperties
                        {
                            FileName       = Path.GetFileName(fullname),
                            FilePath       = Path.GetDirectoryName(fullname),
                            Ext            = Path.GetExtension(fullname),
                            ConnectionName = Path.GetFileName(fullname)
                        };

                        f.Category      = DatasourceCategory.VIEWS;
                        f.DriverVersion = "1";
                        f.DriverName    = "DataViewReader";

                        DMEEditor.ConfigEditor.DataConnections.Add(f);
                        DataViewDataSource ds = (DataViewDataSource)DMEEditor.GetDataSource(f.ConnectionName);
                        EntityDataSource = DMEEditor.GetDataSource(EntitySource.DataSourceID);
                        if (EntitySource != null)
                        {
                            int x = ds.AddEntitytoDataView(EntityDataSource, EntitySource.EntityName, EntityDataSource.Dataconnection.ConnectionProp.SchemaName, null);
                        }
                        ds.WriteDataViewFile(fullname);
                        DataSource = DMEEditor.GetDataSource(f.ConnectionName);
                        DataView   = ds.DataView;
                        DataView.EntityDataSourceID = EntityDataSource.DatasourceName;
                    }
                    DMEEditor.AddLogMessage("Success", "Added View", DateTime.Now, 0, null, Errors.Ok);
                }
                else
                {
                    Visutil.controlEditor.MsgBox("DM Engine", "Please Try another name . DataSource Exist");
                }
            }
            catch (Exception ex)
            {
                string mes = "Could not Added View ";
                DMEEditor.AddLogMessage(ex.Message, mes, DateTime.Now, -1, mes, Errors.Failed);
            };
            return(DataView);
        }
 private IErrorsInfo CheckDataSourcesExistForParameters(List <PassedArgs> p)
 {
     foreach (PassedArgs d in p)
     {
         Inds = DMEEditor.GetDataSource(d.DatasourceName);
         if (Inds == null)
         {
             DMEEditor.AddLogMessage("Checking DataSource Exist", "DataSource Doesnot Exist", DateTime.Now, -1, d.DatasourceName, ErrorObject.Flag);
         }
     }
     return(ErrorObject);
 }
Beispiel #12
0
        //-----------------------
        public async Task <IErrorsInfo> RunChildScriptAsync(SyncEntity ParentScript, IDataSource srcds, IDataSource destds, IProgress <PassedArgs> progress, CancellationToken token)
        {
            if (ParentScript.CopyDataScripts.Count > 0)
            {
                //foreach (LScript sc in ParentScript.CopyDataScripts.Where(p=>p.scriptType==DDLScriptType.CopyData).ToList())
                for (int i = 0; i < ParentScript.CopyDataScripts.Count; i++)
                {
                    SyncEntity sc = ParentScript.CopyDataScripts[i];
                    destds = DMEEditor.GetDataSource(sc.destinationdatasourcename);
                    srcds  = DMEEditor.GetDataSource(sc.sourcedatasourcename);

                    if (destds != null && srcds != null)
                    {
                        DMEEditor.OpenDataSource(sc.destinationdatasourcename);
                        DMEEditor.OpenDataSource(sc.sourcedatasourcename);
                        if (destds.ConnectionStatus == System.Data.ConnectionState.Open)
                        {
                            if (sc.scriptType == DDLScriptType.CopyData)
                            {
                                await Task.Run(() =>
                                {
                                    sc.errorsInfo = RunCopyEntityScript(ref sc, srcds, destds, sc.sourceDatasourceEntityName, sc.destinationentityname, progress, token, true);  //t1.Result;//DMEEditor.ETL.CopyEntityData(srcds, destds, ScriptHeader.Scripts[i], true);
                                });

                                if (DMEEditor.ErrorObject.Flag == Errors.Failed)
                                {
                                    sc.errormessage = DMEEditor.ErrorObject.Message;
                                    sc.errorsInfo   = DMEEditor.ErrorObject;
                                    sc.Active       = false;

                                    if (progress != null)
                                    {
                                        PassedArgs ps = new PassedArgs {
                                            EventType = "Update", ParameterInt1 = CurrentScriptRecord, ParameterInt2 = ScriptCount, ParameterString3 = DMEEditor.ErrorObject.Message
                                        };
                                        progress.Report(ps);
                                    }
                                }
                            }
                            else
                            {
                                DMEEditor.ErrorObject.Flag    = Errors.Failed;
                                DMEEditor.ErrorObject.Message = $" Could not Connect to on the Data Dources {sc.destinationdatasourcename} or {sc.sourcedatasourcename}";
                            }
                            // Report progress as a percentage of the total task.
                            //    UpdateEvents(sc, highestPercentageReached, CurrentRecord, numberToCompute, destds);
                        }
                    }
                }
            }
            return(DMEEditor.ErrorObject);
        }
 public IErrorsInfo RunScript(SyncEntity dDLScripts)
 {
     if (ds.ConnectionStatus == ConnectionState.Open)
     {
         ds = DMEEditor.GetDataSource(DatasourceName);
         return(ds.RunScript(dDLScripts));
     }
     else
     {
         DMEEditor.AddLogMessage("Error", "$Could not Find DataSource {DatasourceName}", DateTime.Now, 0, DatasourceName, Errors.Failed);
         return(null);
     }
 }
        public int AddEntitytoDataView(EntityStructure maintab)
        {
            DMEEditor.ErrorObject.Flag = Errors.Ok;
            string tablename = maintab.DatasourceEntityName;

            try
            {
                maintab.Id     = NextHearId();
                maintab.ViewID = 0;
                if (maintab.ParentId == -1)
                {
                    maintab.ParentId = 0;
                }

                //--- check entity already exist , if it does change Entity Name
                if (CheckEntityExist(maintab.DatasourceEntityName))
                {
                    int cnt = EntitiesNames.Where(p => p.Equals(maintab.DatasourceEntityName, StringComparison.OrdinalIgnoreCase)).Count() + 1;
                    maintab.EntityName = maintab.DatasourceEntityName + "_" + cnt;
                }

                DataView.Entities.Add(maintab);
                EntitiesNames.Add(maintab.EntityName);
                IDataSource entityds = DMEEditor.GetDataSource(maintab.DataSourceID);
                if (entityds != null && entityds.Category == DatasourceCategory.RDBMS)
                {
                    List <ChildRelation> ds = entityds.GetChildTablesList(maintab.DatasourceEntityName, entityds.Dataconnection.ConnectionProp.SchemaName, null);
                    if (ds != null && ds.Count > 0)
                    {
                        // var tb = ds.Tables[0];
                        //-------------------------------
                        // Create Parent Record First
                        //-------------------------------
                        if (ds.Count > 0)
                        {
                            foreach (ChildRelation r in ds)
                            {
                                EntityStructure a;
                                a = SetupEntityInView(DataView, DataView.Entities, r.child_table, maintab.DatasourceEntityName, r.child_column, r.parent_column, maintab.Id, entityds.DatasourceName);
                            }
                        }
                    }
                }

                return(maintab.Id);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
Beispiel #15
0
        private void ValidateFKbutton_Click(object sender, EventArgs e)
        {
            string schemaname = "";

            ds = DMEEditor.GetDataSource(dataSourceIDComboBox.Text);
            IRDBSource rdb = null;

            if (ds.Category == DatasourceCategory.RDBMS)
            {
                rdb        = (IRDBSource)SourceConnection;
                schemaname = rdb.GetSchemaName();
                EntityStructure.Relations = rdb.GetEntityforeignkeys(EntityName.ToUpper(), schemaname);
                dataHierarchyBindingSource.ResetBindings(false);
            }
        }
Beispiel #16
0
        private void ValidateQuerybutton_Click(object sender, EventArgs e)
        {
            object dt;

            ds = DMEEditor.GetDataSource(dataSourceIDComboBox.Text);
            if (SourceConnection != null && EntityStructure.CustomBuildQuery != null)
            {
                dt = SourceConnection.RunQuery(EntityStructure.CustomBuildQuery);
            }
            else
            {
                dt = SourceConnection.GetEntity(EntityName, null);
            }
            CustomQueryDatadataGridView.DataSource = dt;
        }
Beispiel #17
0
 private void ViewIDComboBox_SelectedValueChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.viewIDComboBox.Text))
     {
         ds = (DataViewDataSource)DMEEditor.GetDataSource(this.viewIDComboBox.Text);
         if (ds != null)
         {
             this.entityIDComboBox.Items.Clear();
             List <string> ls = ds.GetEntitesList().ToList();
             foreach (string item in ls)
             {
                 this.entityIDComboBox.Items.Add(item);
             }
         }
     }
 }
        private IDataSource GetDataSourceObject(string entityname)
        {
            IDataSource     retval;
            EntityStructure dh = Entities.Where(x => string.Equals(x.EntityName, entityname, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (dh == null)
            {
                retval = DMEEditor.GetDataSource(DataView.EntityDataSourceID);
            }
            else
            {
                retval = DMEEditor.GetDataSource(dh.DataSourceID);
            }
            retval.Dataconnection.OpenConnection();
            retval.ConnectionStatus = Dataconnection.ConnectionStatus;
            return(retval);
        }
Beispiel #19
0
 private void ValidateFieldsbutton_Click(object sender, EventArgs e)
 {
     if (EntityStructure.Drawn == true)
     {
         SourceConnection = DMEEditor.GetDataSource(dataSourceIDComboBox.Text);
         if (SourceConnection == null)
         {
             DMEEditor.AddLogMessage("Error", "Could not Find DataSource " + EntityStructure.DataSourceID, DateTime.Now, EntityStructure.Id, EntityStructure.EntityName, Errors.Failed);
             MessageBox.Show($"{ErrorObject.Message}");
         }
         else
         {
             EntityStructure ent = SourceConnection.GetEntityStructure(EntityStructure.EntityName, true);
             EntityStructure.Fields = ent.Fields;
             this.dataHierarchyBindingSource.ResetBindings(true);
             this.fieldsBindingSource.ResetBindings(true);
         }
     }
 }
        public List <SyncEntity> GetCreateEntityScript(List <EntityStructure> entities = null)
        {
            List <SyncEntity> ls = new List <SyncEntity>();

            foreach (EntityStructure item in entities)
            {
                ds = DMEEditor.GetDataSource(item.DataSourceID);
                if (ds.ConnectionStatus == ConnectionState.Open)
                {
                    List <EntityStructure> lsent = new List <EntityStructure>();
                    lsent.Add(item);
                    ls.AddRange(ds.GetCreateEntityScript(lsent));
                }
                else
                {
                    DMEEditor.AddLogMessage("Error", "$Could not Find DataSource {item.DataSourceID}", DateTime.Now, 0, item.DataSourceID, Errors.Failed);
                }
            }
            return(ls);
        }
        public object GetDisplayLookup(string datasourceid, string entityname, string KeyField)
        {
            object retval;

            try
            {
                IDataSource     ds  = DMEEditor.GetDataSource(datasourceid);
                EntityStructure ent = ds.GetEntityStructure(entityname, false);
                DisplayField = null;
                // bool found = true;
                // int i = 0;
                List <DefaultValue> defaults = ds.Dataconnection.ConnectionProp.DatasourceDefaults.Where(o => o.propertyType == DefaultValueType.DisplayLookup).ToList();
                List <string>       fields   = ent.Fields.Select(u => u.EntityName).ToList();
                if (defaults != null)
                {
                    DisplayField = (from x in ent.Fields
                                    join y in defaults on x.fieldname equals y.propertyName
                                    orderby y.propoertValue
                                    select x.fieldname).FirstOrDefault();
                }
                if (string.IsNullOrWhiteSpace(DisplayField) || string.IsNullOrEmpty(DisplayField))
                {
                    DisplayField = ent.Fields.Where(r => r.EntityName.Contains("NAME")).Select(u => u.EntityName).FirstOrDefault();
                }
                if (string.IsNullOrWhiteSpace(DisplayField) || string.IsNullOrEmpty(DisplayField))
                {
                    DisplayField = KeyField;
                }
                string qrystr = "select " + DisplayField + "," + KeyField + " from " + entityname;



                retval = ds.RunQuery(qrystr);

                return(retval);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #22
0
        private void FillEntities()
        {
            DataSourceFieldProperties w = (DataSourceFieldProperties)appfieldPropertiesBindingSource.Current;

            if (!w.enitities.Any(s => s.entity == EntityName))
            {
                IDataSource ds = DMEEditor.GetDataSource(dsname);
                EntityStructure = ds.GetEntityStructure(EntityName, true);
                DataSourceEntityProperties y = new DataSourceEntityProperties();
                y.entity = EntityStructure.EntityName;
                foreach (EntityField item in EntityStructure.Fields)
                {
                    AppField x = new AppField();
                    x.datasourcename = dsname;
                    x.entityname     = EntityName;
                    x.fieldname      = item.fieldname;
                    y.properties.Add(x);
                }
                this.enititiesBindingSource.Add(y);
            }
        }
Beispiel #23
0
        public IErrorsInfo PerformAction()
        {
            try
            {
                //----------- Chceck if both Source and Target Exist -----
                if (InParameters.Count > 0)
                {
                    if (OutParameters.Count > 0)
                    {
                        Outds = DMEEditor.GetDataSource(InParameters[0].DatasourceName);
                        if (Outds == null)
                        {
                            string errmsg = "Error In DataSource exists ";

                            DMEEditor.AddLogMessage("Error", errmsg, DateTime.Now, -1, InParameters[0].DatasourceName, Errors.Failed);
                        }
                        else
                        {
                            //    DMEEditor.ErrorObject = RunCreateEntityBackWorker();
                        }
                    }
                    else
                    {
                        string errmsg = "Error No Target Table Data exist ";
                        DMEEditor.AddLogMessage("Error", errmsg, DateTime.Now, -1, InParameters[0].DatasourceName, Errors.Failed);
                    }
                }
                else
                {
                    string errmsg = "Error No Source Table Data exist ";
                    DMEEditor.AddLogMessage("Error", errmsg, DateTime.Now, -1, InParameters[0].DatasourceName, Errors.Failed);
                }
            }
            catch (Exception ex)
            {
                DMEEditor.AddLogMessage("Error", $"Error in Copying Table ({ex.Message})", DateTime.Now, -1, OutParameters[0].DatasourceName, Errors.Failed);
            }

            return(DMEEditor.ErrorObject);
        }
        public List <DataSet> GetDataSetForView(string viewname)
        {
            List <DataSet>  retval = new List <DataSet>();
            EntityStructure entity = new EntityStructure();

            try
            {
                IDataSource     ds     = DMEEditor.GetDataSource(DataView.DataViewDataSourceID);
                EntityStructure maine  = DataView.Entities[0];
                int             mainid = maine.Id;


                ///--------------- Create Main Tables
                foreach (EntityStructure item in DataView.Entities.Where(x => x.ParentId == mainid && mainid != x.Id))
                {
                    DataSet mainds = new DataSet(viewname + "." + item.EntityName);
                    retval.Add(mainds);
                    //  entity = item;
                    if (item.Fields.Count == 0 || item.Relations.Count == 0)
                    {
                        EntityStructure entity1 = ds.GetEntityStructure(item.EntityName, false);

                        item.Relations = entity1.Relations;
                        item.Fields    = entity1.Fields;
                    }

                    // Add main Table
                    mainds.Tables.Add(CreateTableFromEntityStructure(item));
                    // Adding Child Tables
                    GetChildTablesForDataset(ds, ref mainds, item, DataView.Entities.Where(f => f.Id != item.Id).ToList(), item.Id);
                }
            }
            catch (Exception ex)
            {
                string mes = ex.Message;
                DMEEditor.AddLogMessage(ex.Message, "Could not Convert View to Object" + mes, DateTime.Now, -1, mes, Errors.Failed);
            };
            DMEEditor.ConfigEditor.SaveDataconnectionsValues();
            return(retval);
        }
        private void ValidateQuerybutton_Click(object sender, EventArgs e)
        {
            // ds = (DataViewDataSource)DMEEditor.GetDataSource(dataSourceIDComboBox.Text);

            object dt;

            if (!string.IsNullOrEmpty(EntityStructure.CustomBuildQuery) && !string.IsNullOrWhiteSpace(EntityStructure.CustomBuildQuery))
            {
                SourceConnection = DMEEditor.GetDataSource(dataSourceIDComboBox.Text);
                if (SourceConnection.Category != DatasourceCategory.VIEWS)
                {
                    if (SourceConnection != null && EntityStructure.CustomBuildQuery != null)
                    {
                        dt = SourceConnection.RunQuery(EntityStructure.CustomBuildQuery);
                    }
                    else
                    {
                        dt = SourceConnection.GetEntity(EntityName, null);
                    }
                    if (dt != null)
                    {
                        EntityStructure.Fields = DMEEditor.Utilfunction.GetFieldFromGeneratedObject(dt);
                        this.dataHierarchyBindingSource.ResetBindings(true);
                        this.fieldsBindingSource.ResetBindings(true);
                        fieldsBindingSource.DataSource = dataHierarchyBindingSource;
                        fieldsDataGridView.Refresh();
                        CustomQueryDatadataGridView.DataSource = dt;
                    }
                }
                else
                {
                    MessageBox.Show("Cannot Run Query on DataView");
                }
            }
            else
            {
                MessageBox.Show("Query Missing");
            }
        }
Beispiel #26
0
        private void CreateinDBbutton_Click1(object sender, EventArgs e)
        {
            try
            {
                tb = (EntityStructure)entitiesBindingSource.Current;
                SourceConnection = DMEEditor.GetDataSource(databaseTypeComboBox.Text);
                DMEEditor.OpenDataSource(databaseTypeComboBox.Text);
                //SourceConnection.Dataconnection.OpenConnection();
                SourceConnection.ConnectionStatus = SourceConnection.Dataconnection.ConnectionStatus;
                if (SourceConnection.ConnectionStatus == ConnectionState.Open)
                {
                    tb.DatasourceEntityName = tb.EntityName;

                    SourceConnection.CreateEntityAs(tb);
                    if (DMEEditor.ErrorObject.Flag == Errors.Ok)
                    {
                        MessageBox.Show("Entity Creation Success", "Beep");
                        DMEEditor.AddLogMessage("Success", "Table Creation Success", DateTime.Now, -1, "", Errors.Failed);
                    }
                    else
                    {
                        string mes = "Entity Creation Failed";
                        MessageBox.Show(mes, "Beep");
                        DMEEditor.AddLogMessage("Create Table", mes, DateTime.Now, -1, mes, Errors.Failed);
                    }
                }
                else
                {
                    MessageBox.Show("Entity Creation Not Success Could not open Database", "Beep");
                    DMEEditor.AddLogMessage("Fail", "Table Creation Not Success Could not open Database", DateTime.Now, -1, "", Errors.Failed);
                }
            }
            catch (Exception ex)
            {
                string mes = "Entity Creation Failed";
                MessageBox.Show(mes, "Beep");
                DMEEditor.AddLogMessage(ex.Message, mes, DateTime.Now, -1, mes, Errors.Failed);
            };
        }
Beispiel #27
0
        private DataTable CopyReportDefinition(int blocknumber)
        {
            try

            {
                string QueryString = "select " + GetSelectedFields(blocknumber) + " from " + Definition.Blocks[blocknumber].EntityID;
                DataViewDataSource ds = (DataViewDataSource)DMEEditor.GetDataSource(Definition.Blocks[blocknumber].ViewID);

                DataTable PrintData = (DataTable)ds.GetEntity(Definition.Blocks[blocknumber].EntityID, null );
          //      PrintData.Wait();
                DMEEditor.AddLogMessage("Success", $"Copying Report Data", DateTime.Now, 0, null, Errors.Ok);
                return PrintData;
            }
            catch (Exception ex)
            {
                string errmsg = "Error in Copying Report Data";
                DMEEditor.AddLogMessage("Fail", $"{errmsg}:{ex.Message}", DateTime.Now, 0, null, Errors.Failed);
                return null;
            }


        }
Beispiel #28
0
        private void BlocksBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            ReportBlock x = new ReportBlock();

            e.NewObject = x;
            ReportTemplate t = (ReportTemplate)reportsBindingSource.Current;

            if (t.Blocks == null)
            {
                t.Blocks = new List <ReportBlock>();
            }
            if (!string.IsNullOrEmpty(this.viewIDComboBox.Text))
            {
                ds = (DataViewDataSource)DMEEditor.GetDataSource(this.viewIDComboBox.Text);
                EntityStructure           ent = ds.GetEntityStructure(this.entityIDComboBox.Text, true);
                List <ReportBlockColumns> ls  = new List <ReportBlockColumns>();
                if (ent != null)
                {
                    int i = 0;
                    foreach (EntityField item in ent.Fields)
                    {
                        ReportBlockColumns c = new ReportBlockColumns();
                        c.ColumnName  = item.fieldname;
                        c.ColumnSeq   = i;
                        c.DisplayName = item.fieldname;
                        c.Show        = true;
                        i            += 1;

                        ls.Add(c);
                    }
                }
                x.BlockColumns = ls;
            }


            t.Blocks.Add(x);
        }
        private EntityStructure SetupEntityInView(IDMDataView v, List <EntityStructure> Rootnamespacelist, string childtable, string parenttable, string childcolumn, string parentcolumn, int pid, string Datasourcename)
        {
            EntityStructure a;
            int             pkid       = NextHearId();
            IDataSource     ds         = DMEEditor.GetDataSource(Datasourcename);
            string          schemaname = "";

            if (ds.Category == DatasourceCategory.RDBMS)
            {
                IRDBSource rdb = (IRDBSource)ds;
                schemaname = rdb.GetSchemaName();
            }

            if (!Rootnamespacelist.Where(f => f.ParentId == pid && f.EntityName.Equals(childtable, StringComparison.OrdinalIgnoreCase)).Any())//f => f.Id == childtable &&
            {
                //a = new EntityStructure() { Id = pkid, ParentId = pid, EntityName = childtable.ToUpper(), ViewID = v.ViewID };
                //a.DataSourceID = v.Entities.Where(x => x.Id == pid).FirstOrDefault().DataSourceID;
                //a.DatasourceEntityName = childtable;
                //a.Relations = ds.GetEntityforeignkeys(childtable.ToUpper(), schemaname);

                a          = (EntityStructure)ds.GetEntityStructure(childtable, true).Clone();
                a.ParentId = pid;
                a.Id       = NextHearId();
                Rootnamespacelist.Add(a);
            }
            else
            {
                a = Rootnamespacelist.Where(f => f.ParentId == pid && f.EntityName.Equals(childtable, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); //f.Id == childtable &&
                //  a.DataSourceID = DatasourceName;
                a.DatasourceEntityName = childtable;
                a.Relations.Add(new RelationShipKeys {
                    EntityColumnID = childcolumn.ToUpper(), ParentEntityColumnID = parentcolumn.ToUpper(), ParentEntityID = parenttable.ToUpper()
                });
            }
            return(a);
        }
        public IErrorsInfo PerformAction()
        {
            try
            {
                //----------- Chceck if both Source and Target Exist -----
                if (InTableParameters.Count > 0)
                {
                    if (OutTableParameters.Count > 0)
                    {
                        Inds = DMEEditor.GetDataSource(InTableParameters[0].DatasourceName);
                        if (Inds == null)
                        {
                            string errmsg = "Error In DataSource exists ";
                            ErrorObject.Flag    = Errors.Failed;
                            ErrorObject.Message = errmsg;
                            logger.WriteLog(errmsg);
                        }
                        else
                        {
                            Outds = DMEEditor.GetDataSource(OutTableParameters[0].DatasourceName);
                            if (Outds == null)
                            {
                                string errmsg = "Error Out DataSource exists ";
                                ErrorObject.Flag    = Errors.Failed;
                                ErrorObject.Message = errmsg;
                                logger.WriteLog(errmsg);
                            }
                            else //---- Everything Checks OK we can Procceed with Copy
                            {
                                string SourceEntityName = InTableParameters[0].CurrentEntity;
                                if (Outds.CheckEntityExist(SourceEntityName) == false)
                                {
                                    Outds.CreateEntityAs(Inds.GetEntityStructure(SourceEntityName, false));
                                    //   DMEEditor.viewEditor.AddTableToDataView
                                }
                                else
                                {
                                    string errmsg = "Entity already Exist at Destination";
                                    ErrorObject.Flag    = Errors.Failed;
                                    ErrorObject.Message = errmsg;
                                    logger.WriteLog(errmsg);
                                }
                            }
                        }
                    }
                    else
                    {
                        string errmsg = "Error No Target Table Data exist ";
                        ErrorObject.Flag    = Errors.Failed;
                        ErrorObject.Message = errmsg;
                        logger.WriteLog(errmsg);
                    }
                }
                else
                {
                    string errmsg = "Error No Source Table Data exist ";
                    ErrorObject.Flag    = Errors.Failed;
                    ErrorObject.Message = errmsg;
                    logger.WriteLog(errmsg);
                }
            }
            catch (Exception ex)
            {
                ErrorObject.Flag = Errors.Failed;
                ErrorObject.Ex   = ex;

                logger.WriteLog($"Error in Copying Table ({ex.Message})");
            }

            return(ErrorObject);
        }