示例#1
0
        private int AddNumericGroupItems(ExcelPivotTableFieldNumericGroup group, double start, double end, double interval)
        {
            if (interval < 0)
            {
                throw (new Exception("The interval must be a positiv"));
            }
            if (start > end)
            {
                throw (new Exception("Then End number must be larger than the Start number"));
            }

            XmlElement groupItemsNode = group.TopNode.SelectSingleNode("d:fieldGroup/d:groupItems", group.NameSpaceManager) as XmlElement;
            int        items          = 2;
            //First date
            double index     = start;
            double nextIndex = start + interval;

            GroupItems.Clear();
            AddGroupItem(groupItemsNode, "<" + start.ToString(CultureInfo.CurrentCulture));

            while (index < end)
            {
                AddGroupItem(groupItemsNode, string.Format("{0}-{1}", index.ToString(CultureInfo.CurrentCulture), nextIndex.ToString(CultureInfo.CurrentCulture)));
                index      = nextIndex;
                nextIndex += interval;
                items++;
            }
            AddGroupItem(groupItemsNode, ">" + index.ToString(CultureInfo.CurrentCulture));

            UpdateCacheLookupFromItems(GroupItems._list);
            return(items);
        }
示例#2
0
 public void ItemsTakeup()
 {
     down = false;
     GroupItems.Hide();
     pictureBox.Image = openItem;
     //removeAllSelectedItems();
 }
示例#3
0
        public void ItemsOpen()
        {
            down = true;
            GroupItems.Show();
            pictureBox.Image = takeUp;

            //removeAllSelectedItems();
        }
示例#4
0
        private void AddGroupItem(XmlElement groupItems, string value)
        {
            var s = groupItems.OwnerDocument.CreateElement("s", ExcelPackage.schemaMain);

            s.SetAttribute("v", value);
            groupItems.AppendChild(s);
            GroupItems.Add(value);
        }
示例#5
0
 private void ReadGroupItems(GroupItems groupItems)
 {
     for (int groupItemIndex = 1; groupItemIndex <= groupItems.Count; groupItemIndex++)
     {
         GroupItem groupItem = groupItems[groupItemIndex];
         m_xmlProcess.ProcessGroupItem(groupItemIndex);
         TextFrames textFrames = groupItem.TextFrames;
         ReadTextFrames(textFrames);
         error = "0";
     }
 }
