Ejemplo n.º 1
0
 private void UseSearchResult(DR_ResultSearchView result, bool select)
 {
     if (result.Result != Enum_DR_ResultType.ExceptionThrown)
     {
         if (result != null)
         {
             if (!select)
             {
                 ViewEntityArea.AddData(result.ResultDataItems, true);
             }
             else
             {
                 if (DataSelected != null)
                 {
                     DataSelected(this, new DataSelectedEventArg()
                     {
                         DataItem = result.ResultDataItems
                     });
                 }
             }
         }
     }
     else
     {
         AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowMessage(result.Message);
     }
 }
        public void ShowTemporarySearchView()
        {
            CalculateFilterValues();
            bool filtersChanged = false;

            if (CurrentValues.Any(x => !LastFilterValues.Any(y => x.Item1 == y.Item1 && x.Item2 == y.Item2)) ||
                LastFilterValues.Any(x => !CurrentValues.Any(y => x.Item1 == y.Item1 && x.Item2 == y.Item2)))
            {
                filtersChanged = true;
            }
            //بعدا که حالت کمبو هم اضافه شد اینها اعمال شوند
            if (filtersChanged)
            {
                searchInitialyDone = false;
                ViewEntityArea.AddData(new List <DP_DataView>(), true);
            }
            bool?sarchInitially = null;

            if (AreaInitializer.SourceEditArea.AreaInitializer.SourceRelation != null)
            {
                sarchInitially = AreaInitializer.SourceEditArea.AreaInitializer.SourceRelation.Relationship.SearchInitially;
            }
            if (sarchInitially == null)
            {
                sarchInitially = AreaInitializer.SourceEditArea.SimpleEntity.SearchInitially;
            }

            //if (searchInitialyDone)
            //    sarchInitially = false;
            //if (sarchInitially == true)
            //{
            //    if (RelationshipFilters == null || RelationshipFilters.Count == 0)
            //    {
            //        if (searchInitialyDone)
            //            sarchInitially = false;
            //    }
            //}

            if (sarchInitially == true && searchInitialyDone == false)
            {
                DP_SearchRepository searchItems = new DP_SearchRepository(AreaInitializer.EntityID);
                searchInitialyDone = true;
                SearchConfirmed(searchItems, true, false);
            }
            AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowDialog(View, AreaInitializer.TempEntity.Alias, Enum_WindowSize.Big);
        }
        public void SearchConfirmed(DP_SearchRepository searchItems, bool filterValuesClaculated, bool select)
        {
            //try
            //{
            if (filterValuesClaculated == false)
            {
                CalculateFilterValues();
            }
            if (FilterCalculationError != null)
            {
                AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo("خطا در جستجو", FilterCalculationError.Message, Temp.InfoColor.Red);
                return;
            }
            LastFilterValues.Clear();
            foreach (var item in CurrentValues)
            {
                LastFilterValues.Add(new Tuple <int, string>(item.Item1, item.Item2));
            }

            if (RelationshipFilters != null)
            {
                foreach (var filter in RelationshipFilters)
                {
                    var valueRow = CurrentValues.First(x => x.Item1 == filter.ID);
                    // var value = AgentHelper.GetValueSomeHow(AreaInitializer.SourceEditArea.ChildRelationshipInfo.ParentData, filter.ValueRelationshipTail, filter.ValueColumnID);

                    DP_SearchRepository searchItem = CreateSearchItem(searchItems, filter.SearchRelationshipTail);
                    //var searchColumn = searchItem.Phrases.FirstOrDefault(x => x is SearchProperty && (x as SearchProperty).ColumnID == filter.SearchColumnID) as SearchProperty;
                    //if (searchColumn == null)
                    //{
                    var searchColumn = new SearchProperty()
                    {
                        ColumnID = filter.SearchColumnID
                    };
                    searchItem.Phrases.Add(searchColumn);
                    //}
                    searchColumn.Value = valueRow.Item2;
                }
            }

            var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester();
            //سکوریتی داده اعمال میشود
            DR_SearchViewRequest request = new DR_SearchViewRequest(requester, searchItems);
            //request.EntityID = AreaInitializer.EntityID;

            var reuslt = AgentUICoreMediator.GetAgentUICoreMediator.SendSearchViewRequest(request);

            if (!select)
            {
                ViewEntityArea.AddData(reuslt.ResultDataItems, true);
            }
            else
            {
                if (DataSelected != null)
                {
                    DataSelected(this, new DataSelectedEventArg()
                    {
                        DataItem = reuslt.ResultDataItems
                    });
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo("خطا در جستجو", ex.Message, Temp.InfoColor.Red);
            //}
        }