Esempio n. 1
0
        public static GroupCollection GetGroupsAndMemberCount(IYZDbProvider provider, IDbConnection cn, string uid, string filter, string sort)
        {
            try
            {
                GroupCollection groups = new GroupCollection();
                using (YZReader reader = new YZReader(provider.GetGroupsAndMemberCount(cn, uid, filter, sort)))
                {
                    while (reader.Read())
                    {
                        Group group = new Group(reader);
                        group.MemberCount = reader.ReadInt32("MemberCount");

                        if (!String.IsNullOrEmpty(group.Name))
                        {
                            groups.Add(group);
                        }
                    }
                }
                return(groups);
            }
            catch (Exception e)
            {
                throw new BPMException(BPMExceptionType.DBLoadDataErr, "YZAppGroup", e.Message);
            }
        }
Esempio n. 2
0
        private void AddGroup()
        {
            RegexGroup group = new RegexGroup();

            GroupCollection.Add(group);
            SelectedGroup = group;
        }
        /// <summary>
        /// グループ名と説明を指定して、
        /// グループを追加します。
        /// </summary>
        /// <param name="this">GroupCollection</param>
        /// <param name="name">グループ名</param>
        /// <param name="description">説明</param>
        /// <returns>追加したグループを返します。</returns>
        public static Group Add(this GroupCollection @this, string name, string description)
        {
            var g = new GroupCreationInformation()
            {
                Title       = name,
                Description = description,
            };

            return(@this.Add(g));
        }
