Пример #1
0
        private CustomObject GetMainFormulaObject(DP_DataRepository mainDataItem)
        {
            CustomObject formulaObject = new CustomObject();

            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.SeccessfullyDone)
                {
                    formulaObject.DataItem = result.ResultDataItems.FirstOrDefault(); // searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchDataItem).FirstOrDefault();
                }
                else if (result.Result == Enum_DR_ResultType.ExceptionThrown)
                {
                    throw (new Exception(result.Message));
                }
            }
            else
            {
                formulaObject.DataItem = mainDataItem;
            }
            return(formulaObject);
        }
        public FormulaObject(DP_DataRepository dataItem, DR_Requester requester, bool isDefinitionFormulaObject = false)
        {
            Requester = requester;
            bool getFromDB = false;

            if (isDefinitionFormulaObject == false)
            {
                if (!dataItem.IsNewItem && MyDataHelper.DataItemPrimaryKeysHaveValue(dataItem) && !MyDataHelper.DataItemNonPrimaryKeysHaveValues(dataItem))
                {
                    getFromDB = true;
                }
            }
            if (getFromDB)
            {
                SearchRequestManager searchProcessor = new SearchRequestManager();
                DP_SearchRepository  searchDataItem  = new DP_SearchRepository(dataItem.TargetEntityID);
                foreach (var property in dataItem.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.SeccessfullyDone)
                {
                    dataItem = result.ResultDataItems.FirstOrDefault(); // searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchDataItem).FirstOrDefault();
                }
                else if (result.Result == Enum_DR_ResultType.ExceptionThrown)
                {
                    throw (new Exception(result.Message));
                }
            }
            DataItem = dataItem;
            this.PropertyGetCalled   += FormulaObject_PropertyGetCalled;
            IsDefinitionFormulaObject = isDefinitionFormulaObject;

            var entity     = bizTableDrivedEntity.GetPermissionedEntity(Requester, DataItem.TargetEntityID);
            var properties = FormulaInstanceInternalHelper.GetProperties(entity, null, false, true);

            SetProperties(properties);
        }
