public void PushGroup(string name) {
		if(curgr.isEmpty) current.groups.Remove(curgr);
		GroupData g = new GroupData();
		g.name = name;
		current.groups.Add(g);
		curgr = g;
	}
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Group"/> class.
        /// </summary>
        /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
        /// <param name="groupData"><see cref="T:Tridion.ContentManager.CoreService.Client.GroupData" /></param>
        protected Group(Client client, GroupData groupData)
            : base(client, groupData)
        {
            if (groupData == null)
                throw new ArgumentNullException("groupData");

            mGroupData = groupData;
        }
예제 #3
0
 public void PushGroup(string name) {
         if(curgr.isEmpty) current.groups.Remove(curgr);
         GroupData g = new GroupData();
         g.name = name;
         // OBJ.cs ALTERATION3: added to help with missing material libraries see
         g.materialName = "default";    
         current.groups.Add(g);
         curgr = g;
 }
예제 #4
0
        private void beginConfirmedGroupDataChannel()
        {
            _confirmedGroupData = new GroupData();
            _groupDataTransfer = (IGroupDataTransfer)_confirmedGroupData;

            _confirmedGroupData.GroupDataConfirmationRead += OnGroupDataConfirmationRead;
            _confirmedGroupData.GroupDataConfirmationResponse += OnGroupDataConfirmationResponse;
            _confirmedGroupData.GroupDataConfirmationWrite += OnGroupDataConfirmationWrite;

            _confirmedGroupData.GroupDataIndicationRead += OnGroupDataIndicationRead;
            _confirmedGroupData.GroupDataIndicationResponse += OnGroupDataIndicationResponse;
            _confirmedGroupData.GroupDataIndicationWrite += OnGroupDataIndicationWrite;

            _confirmedGroupData.Connection = _connection;
        }
예제 #5
0
 public void PushObject(string name) {
         //Debug.Log("Adding new object " + name + ". Current is empty: " + isEmpty);
         if(isEmpty) objects.Remove(current);
        
         ObjectData n = new ObjectData();
         n.name = name;
         objects.Add(n);
        
         GroupData g = new GroupData();
         g.name = "default";
         n.groups.Add(g);
        
         curgr = g;
         current = n;
 }
	public GeometryBuffer() {
		objects = new List<ObjectData>();
		ObjectData d = new ObjectData();
		d.name = "default";
		objects.Add(d);
		current = d;
		
		GroupData g = new GroupData();
		g.name = "default";
		d.groups.Add(g);
		curgr = g;
		
		vertices = new List<Vector3>();
		uvs = new List<Vector2>();
		normals = new List<Vector3>();
	}
예제 #7
0
    public GeometryBuffer()
    {
        _objects = new List<ObjectData>();
            ObjectData d = new ObjectData();
            d.Name = "default";
            _objects.Add(d);
            _current = d;

            GroupData g = new GroupData();
            g.Name = "default";
            d.Groups.Add(g);
            _curgr = g;

            Vertices = new List<Vector3>();
            Uvs = new List<Vector2>();
            Normals = new List<Vector3>();
    }
예제 #8
0
 public GeometryBuffer() {
         objects = new List<ObjectData>();
         ObjectData d = new ObjectData();
         d.name = "default";
         objects.Add(d);
         current = d;
        
         GroupData g = new GroupData();
         g.name = "default";
         // OBJ.cs ALTERATION3: added to help with missing material libraries see
         g.materialName = "default";    
         d.groups.Add(g);
         curgr = g;
        
         vertices = new List<Vector3>();
         uvs = new List<Vector2>();
         normals = new List<Vector3>();
 }
예제 #9
0
    public GeometryBuffer(bool quadMode = false)
    {
        this.quadMode = quadMode;
        objects = new List<ObjectData>();
        ObjectData d = new ObjectData();
        d.name = "default";
        objects.Add(d);
        current = d;

        GroupData g = new GroupData();
        g.name = "default";
        d.groups.Add(g);
        curgr = g;

        vertices = new List<Vector3>();
        uvs = new List<Vector2>();
        normals = new List<Vector3>();
        tangents = new List<Vector4>();
    }
예제 #10
0
        public static GroupResult From(GroupData item)
        {
            var result = new GroupResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription)
            };

            if (item.GroupMemberships != null)
            {
                result.GroupMemberships = TextEntry.From(GetGroupMembershipSummary(item.GroupMemberships), Resources.LabelGroupMemberships);
            }

            string scope = item.Scope.Length > 0
                ? Resources.GroupScopeSpecificPublications
                : Resources.GroupScopeAllPublications;

            result.Scope = TextEntry.From(scope, Resources.LabelScope);

            AddCommonProperties(item, result);
            return result;
        }
예제 #11
0
파일: GroupManager.cs 프로젝트: BjkGkh/R106
		/// <summary>
		/// Loads the group form the db
		/// </summary>
		/// <param name="groupID">ID of the group to load</param>
		private GroupData LoadGroup(uint groupID)
		{
			DataRow dRow_info;
			DataTable dTable_members;
			DataTable dTable_members_pending;

			using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
			{

				dbClient.setQuery("SELECT groups.*, users.username FROM groups " +
								"LEFT JOIN users ON (groups.owner_id = users.id) " +
								"WHERE groups.id = @groupid");
				dbClient.addParameter("groupid", groupID);
				dRow_info = dbClient.getRow();

				dbClient.setQuery("SELECT userid FROM groups_memberships WHERE groupid = @groupid AND is_pending = '1'");
				dbClient.addParameter("groupid", groupID);
				dTable_members_pending = dbClient.getTable();

                dbClient.setQuery("SELECT userid, member_rank FROM groups_memberships WHERE groupid = @groupid AND is_pending = '0'");
				dbClient.addParameter("groupid", groupID);
				dTable_members = dbClient.getTable();
			}

            if (dRow_info == null) 
                return null;

			GroupData data = new GroupData(dRow_info, dTable_members, dTable_members_pending);

			if(data.ownerID == null)
				data.DestroyGroup();

			return data;
		}
예제 #12
0
 private static extern ErrorCode PrxTrophyGetGroupData(int index, out GroupData data);
예제 #13
0
 public bool StoreGroup(GroupData data)
 {
     return(m_Groups.Store(data));
 }