示例#6
0
 public bool IsGroupItem(NSObject item)
 {
     if (GroupItems.Contains(item.ToString()))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#7
0
        public IEnumerable <Item> GetDiscountedItems(IEnumerable <Item> allItems)
        {
            var validItems = allItems.Where(x => GroupItems.Any(e => e == x)).Distinct();

            if (validItems.Count() == GroupItems.Count())
            {
                return(validItems);
            }

            return(null);
        }
示例#8
0
 public Order(DateTime created, GroupItems groupItems, Client client, int costPrice, int costLogistic, int payment, int profit, int wait, DateTime waitDate)
 {
     Created      = created;
     GroupItems   = groupItems;
     Client       = client;
     CostPrice    = costPrice;
     CostLogistic = costLogistic;
     Payment      = payment;
     Profit       = profit;
     Wait         = wait;
     WaitDate     = waitDate;
 }
示例#9
0
文件: ViewModel.cs 项目: icYFTL/Quark
        public ViewModel()
        {
            _model.PropertyChanged += (s, e) => { RaisePropertyChanged(e.PropertyName); };

            GroupsItemsSelectionChanged = new DelegateCommand <string>(str =>
            {
                if (GroupItems.Contains(str))
                {
                    UpdateStudents(str);
                }
            });


            PasswordField_GotFocus = new DelegateCommand <PasswordBox>(pbox =>
            {
                if (pbox.Password == "Password")
                {
                    pbox.Password = "";
                }
            });

            PasswordField_LostFocus = new DelegateCommand <PasswordBox>(pbox =>
            {
                if (pbox.Password == "")
                {
                    pbox.Password = "******";
                }
            });

            LoginCommand = new DelegateCommand <Object[]>(obj =>
            {
                Login(obj);
            });

            LoginWindow_Loaded = new DelegateCommand(() =>
            {
                Logs.Logs._Init();

                if (!Task.Run(() => source.Utils.NetStat.is_connected()).Result)
                {
                    MessageBox.Show("Не удается подключиться к сети интернет.", "FATAL", MessageBoxButton.OK, MessageBoxImage.Error);
                    Globals.Logger.Error("FATAL: Net connection error.");
                    Environment.Exit(-1);
                }
                Globals.socketClient = Utils.WebSocketClient.get_instance();
                Globals.socketClient.Connect();
                // TODO: https://github.com/rafallopatka/ToastNotifications/blob/master-v2/Docs/CustomNotificatios.md TOASTS
            });

            UpdateGroups();
        }
示例#10
0
        private async Task setItemsAsync()
        {
            IsBusy = true;

            ObservableCollection <GroupItem> allGroups = new ObservableCollection <GroupItem>();

            try
            {
                GroupItems.Clear();
                // Get Group List contains usercount and auth
                //var groupCountList = await CustomFunction.Get<List<GroupAndUserCountItem>>($"api/values/userjoingroups/{GlobalAttributes.User.Id}");
                //if (groupCountList != null)
                //{
                //    foreach (var g in groupCountList)
                //    {
                //        var group = g.Group;
                //        group.UserCount = g.UserCount;
                //        group.IsUserAdmin = g.AdminFlg;
                //        // g.Id has selectGroupList, group.IsSelect is true.
                //        group.IsSelect = this.selectGroupList.Contains(g.Group.Id);
                //        // Add group image
                //        await Service.ImageService.SetImageSource(group);
                //        allGroups.Add(group);
                //    }
                //}
                //this.GroupItems = allGroups;

                var groups = await GroupUserManager.DefaultManager.GetGroupAndUserCountList(GlobalAttributes.User.Id);

                foreach (var g in groups)
                {
                    var group = g.Group;
                    group.UserCount   = g.UserCount;
                    group.IsUserAdmin = g.AdminFlg;
                    // g.Id has selectGroupList, group.IsSelect is true.
                    group.IsSelect = this.selectGroupList.Contains(g.Group.Id);
                    // Add group image
                    await Service.ImageService.SetImageSource(group);

                    allGroups.Add(group);
                }

                this.GroupItems = allGroups;
            }
            catch (Exception e)
            {
                Models.DebugUtil.WriteLine("GroupListViewModel > " + e.Message);
            }
            IsBusy = false;
        }
        internal void FromFieldGroup(FieldGroup fg)
        {
            SetAllNull();

            if (fg.ParentId != null)
            {
                ParentId = fg.ParentId.Value;
            }
            if (fg.Base != null)
            {
                Base = fg.Base.Value;
            }

            using (var oxr = OpenXmlReader.Create(fg))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(RangeProperties))
                    {
                        RangeProperties.FromRangeProperties((RangeProperties)oxr.LoadCurrentElement());
                        HasRangeProperties = true;
                    }
                    else if (oxr.ElementType == typeof(DiscreteProperties))
                    {
                        var       dp = (DiscreteProperties)oxr.LoadCurrentElement();
                        FieldItem fi;
                        using (var oxrDiscrete = OpenXmlReader.Create(dp))
                        {
                            while (oxrDiscrete.Read())
                            {
                                if (oxrDiscrete.ElementType == typeof(FieldItem))
                                {
                                    fi = (FieldItem)oxrDiscrete.LoadCurrentElement();
                                    DiscreteProperties.Add(fi.Val);
                                }
                            }
                        }
                    }
                    else if (oxr.ElementType == typeof(GroupItems))
                    {
                        GroupItems.FromGroupItems((GroupItems)oxr.LoadCurrentElement());
                        HasGroupItems = true;
                    }
                }
            }
        }
        internal SLFieldGroup Clone()
        {
            var fg = new SLFieldGroup();

            fg.ParentId = ParentId;
            fg.Base     = Base;

            fg.HasRangeProperties = HasRangeProperties;
            fg.RangeProperties    = RangeProperties.Clone();

            fg.DiscreteProperties = new List <uint>();
            foreach (var i in DiscreteProperties)
            {
                fg.DiscreteProperties.Add(i);
            }

            fg.HasGroupItems = HasGroupItems;
            fg.GroupItems    = GroupItems.Clone();

            return(fg);
        }
        internal FieldGroup ToFieldGroup()
        {
            var fg = new FieldGroup();

            if (ParentId != null)
            {
                fg.ParentId = ParentId.Value;
            }
            if (Base != null)
            {
                fg.Base = Base.Value;
            }

            if (HasRangeProperties)
            {
                fg.Append(RangeProperties.ToRangeProperties());
            }

            if (DiscreteProperties.Count > 0)
            {
                var dp = new DiscreteProperties();
                dp.Count = (uint)DiscreteProperties.Count;
                foreach (var i in DiscreteProperties)
                {
                    dp.Append(new FieldItem {
                        Val = i
                    });
                }

                fg.Append(dp);
            }

            if (HasGroupItems)
            {
                fg.Append(GroupItems.ToGroupItems());
            }

            return(fg);
        }
