private bool CreateReportTable(TableDrivedEntityDTO entity) { var dbHelper = ConnectionManager.GetDBHelper(entity.DatabaseID); var tmpTableName = "xr_" + entity.TableName; try { var drop = "drop table " + tmpTableName; var dropRes = dbHelper.ExecuteNonQuery(drop); } catch { } var res = dbHelper.CreateTable(tmpTableName, GetExternalReportTableColumns(entity)); return(res != 0); //SearchRequestManager searchRequestManager = new SearchRequestManager(); //var query = searchRequestManager.GetSelectFromExternal(requester, entityID, searchItem, true, ModelEntites.SecurityMode.View); //var entity = bizTableDrivedEntity.GetSimpleEntity(requester, entityID); //var select = "select " + query.Item1 + "," + id + " as ReportKey" + " " + query.Item2; //var inserted = TargetDatabaseManager.InsertFromQueryToTargetDB(entityID, tmpTableName, select); //if (inserted) // return id; }
void AddColumn(TableDrivedEntityDTO sourceEntity, ColumnDTO sourceColumn, TableDrivedEntityDTO targetEntity, bool move, RadGridView sourceDataGrid, RadGridView targetDataGrid, bool checkRelationship) { if (sourceEntity == Message.BaseEntity && sourceColumn.IsNull == false) { MessageBox.Show("ستون اجباری میباشد و امکان انتقال به موجودیت دیگر وجود ندارد"); return; } if (sourceColumn.PrimaryKey) { MessageBox.Show("ستون کلید اصلی میباشد"); return; } if (checkRelationship) { if (sourceEntity.Relationships.Any(x => x.RelationshipColumns.Any(y => y.FirstSideColumnID == sourceColumn.ID))) { MessageBox.Show("ستون مربوط به یک رابطه میباشد"); return; } } if (!targetEntity.Columns.Any(x => x.ID == sourceColumn.ID)) { targetEntity.Columns.Add(sourceColumn); targetDataGrid.ItemsSource = null; targetDataGrid.ItemsSource = targetEntity.Columns; } if (move) { sourceEntity.Columns.Remove(sourceColumn); sourceDataGrid.ItemsSource = null; sourceDataGrid.ItemsSource = sourceEntity.Columns; } }
private void PopulateTreeItems(ItemCollection items, TableDrivedEntityDTO entity, string relationshipPath, string entityPath) { foreach (var column in entity.Columns) { var treeItem = new TreeColumnItem(); treeItem.ColumnID = column.ID; treeItem.ColumnName = column.Name; treeItem.Alias = column.Alias; treeItem.RelationshipPath = relationshipPath; treeItem.EntityPath = entityPath; AddColumnNode(items, treeItem, column.Alias); } foreach (var relationship in entity.Relationships) { var newrelationshipPath = (relationshipPath == "" ? "" : relationshipPath + ",") + relationship.ID; var newEntityPath = (entityPath == "" ? "" : entityPath + ",") + relationship.Entity2; TreeRelationshipItem relItem = new TreeRelationshipItem(); relItem.Relationship = relationship; relItem.RelationshipPath = newrelationshipPath; relItem.EntityPath = newEntityPath; var node = AddRelationshipNode(items, relItem); node.Expanded += Node_Expanded; node.Items.Add("Loading..."); } }
private void SetUIEnablityColumns() { TableDrivedEntityDTO targetEntity = null; //if (cmbUIEnablityRelationshipTail.SelectedItem != null) //{ // var item = cmbUIEnablityRelationshipTail.SelectedItem as EntityRelationshipTailDTO; // targetEntity = bizTableDrivedEntity.GetTableDrivedEntity(item.RelationshipTargetEntityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); //} //else targetEntity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships); //var foreignRels = targetEntity.Relationships.Where(x => x.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary); //var listcolumns = new List<int>(); //foreach (var fRel in foreignRels) //{ // listcolumns.AddRange(fRel.RelationshipColumns.Select(x => x.FirstSideColumnID)); //} var columns = targetEntity.Columns.Where(x => !x.ForeignKey && !x.PrimaryKey).ToList(); colColumn.ItemsSource = columns; colColumn.DisplayMemberPath = "Alias"; colColumn.SelectedValueMemberPath = "ID"; colRelationship.ItemsSource = targetEntity.Relationships.ToList();//.Where(x => x.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary).ToList(); colRelationship.DisplayMemberPath = "Alias"; colRelationship.SelectedValueMemberPath = "ID"; //BizEntityUIComposition bizEntityUIComposition = new BizEntityUIComposition(); //var uiCompositions = bizEntityUIComposition.GetListEntityUIComposition(targetEntity.ID); //colUIComposition.DisplayMemberPath = "Title"; //colUIComposition.SelectedValueMemberPath = "ID"; //colUIComposition.ItemsSource = uiCompositions; }
private void PopulateTreeItems(RadTreeViewItem parentNode, TableDrivedEntityDTO entity) { //var columnsNode = AddFormulaObjectNode(items, "Folder", null, "", "ستونها"); //var relatoinshipNode = AddFormulaObjectNode(items, "Folder", null, "", "روابط"); //var parametersNode = AddFormulaObjectNode(items, "Folder", null, "", "پارامترها"); //var functionNode = AddFormulaObjectNode(items, "Folder", null, "", "Stored Procedures"); foreach (var relationship in entity.Relationships) { if (parentNode.DataContext != null) { if ((parentNode.DataContext as RelationshipDTO).PairRelationshipID == relationship.ID) { continue; } } var node = AddRelationshipNode(parentNode.Items, relationship); node.Expanded += Node_Expanded; node.Items.Add("Loading..."); } //AddColumnNodes(columnsNode.Items, entityID); //AddRalationshipNodes(relatoinshipNode.Items, entityID); //AddParameterNodes(parametersNode.Items, entityID); //AddFunctionNodes(functionNode.Items, entityID); //RadContextMenu.SetContextMenu(parametersNode, GetParametersContextMenu(entityID, parametersNode)); //RadContextMenu.SetContextMenu(functionNode, GetFunctionsContextMenu(entityID, functionNode)); }
private string GetUpdateQuery(TableDrivedEntityDTO entity, string propertyNameWithValues, List <EntityInstanceProperty> keyInstanceProperties) { string keyWhere = ""; foreach (var column in keyInstanceProperties) { keyWhere += (keyWhere == "" ? "" : " and ") + column.Name + "=" + GetPropertyValue(column.Value); } var result = ""; //if (entity != null && !string.IsNullOrEmpty(entity.Criteria)) //{ // var criteria = entity.Criteria; // if (entity.Criteria.Contains("=")) // { // result = "update " + entity.TableName + " set "; // result += propertyNameWithValues + "," + criteria; // result += " where " + keyWhere; // } //} //else //{ result = "update " + GetTableName(entity) + " set "; result += propertyNameWithValues; result += " where " + keyWhere; //} return(result); }
public bool EntityHasUIComposition(TableDrivedEntityDTO entity) { using (var projectContext = new DataAccess.MyProjectEntities()) { return(projectContext.TableDrivedEntity.First(x => x.ID == entity.ID).EntityUIComposition.Any()); } }
private static MyPropertyInfo GeneratePropertyInfo(TableDrivedEntityDTO entity, PropertyType propertyType, MyPropertyInfo parentProperty, int id, string name, object context) { MyPropertyInfo myPropertyInfo = new MyFormulaFunctionStateFunctionLibrary.MyPropertyInfo(); myPropertyInfo.Name = name; // myPropertyInfo.FormulaObject = formulaObject; myPropertyInfo.ID = id; myPropertyInfo.ParentProperty = parentProperty; myPropertyInfo.Context = context; myPropertyInfo.PropertyType = propertyType; if (parentProperty != null) { // myPropertyInfo.RelationshipTail = parentProperty.RelationshipTail + (string.IsNullOrEmpty(parentProperty.RelationshipTail) ? "" : ",") + relationship.ID; myPropertyInfo.RelationshipLevel = parentProperty.RelationshipLevel + 1; if (parentProperty.PropertyType == PropertyType.Relationship) { myPropertyInfo.RelationshipTail = parentProperty.RelationshipTail + (string.IsNullOrEmpty(parentProperty.RelationshipTail) ? "" : ",") + parentProperty.ID; myPropertyInfo.RelationshipPropertyTail = parentProperty.RelationshipPropertyTail + (string.IsNullOrEmpty(parentProperty.RelationshipPropertyTail) ? "" : ".") + parentProperty.Name; } } else { myPropertyInfo.RelationshipTail = ""; myPropertyInfo.RelationshipPropertyTail = ""; } return(myPropertyInfo); }
//public EntitySearchDTO GenerateDefaultSearchList(TableDrivedEntityDTO entity, List<TableDrivedEntityDTO> allEntities) //{ // short index = 0; // foreach (var column in entity.Columns.Where(x => x.PrimaryKey)) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.OrderID = index; // resultColumn.ColumnID = column.ID; // result.EntitySearchAllColumns.Add(resultColumn); // index++; // } // var reviewedRels = new List<RelationshipDTO>(); // foreach (var column in entity.Columns) // { // if (selectedColumns.Any(x => x.ID == column.ID)) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.OrderID = index; // resultColumn.ColumnID = column.ID; // result.EntitySearchAllColumns.Add(resultColumn); // index++; // } // else // { // if (entity.Relationships.Any(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == column.ID))) // { // var relationship = entity.Relationships.First(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == column.ID)); // if (!reviewedRels.Any(x => x.ID == relationship.ID)) // { // reviewedRels.Add(relationship); // //foreach (var relCol in relationship.RelationshipColumns) // //{ // // var resultColumn = new EntityListViewColumnsDTO(); // // resultColumn.OrderID = index; // // resultColumn.ColumnID = column.ID; // // result.EntityListViewAllColumns.Add(resultColumn); // // index++; // //} // var targetEntity = allEntities.First(x => x.ID == relationship.EntityID2); // //List<ColumnDTO> relationColumns = GetRelationColumns(entity, targetEntity, relationship); // //if (relationColumns.Any()) // //{ // //foreach (var relCol in relationColumns) // //{ // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.OrderID = index; // // resultColumn.ColumnID = relCol.ID; // resultColumn.Alias = targetEntity.Alias; // resultColumn.CreateRelationshipID = relationship.ID; // resultColumn.CreateRelationshipTargetEntityID = relationship.EntityID2; // result.EntitySearchAllColumns.Add(resultColumn); // index++; // //} // //} // } // } // } // } // return result; //} private List <ColumnDTO> GetRelationColumns(TableDrivedEntityDTO targetEntity) { List <ColumnDTO> result = new List <ColumnDTO>(); var simplecollumns = targetEntity.Columns.Where(x => !x.PrimaryKey && !targetEntity.Relationships.Any(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == x.ID))).ToList(); return(GetFirstPriorityColumns(simplecollumns)); }
//private static DP_DataRepository GetMainDateItem(DR_Requester requester, DP_DataRepository mainDataItem) //{ // if (!mainDataItem.IsNewItem && MyDataHelper.DataItemPrimaryKeysHaveValue(mainDataItem) && !MyDataHelper.DataItemNonPrimaryKeysHaveValues(mainDataItem)) // { // SearchRequestManager searchProcessor = new SearchRequestManager(); // DP_SearchRepository searchDataItem = new DP_SearchRepository(mainDataItem.TargetEntityID); // foreach (var property in mainDataItem.GetProperties()) // searchDataItem.Phrases.Add(new SearchProperty() { ColumnID = property.ColumnID, Value = property.Value }); // //سکوریتی داده اعمال میشود // //یعنی ممکن است به خود داده دسترسی نداشته باشد و یا حتی به بعضی از فیلدها و روابط // DR_SearchFullDataRequest request = new DR_SearchFullDataRequest(requester, searchDataItem); // var result = searchProcessor.Process(request); // if (result.Result != Enum_DR_ResultType.ExceptionThrown) // return result.ResultDataItems.FirstOrDefault(); // searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchDataItem).FirstOrDefault(); // else // throw (new Exception(result.Message)); // } // else // return mainDataItem; //} private static List <object> GetRefObjects(TableDrivedEntityDTO entity, DR_Requester requester) { List <object> result = new List <object>(); result.Add(new DBFunctionHelper(entity.DatabaseID, requester)); result.Add(new UserInfo(requester)); return(result); }
public frmEntityTree(int entityId) { InitializeComponent(); entity = bizEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityId, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships); if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { PopulateEntityTree(); } }
private void PrepareFormulaInstance(TableDrivedEntityDTO mainEntity) { var dataItem = new ProxyLibrary.DP_DataRepository(EntityID, ""); dataItem.IsFullData = true; FormulaInstance = new FormulaDefinitionInstance(MyProjectManager.GetMyProjectManager.GetRequester(), dataItem, mainEntity); ExpressionEditor.Item = FormulaInstance.MainFormulaObject; }
//private bool CheckRelationshipTailPermission(EntityRelationshipTailDTO relationshipTail, bool first = true) //{ // if (first) // { // var entityEnabled = bizTableDrivedEntity.IsEntityEnabled(relationshipTail.RelationshipTargetEntityID); // if (!entityEnabled) // return false; // } // if (relationshipTail.ChildTail != null) // return CheckRelationshipTailPermission(relationshipTail.ChildTail, false); // else // return true; //} //public void UpdateDefaultListViewInModel(int databaseID) //{ //} public EntityListViewDTO GenerateDefaultListView(TableDrivedEntityDTO entity, List <TableDrivedEntityDTO> allEntities) { EntityListViewDTO result = new EntityListViewDTO(); result.TableDrivedEntityID = entity.ID; result.Title = "لیست نمایشی پیش فرض"; result.EntityListViewAllColumns = GenereateDefaultListViewColumns(entity, allEntities); return(result); }
//public QueryItem() //{ // ChildQueries = new List<MyConnectionManager.QueryItem>(); // SetIdentities = new List<MyConnectionManager.SetIdentity>(); // FKSources = new List<MyConnectionManager.FKToPK>(); // //TargetEntityID = targetEntityID; // //Query = query; //} public QueryItem(TableDrivedEntityDTO targetEntity, Enum_QueryItemType queryType, List <EntityInstanceProperty> editingProperties, DP_DataRepository dataItem) { DataItem = dataItem; QueryType = queryType; //ChildQueries = new List<MyConnectionManager.QueryItem>(); // SetIdentities = new List<MyConnectionManager.SetIdentity>(); // FKSources = new List<MyConnectionManager.FKToPK>(); TargetEntity = targetEntity; EditingProperties = editingProperties; }
List <ColumnDTO> GetExternalReportTableColumns(TableDrivedEntityDTO entity) { var columns = entity.Columns.Where(x => x.PrimaryKey).ToList(); columns.Add(new ColumnDTO() { Name = "ReportKey", ColumnType = Enum_ColumnType.Numeric, DataType = "int" }); return(columns); }
//public void UpdateDefaultSearchInModel(int databaseID) //{ //} public EntitySearchDTO GenerateDefaultSearchList(TableDrivedEntityDTO entity, List <TableDrivedEntityDTO> allEntities) { EntitySearchDTO result = new EntitySearchDTO(); result.TableDrivedEntityID = entity.ID; result.Title = "لیست جستجوی پیش فرض"; result.EntitySearchAllColumns = GenereateDefaultSearchColumns(entity, allEntities); return(result); }
private string GetInsertQuery(TableDrivedEntityDTO entity, string propertyNames, string propertyValues) { var result = ""; result = "insert into " + GetTableName(entity) + " ("; result += propertyNames; result += ") values ("; result += propertyValues += ")"; //} return(result); }
private void SetMainFormulaObject(DP_DataRepository mainDataItem, TableDrivedEntityDTO mainEntity) { MainFormulaObject = GetMainFormulaObject(mainDataItem); var properties = FormulaInstanceInternalHelper.GetProperties(mainEntity, null, true, true); MainFormulaObject.SetProperties(properties); MainFormulaObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //MainFormulaObject.PropertySetChanged += FormulaObject_PropertySetChanged; //MainFormulaObject.PropertyChanged += FormulaObject_PropertyChanged; }
private bool?SetDataReference(TableDrivedEntityDTO entity, List <int> commonManyToOneEntityIDs, List <int> reviewedEntityIDs) { bool isDataReference = false; if (entity.IsDataReference != null) { isDataReference = entity.IsDataReference.Value; } else { if (reviewedEntityIDs.Any(x => x == entity.ID)) { return(null); } reviewedEntityIDs.Add(entity.ID); if (IsDataReferenceBaseCondition(entity)) { if (!entity.Relationships.Any(x => x.TypeEnum == Enum_RelationshipType.ManyToOne)) { isDataReference = true; } else { if (entity.Relationships.Count(x => x.TypeEnum == Enum_RelationshipType.ManyToOne) == 1) { var mtoRel = entity.Relationships.First(x => x.TypeEnum == Enum_RelationshipType.ManyToOne); var oneEntity = listAllEntitis.First(x => x.ID == mtoRel.EntityID2); if (commonManyToOneEntityIDs.Contains(mtoRel.EntityID2)) { isDataReference = true; } else { var otherSideIsDataReference = SetDataReference(oneEntity, commonManyToOneEntityIDs, reviewedEntityIDs); if (otherSideIsDataReference == null) { isDataReference = true; } else { isDataReference = otherSideIsDataReference.Value; } } } } } } if (entity.IsDataReference == null) { entity.IsDataReference = isDataReference; } return(isDataReference); }
public void SetEntityID(int entityID) { if (MainEntity == null || MainEntity.ID != entityID) { MainEntity = bizEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships); if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { PopulateTree(); } } }
public frmFormulaTree(int entityID) { InitializeComponent(); EntityID = entityID; Entity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships); //treeItems.SelectedItemChanged += TreeItems_SelectedItemChanged; if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { PopulateTree(); } }
private void SetUIColumnValueRangeColumns() { TableDrivedEntityDTO targetEntity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID, EntityColumnInfoType.WithFullColumns, EntityRelationshipInfoType.WithoutRelationships); colColumnValueRange.ItemsSource = targetEntity.Columns.Where(x => x.ColumnValueRange != null); colColumnValueRange.DisplayMemberPath = "Alias"; colColumnValueRange.SelectedValueMemberPath = "ID"; colEnumTag.ItemsSource = Enum.GetValues(typeof(EnumColumnValueRangeTag)); ///colColumnValueRangeReset.ItemsSource = targetEntity.Columns.Where(x => x.ColumnValueRange != null); //colColumnValueRangeReset.DisplayMemberPath = "Alias"; //colColumnValueRangeReset.SelectedValueMemberPath = "ID"; }
public frmDataSelect(int entityID) { InitializeComponent(); Entity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); lblEntity.Text = Entity.Alias; foreach (var col in Entity.Columns.Where(x => x.PrimaryKey)) { EntityInstanceProperty keyColumn = new EntityInstanceProperty(col); // keyColumn.ColumnID = col.ID; //keyColumn.IsKey = true; //keyColumn.Name = col.Name; keyColumns.Add(keyColumn); } dtgKeyColumns.ItemsSource = keyColumns; }
private void btnNewEntity_Click_1(object sender, RoutedEventArgs e) { var newItem = new TableDrivedEntityDTO() { Name = "موجودیت جدید" }; foreach (var item in Message.BaseEntity.Columns.Where(x => x.PrimaryKey)) { newItem.Columns.Add(item); } SuperToSubRelationshipDTO superToSub = new SuperToSubRelationshipDTO(); SubToSuperRelationshipDTO subToSuper = new SubToSuperRelationshipDTO(); AddDrivedEntityTab(new Tuple <SuperToSubRelationshipDTO, SubToSuperRelationshipDTO, TableDrivedEntityDTO>(superToSub, subToSuper, newItem)); }
//private List<EntitySearchColumnsDTO> GenereateDefaultSearchColumns(TableDrivedEntityDTO sententity, RelationshipDTO relationship, List<TableDrivedEntityDTO> allEntities, string relationshipPath = "", List<RelationshipDTO> relationships = null, List<EntitySearchColumnsDTO> list = null) //{ // if (list == null) // list = new List<EntitySearchColumnsDTO>(); // TableDrivedEntityDTO entity = null; // List<ColumnDTO> simplecollumns = null; // if (sententity != null) // { // entity = sententity; // simplecollumns = GetEntitySimpleColumnsColumns(entity); // foreach (var column in entity.Columns.Where(x => x.PrimaryKey)) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.ColumnID = column.ID; // resultColumn.Alias = column.Alias; // list.Add(resultColumn); // } // } // else if (relationship != null) // { // entity = allEntities.First(x => x.ID == relationship.EntityID2); // simplecollumns = GetRelationColumns(entity); // } // var reviewedRels = new List<RelationshipDTO>(); // foreach (var column in entity.Columns) // { // if (simplecollumns.Any(x => x.ID == column.ID)) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.ColumnID = column.ID; // resultColumn.CreateRelationshipTailPath = relationshipPath; // resultColumn.AllRelationshipsAreSubTuSuper = relationships != null && relationships.All(x => x.TypeEnum == Enum_RelationshipType.SubToSuper); // resultColumn.Alias = (relationship == null || resultColumn.AllRelationshipsAreSubTuSuper ? "" : entity.Alias + ".") + column.Alias; // //resultColumn.Tooltip = relationship == null ? "" : entity.Alias + "." + column.Alias; // list.Add(resultColumn); // } // else // { // if (entity.Relationships.Any(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == column.ID))) // { // var newrelationship = entity.Relationships.First(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == column.ID)); // if (!reviewedRels.Any(x => x.ID == newrelationship.ID)) // { // reviewedRels.Add(newrelationship); // if (newrelationship.TypeEnum == Enum_RelationshipType.SubToSuper) // { // //کلید های خارجی موجودیت های دیگر مهم نیستند // if (sententity != null) // { // foreach (var relCol in newrelationship.RelationshipColumns) // { // bool fkIsValid = false; // if (sententity == null) // fkIsValid = true; // else // { //چون برای انتیتی اصلی پرایمری ها قبلا اضافه شده اند // fkIsValid = !relCol.FirstSideColumn.PrimaryKey; // } // if (fkIsValid) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.ColumnID = relCol.FirstSideColumnID; // resultColumn.CreateRelationshipTailPath = relationshipPath; // string entityAlias = ""; // if (relationship != null) // { // entityAlias = entity.Alias + "."; // } // resultColumn.Alias = entityAlias + relCol.FirstSideColumn.Alias; // //resultColumn.Tooltip = relationship == null ? "" : entity.Alias + "." + relCol.FirstSideColumn.Alias; // list.Add(resultColumn); // } // } // } // List<RelationshipDTO> relationshipsTail = new List<RelationshipDTO>(); // if (relationships != null) // { // foreach (var relItem in relationships) // relationshipsTail.Add(relItem); // } // relationshipsTail.Add(newrelationship); // GenereateDefaultSearchColumns(null, newrelationship, allEntities, relationshipPath + (relationshipPath == "" ? "" : ",") + newrelationship.ID.ToString(), relationshipsTail, list); // } // else if (relationship == null) // { // var resultColumn = new EntitySearchColumnsDTO(); // resultColumn.CreateRelationshipTailPath = relationshipPath + (relationshipPath == "" ? "" : ",") + newrelationship.ID.ToString(); // resultColumn.Alias = newrelationship.Entity2Alias; // list.Add(resultColumn); // } // } // } // } // } // foreach (var newrelationship in entity.Relationships.Where(x => x.MastertTypeEnum == Enum_MasterRelationshipType.FromPrimartyToForeign)) // { // if (newrelationship.TypeEnum == Enum_RelationshipType.SubUnionToUnion_UnionHoldsKeys // || (newrelationship.TypeEnum == Enum_RelationshipType.SuperToSub && (newrelationship as SuperToSubRelationshipDTO).ISARelationship.IsTolatParticipation)) // { // List<RelationshipDTO> relationshipsTail = new List<RelationshipDTO>(); // if (relationships != null) // { // foreach (var relItem in relationships) // relationshipsTail.Add(relItem); // } // relationshipsTail.Add(newrelationship); // GenereateDefaultSearchColumns(null, newrelationship, allEntities, relationshipPath + (relationshipPath == "" ? "" : ",") + newrelationship.ID.ToString(), relationshipsTail, list); // } // } // if (sententity != null) // { // short index = 0; // foreach (var item in list) // { // item.OrderID = index; // index++; // } // } // return list; //} //private void GenereateDefaultSearchColumnsFromRelationship(TableDrivedEntityDTO sententity, RelationshipDTO relationship, List<TableDrivedEntityDTO> allEntities, string relationshipPath = "", List<RelationshipDTO> relationships = null, List<EntitySearchColumnsDTO> list = null) //{ //} private List <ColumnDTO> GetSimpleSearchColumns(TableDrivedEntityDTO entity) { var simplecollumns = entity.Columns.Where(x => !x.PrimaryKey && !entity.Relationships.Any(z => z.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary && z.RelationshipColumns.Any(y => y.FirstSideColumnID == x.ID))).ToList(); var countLimit = simplecollumns.Count(x => x.ColumnType == Enum_ColumnType.String || x.ColumnType == Enum_ColumnType.Date); List <ColumnDTO> selectedColumns = null; selectedColumns = GetFirstPriorityColumns(simplecollumns); if (selectedColumns.Count < countLimit / 3) { selectedColumns = GetSecondPriorityColumns(simplecollumns, selectedColumns); } if (selectedColumns.Count < countLimit / 3) { selectedColumns = GetThirdPriorityColumns(simplecollumns, selectedColumns); } return(selectedColumns); }
private void GenereateDefaultSearchColumnsFromRelationship(RelationshipDTO relationship, List <TableDrivedEntityDTO> allEntities, List <EntitySearchColumnsDTO> list, string relationshipPath, List <RelationshipDTO> relationships) { TableDrivedEntityDTO entity = allEntities.First(x => x.ID == relationship.EntityID2); var skipRelColumnIDs = relationship.RelationshipColumns.Select(x => x.SecondSideColumn.ID).ToList(); foreach (var column in entity.Columns.Where(x => x.PrimaryKey && !skipRelColumnIDs.Contains(x.ID))) { AddSearchColumn(list, column); } List <ColumnDTO> simplecollumns = GetSimpleSearchColumns(entity); foreach (var column in simplecollumns) { AddSearchColumn(list, column, relationshipPath, relationships); } AddRelationshipDefaultColumns(entity, allEntities, list, relationshipPath, relationships); }
//private void cmbRelationshipTail_SelectionChanged(object sender, SelectionChangedEventArgs e) //{ // SetColumnValueColumns(); //} private void SetColumnValueColumns() { TableDrivedEntityDTO targetEntity = null; //if (cmbColumnValueRelationshipTail.SelectedItem != null) //{ // var item = cmbColumnValueRelationshipTail.SelectedItem as EntityRelationshipTailDTO; // targetEntity = bizTableDrivedEntity.GetTableDrivedEntity(item.RelationshipTargetEntityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); //} //else targetEntity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), EntityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); colColumnValueColumn.ItemsSource = targetEntity.Columns; colColumnValueColumn.DisplayMemberPath = "Alias"; colColumnValueColumn.SelectedValueMemberPath = "ID"; }
public string CheckLinkedServers(TableDrivedEntityDTO firstEntity, EntityRelationshipTailDTO relationshipTail) { BizDatabase bizDatabase = new BizDatabase(); if (firstEntity.ServerID != relationshipTail.Relationship.ServerID2) { if (!bizDatabase.LinkedServerExists(firstEntity.ServerID, relationshipTail.Relationship.ServerID2)) { return("ارتباط لینک سرور بین موجودیت های" + " " + firstEntity.Alias + " " + "و موجودیت" + " " + relationshipTail.Relationship.Entity2Alias + " " + "تعریف نشده است"); } } if (relationshipTail.ChildTail != null) { return(CheckLinkedServers(firstEntity, relationshipTail.ChildTail)); } return(""); }
public frmCodeFunction_Entity(int ID, int entityID) { InitializeComponent(); // CodeFunctionParamTypes = codeFunctionParamTypes; Entity = bizEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); SetLookups(); if (ID == 0) { CodeFunctionEntity = new CodeFunction_EntityDTO(); //lokCodeFunction.ItemsSource = bizCodeFunction.GetCodeFunctionsByEntityID(MyProjectManager.GetMyProjectManager.GetRequester(), Entity.ID); } else { //lokCodeFunction.Visibility = Visibility.Collapsed; GetCodeFunctionEntity(ID); } SetDataGridColumns(); }
public frmDatabaseFunction_Entity(int ID, int entityID) { InitializeComponent(); // DatabaseFunctionParamTypes = DatabaseFunctionParamTypes; Entity = bizEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); SetLookups(); if (ID == 0) { DatabaseFunctionEntity = new DatabaseFunction_EntityDTO(); lokDatabaseFunction.ItemsSource = bizDatabaseFunction.GetDatabaseFunctions(MyProjectManager.GetMyProjectManager.GetRequester(), Enum_DatabaseFunctionType.None, Entity.DatabaseID); } else { lokDatabaseFunction.Visibility = Visibility.Collapsed; GetDatabaseFunctionEntity(ID); } SetDataGridColumns(); }