예제 #14
0
파일: Table.cs 프로젝트: elea30/codereports
        public override void Render(Report report, Flow fm, DataContext dataContext)
        {
            HashSet <String> fieldNames = new HashSet <string>();

            foreach (var c in Columns)
            {
                if (c.DataField != "#")
                {
                    fieldNames.Add(c.DataField);
                }
                if (c.AggregateWeightDataField != null)
                {
                    fieldNames.Add(c.AggregateWeightDataField);
                }
            }

            foreach (var g in Groups)
            {
                foreach (var sc in g.GroupByColumns)
                {
                    fieldNames.Add(sc.DataField);
                }
            }

            var data = dataContext.CreateTable(DataTable, fieldNames.ToArray());


            for (int i = 0; i < Columns.Length; i++)
            {
                Columns[i]._Index          = i;
                Columns[i]._DataFieldIndex = data.GetColumnIndex(Columns[i].DataField);

                if (Columns[i].AggregateWeightDataField != null)
                {
                    Columns[i]._AggregateWeightDataFieldIndex = data.GetColumnIndex(Columns[i].AggregateWeightDataField);
                    if (Columns[i]._AggregateWeightDataFieldIndex == -1)
                    {
                        throw new InvalidOperationException(String.Format("Weight column '{0}' not found.", Columns[i].AggregateWeightDataField));
                    }
                }
            }



            List <SortColumn> sort      = new List <SortColumn>();
            List <GroupData>  groupData = new List <GroupData>();

            int gi = 0;

            if (Groups != null)
            {
                foreach (var g in Groups)
                {
                    var gd = new GroupData();
                    var gc = new List <SortColumn>();
                    if (g.GroupByColumns != null)
                    {
                        foreach (var c in g.GroupByColumns)
                        {
                            var ci = data.GetColumnIndex(c.DataField);
                            if (ci != -1)
                            {
                                gc.Add(new SortColumn
                                {
                                    ColumnIndex   = ci,
                                    SortDirection = c.SortDirection == SortDirection.None ? SortDirection.Ascending : c.SortDirection
                                });
                            }
                        }
                    }
                    gd.Columns = gc.ToArray();
                    sort.AddRange(gd.Columns);
                    gd.GroupIndex = gi++;
                    gd.Group      = g;

                    if (g.CaptionFormat != null)
                    {
                        String[] names;
                        String   format;
                        StringFormatHelper.PrepareFormatWithNames(g.CaptionFormat, out format, out names);

                        gd.PreparedCaptionFormat  = format;
                        gd.PreparedCaptionColumns = names != null?names.Select(a => data.GetColumnIndex(a)).ToArray() : null;
                    }

                    if (g.FooterFormat != null)
                    {
                        String[] names;
                        String   format;
                        StringFormatHelper.PrepareFormatWithNames(g.FooterFormat, out format, out names);

                        gd.PreparedFooterFormat  = format;
                        gd.PreparedFooterColumns = names != null?names.Select(a => data.GetColumnIndex(a)).ToArray() : null;
                    }

                    gd.GroupLevel = Groups.Length - gd.GroupIndex - 1;
                    gd.GroupOpen  = false;
                    groupData.Add(gd);
                }
            }

            sort.AddRange(from c in Columns
                          where c.SortDirection != SortDirection.None
                          orderby c.SortIndex
                          select new SortColumn
            {
                ColumnIndex   = c._DataFieldIndex,
                SortDirection = c.SortDirection
            });

            if (sort.Count != 0)
            {
                data.Sort(sort.ToArray());
            }

            var rows = data.Rows;
            var rect = fm.GetRect(Position, Columns.Length, 0);
            var pos  = new RowCol {
                Col = rect.Col1, Row = rect.Row1
            };
            var         startRow = pos.Row;
            List <Cell> cells    = new List <Cell>();


            object[]        accumulator = new object[Columns.Length];
            decimal[]       count       = new decimal[Columns.Length];
            CellAlignment[] align       = new CellAlignment[Columns.Length];

            for (int c = 0; c < Columns.Length; c++)
            {
                var th = Columns[c]._DataFieldIndex >= 0 ? data.TypeHelper[Columns[c]._DataFieldIndex] : null;
                if (th != null)
                {
                    switch (Columns[c].AggregateFunction)
                    {
                    case AggregateFunction.Sum:
                        accumulator[c] = th.Math.Zero;
                        break;

                    case AggregateFunction.Count:
                        accumulator[c] = 0;
                        break;

                    case AggregateFunction.Avg:
                        if (Columns[c].AggregateWeightDataField != null)
                        {
                            count[c]       = 0;
                            accumulator[c] = 0m;
                        }
                        else
                        {
                            accumulator[c] = th.Math.Zero;
                            count[c]       = 0;
                        }
                        break;

                    case AggregateFunction.Product:
                        accumulator[c] = th.Math.One;
                        break;
                    }
                }
                align[c] = th != null?CalcAlignment(Columns[c].CellAlignment, th) : CellAlignment.Right;
            }

            Data.Row prevRow = null;
            for (int r = 0, rowIndex = 0; r <= rows.Length; r++, rowIndex++)
            {
                var row = r < rows.Length ? rows[r] : null;
                var closeToGroupLevel = row != null ? groupData.Count : 0;

                if (prevRow != null && row != null)
                {
                    for (int g = 0; g < groupData.Count; g++)
                    {
                        if (RowComparer.Compare(row, prevRow, groupData[g].Columns) != 0)
                        {
                            closeToGroupLevel = g;
                            break;
                        }
                    }
                }

                //close higher groups first
                for (int g = groupData.Count - 1; g >= closeToGroupLevel; g--)
                {
                    var gd = groupData[g];
                    if (gd.GroupOpen)
                    {
                        gd.GroupOpen = false;
                        //close group
                        if (gd.Group.ShowFooter)
                        {
                            for (int c = 0; c < Columns.Length; c++)
                            {
                                if (Columns[c].AggregateFunction == AggregateFunction.Avg)
                                {
                                    gd.GroupAccumulator[c] = CalculateAggregate(Columns[c].AggregateFunction, gd.GroupAccumulator[c], gd.GroupCounter[c]);
                                }

                                var style = gd.GetFooterCellStyle(Columns[c].ColumnType);
                                switch (Columns[c].FooterType)
                                {
                                case ColumnFooterType.FooterText:
                                    cells.Add(new Cell {
                                        Column = pos.Col + c, Row = pos.Row, FormattedValue = Columns[c].FooterText, Value = Columns[c].FooterText, CellStyleIndex = style, Alignment = Columns[c].FooterAlignment
                                    });
                                    break;

                                case ColumnFooterType.AggregateValue:
                                    String fv = (Columns[c].FooterFormat != null) ? String.Format(Columns[c].FooterFormat, gd.GroupAccumulator[c]) : (gd.GroupAccumulator[c] != null ? gd.GroupAccumulator[c].ToString() : null);
                                    var    al = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].FooterAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Auto;
                                    cells.Add(new Cell {
                                        Column = pos.Col + c, Row = pos.Row, FormattedValue = fv, Value = gd.GroupAccumulator[c], CellStyleIndex = style, Alignment = al, Format = Columns[c].FooterFormat
                                    });
                                    break;

                                case ColumnFooterType.GroupFooter:
                                    String gfv = gd.PreparedFooterColumns == null ? gd.PreparedFooterFormat : String.Format(gd.PreparedFooterFormat, prevRow.GetMany(gd.PreparedFooterColumns));
                                    var    gal = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].FooterAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Auto;
                                    cells.Add(new Cell {
                                        Column = pos.Col + c, Row = pos.Row, FormattedValue = gfv, Value = gfv, CellStyleIndex = style, Alignment = gal
                                    });
                                    break;
                                }
                                if (Columns[c].FooterColSpan > 1)
                                {
                                    report.MergedCells.Add(new Rect {
                                        Col1 = pos.Col + c, Col2 = pos.Col + c + Columns[c].FooterColSpan - 1, Row1 = pos.Row, Row2 = pos.Row
                                    });
                                    c += Columns[c].FooterColSpan - 1;
                                }
                            }
                            pos.Row++;
                        }
                    }
                }

                for (int g = 0; g < groupData.Count; g++)
                {
                    var gd = groupData[g];
                    //add row
                    if (row != null)
                    {
                        if (!gd.GroupOpen)
                        {
                            gd.GroupOpen = true;
                            rowIndex     = 0;

                            if (gd.Group.ShowCaption)
                            {
                                String caption = gd.PreparedCaptionColumns == null ? gd.PreparedCaptionFormat : String.Format(gd.PreparedCaptionFormat, row.GetMany(gd.PreparedCaptionColumns));

                                cells.Add(new Cell {
                                    Column = pos.Col, Row = pos.Row, FormattedValue = caption, Value = caption, CellStyleIndex = gd.GetCaptionStyle()
                                });
                                report.MergedCells.Add(new Rect {
                                    Col1 = pos.Col, Col2 = pos.Col + Columns.Length - 1, Row1 = pos.Row, Row2 = pos.Row
                                });
                                pos.Row++;
                            }

                            if (gd.Group.ShowHeader)
                            {
                                for (int c = 0; c < Columns.Length; c++)
                                {
                                    var ht    = Columns[c].HeaderText;
                                    var style = gd.GetHeaderCellStyle(Columns[c].ColumnType);
                                    var a     = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].HeaderAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Right;

                                    cells.Add(new Cell
                                    {
                                        Column         = pos.Col + c,
                                        Row            = pos.Row,
                                        FormattedValue = ht,
                                        Value          = ht,
                                        CellStyleIndex = style,
                                        Alignment      = a
                                    });
                                }
                                pos.Row++;
                            }

                            gd.GroupAccumulator = new object[Columns.Length];
                            gd.GroupCounter     = new decimal[Columns.Length];

                            //reset group accumulator
                            for (int c = 0; c < Columns.Length; c++)
                            {
                                var th = Columns[c]._DataFieldIndex >= 0 ? data.TypeHelper[Columns[c]._DataFieldIndex] : null;
                                if (th != null)
                                {
                                    switch (Columns[c].AggregateFunction)
                                    {
                                    case AggregateFunction.Sum:
                                        gd.GroupAccumulator[c] = th.Math.Zero;
                                        break;

                                    case AggregateFunction.Count:
                                        gd.GroupAccumulator[c] = 0;
                                        break;

                                    case AggregateFunction.Avg:
                                        if (Columns[c].AggregateWeightDataField != null)
                                        {
                                            gd.GroupAccumulator[c] = 0m;
                                            gd.GroupCounter[c]     = 0;
                                        }
                                        else
                                        {
                                            gd.GroupAccumulator[c] = th.Math.Zero;
                                            gd.GroupCounter[c]     = 0;
                                        }
                                        break;

                                    case AggregateFunction.Product:
                                        gd.GroupAccumulator[c] = th.Math.One;
                                        break;
                                    }
                                }
                            }
                        }

                        for (int c = 0; c < Columns.Length; c++)
                        {
                            var dfi = Columns[c]._DataFieldIndex;
                            var v   = row[dfi];

                            var th = dfi >= 0 ? data.TypeHelper[dfi] : null;
                            if (th != null)
                            {
                                switch (Columns[c].AggregateFunction)
                                {
                                case AggregateFunction.Sum:
                                    gd.GroupAccumulator[c] = th.Math.SumNullAsZero(gd.GroupAccumulator[c], v);
                                    break;

                                case AggregateFunction.Count:
                                    if (v != null)
                                    {
                                        gd.GroupAccumulator[c] = (int)gd.GroupAccumulator[c] + 1;
                                    }
                                    break;

                                case AggregateFunction.Product:
                                    gd.GroupAccumulator[c] = th.Math.Multiply(gd.GroupAccumulator[c], v);
                                    break;

                                case AggregateFunction.Avg:
                                    if (v != null)
                                    {
                                        if (Columns[c].AggregateWeightDataField != null)
                                        {
                                            var w = row[Columns[c]._AggregateWeightDataFieldIndex];
                                            if (w != null)
                                            {
                                                var wd = Convert.ToDecimal(w);
                                                var wv = wd * Convert.ToDecimal(v);
                                                gd.GroupAccumulator[c] = (decimal)gd.GroupAccumulator[c] + wv;
                                                gd.GroupCounter[c]    += wd;
                                            }
                                        }
                                        else
                                        {
                                            gd.GroupAccumulator[c] = th.Math.Sum(gd.GroupAccumulator[c], v);
                                            ++gd.GroupCounter[c];
                                        }
                                    }
                                    break;

                                case AggregateFunction.Min:
                                    if (gd.GroupAccumulator[c] == null)
                                    {
                                        gd.GroupAccumulator[c] = v;
                                    }
                                    else if (v != null)
                                    {
                                        gd.GroupAccumulator[c] = th.Math.Min(gd.GroupAccumulator[c], v);
                                    }
                                    break;

                                case AggregateFunction.Max:
                                    if (gd.GroupAccumulator[c] == null)
                                    {
                                        gd.GroupAccumulator[c] = v;
                                    }
                                    else if (v != null)
                                    {
                                        gd.GroupAccumulator[c] = th.Math.Max(gd.GroupAccumulator[c], v);
                                    }
                                    break;
                                }
                            }

                            switch (Columns[c].CellDisplayMode)
                            {
                            default:
                            case CellDisplayMode.Normal:
                                v = Columns[c].DataField == "#" ? rowIndex + 1 : row[dfi];
                                break;

                            case CellDisplayMode.RowNumber:
                                v = rowIndex + 1;
                                break;

                            case CellDisplayMode.AccumulatorValue:
                                v = CalculateAggregate(Columns[c].AggregateFunction, gd.GroupAccumulator[c], gd.GroupCounter[c]);
                                break;
                            }

                            CellStyle addStyle = null;
                            if (Columns[c].ConditionalFormatting != null)
                            {
                                addStyle = Columns[c].ConditionalFormatting(v);
                            }

                            String fv = (Columns[c].Format != null) ? String.Format(Columns[c].Format, v) : (v != null ? v.ToString() : null);

                            if (g + 1 == groupData.Count)
                            {
                                cells.Add(new Cell
                                {
                                    Column         = pos.Col + c,
                                    Row            = pos.Row,
                                    Value          = v,
                                    FormattedValue = fv,
                                    CellStyleIndex = Columns[c].ColumnType == TableColumnType.HeaderColumn ? CellStyleIndex.TableRowHeader : Columns[c].ColumnType == TableColumnType.FooterColumn ? CellStyleIndex.TableRowFooter : CellStyleIndex.TableRow,
                                    Alignment      = align[c],
                                    Format         = Columns[c].Format,
                                    CustomStyle    = addStyle
                                });
                            }
                        }

                        if (g + 1 == groupData.Count)
                        {
                            pos.Row++;
                        }
                    }
                }

                prevRow = row;
            }

            fm.GetRect(RowCol.Zero, 0, pos.Row - startRow);

            report.Cells.AddRange(cells);
        }
예제 #15
0
 public bool DestroyMemory(GroupData currGroup, int memoryID)
 {
     return(true);
 }
예제 #16
0
 public void PushGroup(string name)
 {
     if(curgr.isEmpty) current.groups.Remove(curgr);
     GroupData g = new GroupData();
     if (name == null) {
         name = "Unnamed-"+unnamedGroupIndex;
         unnamedGroupIndex++;
     }
     g.name = name;
     current.groups.Add(g);
     curgr = g;
 }