示例#14
0
        internal GroupItems ToGroupItems()
        {
            GroupItems gis = new GroupItems();

            gis.Count = (uint)this.Items.Count;

            foreach (SLSharedGroupItemsTypeIndexPair pair in this.Items)
            {
                switch (pair.Type)
                {
                case SLSharedGroupItemsType.Missing:
                    gis.Append(this.MissingItems[pair.Index].ToMissingItem());
                    break;

                case SLSharedGroupItemsType.Number:
                    gis.Append(this.NumberItems[pair.Index].ToNumberItem());
                    break;

                case SLSharedGroupItemsType.Boolean:
                    gis.Append(this.BooleanItems[pair.Index].ToBooleanItem());
                    break;

                case SLSharedGroupItemsType.Error:
                    gis.Append(this.ErrorItems[pair.Index].ToErrorItem());
                    break;

                case SLSharedGroupItemsType.String:
                    gis.Append(this.StringItems[pair.Index].ToStringItem());
                    break;

                case SLSharedGroupItemsType.DateTime:
                    gis.Append(this.DateTimeItems[pair.Index].ToDateTimeItem());
                    break;
                }
            }

            return(gis);
        }
示例#15
0
        private void ReadLayer()
        {
            Layers layers = m_doc.Layers;

            for (int layIndex = 1; layIndex <= layers.Count; layIndex++)
            {
                try
                {
                    Layer  layer     = layers[layIndex];
                    string layerName = layer.Name.Trim().ToLower();
                    if (layerName.Equals("translation") ||
                        layerName.Equals("translate") ||
                        layerName.Equals("for translation"))
                    {
                        m_xmlProcess.ProcessLayer(layIndex);
                        TextFrames textFrames = layer.TextFrames;
                        ReadTextFrames(textFrames);
                        error = "0";
                        // Sometimes some text is in GroupItems
                        GroupItems groupItems = layer.GroupItems;
                        ReadGroupItems(groupItems);
                    }
                }
                catch (Exception e)
                {
                    m_log.Log(e.ToString());
                    CloseFile();
                    m_app.restartApp();
                    throw new Exception();
                }
            }
            if (error == null)
            {
                error = "There is no layer needed to be translated ";
            }
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                //Items.Clear();
                //var items = await DataStore.GetItemsAsync(true);
                //foreach (var item in items)
                //{
                //    Items.Add(item);
                //}

                GroupItems.Clear();

                var groups = await DataStore.GetGroups();

                foreach (var group in groups)
                {
                    GroupItems.Add(group);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#17
0
        internal GroupItems ToGroupItems()
        {
            GroupItems gis = new GroupItems();
            gis.Count = (uint)this.Items.Count;

            foreach (SLSharedGroupItemsTypeIndexPair pair in this.Items)
            {
                switch (pair.Type)
                {
                    case SLSharedGroupItemsType.Missing:
                        gis.Append(this.MissingItems[pair.Index].ToMissingItem());
                        break;
                    case SLSharedGroupItemsType.Number:
                        gis.Append(this.NumberItems[pair.Index].ToNumberItem());
                        break;
                    case SLSharedGroupItemsType.Boolean:
                        gis.Append(this.BooleanItems[pair.Index].ToBooleanItem());
                        break;
                    case SLSharedGroupItemsType.Error:
                        gis.Append(this.ErrorItems[pair.Index].ToErrorItem());
                        break;
                    case SLSharedGroupItemsType.String:
                        gis.Append(this.StringItems[pair.Index].ToStringItem());
                        break;
                    case SLSharedGroupItemsType.DateTime:
                        gis.Append(this.DateTimeItems[pair.Index].ToDateTimeItem());
                        break;
                }
            }

            return gis;
        }
示例#18
0
        internal void FromGroupItems(GroupItems gis)
        {
            this.SetAllNull();

            SLMissingItem mi;
            SLNumberItem ni;
            SLBooleanItem bi;
            SLErrorItem ei;
            SLStringItem si;
            SLDateTimeItem dti;
            using (OpenXmlReader oxr = OpenXmlReader.Create(gis))
            {
                while (oxr.Read())
                {
                    // make sure to add to Items first, because of the Count thing.
                    if (oxr.ElementType == typeof(MissingItem))
                    {
                        mi = new SLMissingItem();
                        mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Missing, this.MissingItems.Count));
                        this.MissingItems.Add(mi);
                    }
                    else if (oxr.ElementType == typeof(NumberItem))
                    {
                        ni = new SLNumberItem();
                        ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Number, this.NumberItems.Count));
                        this.NumberItems.Add(ni);
                    }
                    else if (oxr.ElementType == typeof(BooleanItem))
                    {
                        bi = new SLBooleanItem();
                        bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Boolean, this.BooleanItems.Count));
                        this.BooleanItems.Add(bi);
                    }
                    else if (oxr.ElementType == typeof(ErrorItem))
                    {
                        ei = new SLErrorItem();
                        ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Error, this.ErrorItems.Count));
                        this.ErrorItems.Add(ei);
                    }
                    else if (oxr.ElementType == typeof(StringItem))
                    {
                        si = new SLStringItem();
                        si.FromStringItem((StringItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.String, this.StringItems.Count));
                        this.StringItems.Add(si);
                    }
                    else if (oxr.ElementType == typeof(DateTimeItem))
                    {
                        dti = new SLDateTimeItem();
                        dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.DateTime, this.DateTimeItems.Count));
                        this.DateTimeItems.Add(dti);
                    }
                }
            }
        }
