private void ValidateTailDataValidation(DP_DataRepository data)
        {
            //برای فرمهایی که از کارتابل باز میشود اینکه داده ها حتما با داده مرجع در ارتباط باشند
            //تست شود
            var  foundItems = AgentHelper.GetRelatedDataItemsSomeHow(data, EditArea.AreaInitializer.TailDataValidation.Item2);
            bool found      = false;

            foreach (var item in foundItems)
            {
                if (AgentHelper.DataItemsAreEqual(item, EditArea.AreaInitializer.TailDataValidation.Item1))
                {
                    found = true;
                    break;
                }
            }
            //پیغام مرتبط شود برای فرم یکی هم اضافه شود
            if (!found)
            {
                AddDataValidationMessage("ارتباط با داده مرجع برقرار نمی باشد", data);
            }
        }
        private DataLinkItemGroup GetIncludedDataLinkItems(EntityRelationshipTailDTO relationshipTail, DataLinkDTO selectedDataLink, DP_DataView relationshipFirstData, DP_DataView targetData, int level
                                                           , EntityRelationshipTailDataMenuDTO relationshipTailDataMenuDTO, DataLinkItem parentDataLinkItem = null, DataLinkItemGroup result = null, List <DataLinkItem> allItems = null)
        {
            if (result == null)
            {
                result = new DataLinkItemGroup();
            }
            if (relationshipTail != null && relationshipTail.ChildTail != null)
            {
                RelationshipTailDataManager relationshipTailDataManager = new RelationshipTailDataManager();

                //var firstData = new DP_DataRepository();
                //firstData.TargetEntityID = FirstData.TargetEntityID;
                //firstData.DataView = FirstData;
                //foreach (var key in FirstData.KeyProperties)
                //{
                //    firstData.AddProperty(new ColumnDTO() { ID = key.ColumnID }, key.Value);
                //}
                var searchDataTuple         = AgentUICoreMediator.GetAgentUICoreMediator.RelationshipDataManager.GetSecondSideSearchDataItemByRelationship(relationshipFirstData, relationshipTail.Relationship.ID);
                var searchPhraseToOtherData = relationshipTailDataManager.GetTargetSearchItemFromRelationshipTail(targetData, relationshipTail.ChildTail.ReverseRelationshipTail);
                searchDataTuple.Phrases.AddRange(searchPhraseToOtherData.Phrases);
                var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester();
                //سکوریتی داده اعمال میشود
                var searchRequest = new DR_SearchViewRequest(requester, searchDataTuple);
                //searchRequest.EntityID = parentTail.RelationshipTargetEntityID;
                var searchResult = AgentUICoreMediator.GetAgentUICoreMediator.requestRegistration.SendSearchViewRequest(searchRequest);

                if (parentDataLinkItem != null)
                {
                    parentDataLinkItem.TailPath = relationshipTail.RelationshipIDPath;
                    if (relationshipTailDataMenuDTO != null)
                    {
                        if (relationshipTailDataMenuDTO.Items.Any(x => x.Path == parentDataLinkItem.TailPath))
                        {
                            parentDataLinkItem.DataMenuID = relationshipTailDataMenuDTO.Items.First(x => x.Path == parentDataLinkItem.TailPath).DataMenuSettingID;
                        }
                    }
                }
                if (searchResult.Result == Enum_DR_ResultType.SeccessfullyDone)
                {
                    foreach (var item in searchResult.ResultDataItems)
                    {
                        DataLinkItem found = null;
                        if (allItems == null)
                        {
                            allItems = new List <DataLinkItem>();
                        }
                        else
                        {
                            if (selectedDataLink.NotJointEntities == true)
                            {
                                if (allItems.Any(x => AgentHelper.DataItemsAreEqual(item, x.DataItem)))
                                {
                                    var fItem = allItems.First(x => AgentHelper.DataItemsAreEqual(item, x.DataItem));
                                    found = fItem;
                                }
                            }
                        }
                        if (found == null)
                        {
                            found          = new DataLinkItem();
                            found.DataItem = item;
                            found.Level    = level;

                            result.Items.Add(found);
                            allItems.Add(found);
                        }
                        if (parentDataLinkItem != null)
                        {
                            result.Relations.Add(new DataLinkRelation(parentDataLinkItem, found));
                        }

                        GetIncludedDataLinkItems(relationshipTail.ChildTail, selectedDataLink, item, targetData, level + 1, relationshipTailDataMenuDTO, found, result);
                    }
                }
                else
                {
                    AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo(searchResult.Message, searchResult.Details, MyUILibrary.Temp.InfoColor.Red);
                }
            }
            return(result);
        }