예제 #17
0
        public Payload RunPlugin(Payload Input)
        {
            Payload pData = new Payload();

            pData.FileID = Input.FileID;


            //so, the logic right now is that if there are more than one of each segment number,
            //that means that the segments should be paired into a group.
            //if there is only one of each segment, then it should all be treated as part of a single group
            string packageMethod    = "All One Group";
            ulong  maxSegmentNumber = 0;

            //this is going to store the indices of each segment
            Dictionary <ulong, List <int> > segCount = new Dictionary <ulong, List <int> >();

            for (int i = 0; i < Input.SegmentNumber.Count; i++)
            {
                if (segCount.ContainsKey(Input.SegmentNumber[i]))
                {
                    packageMethod = "Paired Segments";
                    segCount[Input.SegmentNumber[i]].Add(i);
                }
                else
                {
                    segCount.Add(Input.SegmentNumber[i], new List <int> {
                        i
                    });
                    if (Input.SegmentNumber[i] > maxSegmentNumber)
                    {
                        maxSegmentNumber = Input.SegmentNumber[i];
                    }
                }
            }



            //now, we start packing up our groups


            if (packageMethod == "All One Group")
            {
                #region All One Group

                GroupData Group = new GroupData();

                for (int i = 0; i < Input.SegmentNumber.Count; i++)
                {
                    List <string> personText = new List <string>()
                    {
                        Input.StringList[i]
                    };
                    Group.People.Add(new Person(Input.SegmentNumber[i].ToString(), personText));
                }

                pData.ObjectList.Add(Group);
                pData.SegmentNumber.Add(1);
                if (Input.SegmentID.Count > 0)
                {
                    pData.SegmentID.Add(Input.SegmentID[0]);
                }
                #endregion
            }
            else if (packageMethod == "Paired Segments")
            {
                #region Paired Segments

                //for (ulong i = 0; i < maxSegmentNumber; i++)
                foreach (ulong key in segCount.Keys)
                {
                    GroupData Group = new GroupData();


                    StringBuilder segmentID = new StringBuilder();

                    for (int j = 0; j < segCount[key].Count; j++)
                    {
                        List <string> personText = new List <string>()
                        {
                            Input.StringList[segCount[key][j]]
                        };

                        if (Input.SegmentID.Count > 0)
                        {
                            Group.People.Add(new Person(Input.SegmentID[segCount[key][j]], personText));
                            segmentID.Append(Input.SegmentID[segCount[key][j]] + ";");
                        }
                        else
                        {
                            Group.People.Add(new Person(j.ToString(), personText));
                            segmentID.Append(j.ToString() + ";");
                        }
                    }

                    pData.SegmentNumber.Add(key);
                    pData.SegmentID.Add(segmentID.ToString());
                    pData.ObjectList.Add(Group);
                }

                #endregion
            }


            return(pData);
        }
예제 #18
0
        void LoadSampleList()
        {
            Nl <GroupData <DataCmd> > ds    = new Nl <GroupData <DataCmd> >();
            GroupData <DataCmd>       group = null;

            #region 框架结构
            group = new GroupData <DataCmd>
            {
                new DataCmd
                {
                    Title = "空白窗口",
                    Note  = "整个窗口内容为空,完全自定义,相当于空白页面",
                    Tag   = typeof(BlankWin)
                },
                new DataCmd
                {
                    Title = "主区窗口",
                    Note  = "只包括主区,主区有标题栏,等同于有标题栏的空白窗口",
                    Tag   = typeof(SingleViewWin)
                },
                new DataCmd
                {
                    Title = "动态主区窗口",
                    Note  = "包括左区和主区,主区内容支持UserControl、窗口及所有可视元素,一般通过左区操作联动来切换主区内容",
                    Tag   = typeof(ToggleWinCenter)
                },
                new DataCmd
                {
                    Title = "两区窗口",
                    Note  = "包括左区和主区,每个区都支持多Tab页,各Tab页之间在Windows模式可联动、Phone模式时可导航",
                    Tag   = typeof(TwoPanelWin)
                },
                new DataCmd
                {
                    Title = "三区窗口",
                    Note  = "包括左区、主区、右区,每个区都支持多Tab页,各Tab页之间在Windows模式可联动、Phone模式时可导航",
                    Tag   = typeof(ThreePanelWin)
                },
                new DataCmd
                {
                    Title = "窗口布局",
                    Note  = "Windows模式:窗口分上下左右和主区五个区域,由Tab承载内容,拖动时自动停靠",
                    Tag   = typeof(WinLayout)
                },
                new DataCmd
                {
                    Title = "窗口内导航",
                    Note  = "Phone模式:窗口内所有区域的Tab自适应为可导航的页面,多个Tab可组合成多Tab页,页面之间支持循环导航",
                    Tag   = typeof(WinNavi)
                },
                new DataCmd
                {
                    Title    = "对话框",
                    Note     = "模拟传统对话框,Windows模式显示在窗口上层,可拖动、调整大小、自动关闭等,Phone模式承载在PhonePage内",
                    Tag      = typeof(DlgDemo),
                    Callback = OnNaviTo
                },
                new DataCmd
                {
                    Title    = "提示信息",
                    Note     = "提供两个级别的提示信息(普通、警告),在对话框上层显示,可自动关闭,最多可显示一个操作按钮",
                    Tag      = typeof(NotifyDemo),
                    Callback = OnNaviTo
                },
            };
            group.Title = "框架结构";
            ds.Add(group);
            #endregion

            #region 数据控件
            group = new GroupData <DataCmd>
            {
                new DataCmd
                {
                    Title = "表单Fv",
                    Note  = "表单由单元格组成,单元格包括列名和编辑器,自动布局,支持自定义行数和内容,可作为独立的布局面板使用",
                    Tag   = typeof(FvHome)
                },
                new DataCmd
                {
                    Title = "列表Lv",
                    Note  = "支持三类视图表格、列表、磁贴,两种数据源,三种选择模式,定制分组,上下文菜单",
                    Tag   = typeof(LvHome)
                },
                new DataCmd
                {
                    Title = "树Tv",
                    Note  = "支持动态加载子节点,自定义节点样式、节点内容,动态设置节点模板,上下文菜单",
                    Tag   = typeof(TvHome)
                },
                new DataCmd
                {
                    Title = "报表",
                    Note  = "可视化报表模板设计,报表预览时支持导出、打印、简单编辑,支持报表绘制过程脚本",
                    Tag   = typeof(RptDemo)
                },
                new DataCmd
                {
                    Title = "数据图表",
                    Note  = "支持柱线饼等9大类40种不同图表,每种图表提供多种不同的调色板,支持交互操作",
                    Tag   = typeof(ChartHome)
                },
                new DataCmd
                {
                    Title = "Excel",
                    Note  = "包含类似Excel编辑的常用功能,报表模板设计的基础",
                    Tag   = typeof(ExcelHome)
                },
                new DataCmd
                {
                    Title = "数据访问与异常",
                    Note  = "包括数据表操作、数据序列化、远程/本地数据的增删改查、远程过程调用等",
                    Tag   = typeof(DataAccessHome)
                },
            };
            group.Title = "数据控件";
            ds.Add(group);
            #endregion

            #region 基础控件
            group = new GroupData <DataCmd>
            {
                new DataCmd
                {
                    Title = "菜单",
                    Note  = "包括普通工具栏菜单、上下文菜单,支持多层子项、选择和分组单选等功能",
                    Tag   = typeof(MenuHome),
                },
                new DataCmd
                {
                    Title = "文件",
                    Note  = "跨平台文件选择、上传下载文件、不同类型图像资源",
                    Tag   = typeof(FileHome),
                },
                new DataCmd
                {
                    Title = "Tab页",
                    Note  = "TabControl控件基本功能演示",
                    Tag   = typeof(TabControlDemo)
                },
                new DataCmd
                {
                    Title = "系统监视输出",
                    Note  = "内部使用的调试输出与断言处理,调试输出内容同时保存在日志,断言处理在调试与非调试状态有不同行为",
                    Tag   = typeof(SysTraceDemo)
                },
                new DataCmd
                {
                    Title = "杂项",
                    Note  = "基础事件、分隔栏、可停靠面板、流程图、控件事件顺序",
                    Tag   = typeof(MiscHome)
                },
            };
            group.Title = "基础控件";
            ds.Add(group);
            #endregion

            #region 样式资源
            group = new GroupData <DataCmd>
            {
                new DataCmd
                {
                    Title = "图标",
                    Note  = "内置的矢量文字,可用作图标、提示",
                    Tag   = typeof(IconDemo)
                },
                new DataCmd
                {
                    Title    = "按钮",
                    Note     = "标准按钮和自定义按钮的常用样式",
                    Tag      = typeof(BtnDemo),
                    Callback = OnNaviTo
                },
                new DataCmd
                {
                    Title    = "常用画刷",
                    Note     = "",
                    Tag      = typeof(BrushDemo),
                    Callback = OnNaviTo
                },
                new DataCmd
                {
                    Title    = "生成App图片",
                    Note     = "生成 android 和 iOS 中用到的app图片",
                    Tag      = typeof(AppIcon),
                    Callback = OnNaviTo
                },
            };
            group.Title = "样式资源";
            ds.Add(group);
            #endregion

            #region 临时
            group = new GroupData <DataCmd>
            {
                new DataCmd
                {
                    Title = "测试1",
                    Note  = "Daoting测试",
                    Tag   = typeof(TestDemo1)
                },
                new DataCmd
                {
                    Title = "测试2",
                    Note  = "忠宝测试",
                    Tag   = typeof(TestDemo2)
                },
            };
            group.Title = "临时";
            ds.Add(group);
            #endregion

            _lv.Data = ds;
        }
예제 #19
0
	public GeometryBuffer() {
		objects = new List<ObjectData>();
		ObjectData d = new ObjectData();
		d.name = "default";
		objects.Add(d);
		current = d;
        envelope = null;
        joints = null;
		GroupData g = new GroupData();
		g.name = "default";
		d.groups.Add(g);
		curgr = g;
		
		vertices = new List<Vector3>(40960);
		uvs = new List<Vector2>(40960);
		normals = new List<Vector3>();
        vtopo = new VerticesTopo(vertices);
        
        xmin = float.MaxValue;
        xmax = float.MinValue;
        ymin = float.MaxValue;
        ymax = float.MinValue;
        zmin = float.MaxValue;
        zmax = float.MinValue;
	}
예제 #20
0
 public void PushGroup(string name)
 {
     if(_curgr.IsEmpty) _current.Groups.Remove(_curgr);
         GroupData g = new GroupData();
         g.Name = name;
         _current.Groups.Add(g);
         _curgr = g;
 }