示例#19
0
        private int AddDateGroupItems(ExcelPivotTableFieldGroup group, eDateGroupBy GroupBy, DateTime StartDate, DateTime EndDate, int interval)
        {
            XmlElement groupItemsNode = group.TopNode.SelectSingleNode("d:fieldGroup/d:groupItems", group.NameSpaceManager) as XmlElement;
            int        items          = 2;

            GroupItems.Clear();
            //First date
            AddGroupItem(groupItemsNode, "<" + StartDate.ToString("s", CultureInfo.InvariantCulture).Substring(0, 10));

            switch (GroupBy)
            {
            case eDateGroupBy.Seconds:
            case eDateGroupBy.Minutes:
                AddTimeSerie(60, groupItemsNode);
                items += 60;
                break;

            case eDateGroupBy.Hours:
                AddTimeSerie(24, groupItemsNode);
                items += 24;
                break;

            case eDateGroupBy.Days:
                if (interval == 1)
                {
                    DateTime dt = new DateTime(2008, 1, 1);     //pick a year with 366 days
                    while (dt.Year == 2008)
                    {
                        AddGroupItem(groupItemsNode, dt.ToString("dd-MMM"));
                        dt = dt.AddDays(1);
                    }
                    items += 366;
                }
                else
                {
                    DateTime dt = StartDate;
                    items = 0;
                    while (dt < EndDate)
                    {
                        AddGroupItem(groupItemsNode, dt.ToString("dd-MMM"));
                        dt = dt.AddDays(interval);
                        items++;
                    }
                }
                break;

            case eDateGroupBy.Months:
                AddGroupItem(groupItemsNode, "jan");
                AddGroupItem(groupItemsNode, "feb");
                AddGroupItem(groupItemsNode, "mar");
                AddGroupItem(groupItemsNode, "apr");
                AddGroupItem(groupItemsNode, "may");
                AddGroupItem(groupItemsNode, "jun");
                AddGroupItem(groupItemsNode, "jul");
                AddGroupItem(groupItemsNode, "aug");
                AddGroupItem(groupItemsNode, "sep");
                AddGroupItem(groupItemsNode, "oct");
                AddGroupItem(groupItemsNode, "nov");
                AddGroupItem(groupItemsNode, "dec");
                items += 12;
                break;

            case eDateGroupBy.Quarters:
                AddGroupItem(groupItemsNode, "Qtr1");
                AddGroupItem(groupItemsNode, "Qtr2");
                AddGroupItem(groupItemsNode, "Qtr3");
                AddGroupItem(groupItemsNode, "Qtr4");
                items += 4;
                break;

            case eDateGroupBy.Years:
                if (StartDate.Year >= 1900 && EndDate != DateTime.MaxValue)
                {
                    for (int year = StartDate.Year; year <= EndDate.Year; year++)
                    {
                        AddGroupItem(groupItemsNode, year.ToString());
                    }
                    items += EndDate.Year - StartDate.Year + 1;
                }
                break;

            default:
                throw (new Exception("unsupported grouping"));
            }

            //Lastdate
            AddGroupItem(groupItemsNode, ">" + EndDate.ToString("s", CultureInfo.InvariantCulture).Substring(0, 10));

            UpdateCacheLookupFromItems(GroupItems._list);

            return(items);
        }
