Example #1
0
        /// <summary>
        /// 获取GridView的数据的排序方式
        /// </summary>
        /// <param name="gv">GridView</param>
        /// <param name="lstSort">排序</param>
        /// <returns></returns>
        protected virtual string GetGridViewOrderString(GridView gv)
        {
            SortList lstSort = new SortList();

            FillOrderBy(gv.ClientID, lstSort);
            StringBuilder sbRet = new StringBuilder();

            foreach (Sort objSort in lstSort)
            {
                string name = objSort.PropertyName;
                foreach (DataControlField col in gv.Columns)
                {
                    if (name == col.SortExpression)
                    {
                        sbRet.Append(col.HeaderText);
                        sbRet.Append("-");
                        sbRet.Append(EnumUnit.GetEnumDescription(objSort.SortType));
                        sbRet.Append(",");
                    }
                }
            }
            if (sbRet.Length > 0)
            {
                sbRet.Remove(sbRet.Length - 1, 1);
            }
            return(sbRet.ToString());
        }
Example #2
0
        /// <summary>
        /// 希尔排序,每次增量不同,相当于先按照增量分组宏观地调整一下大小
        /// 增量递减,直至为1
        ///
        /// </summary>
        /// <param name="sortList"></param>
        public static void ShellSort(SortList sortList)
        {
            //数组长度
            int N = sortList.a.Length;

            //每次递增为increment
            for (int increment = N / 2; increment > 0; increment /= 2)
            {
                //对每一组插入排序,共increment组
                for (int i = 0; i < increment; i++)
                {
                    //针对每一组,每个元素与上个元素相差索引为increment
                    for (int j = i + increment; j < N; j += increment)
                    {
                        int current = sortList.a[j];
                        for (int k = j; k >= increment; k -= increment)
                        {
                            if (sortList.a[k - increment] > current)
                            {
                                sortList.a[k]             = sortList.a[k - increment];
                                sortList.a[k - increment] = current;
                            }
                            else
                            {
                                sortList.a[k] = current;
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private IInfoList GetList(string filter, int pageNumber, int pageSize,
                               SortList sortColumns, string filterExpresion,
                               bool notCalculateAccessDeniedList)
        {
            var methodName = string.Format(CultureInfo.InvariantCulture, "Get{0}List", _currentProcessSystemName);

            try
            {
                var listType = _loadedAssembly.GetType(string.Format(CultureInfo.InvariantCulture, "Dynamic{0}.{0}List", _currentProcessSystemName), true);
                var criteria = new PagedCriteria
                                   {
                                       Filter = filter,
                                       PageNumber = pageNumber,
                                       PageSize = pageSize,
                                       SortColumns = sortColumns,
                                       FilterDefinition = filterExpresion,
                                       NotCalculateAccessDeniedList = notCalculateAccessDeniedList,
                                       LoadAllLocalizations = true,
                                       LoadRichText = true
                                   };

                var result = (IInfoList)MethodCaller.CallFactoryMethod(listType, methodName, criteria);

                return result;
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                        "Global Search Exception : AppDomain/ problem on Getting ElementsList {0} process  /Filter : {1}/PageNumber : {2}/PageSize {3}/FilterExpresion : {4}/",
                        _currentProcessSystemName, filter, pageNumber, pageSize, filterExpresion), ex);
            }
        }
Example #4
0
        public double MeasureDiversity(SortList <AIPlayer> individuals)
        {
            int outputSize = individuals.Get(0).neuralNetwork.GetNumberOfOutputs();

            double diversity = 0;

            for (int j = 0; j < runs; j++)
            {
                double[] randInputs = new double[individuals.Get(0).neuralNetwork.GetNumberOfInputs()];
                for (int i = 0; i < randInputs.Length; i++)
                {
                    randInputs[i] = RandomNum.RandomDouble();
                }

                //We use a dictionary to keep track of the size of each specie we encounter
                Dictionary <int, int> counters = new Dictionary <int, int>();
                for (int l = 0; l < individuals.Count; l++)
                {
                    int specie = CalcSpecie(individuals.Get(l).GetOutputs(randInputs));
                    if (counters.Keys.Contains(specie))
                    {
                        counters[specie]++;
                    }
                    else
                    {
                        counters.Add(specie, 1);
                    }
                }

                //Use simpsons diversity
                diversity += CalcSimpsonsDiversity(counters);
            }

            return(diversity / runs);
        }
        public void MergesortFourElements()
        {
            SortList list = new SortList(4);

            Mergesort.mergesort(list);
            Assert.IsTrue(list.isSorted());
        }
Example #6
0
        void InitSortInfo()
        {
            var columns = Columns.ToArray();

            foreach (var column in columns)
            {
                column.SortMethod = BetterListViewSortMethod.Auto;
                column.Style      = false && column.Tag == null ? BetterListViewColumnHeaderStyle.Unsortable : BetterListViewColumnHeaderStyle.Sortable;
            }

            var index = Configuration.QueryViewConfiguration.Instance.SortInfo.Split('|');
            var list  = new BetterListViewSortList();

            index.ForEach(s =>
            {
                var arg = s.Split(',');
                var idx = columns.FindIndex(x => x.Tag as string == arg[0]);
                if (idx >= 0 && idx < Columns.Count)
                {
                    list.Add(idx, arg[1] == "0");
                }
            });
            SortList     = list;
            ItemComparer = new QueryResultItemSorter();

            AfterItemSort += (s, e) =>
            {
                if (!e.ColumnClicked)
                {
                    return;
                }
                Configuration.QueryViewConfiguration.Instance.SortInfo = SortList.Select(x => Columns[x.ColumnIndex].Tag?.ToString() + "," + (x.OrderAscending ? "0" : "1")).JoinAsString("|");
            };
        }
Example #7
0
        private static void Main(string[] args)
        {
            // canonical

            var context = new Context(new ConcreteStrategyA());

            context.AlgorithmInterface();

            context = new Context(new ConcreteStrategyB());
            context.AlgorithmInterface();

            // live
            var sortList = new SortList();

            sortList.Add(10);
            sortList.Add(2);
            sortList.Add(4);
            sortList.Add(5);
            sortList.Add(1);

            sortList.SetStrategy(new BubbleSortStrategy());
            sortList.SetStrategy(new QuickSortStrategy());

            sortList.Sort();
        }
Example #8
0
        /// <summary>
        /// 合并两个公告list
        /// </summary>
        /// <param name="bulletin1"></param>
        /// <param name="bulletin2"></param>
        /// <returns></returns>
        public static List <Bulletin> CombineBulletin(List <Bulletin> bulletin1, List <Bulletin> bulletin2)
        {
            List <Bulletin> retBulletin  = new List <Bulletin>();
            List <Bulletin> BulletinList = new List <Bulletin>();

            BulletinList.AddRange(bulletin1);
            BulletinList.AddRange(bulletin2);
            foreach (Bulletin bulletin in BulletinList)
            {
                bool contins = false;
                foreach (Bulletin retb in retBulletin)
                {
                    if (retb.BulletinID == bulletin.BulletinID)
                    {
                        contins = true;
                        break;
                    }
                }
                if (!contins)
                {
                    retBulletin.Add(bulletin);
                }
            }
            if (retBulletin.Count > 0)
            {
                SortList <Bulletin> sortList =
                    new SortList <Bulletin>(retBulletin[0], "PublishTime", ReverserInfo.Direction.DESC);
                retBulletin.Sort(sortList);
            }

            return(retBulletin);
        }
        public void MergesortHundredElements()
        {
            SortList list = new SortList(100);

            Mergesort.mergesort(list);
            Assert.IsTrue(list.isSorted());
        }
Example #10
0
        /// <summary>
        /// 对实体集合进行排序
        /// </summary>
        /// <param name="lst">实体集合</param>
        /// <param name="lstSort">排序方式</param>
        public static void SortList(IList lst, SortList lstSort)
        {
            List <SortCompartItem> lstCompareItem = null;

            if (lst == null)
            {
                return;
            }
            if (lst.Count <= 0)
            {
                return;
            }
            lstCompareItem = GetSortComparts(lst[0], lstSort);
            if (lstCompareItem.Count > 0 && lst.Count >= 2)
            {
                //用冒泡法对集合进行排序
                for (int i = 0; i < lst.Count - 1; i++)
                {
                    for (int k = i + 1; k < lst.Count; k++)
                    {
                        if (!IsAccordCompare(lst[i], lst[k], lstCompareItem))//如果对比不通过,就互换值
                        {
                            object tmp = lst[i];
                            lst[i] = lst[k];
                            lst[k] = tmp;
                        }
                    }
                }
            }
        }
Example #11
0
        protected internal void PositionChanged(int X, int Y, int DeltaX, int DeltaY)
        {
            int num1;

            base.FindFirst(Y, out num1, this.lineComparer);
            if (num1 >= 0)
            {
                bool flag1 = false;
                for (int num2 = num1; num2 < this.Count; num2++)
                {
                    BookMark mark1  = (BookMark)this[num2];
                    Point    point1 = new Point(mark1.Char, mark1.Line);
                    if (SortList.UpdatePos(X, Y, DeltaX, DeltaY, ref point1, true))
                    {
                        if (mark1.Index != 0x7fffffff)
                        {
                            mark1.Char = point1.X;
                        }
                        mark1.Line = point1.Y;
                        flag1      = true;
                    }
                }
                if (flag1)
                {
                    this.Sort(this.bookMarkComparer);
                }
            }
        }
Example #12
0
        /// <summary>
        /// 填充排序
        /// </summary>
        /// <param name="lstSort"></param>
        protected virtual void FillOrderBy(string name, SortList lstSort)
        {
            string str = ViewState[name + SortViewStateID] as string;

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            string[] sortItems = str.Split(',');
            foreach (string item in sortItems)
            {
                Sort     objSort = new Sort();
                string[] iPart   = item.Trim().Split(' ');
                if (iPart.Length < 1)
                {
                    continue;
                }
                objSort.PropertyName = iPart[0];
                if (iPart.Length < 2)
                {
                    objSort.SortType = SortType.ASC;
                }
                else
                {
                    objSort.SortType = (iPart[1].ToLower() == "asc") ? SortType.ASC : SortType.DESC;
                }
                lstSort.Add(objSort);
            }
        }
Example #13
0
        public void QuicksortFourElements()
        {
            SortList list = new SortList(4);

            Quicksort.quicksort(list);
            Assert.IsTrue(list.isSorted());
        }
Example #14
0
 public Population(Simulation simulation, int generation)
 {
     Simulation  = simulation;
     Generation  = generation;
     individuals = new SortList <AIPlayer>();
     InitializeRandomPopulation();
 }
Example #15
0
        public void QuicksortHundredElements()
        {
            SortList list = new SortList(100);

            Quicksort.quicksort(list);
            Assert.IsTrue(list.isSorted());
        }
Example #16
0
        public void PartitionThreeElements()
        {
            SortList list = new SortList(2, 3, 1);

            Assert.AreEqual(1, Quicksort.partition(list, 0, 0, 2));
            Assert.IsTrue(list.isSorted());
        }
Example #17
0
 private void GenerateSpecified_Click(object sender, EventArgs e)
 {
     if (SortEnabled.Checked)
     {
         if (AddSpecified(SortListBox))
         {
             string order;
             if (random.Next(0, 2) == 1)
             {
                 order = "昇順";
             }
             else
             {
                 order = "降順";
             }
             SpecifiedResult.Text = "ソート:" + Convert.ToString((string)SortList[random.Next(0, SortList.Count)]) + " 行:" + random.Next(1, 4) + " 列:" + random.Next(1, 6) + " ページ:" + random.Next(1, 10) + "(ない場合は最後のページ) " + order;
             SortList.Clear();
         }
     }
     if (UseSpecified.Checked)
     {
         if (AddSpecified(SpecifiedListBox))
         {
             SpecifiedResult.Text = Convert.ToString((string)SortList[random.Next(0, SortList.Count)]);
             SortList.Clear();
         }
     }
 }
Example #18
0
        public void QuicksortReverseSortedInput()
        {
            SortList list = new SortList(100, true, true);

            Quicksort.quicksort(list);
            Assert.IsTrue(list.isSorted());
        }
Example #19
0
        public Boolean AddSpecified(CheckedListBox List)
        {
            int cnt = 0;

            for (int i = 0; i <= (List.Items.Count - 1); i++)
            {
                if (List.GetItemChecked(i))
                {
                    cnt = (i + 1);
                }
            }
            if (cnt >= 2)
            {
                for (i = 0; i <= (List.Items.Count - 1); i++)
                {
                    if (List.GetItemChecked(i))
                    {
                        SortList.Add(List.Items[i].ToString());
                    }
                }
                return(true);
            }
            else
            {
                MessageBox.Show("2つ以上の選択が必要", "Error");
                return(false);
            }
        }
Example #20
0
        public void QuicksortALotOfElements()
        {
            SortList list = new SortList(317);

            Quicksort.quicksort(list);
            Assert.IsTrue(list.isSorted());
        }
        public void SortList_Test_Int()
        {
            // Arrange
            SortList   sortList = new SortList();
            List <int> expected;
            List <int> actual;

            // Act
            sortList.intList = new List <int>()
            {
                5, 2, 3, 1, 4
            };
            expected = new List <int>()
            {
                1, 2, 3, 4, 5
            };

            //This sort uses intList to sort for this test project!
            actual = sortList.Sort();

            // Assert
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
            Assert.AreEqual(expected[3], actual[3]);
            Assert.AreEqual(expected[4], actual[4]);
        }
Example #22
0
        public void PartitionNineElementsLowPivot()
        {
            SortList list = new SortList(9, 5, 3, 1, 2, 6, 7, 8, 4);

            Assert.AreEqual(0, Quicksort.partition(list, 3, 0, 8)); // Partition on the 1
            Assert.AreEqual(1, list[0]);
            Assert.IsTrue(list.isPartitioned(0));
        }
Example #23
0
        public void PartitionNineElements()
        {
            SortList list = new SortList(9, 5, 3, 1, 2, 6, 7, 8, 4);

            Assert.AreEqual(4, Quicksort.partition(list, 1, 0, 8)); // Partition on the 5
            Assert.AreEqual(5, list[4]);
            Assert.IsTrue(list.isPartitioned(4));
        }
Example #24
0
        public void QuicksortNoDirectAccess()
        {
            SortList list = new SortList(100);

            Quicksort.quicksort(list);
            Assert.AreEqual(0, list.Gets, "Quicksort is an in-place algorithm, use only compare() and swap(). The [] getter is reserved for mergesort.");
            Assert.AreEqual(0, list.Sets, "Quicksort is an in-place algorithm, use only compare() and swap(). The [] setter is reserved for mergesort.");
        }
Example #25
0
        public void PartitionNineElementsHighPivot()
        {
            SortList list = new SortList(9, 5, 3, 1, 2, 6, 7, 8, 4);

            Assert.AreEqual(8, Quicksort.partition(list, 0, 0, 8)); // Partition on the 9
            Assert.AreEqual(9, list[8]);
            Assert.IsTrue(list.isPartitioned(8));
        }
Example #26
0
        public void QuicksortReverseSortedInputEfficient()
        {
            SortList list = new SortList(100, true, true);

            Quicksort.quicksort(list);
            Assert.LessOrEqual(list.Comparisons, 5000);
            Assert.LessOrEqual(list.Swaps, 200);
        }
        public void MergesortEfficiently()
        {
            SortList list = new SortList(100);

            Mergesort.mergesort(list);
            Assert.LessOrEqual(list.Gets, 700);
            Assert.LessOrEqual(list.Sets, 700);
        }
Example #28
0
 protected internal override bool ShouldDelete(BookMark bm, Rectangle Rect)
 {
     if (SortList.InsideBlock(new Point(0, bm.Line), Rect))
     {
         return(SortList.InsideBlock(new Point(0x7fffffff, bm.Line), Rect));
     }
     return(false);
 }
Example #29
0
        /// <summary>
        /// 获取全部查询的条件
        /// </summary>
        /// <param name="list">参数列表</param>
        /// <param name="scopeList">范围查找的集合</param>
        /// <returns></returns>
        protected string GetSelectPageContant(ParamList list, ScopeList scopeList)
        {
            SelectCondition condition = new SelectCondition(CurEntityInfo.DBInfo);

            condition.Oper = this._oper;
            condition.Tables.Append(CurEntityInfo.DBInfo.CurrentDbAdapter.FormatTableName(CurEntityInfo.TableName));
            condition.SqlParams.Append(GetSelectParams(scopeList));
            if (scopeList.UseCache)
            {
                condition.CacheTables = CurEntityInfo.DBInfo.QueryCache.CreateMap(CurEntityInfo.TableName);
            }
            condition.Condition.Append("1=1");
            foreach (EntityPropertyInfo ep in CurEntityInfo.PrimaryProperty)
            {
                condition.PrimaryKey.Add(CurEntityInfo.DBInfo.CurrentDbAdapter.FormatParam(ep.ParamName));
            }
            string conditionWhere = "";

            SortList sortList = scopeList.OrderBy;


            if (scopeList != null)
            {
                condition.Condition.Append(DataAccessCommon.FillCondition(CurEntityInfo, list, scopeList));
            }

            if (conditionWhere.Length > 0)
            {
                condition.Condition.Append(conditionWhere);
            }
            //排序方式
            if (sortList != null && sortList.Count > 0)
            {
                string orderBy = GetSortCondition(sortList);
                if (orderBy != "")
                {
                    if (condition.Orders.Length > 0)
                    {
                        condition.Orders.Append("," + orderBy);
                    }
                    else
                    {
                        condition.Orders.Append(orderBy);
                    }
                }
            }
            condition.PageContent = scopeList.PageContent;
            //throw new Exception("");
            condition.DbParamList = list;

            //if (scopeList.UseCache)
            //{

            //    cachetables[CurEntityInfo.DBInfo.CurrentDbAdapter.FormatTableName(CurEntityInfo.TableName)]=true;
            //}

            return(condition.GetSql(true));
        }
Example #30
0
        public void QuicksortSortedInput()
        {
            SortList list = new SortList(100, true);

            Quicksort.quicksort(list);
            Assert.IsTrue(list.isSorted());
            Assert.LessOrEqual(list.Comparisons, 5000);
            Assert.LessOrEqual(list.Swaps, 200);
        }
Example #31
0
        public void Merge(SortList <AIPlayer> individuals, List <AIPlayer> offspring, Simulation simulation)
        {
            //If having only a single parent, replace it if better
            foreach (AIPlayer o in offspring)
            {
                if (o.Parent2 == null)
                {
                    for (int i = 0; i < individuals.Count; i++)
                    {
                        if (individuals.Get(i) == o.Parent1)
                        {
                            if (o.GetFitness() > individuals.Get(i).GetFitness())
                            {
                                individuals.Remove(individuals.Get(i));
                                individuals.Add(o);
                            }
                        }
                    }
                }
                else
                {
                    //The offspring were made from 2 parents
                    //If offspring is better than both parents, replace both parents and add a random AIPlayer
                    bool betterThanParent1 = false;
                    bool betterThanParent2 = false;
                    for (int i = 0; i < individuals.Count; i++)
                    {
                        if (individuals.Get(i) == o.Parent1 && individuals.Get(i).GetFitness() < o.Parent1.GetFitness())
                        {
                            betterThanParent1 = true;
                        }
                        if (individuals.Get(i) == o.Parent2 && individuals.Get(i).GetFitness() < o.Parent2.GetFitness())
                        {
                            betterThanParent2 = true;
                        }
                    }

                    //if better than both parents, remove both parents and add a random immigrant
                    if (betterThanParent1 && betterThanParent2)
                    {
                        individuals.Remove(o.Parent1);
                        individuals.Remove(o.Parent2);
                        individuals.Add(o);
                        AIPlayer randomImmagrant = new AIPlayer(simulation.NeuralNetworkMaker);
                        randomImmagrant.CalcFitness(simulation.Game);
                        individuals.Add(randomImmagrant);
                    }
                }
            }
            individuals.Crop(individuals.Count / 2);
            while (individuals.Count < simulation.PopulationSize)
            {
                AIPlayer randomImmagrant = new AIPlayer(simulation.NeuralNetworkMaker);
                randomImmagrant.CalcFitness(simulation.Game);
                individuals.Add(randomImmagrant);
            }
        }
Example #32
0
    public static void TestCount()
    {
      for (var i = 0; i < 100; i++)
      {
        var x = MonteCarlo.Unordered().ToList();

        var ordered = new SortList<int, Int32Order>(x);

        Console.WriteLine("   {0}", x.ToCSV(100));
        Console.WriteLine(" = {0}", ordered);
        Console.WriteLine();

        Assert.That(ordered.Count, Is.EqualTo(x.Count));
      }
    }
Example #33
0
    public static void TestIndexer()
    {
      for (var i = 0; i < 100; i++)
      {
        var x = MonteCarlo.Unordered().ToList();

        var ordered = new SortList<int, Int32Order>(x);

        Console.WriteLine("   {0}", x.ToCSV(100));
        Console.WriteLine(" = {0}", ordered);
        Console.WriteLine();

        var xSorted = x.OrderBy(n => n).ToArray();
        for (var j = 0; j < x.Count; j++)
          Assert.That(ordered[j], Is.EqualTo(xSorted[j]));
      }
    }
Example #34
0
        void grid_Grouping(object sender, GridViewGroupingEventArgs e)
        {
            var snd = sender as RadGridView;

            var pageableList = _grid.DataContext as IPageableList;
            var columnGroupDescriptor = e.GroupDescriptor as ColumnGroupDescriptor;
            if (columnGroupDescriptor == null || pageableList == null)
                return;

            var column = columnGroupDescriptor.Column;

            if (((IHasColumns)_grid.DataContext).Columns != null)
            {
                if (
                    ((IHasColumns)_grid.DataContext).Columns.FirstOrDefault(
                        x =>
                        string.Format(CultureInfo.InvariantCulture, "{0}{1}", string.IsNullOrEmpty(x.Prefix) ? string.Empty : x.Prefix + ".", x.ColumnName) == column.UniqueName && x.IsGroupable)
                    == null)
                {
                    e.Cancel = true;
                    return;
                }
            }

            RefreshGroupIndexes(columnGroupDescriptor, e);

            if (e.Action == GroupingEventAction.Place)
            {
                //add new sort desriptor for new grouped column and place it in the certain order among other descriptors
                var sortDescriptors = pageableList.SortDescriptors;
                if (sortDescriptors != null && e.Index.HasValue)
                {
                    var currentSorting = sortDescriptors.FirstOrDefault(x => x.ColumnName == column.UniqueName);

                    if (currentSorting != null)
                        sortDescriptors.Remove(currentSorting);
                    sortDescriptors.Insert(e.Index.Value, new SortDescriptor(column.UniqueName, SortDirection.Ascending, true));
                }
                else
                    sortDescriptors = new SortList { new SortDescriptor(column.UniqueName, SortDirection.Ascending, true) };

                if (_grid.GroupCount == 0 || (e.Index.HasValue && e.Index.Value == 0))
                {
                    pageableList.Refresh(columnGroupDescriptor.Column.UniqueName, sortDescriptors);
                    columnGroupDescriptor.Column.AggregateFunctions.Clear();
                    columnGroupDescriptor.Column.AggregateFunctions.Add(new CountFunction { Caption = "Total:", FunctionName = "GroupFunction" });
                }
                else
                    pageableList.Refresh(sortDescriptors);

                if (snd != null)
                    snd.Columns[columnGroupDescriptor.Column.UniqueName].IsVisible = false;
            }
            else if (e.Action == GroupingEventAction.Remove)
            {
                //clear sort descriptor for column removed from group panel
                if (pageableList.SortDescriptors != null && pageableList.SortDescriptors.Count > 0)
                {
                    var currentSorting = pageableList.SortDescriptors.FirstOrDefault(x => x.ColumnName == column.UniqueName);

                    if (currentSorting != null)
                        pageableList.SortDescriptors.Remove(currentSorting);
                }

                if (_grid.GroupCount == 1)
                {
                    columnGroupDescriptor.Column.AggregateFunctions.Clear();
                    pageableList.Refresh(string.Empty);
                }
                else
                {
                    if (columnGroupDescriptor.Column.UniqueName.EndsWith(pageableList.GroupColumn, StringComparison.Ordinal))
                    {
                        columnGroupDescriptor.Column.AggregateFunctions.Clear();

                        var groupDescriptor = _grid.GroupDescriptors[1] as ColumnGroupDescriptor;
                        if (groupDescriptor != null)
                        {
                            groupDescriptor.Column.AggregateFunctions.Clear();

                            pageableList.Refresh(groupDescriptor.Column.UniqueName);
                            groupDescriptor.Column.AggregateFunctions.Add(new CountFunction { Caption = "Total:", FunctionName = "GroupFunction" });
                        }
                    }
                    else
                        pageableList.Refresh(pageableList.GroupColumn);
                }

                if (snd != null)
                    snd.Columns[columnGroupDescriptor.Column.UniqueName].IsVisible = true;
            }
            else if (e.Action == GroupingEventAction.Move)
            {
                if (pageableList.SortDescriptors != null && pageableList.SortDescriptors.Count > 0)
                {
                    var currentSorting = pageableList.SortDescriptors.FirstOrDefault(x => x.ColumnName == column.UniqueName);

                    if (currentSorting != null && e.Index.HasValue)
                    {
                        var currentSortingCopy = new SortDescriptor(currentSorting.ColumnName, currentSorting.Direction, currentSorting.IsGrouped);
                        pageableList.SortDescriptors.Remove(currentSorting);
                        pageableList.SortDescriptors.Insert(e.Index.Value, currentSortingCopy);
                    }
                }

                if (e.Index.HasValue)
                {
                    if (e.Index.Value == 0)
                        pageableList.Refresh(column.UniqueName);
                    else if (pageableList.SortDescriptors != null)
                        pageableList.Refresh(pageableList.SortDescriptors[0].ColumnName);
                }
                else if (pageableList.SortDescriptors != null && pageableList.SortDescriptors.Count > 0)
                    pageableList.Refresh(pageableList.CurrentPageNumber);
            }
            else if (e.Action == GroupingEventAction.Sort)
            {
                if (e.GroupDescriptor.SortDirection == ListSortDirection.Descending)
                    e.GroupDescriptor.SortDirection = null;

                if (pageableList.SortDescriptors != null)
                {
                    if (pageableList.SortDescriptors.Count > 0)
                    {
                        var currentSorting = pageableList.SortDescriptors.FirstOrDefault(x => x.ColumnName == column.UniqueName);

                        if (currentSorting != null)
                        {
                            switch (currentSorting.Direction)
                            {
                                case SortDirection.Ascending:
                                    {
                                        var currentSortingIndex = pageableList.SortDescriptors.IndexOf(currentSorting);
                                        pageableList.SortDescriptors.RemoveAt(currentSortingIndex);
                                        pageableList.SortDescriptors.Insert(currentSortingIndex, new SortDescriptor(currentSorting.ColumnName, SortDirection.Descending, true));
                                    }

                                    break;
                                case SortDirection.Descending:
                                    {
                                        var currentSortingIndex = pageableList.SortDescriptors.IndexOf(currentSorting);
                                        pageableList.SortDescriptors.RemoveAt(currentSortingIndex);
                                        pageableList.SortDescriptors.Insert(currentSortingIndex, new SortDescriptor(currentSorting.ColumnName, SortDirection.Ascending, true));
                                    }

                                    break;
                            }
                        }
                    }
                    else
                        pageableList.SortDescriptors.Add(new SortDescriptor(column.UniqueName, SortDirection.Ascending, true));

                    pageableList.Refresh(pageableList.CurrentPageNumber);
                }
                else
                    pageableList.Refresh(new SortList { new SortDescriptor(column.UniqueName, SortDirection.Ascending, true) });
            }
        }
Example #35
0
        private void LoadReferenceItems(
            string processName, 
            string referenceField, 
            string filterExpression, 
            EditorCreatedEventArgs e, 
            string displayField)
        {
            var sortDescriptors = new SortList {new SortDescriptor(displayField, SortDirection.Ascending)};

            var vm = DataContext as SearchListViewModel;
            if (vm == null)
            {
                return;
            }

            vm.TheDynamicTypeManager.Value.BeginGetCrossReferenceList(
                processName,
                referenceField,
                (o2, result2) =>
                    {
                        if (result2.Error == null)
                        {
                            var infoList = result2.Object;
                            var comboBox = e.Editor.FindChildByType<RadComboBox>();

                            if (comboBox != null)
                            {
                                dataFilter.Tag = true;
                                comboBox.ItemsSource = infoList;
                                comboBox.SelectedValuePath = "Id";

                                Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                                    handler => comboBox.SelectionChanged += handler, handler => comboBox.SelectionChanged -= handler)
                                          .SubscribeWeakly(this, (target, handler) => target.ComboBoxOnSelectionChanged(handler.Sender, handler.EventArgs));

                                var itemType = vm.TheDynamicTypeManager.Value.GetCrossReferenceItemType(processName, referenceField);
                                comboBox.ItemTemplate = CreateTemplateForReferenceField(itemType, displayField);
                                TextSearch.SetTextPath(comboBox, displayField);

                                var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                                if (filterViewModel != null && filterViewModel.Descriptor != null)
                                {
                                    var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                                    if (placeholder != null)
                                        comboBox.SelectedValue = placeholder.Id;
                                }

                                dataFilter.Tag = null;
                            }
                        }
                        else
                            vm.ThePopupFactory.Value.NotifyFailure(result2.Error);
                    },
                sortDescriptors,
                string.Empty,
                int.MaxValue,
                0,
                filterExpression);
        }
        public void SortCommand_WhenExecuted_SortsEventsList()
        {
            // Arrange.
            var windowManager = Mock.Create<IShell>(Behavior.Loose);
            var list = new InfoListBase { TotalRowCount = 100, PageNumber = 0 };
            PagedCriteria criteria = null;
            var dtm = Mock.Create<IDynamicTypeManager>(Behavior.Loose);
            Mock.Arrange(() => dtm.GetListAsync<IInfoList>(Arg.IsAny<PagedCriteria>()))
                .DoInstead<PagedCriteria>(c => criteria = c)
                .Returns(TaskEx.FromResult<IInfoList>(list));

            var popupFactory = Mock.Create<PopupFactory>(Behavior.Loose);

            var viewModel = new IntegrationEventListViewModel
                            {
                                WindowManager = new Lazy<IShell>(() => windowManager),
                                TheDynamicTypeManager = new Lazy<IDynamicTypeManager>(() => dtm),
                                ThePopupFactory = new Lazy<PopupFactory>(() => popupFactory)
                            };

            // Act.
            var sortList = new SortList();
            viewModel.SortCommand.Execute(sortList);

            // Assert.
            Assert.IsNotNull(criteria);
            Assert.AreEqual(Constants.IntegrationEventProcessName, criteria.ProcessName);
            Assert.AreEqual(0, criteria.PageNumber);
            Assert.AreEqual(25, criteria.PageSize);
            Assert.IsTrue(string.IsNullOrEmpty(criteria.Filter));
            Assert.IsTrue(string.IsNullOrEmpty(criteria.FilterDefinition));
            Assert.IsTrue(criteria.LimitResultColumns);
            Assert.AreEqual(sortList, criteria.SortColumns);
            Assert.IsTrue(criteria.ResultColumns.Contains("Id"));
            Assert.IsTrue(criteria.ResultColumns.Contains("Process"));
            Assert.IsTrue(criteria.ResultColumns.Contains("Service"));
            Assert.IsTrue(criteria.ResultColumns.Contains("Username"));
            Assert.IsTrue(criteria.ResultColumns.Contains("TimeCreated"));
            Assert.IsTrue(criteria.ResultColumns.Contains("IsSuccessful"));

            Assert.AreEqual(100, viewModel.TotalRowCount);
            Assert.AreEqual(0, viewModel.PageIndex);
            Assert.AreSame(list, viewModel.Model);
            Assert.AreSame(sortList, viewModel.SortDescriptors);
        }
Example #37
0
        public static void SetGrouping(SortList descriptor)
        {
            if (_grid == null || _grid.Target == null || descriptor == null)
            {
                return;
            }

            var grid = (GridViewDataControl)_grid.Target;

            lock (grid)
            {
                grid.GroupDescriptors.Clear();
                foreach (var sortUnit in descriptor.Where(x => x.IsGrouped))
                {
                    var column = grid.Columns.OfType<GridViewDataColumn>().FirstOrDefault(x => x.UniqueName == sortUnit.ColumnName);
                    if (column == null)
                    {
                        continue;
                    }

                    var columnGroupDescriptor = new ColumnGroupDescriptor
                        {
                            Column = column,
                            DisplayContent = column.Header
                        };

                    if (!grid.GroupDescriptors.Contains(columnGroupDescriptor))
                    {
                        grid.GroupDescriptors.Add(columnGroupDescriptor);
                        SetColumnVisibility(column.UniqueName, false);
                    }
                }
            }
        }
Example #38
0
        public async Task<IHttpActionResult> Search(string process, int page, string searchText = null, int? layout = 0, int? userFilter = 0, string udpFilterOptions = null)
        {
            try
            {
                var listType = DynamicTypeManager.GetListType(process);
                if (listType == null || listType.BaseType == null)
                {
                    Exception exception = new Exception("Process " + process + " not found.");
                    Logger.Log(LogSeverity.Error, this.GetType().ToString(), exception);

                    return InternalServerError(exception);
                }

                var itemType = listType.BaseType.GetGenericArguments()[1];

                int pageSize = 20;
                FilterList filters = new FilterList();
                //int? layout = 0;

                var userLayoutFilter = GetLayoutFilter(process);
                var filterList = new FilterList { userLayoutFilter };
                IList<GridColumn> columns = this.GetLayoutColumns(filterList, layout);

                for (int index = columns.Count - 1; index >= 0; index--)
                {
                    var c = columns[index];
                    var prop = GetProperty(c.SystemName, itemType);
                    if (prop == null) // property not found - normal probably has been removed from the base class.
                    {
                        columns.RemoveAt(index);
                        continue;
                    }
                    c.Index = index;

                    var display = (from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault() as DisplayAttribute;
                    c.Header = (display == null) ? c.Header : display.GetName();
                }

                var sortList = new SortList(columns.Where(c => c.SortLevel != null).Select(c => new SortDescriptor(c.SystemName, c.SortDirection)).ToList());
                string filter = null;

                if (userFilter != null && userFilter > 0)
                {
                    FilterDescriptor procFilter = GetFilterFilter(process);
                    FilterList localFilterList = new FilterList { procFilter };
                    IFilterList<IFilterInfo> ll = this.DynamicTypeManager.GetList<IFilterList<IFilterInfo>>(Constants.FilterProcessName, filter, 0, int.MaxValue, null, localFilterList);

                    if (ll != null)
                    {
                        var filterResult = ll.FirstOrDefault(x => x.Id == userFilter);

                        if (filterResult != null)
                        {
                            //filterName += " - " + filterResult.Name;

                            IFilterDescriptor filterDescriptor = FilterDescriptor.FromJSON(filterResult.FilterDefinition);
                            ICollection<IFilterDescriptor> udpFilters = filterDescriptor.GetAllUdpDescriptors();

                            if (udpFilters != null && udpFilters.Count != 0)
                            {
                                string[] tempUdp = JsonConvert.DeserializeObject<string[]>(udpFilterOptions);

                                IList<string> udpUserOptionsList = udpFilterOptions == null ? new List<string>() : tempUdp.ToList();

                                int i = 0;
                                foreach (var filterValue in udpFilters.Select(udpFilter => udpFilter.Value as FilterValue))
                                {
                                    if (filterValue != null)
                                    {
                                        if (filterValue.SystemName == "CurrentStateGuid")
                                        {
                                            if (udpUserOptionsList.Count > i)
                                            {
                                                if (udpUserOptionsList[i] == "null")
                                                {
                                                    filterValue.ProvidedValue = null;
                                                }
                                                else
                                                {
                                                    var editObject = this.DynamicTypeManager.GetEditableRoot<IEditableRoot>(Constants.StateProcessName, SafeTypeConverter.Convert<int>(udpUserOptionsList[i]));
                                                    filterValue.ProvidedValue = editObject.GetPropertyByName("Guid").GetValue(editObject);
                                                }
                                            }
                                            else
                                            {
                                                filterValue.ProvidedValue = filterValue.DefaultValue;
                                            }
                                        }
                                        else
                                        {
                                            filterValue.ProvidedValue = udpUserOptionsList.Count > i ? (udpUserOptionsList[i] == "null" ? null : udpUserOptionsList[i]) : filterValue.DefaultValue;
                                        }
                                    }
                                    i++;
                                }
                            }

                            filters.Add(filterDescriptor);
                            //filters = new FilterList { filterDescriptor };
                        }
                    }
                }

                AddMandatoryFilter(filters, process);

                // TODO: AS: switch to async (when available)
                IInfoList itemsList = this.DynamicTypeManager.GetList<IInfoList>(process, searchText, page, pageSize, sortList, filters);
                if (itemsList == null)
                {
                    SearchResult res = new SearchResult(0, 0);
                    return await Task.FromResult<IHttpActionResult>(Ok(res));
                }

                int totalRowsCount = (int)itemsList.GetType().GetProperty("TotalRowCount").GetValue(itemsList);
                int pageNumber = (int)itemsList.GetType().GetProperty("PageNumber").GetValue(itemsList);

                SearchResult result = new SearchResult(pageNumber, totalRowsCount);
                result.ProcessDisplayName = itemType.GetCustomAttribute<ProcessInfoAttribute>().DisplayName;

                // prepare columns metadata
                int columnIndex = 0;
                foreach (GridColumn gridColumn in columns)
                {
                    ColumnMetadata columnMeta = new ColumnMetadata(gridColumn);
                    columnMeta.Position = columnIndex++;

                    PropertyInfo property = itemType.GetPropertyByName(columnMeta.SystemName);
                    if (property != null)
                    {
                        columnMeta.ColumnType = property.GetFieldType().ToString();
                    }

                    result.Metadata.Columns.Add(columnMeta);

                    // add hidden URL column for File field
                    if (columnMeta.ColumnType == ColumnTypes.File.ToString())
                    {
                        result.Metadata.Columns.Add(new ColumnMetadata { Header = columnMeta.Header + " Url", SystemName = columnMeta.SystemName + Constants.Url, Position = columnIndex++ });
                    }
                }

                // add id column if it is not in Layout columns (we need it at least for referencing items).
                var idColumn = result.Metadata.Columns.FirstOrDefault(c => c.SystemName == Constants.IdColumnName);
                if (idColumn == null)
                {
                    result.Metadata.Columns.Add(new ColumnMetadata { Header = "Id", SystemName = Constants.IdColumnName, Position = columnIndex++ });
                }

                foreach (IInfoClass infoClass in itemsList)
                {
                    Dictionary<string, string> blockedColumns = ((string)infoClass.GetType().GetProperty("AccessDeniedProperties").GetValue(infoClass)).Split('|').ToDictionary(k => k);

                    SearchItem newItem = new SearchItem();
                    newItem.BlockedColumns = result.Metadata.Columns.Where(mc => blockedColumns.Keys.Any(k => mc.SystemName == k)).Select(mc => mc.Position).ToArray();
                    newItem.Values = new string[result.Metadata.Columns.Count];
                    newItem.Id = infoClass.Id;
                    result.Items.Add(newItem);

                    var properties = infoClass.GetAllPropertiesForInstance();

                    for (int colIndex = 0; colIndex < result.Metadata.Columns.Count; colIndex++)
                    {
                        var prop = itemType.GetPropertyByFullName(result.Metadata.Columns[colIndex].SystemName);
                        if (prop == null)
                        {
                            continue;
                        }

                        if (blockedColumns.ContainsKey(prop.Name))
                        {
                            continue;
                        }

                        var itemInfo = properties[prop];

                        var value = prop.GetValue(itemInfo);

                        var colType = result.Metadata.Columns[colIndex].ColumnType;

                        newItem.Values[colIndex] = FieldValueExtractor.GetPropertyStringValue(prop, value, colType);
                    }
                }

                var editableRootType = DynamicTypeManager.GetEditableRootType(process);
                result.CanAdd = BusinessRules.HasPermission(AuthorizationActions.CreateObject, editableRootType);

                return await Task.FromResult<IHttpActionResult>(this.Ok(result));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #39
0
        private void Sorting(object sender, GridViewSortingEventArgs e)
        {
            e.Cancel = true;

            var column = _grid.Columns[e.Column.UniqueName];
            if (column == null) return;

            var pageableList = _grid.DataContext as IPageableList;
            if (pageableList == null) return;

            //initial sorting state is Ascending
            var direction = SortDirection.Ascending;

            //if there is no current sorting, then it will be created
            if (pageableList.SortDescriptors != null && pageableList.SortDescriptors.Count > 0)
            {
                //will be null if current column is not sorted
                var currentSorting = pageableList.SortDescriptors.FirstOrDefault(x => x.ColumnName == column.UniqueName);

                //current column is already sorted
                if (currentSorting != null)
                {
                    //sorting state is being changed (from Ascending to Descending, 
                    //from Descending to None)
                    switch (currentSorting.Direction)
                    {
                        case SortDirection.Ascending:
                            direction = SortDirection.Descending;
                            break;
                        case SortDirection.Descending:
                            direction = SortDirection.Ascending;
                            break;
                    }
                }

                if (_isShiftKeyPressed)
                {
                    if (currentSorting != null)
                    {
                        if (direction != SortDirection.None)
                        {
                            var currentSortingIndex = pageableList.SortDescriptors.IndexOf(currentSorting);
                            pageableList.SortDescriptors.RemoveAt(currentSortingIndex);
                            pageableList.SortDescriptors.Insert(currentSortingIndex, new SortDescriptor(currentSorting.ColumnName, direction));
                        }
                        else
                            pageableList.SortDescriptors.Remove(currentSorting);
                    }
                    else
                        pageableList.SortDescriptors.Add(new SortDescriptor(column.UniqueName, direction));
                }
                else
                {
                    var list = pageableList.SortDescriptors.Where(x => !x.IsGrouped).ToList();
                    for (var i = list.Count() - 1; i >= 0 ; i--)
                        pageableList.SortDescriptors.Remove(list[i]);

                    if (direction != SortDirection.None)
                        pageableList.SortDescriptors.Add(new SortDescriptor(column.UniqueName, direction));
                }

                pageableList.Refresh(pageableList.CurrentPageNumber);
                _sortDescriptors = pageableList.SortDescriptors;
            }
            else
            {
                var sortDescriptors = new SortList { new SortDescriptor(column.UniqueName, direction) };

                pageableList.Refresh(sortDescriptors);
                _sortDescriptors = sortDescriptors;
            }

            SortingState state;
            if (!Enum.TryParse(direction.ToString(), out state))
                return;

            column.SortingState = state;
            column.SortingStateChanged -= Sorted;
            column.SortingStateChanged += Sorted;
        }
 public void Refresh(SortList sortDescriptors)
 {
     _sortDescriptors = sortDescriptors;
     Refresh(_currentPageNumber);
 }
Example #41
0
        /// <summary>
        /// Schedules the items.
        /// </summary>
        /// <param name="scheduleEdit">The schedule edit.</param>
        /// <param name="finalState">The final state.</param>
        public void ScheduleItems(ISupportScheduling scheduleEdit, Guid finalState)
        {
            using (new BypassPropertyCheckContext())
            {
                if (scheduleEdit == null)
                {
                    return;
                }

                if (scheduleEdit.ProcessingScheduling)
                {
                    return;
                }

                if (!scheduleEdit.ScheduleBasedOnDate.HasValue && !scheduleEdit.ScheduleDisplayDate.HasValue)
                {
                    return;
                }

                if (scheduleEdit.IsScheduleDateChangedForOnlyItem)
                {
                    return;
                }

                var fp = TheDynamicTypeManager.GetEditableRoot<IFrequencyPattern>(Constants.FrequencyPatternProcessName, scheduleEdit.SchedulingFrequencyPatternId);
                if (fp == null)
                {
                    return;
                }

                var supportStateEdit = scheduleEdit as ISupportStates;
                if (supportStateEdit == null)
                {
                    return;
                }

                var isFinalState = finalState == supportStateEdit.CurrentStateGuid;
                if (!isFinalState && !scheduleEdit.IsNew)
                {
                    return;
                }

                if (scheduleEdit.SchedulingEndOption == SchedulingEndOption.EndAfterOccurrences.ToString())
                {
                    if (scheduleEdit.SchedulingEndAfterOccurrencesIndex >= scheduleEdit.SchedulingEndAfterOccurrences)
                    {
                        return;
                    }

                    scheduleEdit.SchedulingEndAfterOccurrencesIndex++;
                }

                DateTime dateOfScheduleEdit = scheduleEdit.ScheduleBasedOnDate ?? scheduleEdit.ScheduleDisplayDate.Value;

                ICalendar calendar = null;
                var userCalendar = scheduleEdit.GetCalendar();

                var tmpCalendar = userCalendar as ICalendar;
                if (tmpCalendar != null)
                {
                    calendar = tmpCalendar;
                }

                if (userCalendar is int)
                {
                    calendar = TheDynamicTypeManager.GetEditableRoot<ICalendar>(Constants.CalendarProcessName, (int)userCalendar);
                }

                if (userCalendar == null)
                {
                    var calendars = TheDynamicTypeManager.GetInfoList<IInfoClass>(Constants.CalendarProcessName, pageSize: 1);
                    if (calendars.Count > 0)
                    {
                        calendar = TheDynamicTypeManager.GetEditableRoot<ICalendar>(Constants.CalendarProcessName, calendars[0].Id);
                    }
                }

                var filter = new FilterList
                                 {
                                     new FilterDescriptor(
                                         LogicalOperators.And,
                                         new MobileObservableCollection<IFilterDescriptor>
                                             {
                                                 new FilterDescriptor(
                                                     Constants.SchedulingSeriesGuid,
                                                     FilterOperator.IsEqualTo,
                                                     scheduleEdit.SchedulingSeriesGuid,
                                                     typeof(string)),
//ELMTDEV-2250
//                                                 new FilterDescriptor(
//                                                     Constants.SchedulingSeriesItemNumber,
//                                                     FilterOperator.IsGreaterThan,
//                                                     scheduleEdit.SchedulingSeriesItemNumber,
//                                                     typeof(int)),
                                                 new FilterDescriptor(
                                                     Constants.IdColumnName,
                                                     FilterOperator.IsNotEqualTo,
                                                     scheduleEdit.Id,
                                                     typeof(int)),
                                                 new FilterDescriptor(
                                                     Constants.CurrentStateIdColumnName,
                                                     FilterOperator.IsNotEqualTo,
                                                     scheduleEdit.ScheduleStartStateId,
                                                     typeof(int))
                                             })
                                 };

                if (!string.IsNullOrEmpty(scheduleEdit.ScheduleFilter))
                {
                    var scheduleFilterList = FilterDescriptor.GetFilterList(scheduleEdit.ScheduleFilter);
                    if (scheduleFilterList != null)
                    {
                        foreach (var filterDescriptor in scheduleFilterList)
                            filter.Add(filterDescriptor);
                    }
                }

                var sortList = new SortList { new SortDescriptor(Constants.SchedulingSeriesItemNumber, SortDirection.Ascending) };

                var infoList = TheDynamicTypeManager.GetInfoList<IInfoClass>(
                    scheduleEdit.ProcessName,
                    pageSize: 100,
                    filterDescriptors: filter,
                    sortDescriptors: sortList);

                var lenght = isFinalState ? scheduleEdit.ScheduledItemsCount : scheduleEdit.ScheduledItemsCount - 1;

                _scheduledList.Clear();
                _scheduledList.Add(dateOfScheduleEdit.Date);
                _previousScheduleDate = dateOfScheduleEdit.Date;
                for (var i = 0; i < lenght; i++)
                {
                    CalculateAndSave(ref dateOfScheduleEdit, infoList.ElementAtOrDefault(i), scheduleEdit, fp, calendar);
                }
             }
        }
Example #42
0
        private async void LoadReferenceItems(
            string processName,
            string referenceField,
            string filterExpression,
            EditorCreatedEventArgs e,
            string displayField)
        {
            var context = DataContext as IFilterSetupViewModel;
            var isCurrentStateGuidFilter = false;
            if (context != null)
            {
                isCurrentStateGuidFilter = !context.IsUserFilter && (referenceField == Constants.CurrentStateColumnName)
                                           && (processName == context.ProcessSystemName);
            }

            var sortDescriptors = new SortList { new SortDescriptor(displayField) };

            //enforce SearchQueryGenerator to adjust Guid field into SQL query. required to find CurrentState by a guid. Admin filters use guid to identify States unlike UserFilters.
            if (isCurrentStateGuidFilter)
            {
                sortDescriptors.Add(new SortDescriptor("Guid", SortDirection.Ascending));
            }

            try
            {
                var infoList =
                    await
                    DynamicTypeManager.GetCrossReferenceListAsync<IReferenceItem>(
                        processName,
                        referenceField,
                        sortDescriptors,
                        null,
                        int.MaxValue,
                        0,
                        filterExpression);

                var comboBox = e.Editor.FindChildByType<RadComboBox>();
                if (comboBox == null)
                {
                    return;
                }

                DataFilter.Tag = true;
                try
                {
                    comboBox.ItemsSource = infoList;
                    comboBox.SelectedValuePath = isCurrentStateGuidFilter ? "Guid" : "Id";

                    Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                        handler => comboBox.SelectionChanged += handler,
                        handler => comboBox.SelectionChanged -= handler).SubscribeWeakly(this, OnComboBoxSelectionChanged);

                    var itemType = DynamicTypeManager.GetCrossReferenceItemType(processName, referenceField);
                    //comboBox.ItemTemplate = CreateTemplateForReferenceField(itemType, displayField);

                    var displayFieldList = GetDisplayFieldList(processName, referenceField);

                    comboBox.ItemTemplate = CreateTemplateForReferenceField(displayFieldList, itemType, displayField);
                    TextSearch.SetTextPath(comboBox, displayField);

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                    if (filterViewModel != null && filterViewModel.Descriptor != null)
                    {
                        var stateInfo = filterViewModel.Descriptor.Value as StateInfoClass;
                        if (stateInfo != null)
                        {
                            var placeholder = stateInfo;
                            comboBox.SelectedValue = placeholder.Guid.ToString();

                            //workaround - some state Guids are lower case and some upper
                            if (comboBox.SelectedValue == null)
                            {
                                comboBox.SelectedValue = placeholder.Guid.ToString().ToUpperInvariant();
                            }
                        }
                        else if (filterViewModel.Descriptor.Value is IInfoClass)
                        {
                            var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                            comboBox.SelectedValue = placeholder.Id;
                        }
                    }
                }
                finally
                {
                    DataFilter.Tag = null;
                }
            }
            catch (DataPortalException ex)
            {
                PopupFactory.NotifyFailure(ex);
            }
        }
 /// <summary>
 /// Refreshes the group column and sort descriptors.
 /// </summary>
 /// <param name="groupColumn">
 /// The group column.
 /// </param>
 /// <param name="sortDescriptors">
 /// The sort descriptors.
 /// </param>
 /// <param name="grouping">
 /// The grouping.
 /// </param>
 public void Refresh(string groupColumn, SortList sortDescriptors = null, bool grouping = false)
 {
 }
 /// <summary>
 /// Updates the <see cref="SortDescriptors"/> collection and refreshes the <see cref="Items"/> collection.
 /// </summary>
 /// <param name="sortDescriptors">
 /// The sort descriptors.
 /// </param>
 public void Refresh(SortList sortDescriptors)
 {
     SortDescriptors = sortDescriptors;
     RefreshInternal();
 }
 public void Refresh(string groupColumn, SortList sortDescriptors = null, bool grouping = false)
 {
     // Not used for RCR fields.
 }
 public void Refresh(SortList sortDescriptors)
 {
     SortDescriptors = sortDescriptors;
     RefreshAvailableItems();
 }
Example #47
0
        /// <summary>
        /// Gets the last successful session.
        /// </summary>
        /// <param name="synchronizer">The synchronizer.</param>
        /// <returns>IESyncSessionInfo.</returns>
        private IESyncSessionInfo GetLastSuccessfulSession(IProcessSynchronizer synchronizer)
        {
            try
            {
                var filterList = new FilterList
                                     {
                                         new FilterDescriptor("SynchronizedProcessName", FilterOperator.IsEqualTo, synchronizer.ProcessName),
                                         new FilterDescriptor(Constants.ESyncSessionSyncProcessGuidColumnName, FilterOperator.IsEqualTo, synchronizer.Guid.ToString()),
                                         new FilterDescriptor(Constants.ESyncSessionIsSuccessfulColumnName, FilterOperator.IsEqualTo, 1),
                                     };

                var sortList = new SortList
                               {
                                   new SortDescriptor(Constants.ESyncSessionEndTimeColumnName, SortDirection.Descending)
                               };

                var list = DynamicTypeManager.GetList<IInfoList>(Constants.ESyncSessionProcessName, string.Empty, 0, 1, sortList, filterList);

                if (list != null && list.Count > 0)
                    return list.Cast<IESyncSessionInfo>().First();
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, "ESYNC", ex);
            }

            return null;
        }