예제 #21
0
    private Object[] Weapons; // Reference to Weapons Prefabs

    #endregion Fields

    #region Methods

    /// ====================
    /// ON GUI
    /// <summary>
    /// Updates window
    /// </summary>
    /// ====================
    public void OnGUI()
    {
        #region LoadPresets
        GUILayout.Label ("Enemy Creator", EditorStyles.boldLabel);
        // Obtain Model from property field
          if (!presetAdded)
          {
         GUILayout.BeginHorizontal();
         GUILayout.Label("Enemy Def/Preset");
         preset = (EntityData)EditorGUILayout.ObjectField(preset, typeof(EntityData), true);
         GUILayout.EndHorizontal();
         if (preset)
         {
             // Load lists
             LoadWeapons();
             LoadArmors();
             LoadDefValues();
             showDetails = true;
             presetAdded = true;
         }
          }
          else
          {
         // Replace for button
         if (GUILayout.Button("Assign New Enemy Def/Preset"))
         {
            preset = null;
            presetAdded = false;
            showDetails = false;
         }
          }
          #endregion
          if (showDetails == true)
          {
         ShowEnemyCustomization = EditorGUILayout.Foldout(ShowEnemyCustomization, "Enemy Customization");
         if (ShowEnemyCustomization)
         {
            #region Customization
            //--------------
            // Display Entity Data
            //--------------

            EditorGUI.indentLevel++;
            //--------------
            // ENEMY DATA DETAILS
            //-------------
            GUILayout.Label("Enemy Data Details", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            GUILayout.BeginHorizontal();
            GUILayout.Label("3D Model");
            // Obtain new Model for enemy
            Model = (GameObject)EditorGUILayout.ObjectField(Model, typeof(GameObject), true);
            GUILayout.EndHorizontal();
            // Obtain name
            Name = EditorGUILayout.TextField("Name", Name);
            // Obtain healthpoints
            HealthPoints = EditorGUILayout.IntSlider("Health Points", HealthPoints, 0, 100);
            // Weapon Drop Down
            WeaponIndex = EditorGUILayout.Popup("Weapon", WeaponIndex, WeaponList);
            // Armor Drop Down
            ArmorIndex = EditorGUILayout.Popup("Armor", ArmorIndex, ArmorList);
            EditorGUI.indentLevel--;
            //--------------
            // FOV CONTROL DETAILS
            //-------------
            GUILayout.Label("FOV Control Details", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            // Obtain target name
            TargetName = EditorGUILayout.TextField("Target", TargetName);
            // obtain showGixmos
            showGizmos = EditorGUILayout.Toggle("Show Gizmos", showGizmos);
            // obtain detection radius
            DetectionRadius = EditorGUILayout.IntSlider("Detection Radius", DetectionRadius, 0, 100);
            // obtain view angle
            ViewAngle = EditorGUILayout.IntSlider("View Angle", ViewAngle, 0, 100);
            EditorGUI.indentLevel--;
            //-------------
            // FOV DEBUG DETAILS
            //-------------
            EditorGUI.indentLevel--;
            #endregion
            #region Buttons
            // ------------
            // BUTTONS
            // ------------
            GUILayout.BeginHorizontal();
            // Save Changes
            if (GUILayout.Button("Add To Group"))
            {
               // Add Enemies to List
               preset.Name = Name;
               preset.MaxHealthPoints = HealthPoints;
               // obtain weapon component
               GameObject weapon = (GameObject)Weapons[WeaponIndex];
               preset.Weapon = weapon.GetComponent<WeaponData>();
               // obtain armor component
               GameObject armor = (GameObject)Armor[ArmorIndex];
               preset.Armor = armor.GetComponent<ArmorData>();
               // Add to list
               Enemies.Add(preset);
               // Display pop up
               Debug.Log(Name + " has been added to enemy group");
            }
            //------------------
            // Save As New Preset
            //------------------
            if (GUILayout.Button("Save As Enemy Prefab"))
            {
               if (!Model)
               {
                  EditorUtility.DisplayDialog("Not Model Provided", "You must provide a 3D model to create an enemy!", "Ok");
                  return;
               }
               // Assign localpath
               string LocalPath = "Assets/Resources/Enemies/" + Name + ".prefab";
               //----------
               // CHECK IF ENEMY ALREADY EXISTS
               //-----------
               // create instance of game object
               GameObject prefab = null;
               // invoke prefab as a gameobject
               prefab = (GameObject)AssetDatabase.LoadAssetAtPath(LocalPath, typeof(GameObject));
               // check if prefab exists
               if (prefab)
               {
                  // If it exists, prompt message
                  if (EditorUtility.DisplayDialog("Are you sure?", "The prefab already exists. Do you want to overwrite it?", "Yes", "No"))
                     OverrideEnemy(prefab);
               }
               else
                  // Create new enemy
                  CreateNewEnemy(LocalPath);
            }
            // -----------
            // RESET VALUES
            // ------------
            if (GUILayout.Button("Reset Values"))
               LoadDefValues();
            GUILayout.EndHorizontal();
            EditorGUILayout.EndFadeGroup();
         }
               #endregion
          }
          //------------
          // ENEMY GROUP
          //------------
          // Check if Number of Enemies is not ZERO
          if (Enemies.Count > 0)
          {
         ShowGroupOverview = EditorGUILayout.Foldout(ShowGroupOverview, "Group Overview");
         if (ShowGroupOverview)
         {
            #region GroupOverview
            //-----------
            // DISPLAY ENEMY GROUP
            //----------
            EditorGUI.indentLevel++;
            GroupName = EditorGUILayout.TextField("Group Name", GroupName);
            for (int i = 0; i < Enemies.Count; i++)
            {
               // Layout
               EditorGUILayout.BeginHorizontal();
               // Enemy Number and name
               EditorGUILayout.LabelField((i + 1).ToString() + ". " + Enemies[i].Name);
               if (GUILayout.Button("Remove From Group"))
               {
                  // Check if Enemies should be removed
                  if (EditorUtility.DisplayDialog("Are you sure?", "Do you want to remove " + Enemies[i].Name + " from group?", "Yes", "No"))
                  {  // remove enemy
                     Enemies.RemoveAt(i);
                     return;
                  }
               }
               EditorGUILayout.EndHorizontal();
            }
            if (GUILayout.Button("Delete Group"))
               // empty list
               Enemies.Clear();
            EditorGUI.indentLevel--;
            #endregion
         }

         ShowDebugScripts = EditorGUILayout.Foldout(ShowDebugScripts, "Debug Scripts To Attach");
         if (ShowDebugScripts)
         {
            #region ScriptOptions
            //------------
            // ATTACH SCRIPTS
            //------------
            EditorGUI.indentLevel++;
            //------------
            // HEALTH SCRIPT
            //------------
            DebugEnabled = EditorGUILayout.Toggle("Attach Health Debug Script", DebugEnabled);
            if (DebugEnabled)
            {
               EditorGUI.indentLevel++;
               // height
               BarHeight = EditorGUILayout.IntField("Bar Height", BarHeight);
               // width
               BarWidth = EditorGUILayout.IntField("Bar Width", BarWidth);
               Offset = EditorGUILayout.Vector2Field("Screen offset", Offset);
               // texture
               EditorGUILayout.BeginHorizontal();
               GUILayout.Label("Texture", EditorStyles.label);
               barTexture = (Texture)EditorGUILayout.ObjectField(barTexture, typeof(Texture), true);
               EditorGUILayout.EndHorizontal();
               EditorGUI.indentLevel--;
            }
            //-----------
            // FOV SCRIPT
            //-----------
            //FOV = EditorGUILayout.Toggle("Attach FOV", FOV);
            //AIBehaviour = EditorGUILayout.Toggle("Attach AI Behaviour", AIBehaviour);
            EditorGUI.indentLevel--;
            #endregion
         }
         #region Deployment
            //------------
            // DEPLOY GROUP
            //------------
            GUILayout.Label("Deployment Details", EditorStyles.boldLabel);
            // start group details
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Deploy Position", EditorStyles.label);
            // Click button to obtain position for deployment
            DeployPosition = (Transform)EditorGUILayout.ObjectField(DeployPosition, typeof(Transform), true);
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
            //---------------
            // Display Formation
            //---------------
            GUILayout.Label("Formation Details", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            Formation = (FormationData.eFormation)EditorGUILayout.EnumPopup("Initial Formation", Formation);
            if(Formation == FormationData.eFormation.CIRCLE)
               Radius = EditorGUILayout.IntField("Radius", Radius);
            else
            {
               EditorGUILayout.BeginHorizontal();
               RectWidth = EditorGUILayout.IntField("Width", RectWidth);
               RectHeight = EditorGUILayout.IntField("Height", RectHeight);
               EditorGUILayout.EndHorizontal();
            }
            // Check if Deploy group button has been pressed
            if (GUILayout.Button("Deploy Group"))
            {
               if(!DeployPosition)
               {
                  EditorUtility.DisplayDialog("No Deploy Position", "You must provide assign a position where group should deployed!", "Ok");
                  return;
               }
               if(DebugEnabled)
               {
                  if(!barTexture)
                  {
                     EditorUtility.DisplayDialog("No Texture Found", "You must provide a texture for Health Debug script!", "Ok");
                     return;
                  }
               }
               // Create Group Parent object
               GameObject instance = new GameObject(GroupName);
               // set instance to deploy position
               instance.transform.position = DeployPosition.position;
               // Add EnemyGroup isntance
               Group = instance.AddComponent<GroupData>();
               // Add Members
               Group.Members = Enemies;
               // check if Circle formation was selected
               if (Formation == FormationData.eFormation.CIRCLE)
                  CircleFormation(DeployPosition.position,instance.transform);
               else
                  RectangleFormation(DeployPosition.position,instance.transform);
               // Display pop up
               EditorUtility.DisplayDialog("Success", "Enemy Group has been deployed", "Ok");
            }
            EditorGUI.indentLevel--;
           #endregion
          }// ENEMY GROUP
    }
예제 #22
0
        //not used
        public Payload RunPlugin(Payload Input)
        {
            Payload pData = new Payload();

            pData.FileID = Input.FileID;

            for (int i = 0; i < Input.ObjectList.Count; i++)
            {
                GroupData  group  = (GroupData)(Input.ObjectList[i]);
                string[][] tokens = new string[group.People.Count][];

                //dictionary to track person vectors
                Dictionary <string, double[]> personVectors = new Dictionary <string, double[]>();

                //dictionary to track number of captured words
                Dictionary <string, int> personCapturedWords = new Dictionary <string, int>();

                #region Get Each Person's Mean Vector

                for (int j = 0; j < group.People.Count; j++)
                {
                    //rebuild the person's text into a single unit for analysis
                    StringBuilder personText = new StringBuilder();
                    for (int personTurn = 0; personTurn < group.People[j].text.Count; personTurn++)
                    {
                        personText.AppendLine(group.People[j].text[personTurn]);
                    }

                    tokens[j] = tokenizer.tokenize(personText.ToString()).Where(x => !stopList.Contains(x)).ToArray();

                    personVectors.Add(group.People[j].id, new double[VectorSize]);
                    //right here is where we need to get the mean vector for each person
                    //int NumberOfDetectedWords = 0;
                    personCapturedWords.Add(group.People[j].id, 0);

                    for (int k = 0; k < VectorSize; k++)
                    {
                        personVectors[group.People[j].id][k] = 0;
                    }

                    //tally up an average vector for the text
                    #region get mean text vector
                    for (int tokenNumber = 0; tokenNumber < tokens[j].Length; tokenNumber++)
                    {
                        if (WordToArrayMap.ContainsKey(tokens[j][tokenNumber]))
                        {
                            double[] detectedVec = model[WordToArrayMap[tokens[j][tokenNumber]]];
                            personVectors[group.People[j].id] = personVectors[group.People[j].id].Zip(detectedVec, (x, y) => x + y).ToArray();
                            personCapturedWords[group.People[j].id]++;
                        }
                    }

                    if (personCapturedWords[group.People[j].id] > 0)
                    {
                        for (int k = 0; k < VectorSize; k++)
                        {
                            personVectors[group.People[j].id][k] = personVectors[group.People[j].id][k] / personCapturedWords[group.People[j].id];
                        }
                    }
                    #endregion
                }

                #endregion



                // go in and actually calculate the LSS scores

                #region Calculate LSS

                for (int j = 0; j < group.People.Count - 1; j++)
                {
                    for (int k = 1; k + j < group.People.Count; k++)
                    {
                        int TCpOne = personCapturedWords[group.People[j].id];
                        int TCpTwo = personCapturedWords[group.People[j + k].id];

                        string TextOneID = group.People[j].id;
                        string TextTwoID = group.People[j + k].id;

                        double lssScore       = 0;
                        string lssScoreString = "";


                        if (personCapturedWords[TextOneID] > 0 && personCapturedWords[TextTwoID] > 0)
                        {
                            double dotproduct = 0;
                            double d1         = 0;
                            double d2         = 0;

                            //calculate cosine similarity components
                            for (int m = 0; m < VectorSize; m++)
                            {
                                dotproduct += personVectors[TextOneID][m] * personVectors[TextTwoID][m];
                                d1         += personVectors[TextOneID][m] * personVectors[TextOneID][m];
                                d2         += personVectors[TextTwoID][m] * personVectors[TextTwoID][m];
                            }

                            lssScore = (dotproduct / (Math.Sqrt(d1) * Math.Sqrt(d2)));

                            lssScoreString = lssScore.ToString();
                        }



                        pData.StringArrayList.Add(new string[] { TextOneID,
                                                                 TextTwoID,
                                                                 personCapturedWords[group.People[j].id].ToString(),
                                                                 personCapturedWords[group.People[j + k].id].ToString(),
                                                                 lssScoreString });

                        pData.SegmentNumber.Add(Input.SegmentNumber[i]);
                        pData.SegmentID.Add(TextOneID + ";" + TextTwoID);
                    }
                }
                #endregion



                //OutputArray[0] = Input.StringArrayList[i].Length.ToString();
                //OutputArray[1] = NumberOfDetectedWords.ToString();
                //for (int j = 0; j < VectorSize; j++) OutputArray[j + 2] = textVector[j].ToString();

                //pData.SegmentNumber.Add(Input.SegmentNumber[i]);
                //pData.StringArrayList.Add(OutputArray);
            }

            return(pData);
        }
예제 #23
0
 public NodeRenderData(GroupData groupData, NodeDatum nodeDatum, Vector2 worldPos)
 {
     GroupData = groupData;
     NodeDatum = nodeDatum;
     WorldPos  = worldPos;
 }
예제 #24
0
        public Payload RunPlugin(Payload Input)
        {
            Payload pData = new Payload();

            pData.FileID = Input.FileID;



            for (int i = 0; i < Input.StringList.Count; i++)
            {
                //setting everything up
                Dictionary <string, List <string> > Text_Split = new Dictionary <string, List <string> >();
                string[]  readText_Lines  = NewlineClean.Split(Input.StringList[i]);
                int       NumberOfLines   = readText_Lines.Length;
                string    PreviousSpeaker = "";
                GroupData group           = new GroupData();
                Dictionary <ulong, Tuple <string, int> > TurnTracker = new Dictionary <ulong, Tuple <string, int> >();

                ulong turnCounter = 0;

                #region Parse Out Line into Speakers

                for (int j = 0; j < NumberOfLines; j++)
                {
                    string CurrentLine = readText_Lines[j];

                    if (regexRepl.Length > 0)
                    {
                        CurrentLine = CompiledRegex.Replace(CurrentLine, "").Trim();
                    }
                    else
                    {
                        CurrentLine = CurrentLine.Trim();
                    }


                    //if the line is empty, move along... move along
                    if (CurrentLine.Length == 0)
                    {
                        continue;
                    }

                    bool FoundSpeaker = false;

                    //loop through each speaker in list to see if the line starts with their name
                    for (int k = 0; k < SpeakerListLength; k++)
                    {
                        // here's what we do if we find a match
                        if (CurrentLine.StartsWith(SpeakerList[k]))
                        {
                            FoundSpeaker    = true;
                            PreviousSpeaker = SpeakerList[k];

                            //clean up the line to remove the speaker tag from the beginning
                            int Place = CurrentLine.IndexOf(SpeakerList[k]);
                            CurrentLine = CurrentLine.Remove(Place, SpeakerList[k].Length).Insert(Place, "").Trim() + "\r\n";

                            if (Text_Split.ContainsKey(SpeakerList[k]))
                            {
                                Text_Split[SpeakerList[k]].Add(CurrentLine.Trim());
                            }
                            else
                            {
                                Text_Split.Add(SpeakerList[k], new List <string>()
                                {
                                    CurrentLine.Trim()
                                });
                            }

                            //make sure we track where the line is located
                            TurnTracker.Add(turnCounter, new Tuple <string, int>(SpeakerList[k], Text_Split[SpeakerList[k]].Count - 1));
                            turnCounter++;

                            //break to the next line in the text
                            break;
                        }
                    }
                    //what we will do if no speaker was found
                    if ((FoundSpeaker == false) && (PreviousSpeaker != ""))
                    {
                        if (multiLine)
                        {
                            Text_Split[PreviousSpeaker][Text_Split[PreviousSpeaker].Count - 1] += CurrentLine.Trim() + "\r\n";
                        }
                    }

                    //end of for loop through each line
                }
                #endregion

                StringBuilder segID = new StringBuilder();

                foreach (KeyValuePair <string, List <string> > entry in Text_Split)
                {
                    group.People.Add(new Person(entry.Key, entry.Value));
                    segID.Append(entry.Key + ";");
                }

                group.TurnTracker = TurnTracker;

                pData.ObjectList.Add(group);
                pData.SegmentID.Add(segID.ToString());
                pData.SegmentNumber.Add(Input.SegmentNumber[i]);
            }

            return(pData);
        }
예제 #25
0
        public async Task <IActionResult> NoteProject([FromBody] NoteProjectViewModel model)
        {
            int userId = _authenticationInfo.ActualUser.UserId;
            TimedUserNoteProjectTable timedUserNoteProjectTable = _stObjMap.StObjs.Obtain <TimedUserNoteProjectTable>();
            TimedUserTable            timedUserTable            = _stObjMap.StObjs.Obtain <TimedUserTable>();
            EvaluatesTable            evaluatesTable            = _stObjMap.StObjs.Obtain <EvaluatesTable>();
            SqlDefaultDatabase        db             = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>();
            PeriodServices            periodServices = new PeriodServices();

            using (var ctx = new SqlStandardCallContext())
            {
                ProjectQueries     projectQueries     = new ProjectQueries(ctx, db);
                TimedPeriodQueries timedPeriodQueries = new TimedPeriodQueries(ctx, db);
                UserQueries        userQueries        = new UserQueries(ctx, db);
                TimedUserQueries   timedUserQueries   = new TimedUserQueries(ctx, db);
                AclQueries         aclQueries         = new AclQueries(ctx, db);
                GroupQueries       groupQueries       = new GroupQueries(ctx, db);

                //Case Change Grade by Administration ====================================================================================================================
                if (model.User == ViewModels.TypeTimedUser.StaffMember)
                {
                    if (!await periodServices.CheckInPeriod(_stObjMap, _authenticationInfo))
                    {
                        Result result = new Result(Status.Unauthorized, "A la date d'aujourd'hui votre etablissement n'est dans une aucune periode");
                        return(this.CreateResult(result));
                    }

                    GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId);

                    if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual))
                    {
                        Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !");
                        return(this.CreateResult(result));
                    }

                    await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade);

                    return(Ok());
                }
                //=========================================================================================================================================================

                PeriodData periodData = await timedPeriodQueries.GetLastPeriodBySchool(model.SchoolId);

                TimedUserData timedUserData = await timedUserQueries.GetTimedUser(userId, periodData.ChildId);

                if (timedUserData == null)
                {
                    TimedUserStruct timedUser = await timedUserTable.CreateOrUpdateTimedUserAsyncWithType(ctx, Data.TypeTimedUser.Anon, periodData.ChildId, userId);

                    timedUserData = new TimedUserData
                    {
                        TimedUserId = timedUser.TimedUserId
                    };
                    await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade);

                    return(Ok());
                }

                if (model.User == ViewModels.TypeTimedUser.Jury)
                {
                    await evaluatesTable.EvaluateOrUpdateGradeProject(ctx, model.JuryId, model.ProjectId, model.Grade);
                }
                else
                {
                    await timedUserNoteProjectTable.AddOrUpdateNote(ctx, timedUserData.TimedUserId, model.ProjectId, model.Grade);
                }

                return(Ok());
            }
        }