示例#20
0
 public void Add(SimObject obj) => GroupItems.Add(obj);
示例#21
0
        internal void FromGroupItems(GroupItems gis)
        {
            this.SetAllNull();

            SLMissingItem  mi;
            SLNumberItem   ni;
            SLBooleanItem  bi;
            SLErrorItem    ei;
            SLStringItem   si;
            SLDateTimeItem dti;

            using (OpenXmlReader oxr = OpenXmlReader.Create(gis))
            {
                while (oxr.Read())
                {
                    // make sure to add to Items first, because of the Count thing.
                    if (oxr.ElementType == typeof(MissingItem))
                    {
                        mi = new SLMissingItem();
                        mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Missing, this.MissingItems.Count));
                        this.MissingItems.Add(mi);
                    }
                    else if (oxr.ElementType == typeof(NumberItem))
                    {
                        ni = new SLNumberItem();
                        ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Number, this.NumberItems.Count));
                        this.NumberItems.Add(ni);
                    }
                    else if (oxr.ElementType == typeof(BooleanItem))
                    {
                        bi = new SLBooleanItem();
                        bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Boolean, this.BooleanItems.Count));
                        this.BooleanItems.Add(bi);
                    }
                    else if (oxr.ElementType == typeof(ErrorItem))
                    {
                        ei = new SLErrorItem();
                        ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Error, this.ErrorItems.Count));
                        this.ErrorItems.Add(ei);
                    }
                    else if (oxr.ElementType == typeof(StringItem))
                    {
                        si = new SLStringItem();
                        si.FromStringItem((StringItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.String, this.StringItems.Count));
                        this.StringItems.Add(si);
                    }
                    else if (oxr.ElementType == typeof(DateTimeItem))
                    {
                        dti = new SLDateTimeItem();
                        dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.DateTime, this.DateTimeItems.Count));
                        this.DateTimeItems.Add(dti);
                    }
                }
            }
        }
