private void GetRelationship(int relatoinshipID) { var relationship = bizRelationship.GetRelationship(relatoinshipID); if (relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary) { Message = bizRelationship.GetRelationship(relationship.PairRelationshipID); } else { Message = relationship; } ShowMessage(); }
private List <Tuple <RelationshipDTO, DP_DataRepository> > GetRemoveItems(List <DP_DataRepository> listdata, List <Tuple <RelationshipDTO, DP_DataRepository> > result = null) { if (result == null) { result = new List <Tuple <RelationshipDTO, DP_DataRepository> >(); } foreach (var item in listdata) { foreach (var removeChild in item.ChildRelationshipInfos.Where(x => x.RemovedDataForUpdate.Any() && x.Relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromPrimartyToForeign)) { if (removeChild.RelationshipDeleteOption == RelationshipDeleteOption.SetNull) { foreach (var removeItem in removeChild.RemovedDataForUpdate) { var relationship = bizRelationship.GetRelationship(removeChild.Relationship.ID); result.Add(new Tuple <RelationshipDTO, DP_DataRepository>(relationship, removeItem)); } } } foreach (var child in item.ChildRelationshipInfos) { GetRemoveItems(child.RelatedData.ToList(), result); } } return(result); }
private void InsertMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e) { var menu = sender as RadMenuItem; var contextMenu = menu.Parent as RadContextMenu; RadTreeViewItem item = contextMenu.GetClickedElement <RadTreeViewItem>(); int entityID = 0; if (item != null) { var fItem = item.DataContext as FormulaItemDTO; if (fItem.ItemType == FormuaItemType.Relationship) { BizRelationship bizRelationship = new BizRelationship(); var rel = bizRelationship.GetRelationship(fItem.ItemID); entityID = rel.EntityID2; } } else { entityID = (int)lokEntity.SelectedValue; } if (entityID != 0) { frmPropertySelector frm = new frmPropertySelector(entityID); frm.PropertySelected += (sender1, e1) => Frm_PropertySelected(sender1, e1, item); MyProjectManager.GetMyProjectManager.ShowDialog(frm, "انتخاب خصوصیت", Enum_WindowSize.Vertical); } }
public frmRelationshipFilter(int relatoinshipID) { InitializeComponent(); RelatoinshipID = relatoinshipID; BizRelationship bizRelationship = new BizRelationship(); Relatoinship = bizRelationship.GetRelationship(relatoinshipID); //SetSearchRelationshipTails(); SetValueRelationshipTails(); //SetSearchRelationshipTails(); var list = bizRelationshipFilter.GetRelationshipFilters(MyProjectManager.GetMyProjectManager.GetRequester(), relatoinshipID); foreach (var item in list) { SetValueColumns(item); SetSearchColumns(item); } dtgRelationshipFilterColumns.ItemsSource = list; dtgRelationshipFilterColumns.RowLoaded += DtgConditions_RowLoaded; dtgRelationshipFilterColumns.CellEditEnded += DtgConditions_CellEditEnded; colValueRelationshipTail.EditItemClicked += ColValueRelationshipTail_EditItemClicked; // colSearchRelationshipTail.EditItemClicked += ColSearchRelationshipTail_EditItemClicked; ControlHelper.GenerateContextMenu(dtgRelationshipFilterColumns); }
//private List<ConditionalPermissionDTO> GetConditionalPermissions(MyProjectEntities context, int entityID, int securitySubjectID) //{ // var cachedItem = CacheManager.GetCacheManager().GetCachedItem(CacheItemType.ConditionalPermission, securitySubjectID.ToString(), entityID.ToString()); // if (cachedItem != null) // return (cachedItem as List<ConditionalPermissionDTO>); // List<ConditionalPermissionDTO> result = new List<ConditionalPermissionDTO>(); // BizPermission bizPermission = new BizPermission(); // var conditionalPermissions = context.ConditionalPermission.Where(x => x.TableDrivedEntityID == entityID && x.SecuritySubjectID == securitySubjectID); // foreach (var dbitem in conditionalPermissions) // { // result.Add(bizPermission.ToConditionalPermission(dbitem, true)); // } // CacheManager.GetCacheManager().AddCacheItem(result, CacheItemType.ConditionalPermission, securitySubjectID.ToString(), entityID.ToString()); // return result; //} public PermissionDTO GetPermission(int securitySubjectID, int securityObjectID) { using (var context = new MyProjectEntities()) { var dbSecurityObject = context.SecurityObject.FirstOrDefault(x => x.ID == securityObjectID); if (dbSecurityObject != null) { var category = (DatabaseObjectCategory)dbSecurityObject.Type; if (category == DatabaseObjectCategory.Relationship) { var relationship = bizRelationship.GetRelationship(securityObjectID); if (relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary) { securityObjectID = relationship.RelationshipColumns.First().FirstSideColumnID; } else { securityObjectID = relationship.RelationshipColumns.First().SecondSideColumnID; } } } else { return(null); } var dbitem = context.Permission.FirstOrDefault(x => x.SecuritySubjectID == securitySubjectID && x.SecurityObjectID == securityObjectID); if (dbitem != null) { return(ToPermission(dbitem)); } else { return(null); } } }
public RelationshipDTO GetRelationship(int relationshipID) { BizRelationship bizRelationship = new BizRelationship(); return(bizRelationship.GetRelationship(relationshipID)); }
public DP_SearchRepository GetSecondSideSearchDataItemByRelationship(DP_BaseData firstSideDataItem, int relationshipID) { var relationship = bizRelationship.GetRelationship(relationshipID); return(GetSecondSideSearchItemByRelationship(firstSideDataItem, relationship)); }
public DataMenuResult GetDataMenu(DR_Requester requester, DP_DataView dataItem, int dataMenuSettingID) { DataMenuResult result = new DataMenuResult(); List <DataMenu> resultMenus = new List <DataMenu>(); result.DataMenus = resultMenus; var entityID = dataItem.TargetEntityID; var simpleEntity = bizTableDrivedEntity.GetSimpleEntity(requester, entityID); if (simpleEntity == null) { return(null); } DataMenuSettingDTO dataMenuSetting = null; if (dataMenuSettingID != 0) { dataMenuSetting = GetDataMenuSetting(requester, dataMenuSettingID, true); } else { dataMenuSetting = GetDefaultDataMenuSetting(requester, entityID, true); } if (dataMenuSetting != null) { result.DataMenuSettingName = dataMenuSetting.Name; } if (simpleEntity.IsView) { if (dataMenuSetting != null) { if (dataMenuSetting.RelationshipID != 0 && dataMenuSetting.TargetDataMenuSettingID != 0) { var relationship = bizRelationship.GetRelationship(dataMenuSetting.RelationshipID); var dataView = CreateDataView(requester, dataItem, relationship); return(GetDataMenu(requester, dataView, dataMenuSetting.TargetDataMenuSettingID)); } } //var fullEntity = bizTableDrivedEntity.GetTableDrivedEntity(requester, entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships); //if (fullEntity.Relationships.Any()) //{ // foreach (var relationsip in fullEntity.Relationships) // { // var dataView = CreateDataView(dataItem, relationsip); // var menu = AddMenu(result, relationsip.Alias, "", DataMenuType.ViewRel); // menu.ViewRelTargetDataItem = dataView; // } //} } else { var dataEntryRootMenu = AddMenu(resultMenus, "نمایش/اصلاح داده", "", DataMenuType.Form, dataItem); //آرشیو داده // BizArchive bizArchive = new BizArchive(); if (bizTableDrivedEntity.DataIsAccessable(requester, entityID, new List <SecurityAction>() { SecurityAction.ArchiveView, SecurityAction.ArchiveEdit })) { var archiveRootMenu = AddMenu(resultMenus, "آرشیو", "", DataMenuType.Archive, dataItem); } //نامه های داده // BizLetterTemplate bizLetterTemplate = new BizLetterTemplate(); if (bizTableDrivedEntity.DataIsAccessable(requester, entityID, new List <SecurityAction>() { SecurityAction.LetterView, SecurityAction.LetterEdit })) { var letterRootMenu = AddMenu(resultMenus, "نامه ها", "", DataMenuType.Letter, dataItem); } //جریان کارهای مرتبط if (bizProcess.EntityHasAnyProcess(entityID)) { var workflowRootMenu = AddMenu(resultMenus, "جریان کار", "", DataMenuType.Workflow, dataItem); } ////لینک های داده //BizDataLink bizDataLink = new MyModelManager.BizDataLink(); //var datalinks = bizDataLink.GetDataLinkByEntitiyID(requester, entityID); //if (datalinks.Any()) //{ // var dataViewRootMenu = AddMenu(resultMenus, "لینک داده", "", DataMenuType.Folder,null); // foreach (var datalink in datalinks) // { // var datalinkMenu = AddMenu(dataViewRootMenu.SubMenus, datalink.ReportTitle, "", DataMenuType.DataLink, dataItem); // datalinkMenu.Datalink = datalink; // } //} //گزارشهای داده های مرتبط if (dataMenuSetting != null) { if (dataMenuSetting.SearchableReportRelationships.Any()) { var relationshipReportRootMenu = AddMenu(resultMenus, "گزارش داده های مرتبط", "", DataMenuType.Folder, null); foreach (var group in dataMenuSetting.SearchableReportRelationships.GroupBy(x => x.Group1 ?? "")) { DataMenu parentGroupMenu = GetGroupMenu(relationshipReportRootMenu, group.Key); foreach (var rel in group) { var menu = AddMenu(parentGroupMenu.SubMenus, rel.SearchableReportReport.ReportTitle, "", DataMenuType.RelationshipTailSearchableReport, dataItem); menu.SearchableReportRelationshipTail = rel; } } } //نمای داده های مرتبط if (dataMenuSetting.DataViewRelationships.Any()) { var dataViewRootMenu = AddMenu(resultMenus, "نمایش داده های مرتبط", "", DataMenuType.Folder, null); foreach (var group in dataMenuSetting.DataViewRelationships.GroupBy(x => x.Group1 ?? "")) { DataMenu parentGroupMenu = GetGroupMenu(dataViewRootMenu, group.Key); foreach (var rel in group) { var dataViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.RelationshipTail.TargetEntityAlias, rel.RelationshipTail.EntityPath, DataMenuType.RelationshipTailDataView, dataItem); dataViewRelMenu.DataviewRelationshipTail = rel.RelationshipTail; dataViewRelMenu.TargetDataMenuSettingID = rel.TargetDataMenuSettingID; } } } if (dataMenuSetting.GridViewRelationships.Any()) { var gridViewRootMenu = AddMenu(resultMenus, "گرید داده های مرتبط", "", DataMenuType.Folder, null); foreach (var group in dataMenuSetting.GridViewRelationships.GroupBy(x => x.Group1 ?? "")) { DataMenu parentGroupMenu = GetGroupMenu(gridViewRootMenu, group.Key); foreach (var rel in group) { var gridViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.RelationshipTail.TargetEntityAlias, rel.RelationshipTail.EntityPath, DataMenuType.RelationshipTailDataGrid, dataItem); gridViewRelMenu.GridviewRelationshipTail = rel.RelationshipTail; gridViewRelMenu.TargetDataMenuSettingID = rel.TargetDataMenuSettingID; } } } if (dataMenuSetting.DataItemReports.Any()) { var gridViewRootMenu = AddMenu(resultMenus, "گزارشات مورد داده", "", DataMenuType.Folder, null); foreach (var group in dataMenuSetting.DataItemReports.GroupBy(x => x.Group1 ?? "")) { DataMenu parentGroupMenu = GetGroupMenu(gridViewRootMenu, group.Key); foreach (var rel in group) { var gridViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.EntityDataItemReport.ReportTitle, "", DataMenuType.DataItemReport, dataItem); gridViewRelMenu.DataItemReport = rel.EntityDataItemReport; } } } } } return(result); }
private Tuple <EntityRelationshipTailDTO, List <TableDrivedEntity>, List <Relationship> > ToEntityRelationshipTailDTO (MyProjectEntities projectContext, string relationshipPath, int initialiEntityID, string initialiEntityAlias, int targetEntityID, string targetEntityAlias , EntityRelationshipTailDTO reverseRelationshipTail, bool withEntitiesAndRelationships, List <TableDrivedEntity> entities = null, List <Relationship> relationships = null) { if (entities == null) { entities = new List <TableDrivedEntity>(); relationships = new List <Relationship>(); } // اینجا درست شه. بعد چک شه همه جا در درسترس بودن انتیتی از کلاس بیز انتیتی چک بشه و نه از گرقتن اسیند پرمیشن ها EntityRelationshipTailDTO result = new EntityRelationshipTailDTO(); result.InitialEntityID = initialiEntityID; result.InitialiEntityAlias = initialiEntityAlias; result.TargetEntityID = targetEntityID; result.TargetEntityAlias = targetEntityAlias; //var targetEntity = bizTableDrivedEntity.GetSimpleEntity(requester, result.TargetEntityID); //if (targetEntity != null) // result.TargetEntityAlias = targetEntity.Alias; //else // result.TargetEntityAlias = result.TargetEntityID.ToString(); result.RelationshipIDPath = relationshipPath; if (!string.IsNullOrEmpty(relationshipPath)) { int relationshipID = 0; string rest = ""; if (relationshipPath.Contains(",")) { var splt = relationshipPath.Split(','); relationshipID = Convert.ToInt32(splt[0]); for (int i = 1; i <= splt.Count() - 1; i++) { rest += (rest == "" ? "" : ",") + splt[i]; } } else { relationshipID = Convert.ToInt32(relationshipPath); } if (withEntitiesAndRelationships) { var relationship = projectContext.Relationship.First(x => x.ID == relationshipID); if (!entities.Any(x => x.ID == relationship.TableDrivedEntityID2)) { entities.Add(relationship.TableDrivedEntity1); } if (!relationships.Any(x => x.ID == relationshipID)) { relationships.Add(relationship); } } result.Relationship = bizRelationship.GetRelationship(relationshipID); if (rest != "") { result.ChildTail = ToEntityRelationshipTailDTO(projectContext, rest, initialiEntityID, initialiEntityAlias, targetEntityID, targetEntityAlias, null, withEntitiesAndRelationships, entities, relationships).Item1; //result.LastRelationship = result.ChildTail.LastRelationship; } } //else // result.LastRelationship = result.Relationship; result.IsOneToManyTail = ((result.Relationship != null && result.Relationship.TypeEnum == Enum_RelationshipType.OneToMany) || (result.ChildTail != null && result.ChildTail.IsOneToManyTail)); result.EntityPath = result.Relationship.Entity1 + "==>" + GetEntityPath(result); if (reverseRelationshipTail == null) { result.ReverseRelationshipTail = ToEntityRelationshipTailDTO(projectContext, GetReveseRaletionshipPath(result), result.TargetEntityID, targetEntityAlias, result.InitialEntityID, initialiEntityAlias, result, withEntitiesAndRelationships, entities, relationships).Item1; } else { result.ReverseRelationshipTail = reverseRelationshipTail; } //if (result.ReverseRelationshipTail.ChildTail != null) // result.ReverseRelationshipTail.LastRelationship = result.ReverseRelationshipTail.ChildTail.LastRelationship; return(new Tuple <EntityRelationshipTailDTO, List <TableDrivedEntity>, List <Relationship> >(result, entities, relationships)); //if (item.ReverseRelationshipTailID != null) // result.ReverseRelationshipTailID = item.ReverseRelationshipTailID.Value; //result.TargetEntityAlias = item.TableDrivedEntity1.Alias; //result.RelationshipSourceEntityID = item.Relationship.TableDrivedEntityID1; //result.RelationshipTargetEntityID = item.Relationship.TableDrivedEntityID2; //BizRelationship bizRElationship = new BizRelationship(); //if (item.Relationship.TypeEnum != null) // result.SourceToTargetRelationshipType = (Enum_RelationshipType)item.Relationship.TypeEnum.Value; //else // result.SourceToTargetRelationshipType = Enum_RelationshipType.None; //result.SourceToTargetMasterRelationshipType = (Enum_MasterRelationshipType)item.Relationship.MasterTypeEnum; //foreach (var relcolumn in item.Relationship.RelationshipColumns) //{ // result.RelationshipColumns.Add(bizRElationship.ToRelationshipColumn(result.SourceToTargetMasterRelationshipType, relcolumn)); //} //result.RelationshipID = item.RelationshipID; //result.Relationship = bizRElationship.ToRelationshipDTO(item.Relationship); //result.RelationshipIDPath = GetRelationshipPath(item); //result.RelationshipPath = GetEntityPath(item); //foreach (var child in item.EntityRelationshipTail11) //{ // result.ChildTail = ToEntityRelationshipTailDTO(child); //} }