예제 #26
0
        public bool CreateGroupProxy(string RequestingAgentID, string agentID, string accessToken, UUID groupID, string serviceLocation, string name, out string reason)
        {
            reason = string.Empty;
            Uri uri = null;

            try
            {
                uri = new Uri(serviceLocation);
            }
            catch (UriFormatException)
            {
                reason = "Bad location for group proxy";
                return(false);
            }

            // Check if it already exists
            GroupData grec = m_Database.RetrieveGroup(groupID);

            if (grec == null ||
                (grec != null && grec.Data["Location"] != string.Empty && grec.Data["Location"].ToLower() != serviceLocation.ToLower()))
            {
                // Create the group
                grec                        = new GroupData();
                grec.GroupID                = groupID;
                grec.Data                   = new Dictionary <string, string>();
                grec.Data["Name"]           = name + " @ " + uri.Authority;
                grec.Data["Location"]       = serviceLocation;
                grec.Data["Charter"]        = string.Empty;
                grec.Data["InsigniaID"]     = UUID.Zero.ToString();
                grec.Data["FounderID"]      = UUID.Zero.ToString();
                grec.Data["MembershipFee"]  = "0";
                grec.Data["OpenEnrollment"] = "0";
                grec.Data["ShowInList"]     = "0";
                grec.Data["AllowPublish"]   = "0";
                grec.Data["MaturePublish"]  = "0";
                grec.Data["OwnerRoleID"]    = UUID.Zero.ToString();

                if (!m_Database.StoreGroup(grec))
                {
                    return(false);
                }
            }

            if (grec.Data["Location"] == string.Empty)
            {
                reason = "Cannot add proxy membership to non-proxy group";
                return(false);
            }

            UUID   uid = UUID.Zero;
            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;

            Util.ParseUniversalUserIdentifier(RequestingAgentID, out uid, out url, out first, out last, out tmp);
            string fromName = first + "." + last + "@" + url;

            // Invite to group again
            InviteToGroup(fromName, groupID, new UUID(agentID), grec.Data["Name"]);

            // Stick the proxy membership in the DB already
            // we'll delete it if the agent declines the invitation
            MembershipData membership = new MembershipData();

            membership.PrincipalID            = agentID;
            membership.GroupID                = groupID;
            membership.Data                   = new Dictionary <string, string>();
            membership.Data["SelectedRoleID"] = UUID.Zero.ToString();
            membership.Data["Contribution"]   = "0";
            membership.Data["ListInProfile"]  = "1";
            membership.Data["AcceptNotices"]  = "1";
            membership.Data["AccessToken"]    = accessToken;

            m_Database.StoreMember(membership);

            return(true);
        }