Esempio n. 4
0
        /// <summary>
        /// Creates group with restricted access permissions on client site collection to allow functionality in matter landing page
        /// </summary>
        /// <param name="siteUrl">URL of the client site collection to create group at</param>
        /// <param name="onlineCredentials">credentials to access site</param>
        internal static void CreateRestrictedGroup(string siteUrl, SharePointOnlineCredentials onlineCredentials)
        {
            try
            {
                Console.WriteLine("Creating " + ConfigurationManager.AppSettings["restrictedAccessGroupName"] + " group.");

                using (ClientContext clientContext = new ClientContext(siteUrl))
                {
                    clientContext.Credentials = onlineCredentials;
                    Site collSite = clientContext.Site;
                    Web  site     = clientContext.Web;

                    //Create group
                    GroupCollection collGroup = site.SiteGroups;
                    clientContext.Load(collGroup, group => group.Include(properties => properties.Title));
                    clientContext.Load(site.RoleDefinitions);
                    clientContext.ExecuteQuery();

                    Group currentGrp = (from grp in collGroup where grp.Title == ConfigurationManager.AppSettings["restrictedAccessGroupName"] select grp).FirstOrDefault();
                    if (currentGrp != null)
                    {
                        collGroup.Remove(currentGrp);
                    }

                    GroupCreationInformation grpInfo = new GroupCreationInformation();
                    grpInfo.Title       = ConfigurationManager.AppSettings["restrictedAccessGroupName"];
                    grpInfo.Description = ConfigurationManager.AppSettings["restrictedAccessGroupDescription"];
                    collGroup.Add(grpInfo);
                    site.Update();
                    clientContext.Load(collGroup);
                    clientContext.ExecuteQuery();

                    currentGrp = (from grp in collGroup where grp.Title == ConfigurationManager.AppSettings["restrictedAccessGroupName"] select grp).FirstOrDefault();

                    AssignPermissionToGroup(clientContext, collSite, site, currentGrp);

                    //Add everyone to group
                    User allUsers = clientContext.Web.EnsureUser(ConfigurationManager.AppSettings["allUsers"]);
                    clientContext.Load(allUsers);
                    clientContext.ExecuteQuery();

                    currentGrp.Users.AddUser(allUsers);
                    site.Update();
                    clientContext.Load(currentGrp);
                    clientContext.ExecuteQuery();

                    Console.WriteLine("Created " + ConfigurationManager.AppSettings["restrictedAccessGroupName"] + " group successfully");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception occurred while creating group: " + exception.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets all.
        /// </summary>
        /// <returns></returns>
        public GroupCollection GetAll()
        {
            GroupCollection          groups = new GroupCollection();
            SharePointListDescriptor items  = Provider.GetAllListItems(ForumConstants.Lists_Groups);

            foreach (SharePointListItem listItem in items.SharePointListItems)
            {
                groups.Add(new Group(listItem.Id, listItem["Title"]));
            }

            return(groups);
        }
Esempio n. 6
0
        private void LoadChildClusterGroups(GroupCluster cluster, GroupCollection groups)
        {
            foreach (Group group in new GroupCollection(cluster.GroupClusterID))
            {
                groups.Add(group);
            }

            foreach (GroupCluster childCluster in cluster.ChildClusters)
            {
                LoadChildClusterGroups(childCluster, groups);
            }
        }
Esempio n. 7
0
        private void SortGroups(string sort)
        {
            DataTable dt = allGroups.DataTable();
            if (sort != string.Empty)
                dt.DefaultView.Sort = sort;

            allGroups = new GroupCollection();
            foreach (DataRowView drv in dt.DefaultView)
            {
                Group group = new Group((int)drv["GroupID"]);
                group.MatchScore = Convert.ToDecimal(drv["MatchScore"]);
                allGroups.Add(group);
            }
        }
Esempio n. 8
0
        private Group GetGroup(string groupName)
        {
            Group retValue;

            if (_settings.Contains(groupName))
            {
                retValue = _settings[groupName];
            }
            else
            {
                retValue      = new Group();
                retValue.Name = groupName;
                _settings.Add(retValue);
            }
            return(retValue);
        }
        private void AddGroup(object param)
        {
            if (string.IsNullOrWhiteSpace(GroupName))
            {
                LabelError = "Błędna nazwa";
                return;
            }
            var ic = new BuildingChargeGroupName {
                GroupName = this.GroupName, BuildingChargeGroupNameId = Guid.NewGuid(), IsDeleted = false
            };

            GroupCollection.Add(ic);

            commandBuffer.Add(new Helpers.CategoryCommand <BuildingChargeGroupName> {
                CommandType = Helpers.CommandEnum.Add, Item = ic
            });
        }
Esempio n. 10
0
        /// <summary>
        /// 
        /// </summary>
        //static public GroupCollection CreateLocalGroupCollection(DB db, DTRequest dtRequest)
        public static GroupCollection CreateLocalGroupCollection(DB db, Client client)
        {
            _client = client;
            //_request = dtRequest;

            GroupCollection gs = new GroupCollection();
            DataTable tbl = db.GetGroupDataTable();
            foreach ( DataRow row in tbl.Rows){
                Group g = new Group();
                g.ID = Convert.ToInt32(row["GroupID"]);
                g.Name = row["GroupName"].ToString().Trim();
                CreateStationCollection(db, g);
                gs.Add(g);
            }

            return gs;
        }
Esempio n. 11
0
        async void AddCreators(ResourceLoader loader)
        {
            creatorQueue.Clear();
            CreatorList.Clear();

            var developGroup = new GroupCollection <Account>(loader.GetString("AboutDevelopment"));

            developGroup.Add(new Account()
            {
                Contact      = string.Format(FACEBOOK_SUPPORT, "yookjy"),
                ContactName  = "@facebook",
                ContactType  = ContactType.Web,
                Contact2     = "http://yookjy.wordpress.com",
                ContactName2 = "@blog",
                ContactType2 = ContactType.Web,
                Name         = loader.GetString("AboutDeveloper")
            });

            var designGroup = new GroupCollection <Account>(loader.GetString("AboutDesign"));

            designGroup.Add(new Account()
            {
                Contact      = string.Format(FACEBOOK_SUPPORT, "yookjy"),
                ContactName  = "@facebook",
                ContactType  = ContactType.Web,
                Contact2     = "http://yookjy.wordpress.com",
                ContactName2 = "@blog",
                ContactType2 = ContactType.Web,
                Name         = loader.GetString("AboutDesigner")
            });

            creatorQueue.Enqueue(developGroup);
            creatorQueue.Enqueue(designGroup);

            await DispatcherHelper.RunAsync(() =>
            {
                CreatorList.Add(creatorQueue.Dequeue());
            });
        }
Esempio n. 12
0
        /// <summary>
        /// Method to check if a group exists and create a new one
        /// </summary>
        /// <param name="collGroup">group collection</param>
        /// <param name="item">data storage</param>
        /// <param name="site">site object</param>
        /// <param name="clientContext">client context</param>
        /// <returns>returns group object</returns>
        private static Group CheckAndCreateGroup(GroupCollection collGroup, DataStorage item, Web site, ClientContext clientContext)
        {
            Group currentGrp = (from grp in collGroup where grp.Title == item.GroupName select grp).FirstOrDefault();

            if (currentGrp != null)
            {
                Console.WriteLine("Deleting group " + item.GroupName + " as it is already present");
                collGroup.Remove(currentGrp);
            }

            //Creating group
            Console.WriteLine("Creating group " + item.GroupName);
            GroupCreationInformation grpInfo = new GroupCreationInformation();

            grpInfo.Title       = item.GroupName;
            grpInfo.Description = item.GroupDesc;
            collGroup.Add(grpInfo);
            site.Update();
            clientContext.Load(collGroup);
            clientContext.ExecuteQuery();
            Console.WriteLine("Successfully created group " + item.GroupName);
            currentGrp = (from grp in collGroup where grp.Title == item.GroupName select grp).FirstOrDefault();
            return(currentGrp);
        }
Esempio n. 13
0
        private string GroupShape(Group group)
        {
            StringBuilder sb = new StringBuilder();

            if (!group.Private &&
                group.Active &&
                group.ClusterType.Category.CategoryID == category.CategoryID)
            {
                if (group.TargetLocation != null &&
                    group.TargetLocation.AddressID != -1 &&
                    group.TargetLocation.Latitude != 0 &&
                    group.TargetLocation.Longitude != 0)
                {
                    double latitude = group.TargetLocation.Latitude;
                    double longitude = group.TargetLocation.Longitude;

                    if (maxLatitude == double.MinValue || maxLatitude < latitude) maxLatitude = latitude;
                    if (maxLongitude == double.MinValue || maxLongitude < longitude) maxLongitude = longitude;
                    if (minLatitude == double.MinValue || minLatitude > latitude) minLatitude = latitude;
                    if (minLongitude == double.MinValue || minLongitude > longitude) minLongitude = longitude;

                    sb.AppendFormat("\n\tshape = new VEShape(VEShapeType.Pushpin, new VELatLong({0}, {1}));\n", latitude.ToString(), longitude.ToString());
                    sb.AppendFormat("\tshape.SetCustomIcon('{0}');\n", GroupIconSetting);
                    sb.AppendFormat("\tshape.SetTitle(\"{0}\");\n", BuildDetailTitle(group.Title));
                    sb.AppendFormat("\tshape.SetDescription(\"{0}\");\n", BuildDetailPanel(group));
                    sb.Append("\tmapGroupLayer.AddShape(shape);\n");

                    group.MatchScore = mapGroupCount;
                    mapGroupCount++;
                }

                allGroups.Add(group);
            }

            return sb.ToString();
        }
Esempio n. 14
0
 public void AddGroup(WonkaRefGroup poNewGroup)
 {
     GroupCollection.Add(poNewGroup);
 }
Esempio n. 15
0
        /// <summary>
        /// Imports the new groups.
        /// </summary>
        private void ImportNewGroups()
        {
            Console.WriteLine("Import new groups...");
            Logger.AddMessage("import new Groups...");
            GroupCollection groupCollectionOnSourceServer = this.GetAllGroups(this.SourceClientContext);
            GroupCollection groupCollectoinOnTargetServer = this.GetAllGroups(this.TargetClientContext);

            HashSet <string> titlesOfGroupsOnTargetServer = groupCollectoinOnTargetServer.GetAllTitles();

            foreach (var sourceGroup in groupCollectionOnSourceServer)
            {
                if (!titlesOfGroupsOnTargetServer.Contains(sourceGroup.Title))
                {
                    Console.WriteLine("import group '{0}'", sourceGroup.Title);
                    Logger.AddMessage("import group '" + sourceGroup.Title + "'");
                    GroupCreationInformation groupCreationInformation = new GroupCreationInformation();
                    groupCreationInformation.Description = sourceGroup.Description;
                    groupCreationInformation.Title       = sourceGroup.Title;

                    Group targetGroup = groupCollectoinOnTargetServer.Add(groupCreationInformation);

                    try
                    {
                        targetGroup.AllowMembersEditMembership = sourceGroup.AllowMembersEditMembership;
                    }
                    catch (PropertyOrFieldNotInitializedException)
                    {
                    }

                    try
                    {
                        targetGroup.AllowRequestToJoinLeave = sourceGroup.AllowRequestToJoinLeave;
                    }
                    catch (PropertyOrFieldNotInitializedException)
                    {
                    }

                    try
                    {
                        targetGroup.AutoAcceptRequestToJoinLeave = sourceGroup.AutoAcceptRequestToJoinLeave;
                    }
                    catch (PropertyOrFieldNotInitializedException)
                    {
                    }
                }
                else
                {
                    Console.WriteLine("don't have to migrate group with title '{0}'", sourceGroup.Title);
                    Logger.AddMessage("don't have to import group '" + sourceGroup.Title + "'");
                }
            }

            try
            {
                this.TargetClientContext.ExecuteQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during importing new SiteGroups.", e);
                Logger.AddMessage("Exception during importing new SiteGroups. Error = " + e.Message);
                throw new ElementsMigrationException("Exception during importing new SiteGroups.", e);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Method to check if a group exists and create a new one
        /// </summary>
        /// <param name="collGroup">group collection</param>
        /// <param name="item">data storage</param>
        /// <param name="site">site object</param>
        /// <param name="clientContext">client context</param>
        /// <returns>returns group object</returns>
        private static Group CheckAndCreateGroup(GroupCollection collGroup, DataStorage item, Web site, ClientContext clientContext)
        {
            Group currentGrp = (from grp in collGroup where grp.Title == item.GroupName select grp).FirstOrDefault();
            if (currentGrp != null)
            {
                Console.WriteLine("Deleting group " + item.GroupName + " as it is already present");
                collGroup.Remove(currentGrp);
            }

            //Creating group
            Console.WriteLine("Creating group " + item.GroupName);
            GroupCreationInformation grpInfo = new GroupCreationInformation();
            grpInfo.Title = item.GroupName;
            grpInfo.Description = item.GroupDesc;
            collGroup.Add(grpInfo);
            site.Update();
            clientContext.Load(collGroup);
            clientContext.ExecuteQuery();
            Console.WriteLine("Successfully created group " + item.GroupName);
            currentGrp = (from grp in collGroup where grp.Title == item.GroupName select grp).FirstOrDefault();
            return currentGrp;
        }
Esempio n. 17
0
 public void AddGroup(Group group)
 {
     groups.Add(group);
 }
Esempio n. 18
0
        static void Main(string[] args)
        {
            GroupCollection collection1 = new GroupCollection();
            GroupCollection collection2 = new GroupCollection();

            /* collection1.AddRange(new int[] { 1 });
            *  collection1.AddRange(new int[] {  3 });
            *  collection1.AddRange(new int[] {  2 });*/
            collection1.Add(1);
            collection1.Add(3);
            collection1.Add(2);
            collection2.Add(1);
            Console.WriteLine(GroupCollection.Intersect(collection1, collection2));

            Console.ReadLine();
            return;

            PhysicsEngine engine = new PhysicsEngine();

            engine.BroadPhase = new Physics2DDotNet.Detectors.SelectiveSweepDetector();
            engine.Solver     = new Physics2DDotNet.Solvers.SequentialImpulsesSolver();

            PhysicsTimer timer = new PhysicsTimer(engine.Update, .01f);

            timer.IsRunning = true;



            Coefficients coffecients = new Coefficients(/*restitution*/ 1, /*friction*/ .5f);


            IShape shape1 = new CircleShape(8, 7);
            IShape shape2 = new PolygonShape(VertexHelper.CreateRectangle(20, 10), 3);

            Scalar mass  = 5;
            Body   body1 = new Body(new PhysicsState(), shape1, mass, coffecients, new Lifespan());
            Body   body2 = new Body(new PhysicsState(), shape2, mass, coffecients, new Lifespan());

            engine.AddBody(body1);
            engine.AddBody(body2);
            Joint joint = new HingeJoint(body1, body2, Vector2D.Zero, new Lifespan());

            engine.AddJoint(joint);
            joint.Lifetime.IsExpired = true;

            engine.AddJoint(new HingeJoint(body1, body2, Vector2D.Zero, new Lifespan()));
            engine.Update(0, 0);

            body1.Lifetime.IsExpired = true;

            timer.IsRunning = false;
            engine.AddProxy(body1, body2, Matrix2x2.Identity);
            //  b1.RemoveFromProxy();



            BinaryFormatter formatter = new BinaryFormatter();
            MemoryStream    stream    = new MemoryStream();

            formatter.Serialize(stream, engine);
            stream.Seek(0, SeekOrigin.Begin);
            PhysicsEngine engine2 = (PhysicsEngine)formatter.Deserialize(stream);



            Console.WriteLine();

            /*
             *
             * Vector2D[] vertexes1 = new Vector2D[]
             * {
             *  new Vector2D(-1,1),
             *  new Vector2D(-3,1),
             *  new Vector2D(-3,-1),
             *  new Vector2D(-1,-1),
             * };
             * Vector2D[] vertexes2 = new Vector2D[]
             * {
             *  new Vector2D(1,-1),
             *  new Vector2D(3,-1),
             *  new Vector2D(3,1),
             *  new Vector2D(1,1),
             * };
             * Vector2D[][] polygons = new Vector2D[2][];
             * polygons[0] = vertexes1;
             * polygons[1] = vertexes2;
             * Console.WriteLine(MultiPartPolygon.GetCentroid(polygons));
             * Console.WriteLine(MultiPartPolygon.GetArea(polygons));
             */
            Console.WriteLine("Finished");
            Console.ReadLine();
        }
Esempio n. 19
0
        async void AddCredits(ResourceLoader loader)
        {
            creditsQueue.Clear();
            CreditsList.Clear();

            var libraryGroup = new GroupCollection <Account>(loader.GetString("AboutLibraryCreators"));

            libraryGroup.Add(new Account()
            {
                Contact      = "https://code.google.com/p/ude/",
                ContactType  = ContactType.Web,
                Name         = "UDE",
                ContactName  = "@source code",
                Contact2     = "https://www.mozilla.org/MPL/",
                ContactType2 = ContactType.Web,
                ContactName2 = "/   license (MPL 1.1)",
            });
            libraryGroup.Add(new Account()
            {
                Contact     = "http://www.mvvmlight.net/",
                ContactType = ContactType.Web,
                Name        = "MVVM Light Toolkit",
                ContactName = "@homepage",
            });
            libraryGroup.Add(new Account()
            {
                Name         = "FFmpegInterop library for Windows",
                Contact      = "https://github.com/Microsoft/FFmpegInterop",
                ContactType  = ContactType.Web,
                ContactName  = "@source code",
                Contact2     = "http://www.apache.org/licenses/LICENSE-2.0",
                ContactType2 = ContactType.Web,
                ContactName2 = "/   license (Apache 2.0 License)",
            });
            libraryGroup.Add(new Account()
            {
                Name         = "FFmpeg",
                Contact      = "http://www.ffmpeg.org/",
                ContactType  = ContactType.Web,
                ContactName  = "@homepage",
                Contact2     = "https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3",
                ContactType2 = ContactType.Web,
                ContactName2 = "/   license (LGPL v2.1 or later)",
            });

            var specialGroup = new GroupCollection <Account>(loader.GetString("AboutSpecialThanks"));

            specialGroup.Add(new Account()
            {
                Name = loader.GetString("AboutSpecialPeople1")
            });
            //specialGroup.Add(new Account()
            //{
            //    Contact = string.Format(FACEBOOK_SUPPORT, "100001136649926"),
            //    ContactType = ContactType.Web,
            //    ContactName = "@facebook",
            //    Name = loader.GetString("AboutSpecialPeople2")
            //});
            specialGroup.Add(new Account()
            {
                Name = loader.GetString("AboutSpecialPeople3")
            });

            var translateGroup = new GroupCollection <Account>(loader.GetString("AboutTranslators"));

            translateGroup.Add(new Account()
            {
                Contact     = "http://about.me/masabalos",
                ContactType = ContactType.Web,
                ContactName = "@homepage",
                Name        = loader.GetString("AboutTranslatePeople1"),
                Attr1       = "Spanish (Español)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople2"),
                Attr1       = "Russian (русский)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "http://m.facebook.com/degetel2007",
                ContactType = ContactType.Web,
                ContactName = "@facebook",
                Name        = loader.GetString("AboutTranslatePeople3"),
                Attr1       = "Romanian (Român)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople4"),
                Attr1       = "Hungarian (Magyar)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "http://preludebg.com/",
                ContactType = ContactType.Web,
                ContactName = "@homepage",
                Name        = loader.GetString("AboutTranslatePeople5"),
                Attr1       = "Bulgarian (български)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople6"),
                Attr1       = "Chinese (中文)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople7"),
                Attr1       = "Ukrainian (Український)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople8"),
                Attr1       = "Persian (فارسی)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople9"),
                Attr1       = "Hindi (भारतीय)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople10"),
                Attr1       = "Turkish (Türk)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "http://about.me/eduardorodrigues",
                ContactType = ContactType.Web,
                ContactName = "@homepage",
                Name        = loader.GetString("AboutTranslatePeople11"),
                Attr1       = "Portuguese (Português)"
            });
            translateGroup.Add(new Account()
            {
                Contact     = "mailto:[email protected]",
                ContactType = ContactType.Email,
                ContactName = "@email",
                Name        = loader.GetString("AboutTranslatePeople12"),
                Attr1       = "French (français)"
            });

            creditsQueue.Enqueue(specialGroup);
            creditsQueue.Enqueue(translateGroup);
            creditsQueue.Enqueue(libraryGroup);

            await DispatcherHelper.RunAsync(() =>
            {
                CreditsList.Add(creditsQueue.Dequeue());
            });
        }
