private void TestData(DP_DataRepository data)
        {
            try
            {
                FormulaFunctionHandler handler = new MyFormulaFunctionStateFunctionLibrary.FormulaFunctionHandler();

                ////var child = new ChildRelationshipInfo();
                ////child.Relationship = new BizRelationship().GetRelationship(33);

                ////SearchRequestManager searchProcessor = new SearchRequestManager();
                ////DP_SearchRepository searchItem = new DP_SearchRepository(75);
                ////searchItem.Phrases.Add(new SearchProperty() { ColumnID = 68, Value = "بانک تجارت" });

                ////DP_DataRepository childdata = null;
                ////var requester = GetRequester();
                //////سکوریتی داده اعمال میشود
                ////DR_SearchFullDataRequest request = new DR_SearchFullDataRequest(requester, searchItem);
                ////var searchResult = searchProcessor.Process(request);
                ////if (searchResult.Result == Enum_DR_ResultType.SeccessfullyDone)
                ////    childdata = searchResult.ResultDataItems.First();
                ////else if (searchResult.Result == Enum_DR_ResultType.ExceptionThrown)
                ////    throw (new Exception(searchResult.Message));

                //////var childdata = searchProcessor.GetDataItemsByListOFSearchProperties(GetRequester(), searchItem).First();

                ////child.ParentData = data;

                //childdata.ParantChildRelationshipInfo = child;
                ////childdata.SetProperties(newProp);
                //child.RelatedData.Add(childdata);
                //data.ChildRelationshipInfos.Add(child);
                var result = handler.CalculateFormula(ExpressionEditor.ExpressionText, data, MyProjectManager.GetMyProjectManager.GetRequester());
                if (string.IsNullOrEmpty(result.Exception))
                {
                    MessageBox.Show(result.Result == null ? "null" : result.Result.ToString());
                }
                else
                {
                    MessageBox.Show(result.Exception);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //برنگشتن آبجکت
            //                آیتمهای فرمول
        }
Example #2
0
        private bool GetConditionResult(EntityStateConditionDTO condition, DP_DataRepository mainDataItem, DR_Requester requester)
        {
            bool result = false;
            bool securitySubjectIsOk = false;

            if (condition.SecuritySubjects.Any())
            {
                bool hasAnyOfSubjects = false;
                foreach (var subject in condition.SecuritySubjects)
                {
                    foreach (var post in requester.Posts)
                    {
                        if (post.CurrentUserID == subject.SecuritySubjectID ||
                            post.ID == subject.SecuritySubjectID ||
                            post.OrganizationID == subject.SecuritySubjectID ||
                            post.OrganizationTypeID == subject.SecuritySubjectID ||
                            post.OrganizationTypeRoleTypeID == subject.SecuritySubjectID ||
                            post.RoleTypeID == subject.SecuritySubjectID
                            )
                        {
                            hasAnyOfSubjects = true;
                        }
                    }
                }

                if (condition.SecuritySubjectInORNotIn == InORNotIn.In)
                {
                    securitySubjectIsOk = hasAnyOfSubjects == true;
                }
                else
                {
                    securitySubjectIsOk = hasAnyOfSubjects == false;
                }
            }
            else
            {
                securitySubjectIsOk = true;
            }

            if (securitySubjectIsOk)
            {
                if (condition.ColumnID != 0)
                {
                    DataitemRelatedColumnValueHandler dataitemRelatedColumnValueHandler = new MyFormulaFunctionStateFunctionLibrary.DataitemRelatedColumnValueHandler();
                    var value = dataitemRelatedColumnValueHandler.GetValueSomeHow(requester, mainDataItem, condition.RelationshipTail, condition.ColumnID);

                    result = StateHasValue(requester, condition, value);
                }
                else if (condition.FormulaID != 0)
                {
                    FormulaFunctionHandler FormulaFunctionHandler = new FormulaFunctionHandler();
                    var value = FormulaFunctionHandler.CalculateFormula(condition.FormulaID, mainDataItem, requester);
                    result = StateHasValue(requester, condition, value.Result);
                }
                else
                {
                    result = securitySubjectIsOk;
                }
            }
            return(result);
        }