예제 #27
0
파일: Groups.cs 프로젝트: BjkGkh/R106
        private List<uint> GetGroupUsersByString(GroupData Group, uint Req, string searchPattern, List<GroupMember> members)
        {
            List<uint> list = new List<uint>();

            switch (Req)
            {
                case 0:
                    foreach (GroupMember member in members)
                    {
                        if (!list.Contains(member.memberID))
                            list.Add(member.memberID);
                    }
                    break;

                case 1:
                    foreach (GroupMember user in Group.GetMembers(searchPattern).Where(p => p.GetRank() < 2).ToList())
                    {
                        if (!list.Contains(user.memberID))
                            list.Add(user.memberID);
                    }
                    break;

                case 2:
                    foreach (GroupMember user in Group.GetPendingMembers(searchPattern))
                    {
                        if (!list.Contains(user.memberID))
                            list.Add(user.memberID);
                    }
                    break;
            }

            return list;
        }
예제 #28
0
    public void PushGroup(string name)
    {
        string currentMaterial = current.groups [current.groups.Count - 1].materialName;

        if(curgr.isEmpty) current.groups.Remove(curgr);
        GroupData g = new GroupData();
        g.materialName = currentMaterial;
        if (name == null) {
            name = "Unnamed-"+unnamedGroupIndex;
            unnamedGroupIndex++;
        }
        g.name = name;
        current.groups.Add(g);
        curgr = g;
    }
예제 #29
0
        /// <summary>
        /// Reload the <see cref="Group" /> with the specified <see cref="T:Tridion.ContentManager.CoreService.Client.GroupData" />
        /// </summary>
        /// <param name="groupData"><see cref="T:Tridion.ContentManager.CoreService.Client.GroupData" /></param>
        protected void Reload(GroupData groupData)
        {
            if (groupData == null)
                throw new ArgumentNullException("groupData");

            mGroupData = groupData;
            base.Reload(groupData);
        }
예제 #30
0
        public bool CreateGroup(string name, string title, int rank)
        {
            // Check if it already exists
            if (GroupExists(name) || string.IsNullOrEmpty(name)) return false;

            // Create the data
            var data = new GroupData { Title = title, Rank = rank };

            // Add it and save
            groupdata.Add(name.ToLower(), data);
            SaveGroups();
            return true;
        }
예제 #31
0
        /// <summary>
        /// Deserialize the message
        /// </summary>
        /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
        public void Deserialize(OSDMap map)
        {
            OSDArray agentArray = (OSDArray)map["AgentData"];
            OSDMap agentMap = (OSDMap)agentArray[0];
            AgentID = agentMap["AgentID"].AsUUID();

            OSDArray groupArray = (OSDArray)map["GroupData"];

            //OSDArray newGroupDataArray = (OSDArray)map["NewGroupData"];

            GroupDataBlock = new GroupData[groupArray.Count];

            for (int i = 0; i < groupArray.Count; i++)
            {
                OSDMap groupMap = (OSDMap)groupArray[i];


                GroupData groupData = new GroupData();

                groupData.GroupID = groupMap["GroupID"].AsUUID();
                groupData.Contribution = groupMap["Contribution"].AsInteger();
                groupData.GroupInsigniaID = groupMap["GroupInsigniaID"].AsUUID();
                groupData.GroupName = groupMap["GroupName"].AsString();
                groupData.GroupPowers = (GroupPowers)groupMap["GroupPowers"].AsLong();
                groupData.ListInProfile = groupMap["ListInProfile"].AsBoolean();
                groupData.AcceptNotices = groupMap["AcceptNotices"].AsBoolean();
                GroupDataBlock[i] = groupData;
            }
        }
예제 #32
0
        public Payload RunPlugin(Payload Input)
        {
            Payload pData = new Payload();

            pData.FileID = Input.FileID;
            //pData.SegmentID = Input.SegmentID;


            for (int i = 0; i < Input.ObjectList.Count; i++)
            {
                //unpack the group
                GroupData group = (GroupData)(Input.ObjectList[i]);

                //set up the tokens and analyze each person's text
                string[][] tokens = new string[group.People.Count][];
                Dictionary <string, int>[] lsmCatResults = new Dictionary <string, int> [group.People.Count];

                for (int j = 0; j < group.People.Count; j++)
                {
                    //rebuild the person's text into a single unit for analysis
                    StringBuilder personText = new StringBuilder();
                    for (int personTurn = 0; personTurn < group.People[j].text.Count; personTurn++)
                    {
                        personText.AppendLine(group.People[j].text[personTurn]);
                    }

                    tokens[j]        = tokenizer.tokenize(personText.ToString()).Where(x => !stopList.Contains(x)).ToArray();
                    lsmCatResults[j] = AnalyzeText(LSMDict.DictData, tokens[j]);
                }


                // go in and actually calculate the LSM scores
                for (int j = 0; j < group.People.Count - 1; j++)
                {
                    for (int k = 1; k + j < group.People.Count; k++)
                    {
                        int TCpOne = tokens[j].Length;
                        int TCpTwo = tokens[j + k].Length;

                        string TextOneID = group.People[j].id;
                        string TextTwoID = group.People[j + k].id;

                        decimal lsmScore       = 0.0m;
                        string  lsmScoreString = "";

                        if (tokens[j].Length > 0 && tokens[j + k].Length > 0)
                        {
                            //loop from 1 to 8 because those are the category numbers for each LSM category
                            for (int l = 1; l < 9; l++)
                            {
                                decimal pOneScore = (decimal)lsmCatResults[j][l.ToString()] / tokens[j].Length;
                                decimal pTwoScore = (decimal)lsmCatResults[j + k][l.ToString()] / tokens[j + k].Length;

                                lsmScore += 1.0m - (Math.Abs(pOneScore - pTwoScore) / (pOneScore + pTwoScore + 0.0001m));
                            }

                            lsmScoreString = (lsmScore / 8.0m).ToString();
                        }



                        pData.StringArrayList.Add(new string[] { TextOneID,
                                                                 TextTwoID,
                                                                 tokens[j].Length.ToString(),
                                                                 tokens[j + k].Length.ToString(),
                                                                 lsmScoreString });

                        pData.SegmentNumber.Add(Input.SegmentNumber[i]);
                        pData.SegmentID.Add(TextOneID + ";" + TextTwoID);
                    }
                }
            }



            return(pData);
        }
예제 #33
0
 public void UpdateGroup(GroupData group)
 {
     this.Invoke("UpdateGroup", new object[] {
                 group});
 }
예제 #34
0
 public int CreateGroup(GroupData GroupData)
 {
     object[] results = this.Invoke("CreateGroup", new object[] {
                 GroupData});
     return ((int)(results[0]));
 }
예제 #35
0
    private void Populate_MapCMSGroupToADGrid(GroupData[] data)
    {
        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "TITLE";
        colBound.HeaderText = m_refMsg.GetMessage("add title");
        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.Wrap = false;
        colBound.HeaderStyle.Width = Unit.Percentage(5);
        colBound.HeaderStyle.Width = Unit.Percentage(5);
        MapCMSGroupToADGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "GROUPTITLE";
        colBound.HeaderText = m_refMsg.GetMessage("active directory group title");
        colBound.ItemStyle.Wrap = false;
        colBound.HeaderStyle.CssClass = "title-header";
        colBound.HeaderStyle.Width = Unit.Percentage(15);
        colBound.HeaderStyle.Width = Unit.Percentage(15);
        MapCMSGroupToADGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "DOMAINTITLE";
        colBound.HeaderStyle.CssClass = "title-header";
        colBound.HeaderText = m_refMsg.GetMessage("domain title");
        colBound.ItemStyle.Wrap = false;
        colBound.HeaderStyle.Width = Unit.Percentage(40);
        colBound.HeaderStyle.Width = Unit.Percentage(40);
        MapCMSGroupToADGrid.Columns.Add(colBound);

        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn("TITLE", typeof(string)));
        dt.Columns.Add(new DataColumn("GROUPTITLE", typeof(string)));
        dt.Columns.Add(new DataColumn("DOMAINTITLE", typeof(string)));
        int i = 0;
        if (!(data == null))
        {
            for (i = 0; i <= data.Length - 1; i++)
            {
                dr = dt.NewRow();
                dr[0] = "<input type=\"Radio\" name=\"usernameanddomain\" value=\"" + data[i].GroupName + "_@_" + data[i].GroupDomain + "\" onClick=\"SetUp(\'" + data[i].GroupName + "_@_" + data[i].GroupDomain + "\')\">";
                dr[1] = data[i].GroupName;
                dr[2] = data[i].GroupDomain;
                dt.Rows.Add(dr);
            }
        }
        else
        {
            dr = dt.NewRow();
            dr[0] = m_refMsg.GetMessage("no ad groups found");
            dr[1] = "";
            dt.Rows.Add(dr);
        }
        System.Text.StringBuilder result = new System.Text.StringBuilder();
        result.Append("<input type=\"hidden\" name=\"id\" value=\"" + user_data.UserId + "\">");
        result.Append("<input type=\"hidden\" name=\"rp\" value=\"" + rp + "\">");
        result.Append("<input type=\"hidden\" name=\"e1\" value=\"" + e1 + "\">");
        result.Append("<input type=\"hidden\" name=\"e2\" value=\"" + e2 + "\">");
        result.Append("<input type=\"hidden\" name=\"f\" value=\"" + f + "\">");
        result.Append("<input type=\"hidden\" name=\"adusername\">");
        result.Append("<input type=\"hidden\" name=\"addomain\">");
        dr = dt.NewRow();
        dr[0] = result.ToString();
        dr[1] = "";
        dt.Rows.Add(dr);

        DataView dv = new DataView(dt);
        MapCMSGroupToADGrid.DataSource = dv;
        MapCMSGroupToADGrid.DataBind();
    }