Esempio n. 20
0
    //Grid填充
    protected static void DoGridFill(HSSFWorkbook book, DataSet dataset)
    {
        HSSFSheet sheetFillDefine = (HSSFSheet)book.GetSheet("GridFill");

        if (sheetFillDefine == null)
        {
            return;
        }

        GridDefineCollection gridDefines = new GridDefineCollection();
        GridDefine           gridDefine  = null;
        object curSection = null;

        for (int r = 1; r <= sheetFillDefine.LastRowNum; r++)
        {
            HSSFRow excelRow = (HSSFRow)sheetFillDefine.GetRow(r);
            if (excelRow == null)
            {
                continue;
            }

            //获得FixFill中的一设定行
            string[] values = new string[12];
            for (int i = 0; i <= values.Length - 1 && i <= excelRow.LastCellNum; i++)
            {
                HSSFCell cell = (HSSFCell)excelRow.GetCell(i);
                if (cell == null)
                {
                    continue;
                }

                string value;
                if (cell.CellType == CellType.NUMERIC)
                {
                    value = cell.NumericCellValue.ToString();
                }
                else
                {
                    value = cell.StringCellValue;
                }

                if (value != null)
                {
                    value = value.Trim();
                }

                values[i] = value;
            }

            string sheetName   = values[0];  //填充到的sheet
            string startRow    = values[1];  //填充到的Cell
            string blockRows   = values[2];  //替换Cell中的一部分
            string tableName   = values[3];  //用那个表中的数据填充
            string sectionName = values[4];  //用那列数据填充
            string minRows     = values[11]; //至少几行

            //应用缺省值
            if (String.IsNullOrEmpty(sheetName))
            {
                sheetName = book.GetSheetName(0);
            }

            if (!String.IsNullOrEmpty(startRow))
            {
                gridDefine = new GridDefine();
                gridDefines.Add(gridDefine);

                gridDefine.SheetName     = sheetName;
                gridDefine.Sheet         = (HSSFSheet)book.GetSheet(sheetName);
                gridDefine.StartRow      = Int32.Parse(startRow) - 1;
                gridDefine.BlockRowCount = Int32.Parse(blockRows);
                gridDefine.FillTableName = tableName;
                gridDefine.MinRows       = 0;
                Int32.TryParse(minRows, out gridDefine.MinRows);
            }

            if (gridDefine == null)
            {
                continue;
            }

            if (!String.IsNullOrEmpty(sectionName))
            {
                if (String.Compare(sectionName, "Fill", true) == 0)
                {
                    curSection = gridDefine.GridCellFills;
                }
                else if (String.Compare(sectionName, "Template", true) == 0)
                {
                    curSection = gridDefine.GridBlockTemplates;
                }
                else if (String.Compare(sectionName, "Group", true) == 0)
                {
                    curSection = gridDefine.Groups;
                }
                else
                {
                    curSection = null;
                }
            }
            else
            {
                if (curSection is GridCellFillCollection)
                {
                    GridCellFillCollection fills = curSection as GridCellFillCollection;
                    GridCellFill           fill  = new GridCellFill();
                    fills.Add(fill);

                    string cellName       = values[5];
                    string cellVarName    = values[6];
                    string fillColumnName = values[7];
                    string renderFunction = values[8];
                    string emptyText      = values[9];

                    //应用缺省值
                    if (String.IsNullOrEmpty(renderFunction))
                    {
                        renderFunction = "DefaultRender";
                    }

                    Point cellPos = YZExcelHelper.CellNameToIndex(cellName);

                    fill.RowOffset      = cellPos.Y - gridDefine.StartRow;
                    fill.ColumnIndex    = cellPos.X;
                    fill.CellVarName    = cellVarName;
                    fill.FillColumnName = fillColumnName;
                    fill.RenderFunction = renderFunction;
                    fill.EmptyText      = emptyText;
                }
                else if (curSection is GridBlockTemplateCollection)
                {
                    string templateName     = values[5];
                    string startRowIndexStr = values[6];
                    string condition        = values[7];

                    int startRowIndex = 0;
                    if (Int32.TryParse(startRowIndexStr, out startRowIndex))
                    {
                        GridBlockTemplateCollection templates = curSection as GridBlockTemplateCollection;
                        GridBlockTemplate           template  = new GridBlockTemplate(gridDefine);
                        templates.Add(template);

                        template.Name      = templateName;
                        template.StartRow  = startRowIndex - 1;
                        template.Condition = condition;
                    }
                }
                else if (curSection is GroupCollection)
                {
                    string columnName = values[5];

                    if (!String.IsNullOrEmpty(columnName))
                    {
                        GroupCollection groups = curSection as GroupCollection;
                        Group           group  = new Group();
                        groups.Add(group);

                        group.ColumnName = columnName;
                    }
                }
                else
                {
                }
            }
        }

        gridDefines.Sort();

        foreach (GridDefine grid in gridDefines)
        {
            HSSFSheet sheetfill = grid.Sheet;

            foreach (GridBlockTemplate template in grid.GridBlockTemplates)
            {
                for (int i = 0; i < grid.BlockRowCount; i++)
                {
                    HSSFRow row = (HSSFRow)sheetfill.GetRow(template.StartRow + i);
                    template.Rows.Add(row);
                }

                for (int i = 0; i < sheetfill.NumMergedRegions; i++)
                {
                    CellRangeAddress region = sheetfill.GetMergedRegion(i);
                    if (region.FirstRow >= template.StartRow && region.LastRow <= template.StartRow + grid.BlockRowCount - 1)
                    {
                        region           = region.Copy();
                        region.FirstRow -= template.StartRow;
                        region.LastRow  -= template.StartRow;
                        template.MergedRegions.Add(region);
                    }
                }

                for (int i = 0; i < book.NumberOfSheets; i++)
                {
                    HSSFSheet sheet = book.GetSheetAt(i) as HSSFSheet;

                    if (IsSystemSheet(sheet))
                    {
                        continue;
                    }

                    foreach (HSSFChart chart in HSSFChart.GetSheetCharts(sheet))
                    {
                        foreach (HSSFChart.HSSFSeries series in chart.Series)
                        {
                            if (template.Contains(sheet, series))
                            {
                                SeriesTemplate seriesTemplate = new SeriesTemplate();
                                template.SeriesTemplates.Add(seriesTemplate);
                                seriesTemplate.Chart  = chart;
                                seriesTemplate.Series = series;
                            }
                        }
                    }
                }
            }

            if (grid.GridBlockTemplates.Count != 0)
            {
                grid.GridBlockTemplates[grid.GridBlockTemplates.Count - 1].Condition = null;
            }
        }

        for (int i = 0; i < book.NumberOfSheets; i++)
        {
            HSSFSheet sheet = book.GetSheetAt(i) as HSSFSheet;
            if (IsSystemSheet(sheet))
            {
                continue;
            }

            foreach (CellValueRecordInterface recInferface in sheet.Sheet.RowsAggregate.GetValueRecords())
            {
                if (recInferface is FormulaRecordAggregate)
                {
                    FormulaRecordAggregate fraInterface  = recInferface as FormulaRecordAggregate;
                    FormulaRecord          formulaRecord = fraInterface.FormulaRecord;
                    if (formulaRecord.IsSharedFormula)
                    {
                        fraInterface.UnlinkSharedFormula();
                    }
                }
            }
        }

        foreach (GridDefine grid in gridDefines)
        {
            //创建空Grid
            HSSFSheet sheetfill         = grid.Sheet;
            DataTable dataTable         = dataset.Tables[grid.FillTableName];
            int       gridTagBlockCount = Math.Max(dataTable.Rows.Count, grid.MinRows);
            int       gridTagRowCount   = grid.BlockRowCount * gridTagBlockCount;

            //GroupData(dataTable);
            //DataView view1 = new DataView(dataTable);
            //view1.Sort = "City asc,Shop asc";
            //dataTable = view1.ToTable();

            if (dataTable != null && dataTable.Rows.Count != 0)
            {
                if (dataTable.Rows.Count != 0 && sheetfill.LastRowNum >= grid.TemplateEndRow + 1)
                {
                    sheetfill.ShiftRows(grid.TemplateEndRow + 1, sheetfill.LastRowNum, gridTagRowCount, true, false);
                }

                for (int i = 0; i < sheetfill.NumMergedRegions; i++)
                {
                    CellRangeAddress region = sheetfill.GetMergedRegion(i);
                    if (region.FirstRow <= grid.StartRow && region.LastRow >= grid.TemplateEndRow)
                    {
                        region.LastRow += Math.Max(dataTable.Rows.Count, grid.MinRows);
                    }
                }

                HSSFSheet hssfsheet = sheetfill as HSSFSheet;
                foreach (CellValueRecordInterface recInferface in hssfsheet.Sheet.RowsAggregate.GetValueRecords())
                {
                    if (recInferface is FormulaRecordAggregate)
                    {
                        FormulaRecord formulaRecord = ((FormulaRecordAggregate)recInferface).FormulaRecord;
                        Ptg[]         ptgs          = formulaRecord.ParsedExpression;
                        foreach (Ptg ptg in ptgs)
                        {
                            List <int> rowIndexs    = new List <int>();
                            List <int> newRowIndexs = new List <int>();

                            if (ptg is RefPtgBase)
                            {
                                RefPtgBase refPtg = ptg as RefPtgBase;
                                rowIndexs.Add(refPtg.Row);
                            }
                            else if (ptg is AreaPtgBase)
                            {
                                AreaPtgBase aptg = ptg as AreaPtgBase;
                                rowIndexs.Add(aptg.FirstRow);
                                rowIndexs.Add(aptg.LastRow);
                            }

                            foreach (int rowIndex in rowIndexs)
                            {
                                int newRowIndex = rowIndex;
                                if (formulaRecord.Row < grid.StartRow || formulaRecord.Row > grid.TemplateEndRow)
                                {
                                    if (rowIndex == grid.StartRow)
                                    {
                                        newRowIndex = grid.TemplateEndRow + 1;
                                    }

                                    if (rowIndex == grid.TemplateEndRow)
                                    {
                                        newRowIndex = grid.TemplateEndRow + gridTagRowCount;
                                    }
                                }

                                newRowIndexs.Add(newRowIndex);
                            }

                            for (int i = 0; i < rowIndexs.Count; i++)
                            {
                                int rowIndex    = rowIndexs[i];
                                int newRowIndex = newRowIndexs[i];

                                if (newRowIndex != rowIndex)
                                {
                                    if (ptg is RefPtgBase)
                                    {
                                        RefPtgBase refPtg = ptg as RefPtgBase;
                                        refPtg.Row = newRowIndex;
                                    }
                                    else if (ptg is AreaPtgBase)
                                    {
                                        AreaPtgBase aptg = ptg as AreaPtgBase;
                                        if (i == 0)
                                        {
                                            aptg.FirstRow = newRowIndex;
                                        }
                                        else
                                        {
                                            aptg.LastRow = newRowIndex;
                                        }
                                    }
                                    formulaRecord.ParsedExpression = ptgs;
                                }
                            }
                        }
                    }
                }

                for (int i = 0; i < book.NumberOfSheets; i++)
                {
                    HSSFSheet sheet = book.GetSheetAt(i) as HSSFSheet;

                    if (IsSystemSheet(sheet))
                    {
                        continue;
                    }

                    foreach (RecordBase recbase in sheet.Sheet.Records)
                    {
                        if (recbase is LinkedDataRecord)
                        {
                            LinkedDataRecord link = recbase as LinkedDataRecord;
                            Ptg[]            ptgs = ptgs = link.FormulaOfLink;
                            foreach (Ptg ptg in ptgs)
                            {
                                HSSFSheet sheetptg = PtgCollection.GetPtgSheet(sheet, ptg);
                                if (sheetptg == sheetfill)
                                {
                                    if (ptg is RefPtgBase)
                                    {
                                        RefPtgBase refPtg = ptg as RefPtgBase;

                                        if (refPtg.Row > grid.TemplateEndRow)
                                        {
                                            refPtg.Row        += gridTagRowCount - (grid.TemplateEndRow - grid.StartRow + 1);
                                            link.FormulaOfLink = ptgs;
                                        }
                                    }
                                    if (ptg is AreaPtgBase)
                                    {
                                        AreaPtgBase areaPtg = ptg as AreaPtgBase;
                                        if (areaPtg.FirstRow <= grid.StartRow && areaPtg.LastRow >= grid.TemplateEndRow)
                                        {
                                            areaPtg.LastRow   += gridTagRowCount - (grid.TemplateEndRow - grid.StartRow + 1);
                                            link.FormulaOfLink = ptgs;
                                        }
                                        else if (areaPtg.FirstRow > grid.TemplateEndRow)
                                        {
                                            areaPtg.FirstRow  += gridTagRowCount - (grid.TemplateEndRow - grid.StartRow + 1);
                                            areaPtg.LastRow   += gridTagRowCount - (grid.TemplateEndRow - grid.StartRow + 1);
                                            link.FormulaOfLink = ptgs;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                dataTable.Columns.Add("_gridTemplateIndex", typeof(object));
                foreach (GridBlockTemplate template in grid.GridBlockTemplates)
                {
                    if (String.IsNullOrEmpty(template.Condition))
                    {
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            if (Convert.IsDBNull(dataRow["_gridTemplateIndex"]))
                            {
                                dataRow["_gridTemplateIndex"] = template;
                            }
                        }

                        break;
                    }

                    DataView view = new DataView(dataTable);
                    view.RowFilter = template.Condition.Replace("$totalRow", dataTable.Rows.Count.ToString());
                    DataTable rvTable = view.ToTable();
                    foreach (DataRow dataRow in rvTable.Rows)
                    {
                        int     rowIndex   = Convert.ToInt32(dataRow["RowNum"]);
                        DataRow dataRowSrc = dataTable.Rows[rowIndex - 1];
                        dataRowSrc["_gridTemplateIndex"] = template;
                    }
                }

                for (int i = 0; i < gridTagBlockCount; i++)
                {
                    GridBlockTemplate template;

                    if (i >= dataTable.Rows.Count)
                    {
                        template = grid.GridBlockTemplates[grid.GridBlockTemplates.Count - 1];
                    }
                    else
                    {
                        template = dataTable.Rows[i]["_gridTemplateIndex"] as GridBlockTemplate;
                    }

                    int startRowIndex = grid.TemplateEndRow + 1 + i * grid.BlockRowCount;
                    for (int j = 0; j < grid.BlockRowCount; j++)
                    {
                        int     newRowIndex = startRowIndex + j;
                        HSSFRow newRow      = (HSSFRow)sheetfill.GetRow(newRowIndex);
                        if (newRow == null)
                        {
                            newRow = (HSSFRow)sheetfill.CreateRow(newRowIndex);
                        }

                        if (template != null)
                        {
                            HSSFRow srcRow = template.Rows[j];
                            CopyRow(grid.BlockRowCount, j, srcRow, newRow);
                        }
                    }

                    foreach (CellRangeAddress region in template.MergedRegions)
                    {
                        sheetfill.AddMergedRegion(new CellRangeAddress(startRowIndex + region.FirstRow, startRowIndex + region.FirstRow, region.FirstColumn, region.LastColumn));
                    }

                    foreach (SeriesTemplate seriesTemplate in template.SeriesTemplates)
                    {
                        seriesTemplate.CloneSeries(sheetfill, i * grid.BlockRowCount - (template.StartRow - grid.StartRow));
                    }
                }

                foreach (GridBlockTemplate template in grid.GridBlockTemplates)
                {
                    foreach (SeriesTemplate seriesTemplate in template.SeriesTemplates)
                    {
                        seriesTemplate.Chart.RemoveSeries(seriesTemplate.Series);
                    }
                }
            }

            //删除模板
            int addedExcelRowCount = 0;
            if (dataTable != null)
            {
                addedExcelRowCount = dataTable.Rows.Count * grid.BlockRowCount;
            }

            for (int i = grid.StartRow; i <= grid.TemplateEndRow; i++)
            {
                sheetfill.CreateRow(i);
            }

            int firstRow = grid.StartRow;
            int lastRow  = grid.TemplateEndRow;

            ShiftRows(sheetfill, grid.TemplateEndRow + 1, -(grid.TemplateEndRow - grid.StartRow + 1));

            //填充数据
            if (dataTable != null)
            {
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    foreach (GridCellFill fill in grid.GridCellFills)
                    {
                        Point cellPos = new Point();
                        cellPos.X = fill.ColumnIndex;
                        cellPos.Y = grid.StartRow + fill.RowOffset + i * grid.BlockRowCount;

                        //获得要填充的cell的行列序号
                        HSSFRow rowfill = (HSSFRow)sheetfill.GetRow(cellPos.Y);
                        if (rowfill == null)
                        {
                            continue;
                        }

                        //获得要填充的cell
                        HSSFCell cellfill = (HSSFCell)rowfill.GetCell(cellPos.X);
                        if (cellfill == null)
                        {
                            cellfill = (HSSFCell)rowfill.CreateCell(cellPos.X);
                        }

                        //获得填充值
                        object valuefill = null;
                        if (dataTable.Columns.Contains(fill.FillColumnName))
                        {
                            valuefill = row[fill.FillColumnName];
                        }

                        //执行填充
                        DoRender(fill.RenderFunction, cellfill, fill.CellVarName, dataset, valuefill, fill.EmptyText);
                    }
                }

                for (int i = dataTable.Rows.Count; i < grid.MinRows; i++)
                {
                    foreach (GridCellFill fill in grid.GridCellFills)
                    {
                        Point cellPos = new Point();
                        cellPos.X = fill.ColumnIndex;
                        cellPos.Y = grid.StartRow + fill.RowOffset + i * grid.BlockRowCount;

                        //获得要填充的cell的行列序号
                        HSSFRow rowfill = (HSSFRow)sheetfill.GetRow(cellPos.Y);
                        if (rowfill == null)
                        {
                            continue;
                        }

                        //获得要填充的cell
                        HSSFCell cellfill = (HSSFCell)rowfill.GetCell(cellPos.X);
                        if (cellfill == null)
                        {
                            cellfill = (HSSFCell)rowfill.CreateCell(cellPos.X);
                        }

                        //获得填充值
                        cellfill.SetCellValue("");
                    }
                }

                MergeCells(sheetfill, grid, grid.Groups, 0, grid.StartRow, gridTagRowCount);
            }
        }
    }