示例#22
0
        // Generates content of pivotTableCacheDefinitionPart1.
        private void GeneratePivotTableCacheDefinitionPart1Content(PivotTableCacheDefinitionPart pivotTableCacheDefinitionPart1)
        {
            PivotCacheDefinition pivotCacheDefinition1 = new PivotCacheDefinition(){ Id = "rId1", RefreshedBy = "Masaki Tamura (Pasona Tech)", RefreshedDate = 40946.731165509256D, CreatedVersion = 4, RefreshedVersion = 5, MinRefreshableVersion = 3, RecordCount = (UInt32Value)4U };
            pivotCacheDefinition1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");

            CacheSource cacheSource1 = new CacheSource(){ Type = SourceValues.Worksheet };
            WorksheetSource worksheetSource1 = new WorksheetSource(){ Name = "DataTable1" };

            cacheSource1.Append(worksheetSource1);

            CacheFields cacheFields1 = new CacheFields(){ Count = (UInt32Value)7U };

            CacheField cacheField1 = new CacheField(){ Name = "Date", NumberFormatId = (UInt32Value)14U };

            SharedItems sharedItems1 = new SharedItems(){ ContainsSemiMixedTypes = false, ContainsNonDate = false, ContainsDate = true, ContainsString = false, MinDate = System.Xml.XmlConvert.ToDateTime("2000-01-01T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), MaxDate = System.Xml.XmlConvert.ToDateTime("2002-12-30T20:50:43Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), Count = (UInt32Value)4U };
            DateTimeItem dateTimeItem1 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-01T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem2 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-02T03:35:07Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem3 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2002-12-30T06:43:15Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem4 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2002-12-30T20:50:43Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };

            sharedItems1.Append(dateTimeItem1);
            sharedItems1.Append(dateTimeItem2);
            sharedItems1.Append(dateTimeItem3);
            sharedItems1.Append(dateTimeItem4);

            FieldGroup fieldGroup1 = new FieldGroup(){ ParentId = (UInt32Value)6U, Base = (UInt32Value)0U };
            RangeProperties rangeProperties1 = new RangeProperties(){ GroupBy = GroupByValues.Months, StartDate = System.Xml.XmlConvert.ToDateTime("2000-01-01T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), EndDate = System.Xml.XmlConvert.ToDateTime("2002-12-30T20:50:43Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };

            GroupItems groupItems1 = new GroupItems(){ Count = (UInt32Value)14U };
            StringItem stringItem1 = new StringItem(){ Val = "<2000/01/01" };
            StringItem stringItem2 = new StringItem(){ Val = "1月" };
            StringItem stringItem3 = new StringItem(){ Val = "2月" };
            StringItem stringItem4 = new StringItem(){ Val = "3月" };
            StringItem stringItem5 = new StringItem(){ Val = "4月" };
            StringItem stringItem6 = new StringItem(){ Val = "5月" };
            StringItem stringItem7 = new StringItem(){ Val = "6月" };
            StringItem stringItem8 = new StringItem(){ Val = "7月" };
            StringItem stringItem9 = new StringItem(){ Val = "8月" };
            StringItem stringItem10 = new StringItem(){ Val = "9月" };
            StringItem stringItem11 = new StringItem(){ Val = "10月" };
            StringItem stringItem12 = new StringItem(){ Val = "11月" };
            StringItem stringItem13 = new StringItem(){ Val = "12月" };
            StringItem stringItem14 = new StringItem(){ Val = ">2002/12/30" };

            groupItems1.Append(stringItem1);
            groupItems1.Append(stringItem2);
            groupItems1.Append(stringItem3);
            groupItems1.Append(stringItem4);
            groupItems1.Append(stringItem5);
            groupItems1.Append(stringItem6);
            groupItems1.Append(stringItem7);
            groupItems1.Append(stringItem8);
            groupItems1.Append(stringItem9);
            groupItems1.Append(stringItem10);
            groupItems1.Append(stringItem11);
            groupItems1.Append(stringItem12);
            groupItems1.Append(stringItem13);
            groupItems1.Append(stringItem14);

            fieldGroup1.Append(rangeProperties1);
            fieldGroup1.Append(groupItems1);

            cacheField1.Append(sharedItems1);
            cacheField1.Append(fieldGroup1);

            CacheField cacheField2 = new CacheField(){ Name = "Product", NumberFormatId = (UInt32Value)0U };

            SharedItems sharedItems2 = new SharedItems(){ Count = (UInt32Value)10U };
            StringItem stringItem15 = new StringItem(){ Val = "product_A" };
            StringItem stringItem16 = new StringItem(){ Val = "product_D" };
            StringItem stringItem17 = new StringItem(){ Val = "product_E" };
            StringItem stringItem18 = new StringItem(){ Val = "product_C", Unused = true };
            StringItem stringItem19 = new StringItem(){ Val = "product_B", Unused = true };
            StringItem stringItem20 = new StringItem(){ Val = "product_J", Unused = true };
            StringItem stringItem21 = new StringItem(){ Val = "product_I", Unused = true };
            StringItem stringItem22 = new StringItem(){ Val = "product_H", Unused = true };
            StringItem stringItem23 = new StringItem(){ Val = "product_G", Unused = true };
            StringItem stringItem24 = new StringItem(){ Val = "product_F", Unused = true };

            sharedItems2.Append(stringItem15);
            sharedItems2.Append(stringItem16);
            sharedItems2.Append(stringItem17);
            sharedItems2.Append(stringItem18);
            sharedItems2.Append(stringItem19);
            sharedItems2.Append(stringItem20);
            sharedItems2.Append(stringItem21);
            sharedItems2.Append(stringItem22);
            sharedItems2.Append(stringItem23);
            sharedItems2.Append(stringItem24);

            cacheField2.Append(sharedItems2);

            CacheField cacheField3 = new CacheField(){ Name = "Quantity", NumberFormatId = (UInt32Value)0U };
            SharedItems sharedItems3 = new SharedItems(){ ContainsSemiMixedTypes = false, ContainsString = false, ContainsNumber = true, ContainsInteger = true, MinValue = 4D, MaxValue = 29D };

            cacheField3.Append(sharedItems3);

            CacheField cacheField4 = new CacheField(){ Name = "Price", NumberFormatId = (UInt32Value)0U };
            SharedItems sharedItems4 = new SharedItems(){ ContainsSemiMixedTypes = false, ContainsString = false, ContainsNumber = true, ContainsInteger = true, MinValue = 312D, MaxValue = 15990D };

            cacheField4.Append(sharedItems4);

            CacheField cacheField5 = new CacheField(){ Name = "DeliveryDate", NumberFormatId = (UInt32Value)14U };

            SharedItems sharedItems5 = new SharedItems(){ ContainsSemiMixedTypes = false, ContainsNonDate = false, ContainsDate = true, ContainsString = false, MinDate = System.Xml.XmlConvert.ToDateTime("2000-01-06T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), MaxDate = System.Xml.XmlConvert.ToDateTime("2003-01-03T06:43:15Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), Count = (UInt32Value)4U };
            DateTimeItem dateTimeItem5 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-06T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem6 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2000-01-07T03:35:07Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem7 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2003-01-03T06:43:15Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };
            DateTimeItem dateTimeItem8 = new DateTimeItem(){ Val = System.Xml.XmlConvert.ToDateTime("2002-12-31T20:50:43Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };

            sharedItems5.Append(dateTimeItem5);
            sharedItems5.Append(dateTimeItem6);
            sharedItems5.Append(dateTimeItem7);
            sharedItems5.Append(dateTimeItem8);

            cacheField5.Append(sharedItems5);

            CacheField cacheField6 = new CacheField(){ Name = "Employee", NumberFormatId = (UInt32Value)0U };
            SharedItems sharedItems6 = new SharedItems();

            cacheField6.Append(sharedItems6);

            CacheField cacheField7 = new CacheField(){ Name = "Years", NumberFormatId = (UInt32Value)0U, DatabaseField = false };

            FieldGroup fieldGroup2 = new FieldGroup(){ Base = (UInt32Value)0U };
            RangeProperties rangeProperties2 = new RangeProperties(){ GroupBy = GroupByValues.Years, StartDate = System.Xml.XmlConvert.ToDateTime("2000-01-01T15:40:41Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind), EndDate = System.Xml.XmlConvert.ToDateTime("2002-12-30T20:50:43Z", System.Xml.XmlDateTimeSerializationMode.RoundtripKind) };

            GroupItems groupItems2 = new GroupItems(){ Count = (UInt32Value)5U };
            StringItem stringItem25 = new StringItem(){ Val = "<2000/01/01" };
            StringItem stringItem26 = new StringItem(){ Val = "2000年" };
            StringItem stringItem27 = new StringItem(){ Val = "2001年" };
            StringItem stringItem28 = new StringItem(){ Val = "2002年" };
            StringItem stringItem29 = new StringItem(){ Val = ">2002/12/30" };

            groupItems2.Append(stringItem25);
            groupItems2.Append(stringItem26);
            groupItems2.Append(stringItem27);
            groupItems2.Append(stringItem28);
            groupItems2.Append(stringItem29);

            fieldGroup2.Append(rangeProperties2);
            fieldGroup2.Append(groupItems2);

            cacheField7.Append(fieldGroup2);

            cacheFields1.Append(cacheField1);
            cacheFields1.Append(cacheField2);
            cacheFields1.Append(cacheField3);
            cacheFields1.Append(cacheField4);
            cacheFields1.Append(cacheField5);
            cacheFields1.Append(cacheField6);
            cacheFields1.Append(cacheField7);

            PivotCacheDefinitionExtensionList pivotCacheDefinitionExtensionList1 = new PivotCacheDefinitionExtensionList();

            PivotCacheDefinitionExtension pivotCacheDefinitionExtension1 = new PivotCacheDefinitionExtension(){ Uri = "{725AE2AE-9491-48be-B2B4-4EB974FC3084}" };
            pivotCacheDefinitionExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
            X14.PivotCacheDefinition pivotCacheDefinition2 = new X14.PivotCacheDefinition(){ PivotCacheId = (UInt32Value)2U };

            pivotCacheDefinitionExtension1.Append(pivotCacheDefinition2);

            pivotCacheDefinitionExtensionList1.Append(pivotCacheDefinitionExtension1);

            pivotCacheDefinition1.Append(cacheSource1);
            pivotCacheDefinition1.Append(cacheFields1);
            pivotCacheDefinition1.Append(pivotCacheDefinitionExtensionList1);

            pivotTableCacheDefinitionPart1.PivotCacheDefinition = pivotCacheDefinition1;
        }
        internal void FromGroupItems(GroupItems gis)
        {
            SetAllNull();

            SLMissingItem  mi;
            SLNumberItem   ni;
            SLBooleanItem  bi;
            SLErrorItem    ei;
            SLStringItem   si;
            SLDateTimeItem dti;

            using (var oxr = OpenXmlReader.Create(gis))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(MissingItem))
                    {
                        mi = new SLMissingItem();
                        mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Missing, MissingItems.Count));
                        MissingItems.Add(mi);
                    }
                    else if (oxr.ElementType == typeof(NumberItem))
                    {
                        ni = new SLNumberItem();
                        ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Number, NumberItems.Count));
                        NumberItems.Add(ni);
                    }
                    else if (oxr.ElementType == typeof(BooleanItem))
                    {
                        bi = new SLBooleanItem();
                        bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Boolean, BooleanItems.Count));
                        BooleanItems.Add(bi);
                    }
                    else if (oxr.ElementType == typeof(ErrorItem))
                    {
                        ei = new SLErrorItem();
                        ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Error, ErrorItems.Count));
                        ErrorItems.Add(ei);
                    }
                    else if (oxr.ElementType == typeof(StringItem))
                    {
                        si = new SLStringItem();
                        si.FromStringItem((StringItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.String, StringItems.Count));
                        StringItems.Add(si);
                    }
                    else if (oxr.ElementType == typeof(DateTimeItem))
                    {
                        dti = new SLDateTimeItem();
                        dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement());
                        Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.DateTime,
                                                                      DateTimeItems.Count));
                        DateTimeItems.Add(dti);
                    }
                }
            }
        }