예제 #36
0
파일: Table.cs 프로젝트: elea30/codereports
        public override void Render(Report report, Flow fm, DataContext dataContext)
        {
            HashSet<String> fieldNames = new HashSet<string>();

            foreach (var c in Columns)
            {
                if (c.DataField != "#")
                    fieldNames.Add(c.DataField);
                if (c.AggregateWeightDataField != null)
                    fieldNames.Add(c.AggregateWeightDataField);
            }

            foreach (var g in Groups)
                foreach (var sc in g.GroupByColumns)
                    fieldNames.Add(sc.DataField);

            var data = dataContext.CreateTable(DataTable, fieldNames.ToArray());

            for (int i = 0; i < Columns.Length; i++)
            {
                Columns[i]._Index = i;
                Columns[i]._DataFieldIndex = data.GetColumnIndex(Columns[i].DataField);

                if (Columns[i].AggregateWeightDataField != null)
                {
                    Columns[i]._AggregateWeightDataFieldIndex = data.GetColumnIndex(Columns[i].AggregateWeightDataField);
                    if (Columns[i]._AggregateWeightDataFieldIndex == -1)
                        throw new InvalidOperationException(String.Format("Weight column '{0}' not found.", Columns[i].AggregateWeightDataField));
                }
            }

            List<SortColumn> sort = new List<SortColumn>();
            List<GroupData> groupData = new List<GroupData>();

            int gi = 0;
            if (Groups != null)
            {
                foreach (var g in Groups)
                {
                    var gd = new GroupData();
                    var gc = new List<SortColumn>();
                    if (g.GroupByColumns!=null)
                        foreach (var c in g.GroupByColumns)
                        {
                            var ci = data.GetColumnIndex(c.DataField);
                            if (ci != -1)
                                gc.Add(new SortColumn
                                {
                                    ColumnIndex = ci,
                                    SortDirection = c.SortDirection == SortDirection.None ? SortDirection.Ascending : c.SortDirection
                                });
                        }
                    gd.Columns = gc.ToArray();
                    sort.AddRange(gd.Columns);
                    gd.GroupIndex = gi++;
                    gd.Group = g;

                    if (g.CaptionFormat != null)
                    {
                        String[] names;
                        String format;
                        StringFormatHelper.PrepareFormatWithNames(g.CaptionFormat, out format, out names);

                        gd.PreparedCaptionFormat = format;
                        gd.PreparedCaptionColumns = names != null ? names.Select(a => data.GetColumnIndex(a)).ToArray() : null;
                    }

                    if (g.FooterFormat != null)
                    {
                        String[] names;
                        String format;
                        StringFormatHelper.PrepareFormatWithNames(g.FooterFormat, out format, out names);

                        gd.PreparedFooterFormat = format;
                        gd.PreparedFooterColumns = names!=null ? names.Select(a => data.GetColumnIndex(a)).ToArray() : null;
                    }

                    gd.GroupLevel = Groups.Length - gd.GroupIndex - 1;
                    gd.GroupOpen = false;
                    groupData.Add(gd);
                }
            }

            sort.AddRange(from c in Columns
                          where c.SortDirection != SortDirection.None
                          orderby c.SortIndex
                          select new SortColumn
                          {
                              ColumnIndex = c._DataFieldIndex,
                              SortDirection = c.SortDirection
                          });

            if (sort.Count != 0)
                data.Sort(sort.ToArray());

            var rows = data.Rows;
            var rect = fm.GetRect(Position, Columns.Length, 0);
            var pos = new RowCol { Col = rect.Col1, Row = rect.Row1 };
            var startRow = pos.Row;
            List<Cell> cells = new List<Cell>();

            object[] accumulator = new object[Columns.Length];
            decimal[] count = new decimal[Columns.Length];
            CellAlignment[] align = new CellAlignment[Columns.Length];

            for (int c = 0; c < Columns.Length; c++)
            {
                var th = Columns[c]._DataFieldIndex >= 0 ? data.TypeHelper[Columns[c]._DataFieldIndex] : null;
                if (th != null)
                    switch (Columns[c].AggregateFunction)
                    {
                        case AggregateFunction.Sum:
                            accumulator[c] = th.Math.Zero;
                            break;
                        case AggregateFunction.Count:
                            accumulator[c] = 0;
                            break;
                        case AggregateFunction.Avg:
                            if (Columns[c].AggregateWeightDataField != null)
                            {
                                count[c] = 0;
                                accumulator[c] = 0m;
                            }
                            else
                            {
                                accumulator[c] = th.Math.Zero;
                                count[c] = 0;
                            }
                            break;
                        case AggregateFunction.Product:
                            accumulator[c] = th.Math.One;
                            break;
                    }
                align[c] = th != null ? CalcAlignment(Columns[c].CellAlignment, th) : CellAlignment.Right;
            }

            Data.Row prevRow = null;
            for (int r = 0, rowIndex = 0; r <= rows.Length; r++, rowIndex++)
            {
                var row = r < rows.Length ? rows[r] : null;
                var closeToGroupLevel = row!=null ? groupData.Count : 0;

                if (prevRow != null && row != null)
                    for (int g = 0; g < groupData.Count; g++)
                        if (RowComparer.Compare(row, prevRow, groupData[g].Columns) != 0)
                        {
                            closeToGroupLevel = g;
                            break;
                        }

                //close higher groups first
                for (int g = groupData.Count - 1; g >= closeToGroupLevel; g--)
                {
                    var gd = groupData[g];
                    if (gd.GroupOpen)
                    {
                        gd.GroupOpen = false;
                        //close group
                        if (gd.Group.ShowFooter)
                        {
                            for (int c = 0; c < Columns.Length; c++)
                            {
                                if (Columns[c].AggregateFunction == AggregateFunction.Avg)
                                    gd.GroupAccumulator[c] = CalculateAggregate(Columns[c].AggregateFunction, gd.GroupAccumulator[c], gd.GroupCounter[c]);

                                var style = gd.GetFooterCellStyle(Columns[c].ColumnType);
                                switch (Columns[c].FooterType)
                                {
                                    case ColumnFooterType.FooterText:
                                        cells.Add(new Cell { Column = pos.Col + c, Row = pos.Row, FormattedValue = Columns[c].FooterText, Value = Columns[c].FooterText, CellStyleIndex = style, Alignment = Columns[c].FooterAlignment });
                                        break;
                                    case ColumnFooterType.AggregateValue:
                                        String fv = (Columns[c].FooterFormat != null) ? String.Format(Columns[c].FooterFormat, gd.GroupAccumulator[c]) : (gd.GroupAccumulator[c] != null ? gd.GroupAccumulator[c].ToString() : null);
                                        var al = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].FooterAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Auto;
                                        cells.Add(new Cell { Column = pos.Col + c, Row = pos.Row, FormattedValue = fv, Value = gd.GroupAccumulator[c], CellStyleIndex = style, Alignment = al, Format = Columns[c].FooterFormat });
                                        break;
                                    case ColumnFooterType.GroupFooter:
                                        String gfv = gd.PreparedFooterColumns == null ? gd.PreparedFooterFormat : String.Format(gd.PreparedFooterFormat, prevRow.GetMany(gd.PreparedFooterColumns));
                                        var gal = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].FooterAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Auto;
                                        cells.Add(new Cell { Column = pos.Col + c, Row = pos.Row, FormattedValue = gfv, Value = gfv, CellStyleIndex = style, Alignment = gal });
                                        break;
                                }
                                if (Columns[c].FooterColSpan > 1)
                                {
                                    report.MergedCells.Add(new Rect { Col1 = pos.Col + c, Col2 = pos.Col + c + Columns[c].FooterColSpan - 1, Row1 = pos.Row, Row2 = pos.Row });
                                    c += Columns[c].FooterColSpan - 1;
                                }
                            }
                            pos.Row++;
                        }
                    }
                }

                for (int g = 0; g < groupData.Count; g++) {
                    var gd = groupData[g];
                    //add row
                    if (row != null)
                    {
                        if (!gd.GroupOpen)
                        {
                            gd.GroupOpen = true;
                            rowIndex = 0;

                            if (gd.Group.ShowCaption)
                            {
                                String caption = gd.PreparedCaptionColumns == null ? gd.PreparedCaptionFormat : String.Format(gd.PreparedCaptionFormat, row.GetMany(gd.PreparedCaptionColumns));

                                cells.Add(new Cell { Column = pos.Col, Row = pos.Row, FormattedValue = caption, Value = caption, CellStyleIndex = gd.GetCaptionStyle()});
                                report.MergedCells.Add(new Rect { Col1 = pos.Col, Col2 = pos.Col + Columns.Length - 1, Row1 = pos.Row, Row2 = pos.Row });
                                pos.Row++;
                            }

                            if (gd.Group.ShowHeader)
                            {
                                for (int c = 0; c < Columns.Length; c++)
                                {
                                    var ht = Columns[c].HeaderText;
                                    var style = gd.GetHeaderCellStyle(Columns[c].ColumnType);
                                    var a = Columns[c]._DataFieldIndex >= 0 ? CalcAlignment(Columns[c].HeaderAlignment, data.TypeHelper[Columns[c]._DataFieldIndex]) : CellAlignment.Right;

                                    cells.Add(new Cell
                                    {
                                        Column = pos.Col + c,
                                        Row = pos.Row,
                                        FormattedValue = ht,
                                        Value = ht,
                                        CellStyleIndex = style,
                                        Alignment = a
                                    });
                                }
                                pos.Row++;
                            }

                            gd.GroupAccumulator = new object[Columns.Length];
                            gd.GroupCounter = new decimal[Columns.Length];

                            //reset group accumulator
                            for (int c = 0; c < Columns.Length; c++)
                            {
                                var th = Columns[c]._DataFieldIndex >= 0 ? data.TypeHelper[Columns[c]._DataFieldIndex] : null;
                                if (th != null)
                                    switch (Columns[c].AggregateFunction)
                                    {
                                        case AggregateFunction.Sum:
                                            gd.GroupAccumulator[c] = th.Math.Zero;
                                            break;
                                        case AggregateFunction.Count:
                                            gd.GroupAccumulator[c] = 0;
                                            break;
                                        case AggregateFunction.Avg:
                                            if (Columns[c].AggregateWeightDataField != null)
                                            {
                                                gd.GroupAccumulator[c] = 0m;
                                                gd.GroupCounter[c] = 0;
                                            }
                                            else
                                            {
                                                gd.GroupAccumulator[c] = th.Math.Zero;
                                                gd.GroupCounter[c] = 0;
                                            }
                                            break;
                                        case AggregateFunction.Product:
                                            gd.GroupAccumulator[c] = th.Math.One;
                                            break;
                                    }
                            }
                        }

                        for (int c = 0; c < Columns.Length; c++)
                        {
                            var dfi = Columns[c]._DataFieldIndex;
                            var v = row[dfi];

                            var th = dfi >= 0 ? data.TypeHelper[dfi] : null;
                            if (th != null)
                            {
                                switch (Columns[c].AggregateFunction)
                                {
                                    case AggregateFunction.Sum:
                                        gd.GroupAccumulator[c] = th.Math.SumNullAsZero(gd.GroupAccumulator[c], v);
                                        break;
                                    case AggregateFunction.Count:
                                        if (v != null)
                                            gd.GroupAccumulator[c] = (int)gd.GroupAccumulator[c] + 1;
                                        break;
                                    case AggregateFunction.Product:
                                        gd.GroupAccumulator[c] = th.Math.Multiply(gd.GroupAccumulator[c], v);
                                        break;
                                    case AggregateFunction.Avg:
                                        if (v != null)
                                        {
                                            if (Columns[c].AggregateWeightDataField != null)
                                            {
                                                var w = row[Columns[c]._AggregateWeightDataFieldIndex];
                                                if (w != null)
                                                {
                                                    var wd = Convert.ToDecimal(w);
                                                    var wv = wd * Convert.ToDecimal(v);
                                                    gd.GroupAccumulator[c] = (decimal)gd.GroupAccumulator[c] + wv;
                                                    gd.GroupCounter[c] += wd;
                                                }
                                            }
                                            else
                                            {
                                                gd.GroupAccumulator[c] = th.Math.Sum(gd.GroupAccumulator[c], v);
                                                ++gd.GroupCounter[c];
                                            }
                                        }
                                        break;
                                    case AggregateFunction.Min:
                                        if (gd.GroupAccumulator[c] == null)
                                            gd.GroupAccumulator[c] = v;
                                        else if (v != null)
                                            gd.GroupAccumulator[c] = th.Math.Min(gd.GroupAccumulator[c], v);
                                        break;
                                    case AggregateFunction.Max:
                                        if (gd.GroupAccumulator[c] == null)
                                            gd.GroupAccumulator[c] = v;
                                        else if (v != null)
                                            gd.GroupAccumulator[c] = th.Math.Max(gd.GroupAccumulator[c], v);
                                        break;
                                }
                            }

                            switch (Columns[c].CellDisplayMode)
                            {
                                default:
                                case CellDisplayMode.Normal:
                                    v = Columns[c].DataField == "#" ? rowIndex + 1 : row[dfi];
                                    break;
                                case CellDisplayMode.RowNumber:
                                    v = rowIndex + 1;
                                    break;
                                case CellDisplayMode.AccumulatorValue:
                                    v = CalculateAggregate(Columns[c].AggregateFunction, gd.GroupAccumulator[c], gd.GroupCounter[c]);
                                    break;
                            }

                            CellStyle addStyle = null;
                            if (Columns[c].ConditionalFormatting != null)
                                addStyle = Columns[c].ConditionalFormatting(v);

                            String fv = (Columns[c].Format != null) ? String.Format(Columns[c].Format, v) : (v != null ? v.ToString() : null);

                            if (g + 1 == groupData.Count)
                                cells.Add(new Cell
                                {
                                    Column = pos.Col + c,
                                    Row = pos.Row,
                                    Value = v,
                                    FormattedValue = fv,
                                    CellStyleIndex = Columns[c].ColumnType == TableColumnType.HeaderColumn ? CellStyleIndex.TableRowHeader : Columns[c].ColumnType == TableColumnType.FooterColumn ? CellStyleIndex.TableRowFooter : CellStyleIndex.TableRow,
                                    Alignment = align[c],
                                    Format = Columns[c].Format,
                                    CustomStyle = addStyle
                                });
                        }

                        if (g + 1 == groupData.Count)
                            pos.Row++;
                    }
                }

                prevRow = row;
            }

            fm.GetRect(RowCol.Zero, 0, pos.Row - startRow);

            report.Cells.AddRange(cells);
        }
