public IDMDataView GenerateView(string ViewName, string ConnectionName)
        {
            DMEEditor.ErrorObject.Flag = Errors.Ok;
            IDMDataView retval = null;

            try
            {
                retval                      = new DMDataView();
                retval.ViewID               = 0;
                retval.EntityDataSourceID   = ViewName;
                retval.ViewName             = ViewName;
                retval.DataViewDataSourceID = ViewName;
                retval.Viewtype             = ViewType.Table;
                retval.VID                  = Guid.NewGuid().ToString();
                //EntityStructure viewheader = new EntityStructure() { Id = 1, EntityName = ViewName };

                //viewheader.EntityName = ViewName;
                //viewheader.ViewID = retval.ViewID;
                //viewheader.ParentId = 0;
                //retval.Entities.Add(viewheader);
            }
            catch (Exception ex)
            {
                DMEEditor.AddLogMessage("Fail", $"Error in creating View ({ex.Message}) ", DateTime.Now, 0, ViewName, Errors.Failed);
            }
            return(retval);
        }
Beispiel #2
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 #3
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 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);
        }