示例#24
0
        public override void Execute
        (
            PftContext context
        )
        {
            GroupItems = context.Record.Fields.GetField(Tag);
            string embedded = Field.Field.Embedded;

            if (!string.IsNullOrEmpty(embedded))
            {
                GroupItems = GroupItems.SelectMany(f => f.GetEmbeddedFields())
                             .GetField(embedded);
            }

            GroupIndex = 0;

            bool needMore;

            // ќбратите внимание, что группа повтор¤етс¤ всегда
            // на один раз больше, чем есть повторений пол¤.

            // —м. http://irbis.gpntb.ru/read.php?7,22730
            // ¬ документации (ќбщее описание, ѕриложение 4)
            // по этому поводу сказано следующее:
            // Ђ≈сли в процессе текущего просмотра всей повтор¤ющейс¤
            // группы ничего не выводитс¤ (то есть в пределах группы больше
            // не оказалось экземпл¤ров повтор¤ющегос¤ пол¤), то процесс
            // обработки повтор¤ющейс¤ группы завершаетс¤.ї
            // «десь требуетс¤ уточнение. ¬ыход из повтор¤ющейс¤ группы
            // происходит, если при очередном проходе Ќ» ќƒЌј из »—ѕќЋЌя≈ћџ’
            // (в процессе данного прохода) конструкций выбора ѕќЋя
            // (именно пол¤, а не подпол¤, т.е если исполн¤етс¤ конструкци¤
            // вида V100^A, то в расчет данного услови¤ беретс¤ только V100)
            // и Ќ» ќƒ»Ќ из »—ѕќЋЌя≈ћџ’ форматных выходов (&uf) не возвращают
            // Ќ≈ѕ”—“ќ≈ значение (можно сформулировать это условие иначе
            // - Еесли ¬—≈ »—ѕќЋЌя≈ћџ≈ конструкции выбора ѕќЋя и форматные
            // выходы возвращают ѕ”—“ќ“”)

            // “ака¤ группа должна зациклитьс¤ в »–Ѕ»—:
            // (if &uf("Av100#1")>v200 then ... else ... fi/)
            // ¬ообще, непродуманное употребление форматного выхода дл¤ получени¤
            // заданного повторени¤ пол¤ (&uf(СAvMM#NТ) чаще всего приводит
            // к зацикливанию повтор¤ющихс¤ групп.

            // „тобы группа выполнилась столько раз, сколько повторений пол¤,
            // нужно использовать конструкцию:
            // (if p(v100^A) then Е fi/)

            // ¬ оригинальном форматере имеетс¤ программна¤ защита от зацикливани¤
            // повтор¤ющихс¤ групп, котора¤ основана на жестком ограничении
            // максимального количества проходов: в »–Ѕ»—32 это 500, в »–Ѕ»—64 Ц 5000
            // (разумеетс¤, эти величины условные и при необходимости их можно будет изменить)

            BreakEncountered = false;

            do
            {
                foreach (PftAst child in Children)
                {
                    child.Execute(context);
                    if (BreakEncountered)
                    {
                        break;
                    }
                }

                GroupIndex++;
                needMore = (GroupIndex < GroupItems.Length);
            } while (needMore);
        }