예제 #37
0
        /// <summary>
        /// Deserialize the message
        /// </summary>
        /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
        public void Deserialize(OSDMap map)
        {
            OSDArray agentArray = (OSDArray)map["AgentData"];
            OSDMap agentMap = (OSDMap)agentArray[0];
            AgentID = agentMap["AgentID"].AsUUID();

            OSDArray groupArray = (OSDArray)map["GroupData"];

            GroupDataBlock = new GroupData[groupArray.Count];

            for (int i = 0; i < groupArray.Count; i++)
            {
                OSDMap groupMap = (OSDMap)groupArray[i];

                GroupData groupData = new GroupData();

                groupData.GroupID = groupMap["GroupID"].AsUUID();
                groupData.Contribution = groupMap["Contribution"].AsInteger();
                groupData.GroupInsigniaID = groupMap["GroupInsigniaID"].AsUUID();
                groupData.GroupName = groupMap["GroupName"].AsString();
                groupData.GroupPowers = (GroupPowers)groupMap["GroupPowers"].AsLong();
                groupData.AcceptNotices = groupMap["AcceptNotices"].AsBoolean();
                GroupDataBlock[i] = groupData;
            }

            // If request for current groups came very close to login
            // the Linden sim will not include the NewGroupData block, but
            // it will instead set all ListInProfile fields to false
            if (map.ContainsKey("NewGroupData"))
            {
                OSDArray newGroupArray = (OSDArray)map["NewGroupData"];

                NewGroupDataBlock = new NewGroupData[newGroupArray.Count];

                for (int i = 0; i < newGroupArray.Count; i++)
                {
                    OSDMap newGroupMap = (OSDMap)newGroupArray[i];
                    NewGroupData newGroupData = new NewGroupData();
                    newGroupData.ListInProfile = newGroupMap["ListInProfile"].AsBoolean();
                    NewGroupDataBlock[i] = newGroupData;
                }
            }
            else
            {
                NewGroupDataBlock = new NewGroupData[GroupDataBlock.Length];
                for (int i = 0; i < NewGroupDataBlock.Length; i++)
                {
                    NewGroupData newGroupData = new NewGroupData();
                    newGroupData.ListInProfile = false;
                    NewGroupDataBlock[i] = newGroupData;
                }
            }
        }
예제 #38
0
 /// <summary>
 /// Sets squad of this entity to given group
 /// </summary>
 /// <param name="g">Squad this entity belongs to</param>
 public void SetSquad(GroupData g)
 {
     squad = g;
 }
예제 #39
0
        private object PreprocessValue(object value, out bool isCommand)
        {
            isCommand = false;

            // If this isn't a command then ignore it
            var command = value as Command;
            if (command == null)
            {
                return value;
            }

            isCommand = true;

            if (command.Type == CommandType.AddToGroup)
            {
                var group = new GroupData
                {
                    Name = command.Value,
                    Cursor = _bus.GetCursor(command.Value)
                };

                command.Value = _serializer.Stringify(group);
            }
            else if (command.Type == CommandType.RemoveFromGroup)
            {
                var group = new GroupData
                {
                    Name = command.Value
                };

                command.Value = _serializer.Stringify(group);
            }

            return command;
        }
예제 #40
0
        private void BindData(string companyid)
        {
            DataTable        dt        = DBAccess.getLevelHierarchyData(companyid);
            var              distGroup = dt.AsEnumerable().Select(k => k.Field <string>("Entity")).Distinct();
            List <GroupData> listGooup = new List <GroupData>();

            foreach (var groupRow in distGroup)
            {
                GroupData data = new GroupData();
                data.Group = groupRow;
                List <CompanyData> listCompany = new List <CompanyData>();
                var distCompany = dt.AsEnumerable().Where(k => k.Field <string>("Entity") == groupRow).Select(k => k.Field <string>("CompanyID")).Distinct();
                foreach (var companyRow in distCompany)
                {
                    if (companyRow != null && companyRow != "null")
                    {
                        CompanyData dataCompany = new CompanyData();
                        dataCompany.Company = companyRow;
                        List <PlantData1> listPlant = new List <PlantData1>();
                        var distPlant = dt.AsEnumerable().Where(k => k.Field <string>("Entity") == groupRow && k.Field <string>("CompanyID") == companyRow).Select(k => k.Field <string>("PlantID")).Distinct();
                        foreach (var plantRow in distPlant)
                        {
                            if (plantRow != null && plantRow != "null")
                            {
                                PlantData1 dataPlant = new PlantData1();
                                dataPlant.Plant   = plantRow;
                                dataPlant.Company = companyRow;
                                dataPlant.Group   = groupRow;
                                listPlant.Add(dataPlant);
                            }
                        }
                        if (listPlant.Count == 0)
                        {
                            dataCompany.IconVisibility = "iconhidden";
                        }
                        else
                        {
                            int c = distPlant.Count();
                            dataCompany.IconVisibility = "iconvisible";
                        }
                        dataCompany.PlantList = listPlant;
                        listCompany.Add(dataCompany);
                    }
                }
                data.CompanyList = listCompany;
                if (listCompany.Count == 0)
                {
                    data.IconVisibility = "iconhidden";
                }
                else
                {
                    data.IconVisibility = "iconvisible";
                }
                listGooup.Add(data);
            }

            //List<GroupData> listGooup = new List<GroupData>();
            //GroupData data = new GroupData();
            //data.Group = "Group 1";
            //List<CompanyData> listCompany = new List<CompanyData>();
            //CompanyData dataCompany = new CompanyData();
            //dataCompany.Company="Company 1";
            //List<PlantData1> listPlant = new List<PlantData1>();
            //listPlant.Add(new PlantData1() { Plant = "Plant 1" });
            //listPlant.Add(new PlantData1() { Plant = "Plant 2" });
            //dataCompany.PlantList = listPlant;
            //listCompany.Add(dataCompany);
            //dataCompany = new CompanyData();
            //dataCompany.Company = "Company 2";
            //listPlant = new List<PlantData1>();
            //listPlant.Add(new PlantData1() { Plant = "Plant 1" });
            //listPlant.Add(new PlantData1() { Plant = "Plant 2" });
            //dataCompany.PlantList = listPlant;
            //listCompany.Add(dataCompany);
            //data.CompanyList = listCompany;
            //listGooup.Add(data);



            //data = new GroupData();
            //data.Group = "Group 2";
            //listCompany = new List<CompanyData>();
            //dataCompany = new CompanyData();
            //dataCompany.Company = "Company 3";
            //listPlant = new List<PlantData1>();
            //listPlant.Add(new PlantData1() { Plant = "Plant 1" });
            //listPlant.Add(new PlantData1() { Plant = "Plant 2" });
            //dataCompany.PlantList = listPlant;
            //listCompany.Add(dataCompany);
            //dataCompany = new CompanyData();
            //dataCompany.Company = "Company 4";
            //listPlant = new List<PlantData1>();
            //listPlant.Add(new PlantData1() { Plant = "Plant 4" });
            //listPlant.Add(new PlantData1() { Plant = "Plant 5" });
            //dataCompany.PlantList = listPlant;
            //listCompany.Add(dataCompany);
            //data.CompanyList = listCompany;
            //listGooup.Add(data);

            // gridview.DataSource = listGooup;
            //  gridview.DataBind();
            lvData.DataSource = listGooup;
            lvData.DataBind();
        }