Пример #3
0
        private static DP_DataRepository GetMainDateItem(DR_Requester requester, DP_BaseData dataItem)
        {
            bool getDataItem = false;

            if (dataItem is DP_DataView)
            {
                getDataItem = true;
            }
            else
            {
                if (!(dataItem as DP_DataRepository).IsNewItem && MyDataHelper.DataItemPrimaryKeysHaveValue((dataItem as DP_DataRepository)) && !MyDataHelper.DataItemNonPrimaryKeysHaveValues((dataItem as DP_DataRepository)))
                {
                    getDataItem = true;
                }
            }

            if (getDataItem)
            {
                SearchRequestManager searchProcessor = new SearchRequestManager();
                DP_SearchRepository  searchDataItem  = new DP_SearchRepository(dataItem.TargetEntityID);
                foreach (var property in dataItem.KeyProperties)
                {
                    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(dataItem as DP_DataRepository);
            }
        }
        public FunctionResult ValidateServiceRequest(CodeFunctionParamOneDataItem data)
        {
            FunctionResult result         = new FunctionResult();
            var            productItemRel = data.DataItem.ChildRelationshipInfos.FirstOrDefault(x => x.Relationship.Entity2Alias.Contains("کالا"));

            if (productItemRel != null)
            {
                if (productItemRel.RelatedData.Any())
                {
                    var dataItem = productItemRel.RelatedData.First();
                    if (!dataItem.IsFullData)
                    {
                        SearchRequestManager requestManager = new SearchRequestManager();

                        DP_SearchRepository SearchDataItem = new DP_SearchRepository(dataItem.TargetEntityID);
                        foreach (var col in dataItem.KeyProperties)
                        {
                            SearchDataItem.Phrases.Add(new SearchProperty()
                            {
                                ColumnID = col.ColumnID, Value = col.Value
                            });
                        }
                        var requester = new DR_Requester()
                        {
                            SkipSecurity = true
                        };
                        var request      = new DR_SearchFullDataRequest(requester, SearchDataItem);
                        var resultSearch = requestManager.Process(request);
                        dataItem = resultSearch.ResultDataItems[0];
                    }
                    var property = dataItem.Properties.FirstOrDefault(x => x.Column.Name.ToLower().Contains("brand"));
                    if (property != null)
                    {
                        if (property.Value != null && property.Value.ToString().ToLower() == "Hisense".ToLower())
                        {
                            result.Result    = false;
                            result.Exception = new Exception("امکان استفاده از برند انتخاب شده وجود ندارد");
                        }
                    }
                }
            }
            result.Result = true;
            return(result);
        }
        public long GetExternalReportKey(DR_Requester requester, int reportID, int entityID, DP_SearchRepository searchItem)
        {
            BizEntityExternalReport bizEntityExternalReport = new BizEntityExternalReport();
            BizTableDrivedEntity    bizTableDrivedEntity    = new BizTableDrivedEntity();
            SearchRequestManager    searchRequestManager    = new SearchRequestManager();
            var query  = searchRequestManager.GetSelectFromExternal(requester, entityID, searchItem, true);
            var entity = bizTableDrivedEntity.GetSimpleEntity(requester, entityID);

            if (query != null)
            {
                //  var transactionresult = ConnectionManager.ExecuteTransactionalQueryItems(allQueryItems.Where(x => !string.IsNullOrEmpty(x.Query)).ToList());

                //var guid = Guid.NewGuid().ToString();
                var id = 0;
                using (var model = new MyIdeaDataDBEntities())
                {
                    var newItem = new ExternalReportKeys();
                    newItem.DateTime    = DateTime.Now;
                    newItem.RequesterID = requester.Identity;
                    newItem.ReportID    = reportID;
                    model.ExternalReportKeys.Add(newItem);
                    model.SaveChanges();
                    id = newItem.ID;
                }
                if (id != 0)
                {
                    var inserted = bizEntityExternalReport.InsertDataIntoExternalReportTable(requester, reportID, entityID, id, query.Item2);

                    if (inserted)
                    {
                        return(id);
                    }
                }
            }
            return(0);
        }
Пример #6
0
        private List <DP_DataRepository> GetRelatedDataItems(DP_DataRepository dataItem, RelationshipDTO relationship, List <EntityInstanceProperty> relationshipProperties)
        {
            List <DP_DataRepository> result = new List <DP_DataRepository>();
            var childRelationshipInfo       = dataItem.ChildRelationshipInfos.FirstOrDefault(x => x.Relationship.ID == relationship.ID);

            if (childRelationshipInfo != null)
            {
                result = childRelationshipInfo.RelatedData.ToList();
            }
            else
            {
                bool gotFromParant = false;
                if (dataItem.ParantChildRelationshipInfo != null)
                {
                    //اگر داده پرنت بصورت بازگشتی صدا زده شده باشد از پایگاه داده نمی خواند و سعی میکند از همان داده پرنت هر چه که هست استفاده کند
                    if (dataItem.ParantChildRelationshipInfo.Relationship.TypeEnum != Enum_RelationshipType.ManyToOne)
                    {
                        if (dataItem.ParantChildRelationshipInfo.Relationship.ID == relationship.PairRelationshipID)
                        {
                            result.Add(dataItem.ParantChildRelationshipInfo.SourceData);
                            gotFromParant = true;
                        }
                    }
                }
                if (!gotFromParant)
                {
                    result = new List <DP_DataRepository>();
                    if (!relationshipProperties.Any(x => x.Value == null || string.IsNullOrEmpty(x.Value.ToString())))
                    {
                        SearchRequestManager searchProcessor = new SearchRequestManager();
                        DP_SearchRepository  searchItem      = new DP_SearchRepository(relationship.EntityID2);
                        foreach (var col in relationshipProperties)
                        {
                            searchItem.Phrases.Add(new SearchProperty()
                            {
                                ColumnID = col.ColumnID, Value = col.Value
                            });
                        }

                        //سکوریتی داده اعمال میشود
                        DR_SearchFullDataRequest request = new DR_SearchFullDataRequest(Requester, searchItem);

                        var searchResult = searchProcessor.Process(request);
                        if (searchResult.Result == Enum_DR_ResultType.SeccessfullyDone)
                        {
                            result = searchResult.ResultDataItems; // searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchDataItem).FirstOrDefault();
                        }
                        else if (searchResult.Result == Enum_DR_ResultType.ExceptionThrown)
                        {
                            throw (new Exception(searchResult.Message));
                        }

                        //result = searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchItem);

                        //nullدرست شود
                        childRelationshipInfo              = new ChildRelationshipInfo();
                        childRelationshipInfo.SourceData   = dataItem;
                        childRelationshipInfo.Relationship = relationship;
                        foreach (var item in result)
                        {
                            childRelationshipInfo.RelatedData.Add(item);
                        }
                    }
                }
            }
            return(result);
        }
Пример #7
0
        private DP_SearchRepository GetSecondSideSearchItemByRelationship(DP_BaseData firstSideDataItem, RelationshipDTO relationship)
        {
            var relationshipFirstSideColumnExist = true;

            foreach (var col in relationship.RelationshipColumns)
            {
                if (!firstSideDataItem.Properties.Any(x => x.Value != null && !string.IsNullOrEmpty(x.Value.ToString()) && x.ColumnID == col.FirstSideColumnID))
                {
                    relationshipFirstSideColumnExist = false;
                }
            }
            if (relationshipFirstSideColumnExist)
            {
                List <EntityInstanceProperty> properties     = new List <EntityInstanceProperty>();
                DP_SearchRepository           resultDataItem = new DP_SearchRepository(relationship.EntityID2);
                foreach (var col in relationship.RelationshipColumns)
                {
                    var value = firstSideDataItem.GetProperty(col.FirstSideColumnID).Value;
                    if (value == null)
                    {
                        return(null);
                    }
                    resultDataItem.Phrases.Add(new SearchProperty()
                    {
                        ColumnID = col.SecondSideColumnID, Value = value
                    });
                }
                return(resultDataItem);
            }
            else if (relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromPrimartyToForeign ||
                     relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary)
            {
                DP_SearchRepository resultDataItem = new DP_SearchRepository(relationship.EntityID2);
                if (firstSideDataItem.KeyProperties.Any() && firstSideDataItem.KeyProperties.All(x => x.Value != null && !string.IsNullOrEmpty(x.Value.ToString())))
                {
                    DP_SearchRepository searchItem = new DP_SearchRepository(relationship.EntityID1);
                    foreach (var col in firstSideDataItem.KeyProperties)
                    {
                        searchItem.Phrases.Add(new SearchProperty()
                        {
                            ColumnID = col.ColumnID, Value = col.Value
                        });
                    }
                    var requester = new DR_Requester();
                    requester.SkipSecurity = true;
                    DR_SearchFullDataRequest request         = new DR_SearchFullDataRequest(requester, searchItem);
                    SearchRequestManager     searchProcessor = new SearchRequestManager();
                    var searchResult = searchProcessor.Process(request);
                    if (searchResult.Result == Enum_DR_ResultType.SeccessfullyDone)
                    {
                        firstSideDataItem = searchResult.ResultDataItems.First();
                    }
                    else if (searchResult.Result == Enum_DR_ResultType.ExceptionThrown)
                    {
                        throw (new Exception(searchResult.Message));
                    }

                    List <EntityInstanceProperty> properties = new List <EntityInstanceProperty>();

                    foreach (var col in relationship.RelationshipColumns)
                    {
                        var value = firstSideDataItem.GetProperty(col.FirstSideColumnID).Value;
                        if (value == null)
                        {
                            return(null);
                        }
                        resultDataItem.Phrases.Add(new SearchProperty()
                        {
                            ColumnID = col.SecondSideColumnID, Value = value
                        });
                    }
                    return(resultDataItem);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
        public object GetValueSomeHow(DR_Requester requester, DP_DataRepository sentdata, EntityRelationshipTailDTO valueRelationshipTail, int valueColumnID, bool firstIfMultiple = false)
        {
            if (valueRelationshipTail == null)
            {
                var proprty = sentdata.GetProperty(valueColumnID);
                return(proprty?.Value);
            }
            else
            {
                DP_DataRepository relatedData = null;
                if (sentdata.ParantChildRelationshipInfo != null && sentdata.ParantChildRelationshipInfo.Relationship.PairRelationshipID == valueRelationshipTail.Relationship.ID)
                {
                    if (sentdata.ParantChildRelationshipInfo.Relationship.PairRelationshipID == valueRelationshipTail.Relationship.ID)
                    {
                        relatedData = sentdata.ParantChildRelationshipInfo.SourceData;
                    }
                }
                else if (sentdata.ChildRelationshipInfos.Any(x => x.Relationship.ID == valueRelationshipTail.Relationship.ID))
                {
                    var childInfo = sentdata.ChildRelationshipInfos.First(x => x.Relationship.ID == valueRelationshipTail.Relationship.ID);
                    if (childInfo.RelatedData.Count > 1)
                    {
                        if (firstIfMultiple)
                        {
                            relatedData = childInfo.RelatedData.First();
                        }
                        else
                        {
                            throw new Exception("asav");
                        }
                    }
                    else if (childInfo.RelatedData.Count == 1)
                    {
                        relatedData = childInfo.RelatedData.First();
                    }
                    else if (childInfo.RelatedData.Count == 0)
                    {
                        //یعنی یا داده مرتبطی وجود نداشته یا حذف شده
                        return("");
                    }
                }
                if (relatedData != null)
                {
                    return(GetValueSomeHow(requester, relatedData, valueRelationshipTail.ChildTail, valueColumnID, firstIfMultiple));
                }
                else
                {
                    //var columnValues = sentdata.KeyProperties;
                    //if (columnValues == null || columnValues.Count == 0)
                    //    throw new Exception("asasd");

                    //سکوریتی داده اعمال میشود
                    //  var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester();

                    //این شرط منطقیه؟؟
                    if (!sentdata.IsNewItem)
                    {
                        var relationshipTailDataManager  = new RelationshipTailDataManager();
                        var searchDataTuple              = relationshipTailDataManager.GetTargetSearchItemFromRelationshipTail(sentdata, valueRelationshipTail);
                        DR_SearchFullDataRequest request = new DR_SearchFullDataRequest(requester, searchDataTuple);
                        var searchResult = new SearchRequestManager().Process(request);
                        if (searchResult.ResultDataItems.Count > 1)
                        {
                            throw new Exception("asdasd");
                        }
                        else if (searchResult.ResultDataItems.Count == 1)
                        {
                            var foundDataItem = searchResult.ResultDataItems.First();
                            var prop          = foundDataItem.GetProperty(valueColumnID);
                            if (prop != null)
                            {
                                return(prop.Value);
                            }
                            else
                            {
                                return("");
                            }
                        }
                        else
                        {
                            return("");
                        }
                    }
                    else
                    {
                        return("");
                    }
                }
            }
            //return "";
        }
Пример #9
0
 public void TestInit()
 {
     this.driver = DriverContext.CreateDriver();
     this.searchRequestManager = new SearchRequestManager(driver);
 }
Пример #10
0
        public DR_ResultSearchKeysOnly SendSearchKeysOnlyRequest(DR_SearchKeysOnlyRequest request)
        {
            SearchRequestManager editProcessor = new SearchRequestManager();

            return(editProcessor.Process(request as DR_SearchKeysOnlyRequest));
        }
Пример #11
0
        public DR_ResultSearchFullData SendSearchFullDataRequest(DR_SearchFullDataRequest request)
        {
            SearchRequestManager editProcessor = new SearchRequestManager();

            return(editProcessor.Process(request as DR_SearchFullDataRequest));
        }