protected void Page_Load(object sender, EventArgs e)
    {
        // Only community manager can delete group
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE))
        {
            RedirectToAccessDenied("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE);
        }

        int groupId = QueryHelper.GetInteger("groupid", 0);
        gi = GroupInfoProvider.GetGroupInfo(groupId);

        if (gi != null)
        {
            lblMsg.Style.Add("font-weight", "bold");
            chkDeleteAll.Text = MacroResolver.Resolve(GetString("group.deleterelated"));
            mGroupListUrl = ResolveUrl(mGroupListUrl);

            // Pagetitle
            PageTitle.TitleText = GetString("group.deletegroup") + " \"" + HTMLHelper.HTMLEncode(gi.GroupDisplayName) + "\"";
            // Initialize breadcrumbs
            PageBreadcrumbs.Items.Add(new BreadcrumbItem()
            {
                Text = GetString("deletegroup.listlink"),
                RedirectUrl = mGroupListUrl,
            });
            PageBreadcrumbs.Items.Add(new BreadcrumbItem()
            {
                Text = HTMLHelper.HTMLEncode(gi.GroupDisplayName),
            });

            btnDelete.Click += new EventHandler(btnDelete_Click);
            btnCancel.Click += new EventHandler(btnCancel_Click);
        }
    }
Beispiel #2
0
 public static void Init(GroupInfo[] groupInfo)
 {
     for (int index = 0; index < groupInfo.Length; ++index)
     {
         m_groupDict.Add(groupInfo[index].Name, groupInfo[index].Group);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Only community manager can delete group
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE))
        {
            RedirectToCMSDeskAccessDenied("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE);
        }

        int groupId = QueryHelper.GetInteger("groupid", 0);
        gi = GroupInfoProvider.GetGroupInfo(groupId);

        if (gi != null)
        {
            lblMsg.Style.Add("font-weight", "bold");
            mGroupListUrl = ResolveUrl(mGroupListUrl);

            // Pagetitle
            CurrentMaster.Title.TitleText = GetString("group.deletegroup") + " \"" + HTMLHelper.HTMLEncode(gi.GroupDisplayName) + "\"";
            CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Groups/groupdelete.png");

            // Initializes breadcrumbs
            string[,] breadcrumbs = new string[2,3];
            breadcrumbs[0, 0] = GetString("group.deletegroup.listlink");
            breadcrumbs[0, 1] = mGroupListUrl;
            breadcrumbs[0, 2] = "";
            breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(gi.GroupDisplayName);
            breadcrumbs[1, 1] = "";
            breadcrumbs[1, 2] = "";
            CurrentMaster.Title.Breadcrumbs = breadcrumbs;

            btnDelete.Click += new EventHandler(btnDelete_Click);
            btnCancel.Click += new EventHandler(btnCancel_Click);
        }
    }
    /// <summary>
    /// Creates group. Called when the "Create group" button is pressed.
    /// </summary>
    private bool CreateGroup()
    {
        // Create new group object
        GroupInfo newGroup = new GroupInfo();

        // Set the properties
        newGroup.GroupDisplayName = "My new group";
        newGroup.GroupName = "MyNewGroup";
        newGroup.GroupSiteID = CMSContext.CurrentSiteID;
        newGroup.GroupDescription = "";
        newGroup.GroupApproveMembers = GroupApproveMembersEnum.AnyoneCanJoin;
        newGroup.GroupAccess = SecurityAccessEnum.AllUsers;
        newGroup.GroupApproved = true;
        newGroup.GroupApprovedByUserID = CurrentUser.UserID;
        newGroup.GroupCreatedByUserID = CurrentUser.UserID;
        newGroup.AllowCreate = SecurityAccessEnum.GroupMembers;
        newGroup.AllowDelete = SecurityAccessEnum.GroupMembers;
        newGroup.AllowModify = SecurityAccessEnum.GroupMembers;
        newGroup.GroupNodeGUID = Guid.Empty;

        // Save the group
        GroupInfoProvider.SetGroupInfo(newGroup);

        return true;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            GroupContext groupContext = GroupContext.GetGroupContext();

            GroupInfo groupInfo = new GroupInfo();
            groupInfo.GroupID = groupContext.CurrentGroupID;

            string fromSQL = groupInfo.FromSQL;
            string whereSQL = groupInfo.WhereSQL;

            if (whereSQL != "")
                whereSQL = "WHERE " + whereSQL;
            string selectSQL = "SELECT SALESPOTENTIAL, CLOSEPROBABILITY, ACTUALAMOUNT, DATEOPENED, CLOSED, ESTIMATEDCLOSE ";
            string groupSQL = selectSQL + "FROM " + fromSQL + " " + whereSQL;

            using (new SparseQueryScope())
            using (IDbConnection vConn = GroupInfo.GetOpenConnection())
            {
                OleDbDataAdapter vAdapter = new OleDbDataAdapter(groupSQL, vConn as OleDbConnection);
                foreach (DbParameter p in groupInfo.Parameters)
                {
                    vAdapter.SelectCommand.Parameters.Add(p);
                }
                vAdapter.SelectCommand.Prepare();
                DataTable dt = new DataTable();
                vAdapter.Fill(dt);

                if (dt.Rows.Count != 0)
                {
                    GetNumOfOpportunities(dt);
                    GetPotentialValues(dt);
                    GetAverageCloseProb(dt);
                    GetActualAmountValues(dt);
                    GetAverageDaysOpen(dt);
                    GetRangeofDates(dt);
                }
                else
                {
                    lblNumOfOppsVal.Text = "0";
                    curSalesPotentialTotalVal.Text = "0";
                    curSalesPotentialAverageVal.Text = "0";
                    curWeightedPotentialAverageVal.Text = "0";
                    curWeightedPotentialTotalVal.Text = "0";
                    lblAverageCloseProbabilityVal.Text = "0";
                    curActualAmountTotalVal.Text = "0";
                    curActualAmountAverageVal.Text = "0";
                    lblAverageNumOfDaysOpenVal.Text = "0";
                    lblRangeOfEstCloseVal.Text = GetLocalResourceObject("None_rsc").ToString();
                }
            }
        }
        catch //Group didn't contain any records disable active controls
        {
            btnUpdateOpps.Enabled = false;
            ddlReports.Enabled = false;
        }
    }
        private object MakeFooter(GroupInfo<Lunch> info)
        {
            //will add the word Total at the grid level footer (Level == 0)
            var pref = info.Level == 0 ? "Total " : "";

            return new
                    {
                        Food = pref + " count = " + info.Items.Count(),
                        Location = info.Items.Select(o => o.Location).Distinct().Count() + " distinct locations",
                        Date = pref + " max: " + info.Items.Max(o => o.Date).Date.ToShortDateString(),
                        Price = info.Items.Sum(o => o.Price)
                    };
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        RestoreState();

        GroupInfo info = new GroupInfo();
        info.GroupID = GroupContext.CurrentGroupID;

        items.DataSource = CreateFilterItems();
        items.DataBind();

        StringBuilder resources = new StringBuilder();
        resources.AppendFormat("Sage.TaskPane.FiltersTasklet.Resources = {0};", JsonConvert.SerializeObject(new ClientResourcesRepresentation(this)));

        ScriptManager.GetCurrent(Page).Scripts.Add(new ScriptReference("~/SmartParts/TaskPane/Filters/FiltersTasklet.js"));
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "taskpane-filters-resources", resources.ToString(), true);
    }
        public ActionResult Edit(int id, GroupInfo gi, string action)
        {
            try
            {
                ServiceClient sc = Sas.GetAuthenticatedServiceClient(this, action);
                if (sc != null)
                {
                    sc.UpdateGroup(id, gi.Name, gi.Description);
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    protected void ddlReports_TextChanged(object sender, EventArgs e)
    {
        Plugin report = new Plugin();
        string reportURL = "";

        GroupContext groupContext = GroupContext.GetGroupContext();

        GroupInfo groupInfo = new GroupInfo();
        groupInfo.GroupID = groupContext.CurrentGroupID;

        switch (ddlReports.Text)
        {
            case "None":
                break;
            case "Sales Process Stage Analysis":
                report = Sage.SalesLogix.Plugins.Plugin.LoadByName("Sales Process Stage Analysis", "Opportunity", Sage.SalesLogix.Plugins.PluginType.CrystalReport);
                break;
            case "Sales Process Step Usage":
                report = Sage.SalesLogix.Plugins.Plugin.LoadByName("Sales Process Step Usage", "Opportunity", Sage.SalesLogix.Plugins.PluginType.CrystalReport);
                break;
            //case "Quota vs. Actual Sales":
            //    report = Sage.SalesLogix.Plugins.Plugin.LoadByName("Quota Vs. Actual Sales", "Opportunity", Sage.SalesLogix.Plugins.PluginType.CrystalReport);
            //    break;
            case "Forecast by Account Manager":
                report = Sage.SalesLogix.Plugins.Plugin.LoadByName("Forecast by Account Manager", "Opportunity", Sage.SalesLogix.Plugins.PluginType.CrystalReport);
                break;
            //case "Competetive Analysis":
            //    report = Sage.SalesLogix.Plugins.Plugin.LoadByName("Competetive Analysis", "Opportunity", Sage.SalesLogix.Plugins.PluginType.CrystalReport);
            //    break;
        }

        if (report.PluginId != null)
        {
            reportURL = "~/ReportManager.aspx?showthisreport=" + report.PluginId + "&showrptfamily=" + report.Family + "&filterbygroupid=" + groupInfo.GroupID;

            Response.Redirect(reportURL);
        }
    }
Beispiel #10
0
        public GroupInfo Parse(SelectAtomContext ctx)
        {
            var result = new GroupInfo();

            foreach (var f in this.Field_regulars)
            {
                var temp = f.Parse(ctx);
                FieldRegularInfo fr = temp;
                if (fr == null)
                    System.Diagnostics.Debug.Assert(false, "�����ֶ���������");

                result.Fields.Add(fr.FullName);
            }

            if (Having_clause_full != null)
            {
                result.Having = new HavingInfo();
                Having_clause_full.Parse(result.Having);
                //result.Having = temp;
                //result = result.Join(temp);
            }
            return result;
        }
Beispiel #11
0
 private int FindClosestGroup()
 {
     Groups.Clear();
     int GroupRange = WowControl.GroupRange;
     int RangeFromPlayerToGroup = WowControl.RangeFromPlayerToGroup;
     int MinPlayersInGroup = WowControl.MinPlayersInGroup;
     for (int i = 1; i < wow.Objects.Count; i++)
     {
         if ((wow.Objects[i].Health > 1) & (wow.Objects[i].Faction == wow.Objects[0].Faction))
         {
             GroupInfo Temp = new GroupInfo();
             Temp.Indexes = new List<int>();
             if (Groups.Count == 0)
             {
                 Temp.X = wow.Objects[i].X;
                 Temp.Y = wow.Objects[i].Y;
                 Temp.Z = wow.Objects[i].Z;
                 Temp.CountPlayers++;
                 Temp.Range = WowControl.CheckPoint(wow.Objects[0].X, wow.Objects[0].Y, wow.Objects[0].Z, wow.Objects[i].X, wow.Objects[i].Y, wow.Objects[i].Z);
                 Temp.Indexes.Add(i);
                 Groups.Add(Temp);
             }
             else
             {
                 bool InGroup = false;
                 for (int g = 0; g < Groups.Count; g++)
                 {
                     double Range = WowControl.CheckPoint(wow.Objects[i].X, wow.Objects[i].Y, wow.Objects[i].Z, Groups[g].X, Groups[g].Y, Groups[g].Z);
                     if (Range < GroupRange)
                     {
                         InGroup = true;
                         GroupInfo[] TempGroup = Groups.ToArray();
                         //TempGroup[g].Indexes = new List<int>(Groups[g].Indexes.Count);
                         //for (int count = 0; count < Groups[g].Indexes.Count; count++)
                             //TempGroup[g].Indexes.Add(Groups[g].Indexes[count]);
                         TempGroup[g].Indexes.Add(i);
                         TempGroup[g].CountPlayers++;
                         float x = 0, y = 0, z = 0;
                         for (int gi = 0; gi < TempGroup[g].Indexes.Count; gi++)
                         {
                             x += wow.Objects[TempGroup[g].Indexes[gi]].X;
                             y += wow.Objects[TempGroup[g].Indexes[gi]].Y;
                             z += wow.Objects[TempGroup[g].Indexes[gi]].Z;
                         }
                         TempGroup[g].X = x / TempGroup[g].Indexes.Count;
                         TempGroup[g].Y = y / TempGroup[g].Indexes.Count;
                         TempGroup[g].Z = z / TempGroup[g].Indexes.Count;
                         TempGroup[g].Range = WowControl.CheckPoint(TempGroup[g].X, TempGroup[g].Y, TempGroup[g].Z, Groups[0].X, Groups[0].Y, Groups[0].Z);
                         Groups.Clear();
                         for (int c = 0; c < TempGroup.Length; c++)
                         {
                             Groups.Add(TempGroup[c]);
                             //for (int ii = 0; ii < TempGroup[c].Indexes.Count; ii++)
                                 //Groups[c].Indexes.Add(TempGroup[c].Indexes[ii]);
                         }
                     }
                 }
                 if (InGroup == false)
                 {
                     Temp.X = wow.Objects[i].X;
                     Temp.Y = wow.Objects[i].Y;
                     Temp.Z = wow.Objects[i].Z;
                     Temp.CountPlayers++;
                     Temp.Range = WowControl.CheckPoint(wow.Objects[0].X, wow.Objects[0].Y, wow.Objects[0].Z, wow.Objects[i].X, wow.Objects[i].Y, wow.Objects[i].Z);
                     Temp.Indexes.Add(i);
                     Groups.Add(Temp);
                 }
             }
         }
     }
     double MinRange = 10000;
     int ClosestGroup = 1000;
     for (int i = 0; i < Groups.Count; i++)
     {
         double Range = WowControl.CheckPoint(wow.Objects[0].X, wow.Objects[0].Y, wow.Objects[0].Z, Groups[i].X, Groups[i].Y, Groups[i].Z);
         if (Range < RangeFromPlayerToGroup)
             if ((Groups[i].Range != 0) & (Groups[i].Range < MinRange) & (Groups[i].Range < RangeFromPlayerToGroup) & (Groups[i].CountPlayers >= MinPlayersInGroup))
             {
                 MinRange = Groups[i].Range;
                 ClosestGroup = i;
             }
     }
     return ClosestGroup;
 }
    /// <summary>
    /// Creates group media library.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupMediaLibrary(GroupInfo group)
    {
        // Set general values
        string codeName = "Library_group_" + group.GroupGUID;

        // Check if library with same name already exists
        MediaLibraryInfo mlInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(codeName, SiteContext.CurrentSiteID, group.GroupID);
        if (mlInfo == null)
        {
            // Create new object (record) if needed
            mlInfo = new MediaLibraryInfo();
            const string suffix = " media";
            mlInfo.LibraryDisplayName = TextHelper.LimitLength(@group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
            mlInfo.LibraryFolder = @group.GroupName;
            mlInfo.LibraryName = codeName;
            mlInfo.LibraryDescription = string.Empty;
            mlInfo.LibraryGroupID = @group.GroupID;
            mlInfo.LibrarySiteID = SiteContext.CurrentSiteID;

            // Set security
            mlInfo.FileCreate = SecurityAccessEnum.GroupMembers;
            mlInfo.FileDelete = SecurityAccessEnum.GroupMembers;
            mlInfo.FileModify = SecurityAccessEnum.GroupMembers;
            mlInfo.FolderCreate = SecurityAccessEnum.GroupMembers;
            mlInfo.FolderDelete = SecurityAccessEnum.GroupMembers;
            mlInfo.FolderModify = SecurityAccessEnum.GroupMembers;
            mlInfo.Access = SecurityAccessEnum.GroupMembers;

            try
            {
                MediaLibraryInfoProvider.SetMediaLibraryInfo(mlInfo);
            }
            catch
            {
            }

            // Create additional folders
            //MediaLibraryInfoProvider.CreateMediaLibraryFolder(SiteContext.CurrentSiteName, mlInfo.LibraryID, "Videos", false);
            //MediaLibraryInfoProvider.CreateMediaLibraryFolder(SiteContext.CurrentSiteName, mlInfo.LibraryID, "Other", false);
            //MediaLibraryInfoProvider.CreateMediaLibraryFolder(SiteContext.CurrentSiteName, mlInfo.LibraryID, "Photos & Images", false);
        }
    }
    /// <summary>
    /// Creates forum search index.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupForumSearchIndex(GroupInfo group)
    {
        string codeName = "forums_group_" + group.GroupGUID;

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);
        if (sii == null)
        {
            // Create search index info
            sii = new SearchIndexInfo();
            sii.IndexName = codeName;
            const string suffix = " - Forums";
            sii.IndexDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
            sii.IndexAnalyzerType = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType = PredefinedObjectType.FORUM;
            sii.IndexIsCommunityGroup = false;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID = Guid.NewGuid();
            sisi.ForumNames = "*_group_" + group.GroupGUID;
            sisi.Type = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.SiteName = SiteContext.CurrentSiteName;

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assing to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
            CultureInfo ci = DocumentContext.CurrentDocumentCulture;
            if (ci != null)
            {
                SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
            }
        }
    }
    /// <summary>
    /// Creates group forum.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupForum(GroupInfo group)
    {
        #region "Create forum group"

        // Get forum group code name
        string forumGroupCodeName = "Forums_group_" + group.GroupGUID;

        // Check if forum group with given name already exists
        if (ForumGroupInfoProvider.GetForumGroupInfo(forumGroupCodeName, SiteContext.CurrentSiteID) != null)
        {
            return;
        }

        // Create forum base URL
        string baseUrl = null;
        TreeNode groupDocument = TreeProvider.SelectSingleNode(group.GroupNodeGUID, DocumentContext.CurrentDocumentCulture.CultureCode, SiteContext.CurrentSiteName);
        if (groupDocument != null)
        {
            baseUrl = DocumentURLProvider.GetUrl(groupDocument.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS);
        }

        ForumGroupInfo forumGroupObj = new ForumGroupInfo();
        const string suffix = " forums";
        forumGroupObj.GroupDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
        forumGroupObj.GroupName = forumGroupCodeName;
        forumGroupObj.GroupOrder = 0;
        forumGroupObj.GroupEnableQuote = true;
        forumGroupObj.GroupGroupID = group.GroupID;
        forumGroupObj.GroupSiteID = SiteContext.CurrentSiteID;
        forumGroupObj.GroupBaseUrl = baseUrl;

        // Additional settings
        forumGroupObj.GroupEnableCodeSnippet = true;
        forumGroupObj.GroupEnableFontBold = true;
        forumGroupObj.GroupEnableFontColor = true;
        forumGroupObj.GroupEnableFontItalics = true;
        forumGroupObj.GroupEnableFontStrike = true;
        forumGroupObj.GroupEnableFontUnderline = true;
        forumGroupObj.GroupEnableQuote = true;
        forumGroupObj.GroupEnableURL = true;
        forumGroupObj.GroupEnableImage = true;

        // Set forum group info
        ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj);

        #endregion

        #region "Create forum"

        string codeName = "General_discussion_group_" + group.GroupGUID;

        // Check if forum with given name already exists
        if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSiteID, group.GroupID) != null)
        {
            return;
        }

        // Create new forum object
        ForumInfo forumObj = new ForumInfo();
        forumObj.ForumSiteID = SiteContext.CurrentSiteID;
        forumObj.ForumIsLocked = false;
        forumObj.ForumOpen = true;
        forumObj.ForumDisplayEmails = false;
        forumObj.ForumRequireEmail = false;
        forumObj.ForumDisplayName = "General discussion";
        forumObj.ForumName = codeName;
        forumObj.ForumGroupID = forumGroupObj.GroupID;
        forumObj.ForumModerated = false;
        forumObj.ForumAccess = 40000;
        forumObj.ForumPosts = 0;
        forumObj.ForumThreads = 0;
        forumObj.ForumPostsAbsolute = 0;
        forumObj.ForumThreadsAbsolute = 0;
        forumObj.ForumOrder = 0;
        forumObj.ForumUseCAPTCHA = false;
        forumObj.SetValue("ForumHTMLEditor", null);

        // Set security
        forumObj.AllowAccess = SecurityAccessEnum.GroupMembers;
        forumObj.AllowAttachFiles = SecurityAccessEnum.GroupMembers;
        forumObj.AllowMarkAsAnswer = SecurityAccessEnum.GroupMembers;
        forumObj.AllowPost = SecurityAccessEnum.GroupMembers;
        forumObj.AllowReply = SecurityAccessEnum.GroupMembers;
        forumObj.AllowSubscribe = SecurityAccessEnum.GroupMembers;

        if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert))
        {
            ForumInfoProvider.SetForumInfo(forumObj);
        }

        #endregion
    }
    /// <summary>
    /// Creates content search index.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupContentSearchIndex(GroupInfo group)
    {
        string codeName = "default_group_" + group.GroupGUID;

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);
        if (sii == null)
        {
            // Create search index info
            sii = new SearchIndexInfo();
            sii.IndexName = codeName;
            const string suffix = " - Default";
            sii.IndexDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
            sii.IndexAnalyzerType = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType = TreeNode.OBJECT_TYPE;
            sii.IndexIsCommunityGroup = false;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID = Guid.NewGuid();
            sisi.Path = mGroupTemplateTargetAliasPath + "/" + group.GroupName + "/%";
            sisi.SiteName = SiteContext.CurrentSiteName;
            sisi.Type = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.ClassNames = "";

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assign to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
            CultureInfo ci = DocumentContext.CurrentDocumentCulture;
            if (ci != null)
            {
                SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
            }

            // Register rebuild index action
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, null, null, sii.IndexName, sii.IndexID);
        }
    }
    /// <summary>
    /// Updates the current Group or creates new if no GroupID is present.
    /// </summary>
    public void SaveData()
    {
        // Check banned IP
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            ShowError(GetString("General.BannedIP"));
            return;
        }

        // Validate form entries
        string errorMessage = ValidateForm();
        if (errorMessage == string.Empty)
        {
            try
            {
                codeName = GetSafeCodeName();
                codeName = GetUniqueCodeName(codeName);

                GroupInfo group = new GroupInfo();
                group.GroupDisplayName = txtDisplayName.Text;
                group.GroupName = codeName;
                group.GroupDescription = txtDescription.Text;
                group.GroupAccess = GetGroupAccess();
                group.GroupSiteID = mSiteId;
                group.GroupApproveMembers = GetGroupApproveMembers();

                // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user
                var user = MembershipContext.AuthenticatedUser;

                if (user != null)
                {
                    group.GroupCreatedByUserID = user.UserID;

                    if ((!RequireApproval) || (CurrentUserIsAdmin()))
                    {
                        group.GroupApprovedByUserID = user.UserID;
                        group.GroupApproved = true;
                    }
                }

                // Save Group in the database
                GroupInfoProvider.SetGroupInfo(group);

                // Create group admin role
                RoleInfo roleInfo = new RoleInfo();
                roleInfo.DisplayName = "Group admin";
                roleInfo.RoleName = group.GroupName + "_groupadmin";
                roleInfo.RoleGroupID = group.GroupID;
                roleInfo.RoleIsGroupAdministrator = true;
                roleInfo.SiteID = mSiteId;
                // Save group admin role
                RoleInfoProvider.SetRoleInfo(roleInfo);

                if (user != null)
                {
                    // Set user as member of group
                    GroupMemberInfo gmi = new GroupMemberInfo();
                    gmi.MemberUserID = user.UserID;
                    gmi.MemberGroupID = group.GroupID;
                    gmi.MemberJoined = DateTime.Now;
                    gmi.MemberStatus = GroupMemberStatus.Approved;
                    gmi.MemberApprovedWhen = DateTime.Now;
                    gmi.MemberApprovedByUserID = user.UserID;

                    // Save user as member of group
                    GroupMemberInfoProvider.SetGroupMemberInfo(gmi);

                    // Set user as member of admin group role
                    UserRoleInfo userRole = new UserRoleInfo();
                    userRole.UserID = user.UserID;
                    userRole.RoleID = roleInfo.RoleID;

                    // Save user as member of admin group role
                    UserRoleInfoProvider.SetUserRoleInfo(userRole);
                }

                // Clear user session a request
                MembershipContext.AuthenticatedUser.Generalized.Invalidate(false);
                MembershipContext.AuthenticatedUser = null;

                string culture = CultureHelper.EnglishCulture.ToString();
                if (DocumentContext.CurrentDocument != null)
                {
                    culture = DocumentContext.CurrentDocument.DocumentCulture;
                }

                // Copy document
                errorMessage = GroupInfoProvider.CopyGroupDocument(group, GroupTemplateSourceAliasPath, GroupTemplateTargetAliasPath, GroupProfileURLPath, culture, CombineWithDefaultCulture, MembershipContext.AuthenticatedUser, roleInfo);

                if (!String.IsNullOrEmpty(errorMessage))
                {
                    // Display error message
                    ShowError(errorMessage);
                    return;
                }

                // Create group forum
                if (CreateForum)
                {
                    CreateGroupForum(group);

                    // Create group forum search index
                    if (CreateSearchIndexes)
                    {
                        CreateGroupForumSearchIndex(group);
                    }
                }

                // Create group media library
                if (CreateMediaLibrary)
                {
                    CreateGroupMediaLibrary(group);
                }

                // Create search index for group documents
                if (CreateSearchIndexes)
                {
                    CreateGroupContentSearchIndex(group);
                }

                // Display information on success
                ShowConfirmation(GetString("group.group.createdinfo"));

                // If URL is set, redirect user to specified page
                if (!String.IsNullOrEmpty(RedirectToURL))
                {
                    URLHelper.Redirect(ResolveUrl(DocumentURLProvider.GetUrl(RedirectToURL)));
                }

                // After registration message
                if ((RequireApproval) && (!CurrentUserIsAdmin()))
                {
                    ShowConfirmation(SuccessfullRegistrationWaitingForApprovalText);

                    // Send approval email to admin
                    if (!String.IsNullOrEmpty(SendWaitingForApprovalEmailTo))
                    {
                        // Create the message
                        EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("Groups.WaitingForApproval", SiteContext.CurrentSiteName);
                        if (eti != null)
                        {
                            EmailMessage message = new EmailMessage();
                            if (String.IsNullOrEmpty(eti.TemplateFrom))
                            {
                                message.From = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSSendEmailNotificationsFrom");
                            }
                            else
                            {
                                message.From = eti.TemplateFrom;
                            }

                            MacroResolver resolver = MacroContext.CurrentResolver;
                            resolver.SetAnonymousSourceData(group);
                            resolver.SetNamedSourceData("Group", group);

                            message.Recipients = SendWaitingForApprovalEmailTo;
                            message.Subject = resolver.ResolveMacros(eti.TemplateSubject);
                            message.Body = resolver.ResolveMacros(eti.TemplateText);

                            resolver.Settings.EncodeResolvedValues = false;
                            message.PlainTextBody = resolver.ResolveMacros(eti.TemplatePlainText);

                            // Send the message using email engine
                            EmailSender.SendEmail(message);
                        }
                    }
                }
                else
                {
                    string groupPath = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSGroupProfilePath");
                    string url = String.Empty;

                    if (!String.IsNullOrEmpty(groupPath))
                    {
                        url = DocumentURLProvider.GetUrl(groupPath.Replace("{GroupName}", group.GroupName));
                    }
                    ShowConfirmation(String.Format(SuccessfullRegistrationText, url));
                }

                // Hide form
                if (HideFormAfterRegistration)
                {
                    plcForm.Visible = false;
                }
                else
                {
                    ClearForm();
                }
            }
            catch (Exception ex)
            {
                // Display error message
                ShowError(GetString("general.saveerror"), ex.Message, null);
            }
        }
        else
        {
            // Display error message
            ShowError(errorMessage);
        }
    }
    /// <summary>
    /// Gets and bulk updates groups. Called when the "Get and bulk update groups" button is pressed.
    /// Expects the CreateGroup method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateGroups()
    {
        // Prepare the parameters
        string where = "GroupName LIKE N'MyNewGroup%'";

        // Get the data
        DataSet groups = GroupInfoProvider.GetGroups(where, null);
        if (!DataHelper.DataSourceIsEmpty(groups))
        {
            // Loop through the individual items
            foreach (DataRow groupDr in groups.Tables[0].Rows)
            {
                // Create object from DataRow
                GroupInfo modifyGroup = new GroupInfo(groupDr);

                // Update the properties
                modifyGroup.GroupDisplayName = modifyGroup.GroupDisplayName.ToUpper();

                // Save the changes
                GroupInfoProvider.SetGroupInfo(modifyGroup);
            }

            return true;
        }

        return false;
    }
    protected void LoadGrid()
    {
        if (this.Visible)
        {
            GenerateScript();

            EnableEstCloseControls();

            GroupContext groupContext = GroupContext.GetGroupContext();

            string fromSQL = null;
            string whereSQL = null;
            string selectSQL = null;
            string groupSQL = null;
            //string joinSQL = null;
            IList<DbParameter> parameters;

            if (groupContext.CurrentGroupID != "LOOKUPRESULTS")
            {
                GroupInfo groupInfo = new GroupInfo();
                groupInfo.GroupID = groupContext.CurrentGroupID;
                fromSQL = groupInfo.FromSQL;
                whereSQL = groupInfo.WhereSQL;
                parameters = groupInfo.Parameters;
            }
            else
            {
                CachedGroup groupInfo = groupContext.CurrentGroupInfo.CurrentGroup;
                fromSQL = groupInfo.GroupInformation.FromSQL;
                whereSQL = groupInfo.GroupInformation.WhereSQL;
                parameters = groupInfo.GroupInformation.Parameters;
            }

            // the joing caused ambiguous columns in the select clause so aliases had to be specified.
            // I made an assumption that opportunity is a required table and that the format of the
            // query would remain the same.  Shaky at best, I know.
            //string opportunityAlias = null;
            //int startIndex = fromSQL.ToLower().IndexOf("opportunity ") + "opportunity ".Length;
            //int stringLength = fromSQL.ToLower().IndexOf(" ", startIndex);
            //opportunityAlias = fromSQL.Substring(startIndex, stringLength - startIndex);

            //if (whereSQL != "")
            //    whereSQL = " WHERE " + whereSQL;
            //selectSQL = "SELECT opportunityid, " + opportunityAlias + ".description, estimatedclose, closeprobability, addtoforecast, " + opportunityAlias + ".notes, salespotential, UserInfoCustom.LastName + ', ' + UserInfoCustom.FirstName as AccountManager";
            //joinSQL = "LEFT OUTER JOIN USERINFO UserInfoCustom ON (" + opportunityAlias + ".AccountManagerId = UserInfoCustom.USERID)";
            //groupSQL = selectSQL + " FROM " + fromSQL + " " + joinSQL + " " + whereSQL;

            if (whereSQL != "")
                whereSQL = " WHERE " + whereSQL;
            selectSQL = "SELECT opportunityid, description, estimatedclose, closeprobability, accountmanagerid, addtoforecast, notes, salespotential";
            groupSQL = selectSQL + " FROM " + fromSQL + " " + whereSQL;

            var vConn = GroupInfo.GetOpenConnection();
            var vAdapter = new OleDbDataAdapter(groupSQL, vConn as OleDbConnection);
            foreach (DbParameter p in parameters)
                vAdapter.SelectCommand.Parameters.Add(p);

            DataTable dt = new DataTable();
            try
            {
                using (new SparseQueryScope())
                {
                    vAdapter.Fill(dt);
                }
            }
            catch
            {
                //throw new GroupInfoException(string.Format("Error Executing SQL", groupSQL), e);
                throw new Exception("Error Executing SQL");
            }
            finally
            {
                vConn.Close();
            }

            UpdateOppsGrid.DataSource = dt;
            UpdateOppsGrid.DataBind();
            CalcOppValues();
        }
    }
Beispiel #19
0
 /// <summary>
 /// Retrieve the avatar of the specified group in the specified format.
 /// </summary>
 /// <param name="group">Group</param>
 /// <param name="size">Requested avatar size</param>
 /// <returns>The avatar as bitmap on success or null on failure.</returns>
 public Bitmap GetGroupAvatar(GroupInfo group, AvatarSize size = AvatarSize.Small)
 {
     User user = new User();
     user.avatarUrl = group.avatarUrl;
     return GetUserAvatar(user, size);
 }
 /// <summary>
 /// Log activity
 /// </summary>
 /// <param name="gmi">Member info</param>
 /// <param name="group">Group info</param>
 private void LogJoinActivity(GroupMemberInfo gmi,GroupInfo group)
 {
     Activity activity = new ActivityJoinGroup(gmi, group, AnalyticsContext.ActivityEnvironmentVariables);
     activity.Log();
 }
    /// <summary>
    /// Generates the permission matrix for the cutrrent group.
    /// </summary>
    private void CreateMatrix()
    {
        // Get group resource info
        if (resGroups == null)
        {
            resGroups = ResourceInfoProvider.GetResourceInfo("CMS.Groups");
        }

        if (resGroups != null)
        {
            group = GroupInfoProvider.GetGroupInfo(this.GroupID);

            // Get permissions for the current group resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resGroups.ResourceId);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.Text = GetString("general.emptymatrix");
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.CssClass = "UniGridHead";
                TableCell newCell = new TableCell();
                TableHeaderCell newHeaderCell = new TableHeaderCell();

                newHeaderCell.Text = "&nbsp;";
                newHeaderCell.CssClass = "MatrixHeader";
                newHeaderCell.Attributes["style"] = "width:30%;";
                headerRow.Cells.Add(newHeaderCell);

                foreach (string permission in allowedPermissions)
                {
                    DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'");
                    if ((drArray != null) && (drArray.Length > 0))
                    {
                        DataRow dr = drArray[0];
                        newHeaderCell = new TableHeaderCell();
                        newHeaderCell.CssClass = "MatrixHeader";
                        newHeaderCell.Attributes["style"] = "width:18%;text-align:center;white-space:nowrap;";
                        newHeaderCell.Text = dr["PermissionDisplayName"].ToString();
                        newHeaderCell.ToolTip = dr["PermissionDescription"].ToString();
                        newHeaderCell.HorizontalAlign = HorizontalAlign.Center;

                        headerRow.Cells.Add(newHeaderCell);
                    }
                    else
                    {
                        throw new Exception("[Security matrix] Column '" + permission + "' cannot be found.");
                    }
                }
                // Insert the empty cell at the end
                newHeaderCell = new TableHeaderCell();
                newHeaderCell.Text = "&nbsp;";
                headerRow.Cells.Add(newHeaderCell);
                tblMatrix.Rows.Add(headerRow);

                // Render group access permissions
                object[,] accessNames = new object[5, 2];
                accessNames[0, 0] = GetString("security.nobody");
                accessNames[0, 1] = SecurityAccessEnum.Nobody;
                accessNames[1, 0] = GetString("security.allusers");
                accessNames[1, 1] = SecurityAccessEnum.AllUsers;
                accessNames[2, 0] = GetString("security.authenticated");
                accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[3, 0] = GetString("security.groupmembers");
                accessNames[3, 1] = SecurityAccessEnum.GroupMembers;
                accessNames[4, 0] = GetString("security.authorizedroles");
                accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow = null;
                int rowIndex = 0;

                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);

                    // Generate cell holding access item name
                    newRow = new TableRow();
                    newRow.CssClass = ((rowIndex % 2 == 0) ? "EvenRow" : "OddRow");
                    newCell = new TableCell();
                    newCell.CssClass = "MatrixHeader";
                    newCell.Text = accessNames[access, 0].ToString();
                    newCell.Wrap = false;
                    newRow.Cells.Add(newCell);
                    rowIndex++;

                    // Render the permissions access items
                    bool isAllowed = false;
                    int permissionIndex = 0;
                    for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 2); permission++)
                    {
                        newCell = new TableCell();
                        newCell.CssClass = "MatrixCell";
                        newCell.HorizontalAlign = HorizontalAlign.Center;

                        // Check if the currently processed access is applied for permission
                        isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                        // Disable column in roles grid if needed
                        if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                        {
                            gridMatrix.DisableColumn(permissionIndex);
                        }

                        // Insert the radio button for the current permission
                        string permissionText = tblMatrix.Rows[0].Cells[permission + 1].Text;
                        string elemId = ClientID + "_" + permission + "_" + access;
                        string disabled = null;
                        if (!this.Enabled)
                        {
                            disabled = "disabled=\"disabled\"";
                        }
                        newCell.Text = "<label style=\"display:none;\" for=\"" + elemId + "\">" + permissionText + "</label><input type=\"radio\" id=\"" + elemId + "\" name=\"" + permissionText + "\" " + disabled + " onclick=\"" +
                         ControlsHelper.GetPostBackEventReference(this, permission.ToString() + ";" + Convert.ToInt32(currentAccess).ToString()) + "\" " +
                            ((isAllowed) ? "checked = \"checked\"" : "") + "/>";

                        newCell.Wrap = false;
                        newRow.Cells.Add(newCell);
                        permissionIndex++;
                    }

                    newCell = new TableCell();
                    newCell.Text = "&nbsp;";
                    newRow.Cells.Add(newCell);
                    // Add the access row to the table
                    tblMatrix.Rows.Add(newRow);
                }

                // Get permission matrix for current group resource
                bool rowIsSeparator = false;

                // Get permission matrix for the current group resource
                this.mNoRolesAvailable = !gridMatrix.HasData;

                if (!this.mNoRolesAvailable)
                {
                    // Security - Role separator
                    newRow = new TableRow();
                    newCell = new TableCell();
                    newCell.Text = "&nbsp;";
                    newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count));
                    newRow.Controls.Add(newCell);
                    tblMatrix.Rows.Add(newRow);

                    // Security - Role separator text
                    newRow = new TableRow();
                    newCell = new TableCell();
                    newCell.CssClass = "MatrixLabel";
                    newCell.Text = GetString("SecurityMatrix.RolesAvailability");
                    newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count - 1));
                    newRow.Controls.Add(newCell);
                    tblMatrix.Rows.Add(newRow);
                }

                // Add the latest row if present
                if (newRow != null)
                {
                    // The row is only role row and at the same time is divider between accesses section and roles section - make border higher
                    if (rowIsSeparator)
                    {
                        rowIsSeparator = false;
                    }
                    if (!mNoRolesAvailable)
                    {
                        newRow.Cells.Add(new TableCell());
                        tblMatrix.Rows.Add(newRow);
                    }
                }
            }
        }
    }
Beispiel #22
0
        private IQueryPlanNode PlanQuery(IQueryContext context, SqlQueryExpression queryExpression,
			QueryExpressionFrom queryFrom, IList<SortColumn> sortColumns)
        {
            // ----- Resolve the SELECT list
            // If there are 0 columns selected, then we assume the result should
            // show all of the columns in the result.
            bool doSubsetColumn = (queryExpression.SelectColumns.Any());

            // What we are selecting
            var columns = BuildSelectColumns(queryExpression, queryFrom);

            // Prepare the column_set,
            var preparedColumns = columns.Prepare(context);

            sortColumns = ResolveOrderByRefs(preparedColumns, sortColumns);

            // -----

            // Set up plans for each table in the from clause of the command.  For
            // sub-queries, we recurse.

            var tablePlanner = CreateTablePlanner(context, queryFrom);

            // -----

            // The WHERE and HAVING clauses
            var whereClause = queryExpression.WhereExpression;
            var havingClause = queryExpression.HavingExpression;

            PrepareJoins(tablePlanner, queryExpression, queryFrom, ref whereClause);

            // Prepare the WHERE and HAVING clause, qualifies all variables and
            // prepares sub-queries.
            whereClause = PrepareSearchExpression(context, queryFrom, whereClause);
            havingClause = PrepareSearchExpression(context, queryFrom, havingClause);

            // Any extra Aggregate functions that are part of the HAVING clause that
            // we need to add.  This is a list of a name followed by the expression
            // that contains the aggregate function.
            var extraAggregateFunctions = new List<SqlExpression>();
            if (havingClause != null)
                havingClause = FilterHaving(havingClause, extraAggregateFunctions, context);

            // Any GROUP BY functions,
            ObjectName[] groupByList;
            IList<SqlExpression> groupByFunctions;
            var gsz = ResolveGroupBy(queryExpression, queryFrom, context, out groupByList, out groupByFunctions);

            // Resolve GROUP MAX variable to a reference in this from set
            var groupmaxColumn = ResolveGroupMax(queryExpression, queryFrom);

            // -----

            // Now all the variables should be resolved and correlated variables set
            // up as appropriate.

            // If nothing in the FROM clause then simply evaluate the result of the
            // select
            if (queryFrom.SourceCount == 0)
                return EvaluateToSingle(preparedColumns);

            // Plan the where clause.  The returned node is the plan to evaluate the
            // WHERE clause.
            var node = tablePlanner.PlanSearchExpression(whereClause);

            SqlExpression[] defFunList;
            string[] defFunNames;
            var fsz = MakeupFunctions(preparedColumns, extraAggregateFunctions, out defFunList, out defFunNames);

            var groupInfo = new GroupInfo {
                Columns = preparedColumns,
                FunctionCount = fsz,
                FunctionNames = defFunNames,
                FunctionExpressions = defFunList,
                GroupByCount = gsz,
                GroupByNames = groupByList,
                GroupByExpressions = groupByFunctions.ToArray(),
                GroupMax = groupmaxColumn
            };

            node = PlanGroup(node, groupInfo);

            // The result column list
            var selectColumns = preparedColumns.SelectedColumns.ToList();
            int sz = selectColumns.Count;

            // Evaluate the having clause if necessary
            if (havingClause != null) {
                // Before we evaluate the having expression we must substitute all the
                // aliased variables.
                var havingExpr = havingClause;

                // TODO: this requires a visitor to modify the having expression
                havingExpr = ReplaceAliasedVariables(havingExpr, selectColumns);

                var source = tablePlanner.SinglePlan;
                source.UpdatePlan(node);
                node = tablePlanner.PlanSearchExpression(havingExpr);
            }

            // Do we have a composite select expression to process?
            IQueryPlanNode rightComposite = null;
            if (queryExpression.NextComposite != null) {
                var compositeExpr = queryExpression.NextComposite;
                var compositeFrom = QueryExpressionFrom.Create(context, compositeExpr);

                // Form the right plan
                rightComposite = PlanQuery(context, compositeExpr, compositeFrom, null);
            }

            // Do we do a final subset column?
            ObjectName[] aliases = null;
            if (doSubsetColumn) {
                // Make up the lists
                var subsetVars = new ObjectName[sz];
                aliases = new ObjectName[sz];
                for (int i = 0; i < sz; ++i) {
                    SelectColumn scol = selectColumns[i];
                    subsetVars[i] = scol.InternalName;
                    aliases[i] = scol.ResolvedName;
                }

                // If we are distinct then add the DistinctNode here
                if (queryExpression.Distinct)
                    node = new DistinctNode(node, subsetVars);

                // Process the ORDER BY?
                // Note that the ORDER BY has to occur before the subset call, but
                // after the distinct because distinct can affect the ordering of the
                // result.
                if (rightComposite == null && sortColumns != null)
                    node = PlanForOrderBy(node, sortColumns, queryFrom, selectColumns);

                // Rename the columns as specified in the SELECT
                node = new SubsetNode(node, subsetVars, aliases);
            } else {
                // Process the ORDER BY?
                if (rightComposite == null && sortColumns != null)
                    node = PlanForOrderBy(node, sortColumns, queryFrom, selectColumns);
            }

            // Do we have a composite to merge in?
            if (rightComposite != null) {
                // For the composite
                node = new CompositeNode(node, rightComposite, queryExpression.CompositeFunction, queryExpression.IsCompositeAll);

                // Final order by?
                if (sortColumns != null)
                    node = PlanForOrderBy(node, sortColumns, queryFrom, selectColumns);

                // Ensure a final subset node
                if (!(node is SubsetNode) && aliases != null) {
                    node = new SubsetNode(node, aliases, aliases);
                }
            }

            return node;
        }
Beispiel #23
0
        private IQueryPlanNode PlanGroup(IQueryPlanNode node, GroupInfo groupInfo)
        {
            // If there is more than 1 aggregate function or there is a group by
            // clause, then we must add a grouping plan.
            if (groupInfo.Columns.AggregateCount > 0 ||
                groupInfo.GroupByCount > 0) {
                // If there is no GROUP BY clause then assume the entire result is the
                // group.
                if (groupInfo.GroupByCount == 0) {
                    node = new GroupNode(node, groupInfo.GroupMax, groupInfo.FunctionExpressions, groupInfo.FunctionNames);
                } else {
                    // Do we have any group by functions that need to be planned first?
                    int gfsz = groupInfo.GroupByExpressions.Length;
                    if (gfsz > 0) {
                        var groupFunList = new SqlExpression[gfsz];
                        var groupFunName = new string[gfsz];
                        for (int i = 0; i < gfsz; ++i) {
                            groupFunList[i] = groupInfo.GroupByExpressions[i];
                            groupFunName[i] = "#GROUPBY-" + i;
                        }

                        node = new CreateFunctionsNode(node, groupFunList, groupFunName);
                    }

                    // Otherwise we provide the 'group_by_list' argument
                    node = new GroupNode(node, groupInfo.GroupByNames, groupInfo.GroupMax, groupInfo.FunctionExpressions, groupInfo.FunctionNames);
                }
            } else {
                // Otherwise no grouping is occurring.  We simply need create a function
                // node with any functions defined in the SELECT.
                // Plan a FunctionsNode with the functions defined in the SELECT.
                if (groupInfo.FunctionCount > 0)
                    node = new CreateFunctionsNode(node, groupInfo.FunctionExpressions, groupInfo.FunctionNames);
            }

            return node;
        }
        public GroupInfo GetGroupInfo(int index)
        {
            var component = m_blockDefinition.Components[index];
            GroupInfo info = new GroupInfo()
            {
                Component = component.Definition,
                TotalCount = component.Count,
                MountedCount = 0,
				AvailableCount = 0,
                Integrity = 0.0f,
                MaxIntegrity = component.Count * component.Definition.MaxIntegrity,
            };
            if (index < m_topGroupIndex)
            {
                info.MountedCount = component.Count;
                info.Integrity = component.Count * component.Definition.MaxIntegrity;
            }
            else if (index == m_topGroupIndex)
            {
                info.MountedCount = m_topComponentIndex + 1;
                info.Integrity = GetTopComponentIntegrity() + m_topComponentIndex * component.Definition.MaxIntegrity;
            }
            return info;
        }
Beispiel #25
0
 private bool AddNewGroup(GroupInfo info) {
     var i = info.Path.IndexOf('>', GroupPaths[info.Index].Length + 1);
     var newGroupPath = info.Path.Substring(0, i + 1);
     if (!GroupPaths.Contains(newGroupPath)) {
         GroupPaths.Add(newGroupPath);
         return true;
     }
     return false;
 }
    /// <summary>
    /// Updates the current Group or creates new if no GroupID is present.
    /// </summary>
    public void SaveData()
    {
        if (!CheckPermissions("cms.groups", PERMISSION_MANAGE, GroupID))
        {
            return;
        }

        // Trim display name and code name
        string displayName = txtDisplayName.Text.Trim();
        string codeName = txtCodeName.Text.Trim();

        // Validate form entries
        string errorMessage = ValidateForm(displayName, codeName);
        if (errorMessage == "")
        {
            GroupInfo group = null;

            try
            {
                bool newGroup = false;

                // Update existing item
                if ((GroupID > 0) && (gi != null))
                {
                    group = gi;
                }
                else
                {
                    group = new GroupInfo();
                    newGroup = true;
                }

                if (group != null)
                {
                    if (displayName != group.GroupDisplayName)
                    {
                        // Refresh a breadcrumb if used in the tabs layout
                        ScriptHelper.RefreshTabHeader(Page, displayName);
                    }

                    if (DisplayAdvanceOptions)
                    {
                        // Update Group fields
                        group.GroupDisplayName = displayName;
                        group.GroupName = codeName;
                        group.GroupNodeGUID = ValidationHelper.GetGuid(groupPageURLElem.Value, Guid.Empty);
                    }

                    if (AllowChangeGroupDisplayName && IsLiveSite)
                    {
                        group.GroupDisplayName = displayName;
                    }

                    group.GroupDescription = txtDescription.Text;
                    group.GroupAccess = GetGroupAccess();
                    group.GroupSiteID = SiteID;
                    group.GroupApproveMembers = GetGroupApproveMembers();
                    group.GroupSendJoinLeaveNotification = chkJoinLeave.Checked;
                    group.GroupSendWaitingForApprovalNotification = chkWaitingForApproval.Checked;
                    groupPictureEdit.UpdateGroupPicture(group);

                    // If new group was created
                    if (newGroup)
                    {
                        // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user
                        var user = MembershipContext.AuthenticatedUser;
                        if (user != null)
                        {
                            group.GroupCreatedByUserID = user.UserID;
                            group.GroupApprovedByUserID = user.UserID;
                            group.GroupApproved = true;
                        }
                    }

                    if (!IsLiveSite && (group.GroupNodeGUID == Guid.Empty))
                    {
                        plcStyleSheetSelector.Visible = false;
                    }

                    // Save theme
                    int selectedSheetID = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0);
                    if (plcStyleSheetSelector.Visible)
                    {
                        if (group.GroupNodeGUID != Guid.Empty)
                        {
                            // Save theme for every site culture
                            var cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName);
                            if (cultures != null)
                            {
                                TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

                                // Return class name of selected tree node
                                TreeNode treeNode = tree.SelectSingleNode(group.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName);
                                if (treeNode != null)
                                {
                                    // Return all culture version of node
                                    DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, null, TreeProvider.ALL_CULTURES, false, treeNode.NodeClassName, "NodeGUID ='" + group.GroupNodeGUID + "'", String.Empty, -1, false);
                                    if (!DataHelper.DataSourceIsEmpty(ds))
                                    {
                                        // Loop through all nodes
                                        foreach (DataRow dr in ds.Tables[0].Rows)
                                        {
                                            // Create node and set tree provider for user validation
                                            TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["className"], String.Empty), dr);
                                            node.TreeProvider = tree;

                                            // Update stylesheet id if set
                                            if (selectedSheetID == 0)
                                            {
                                                node.DocumentStylesheetID = 0;
                                                node.DocumentInheritsStylesheet = true;
                                            }
                                            else
                                            {
                                                node.DocumentStylesheetID = selectedSheetID;
                                            }

                                            node.Update();
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (!IsLiveSite && (group.GroupNodeGUID != Guid.Empty))
                    {
                        plcStyleSheetSelector.Visible = true;
                    }

                    if (plcOnline.Visible)
                    {
                        // On-line marketing setting is visible => set flag according to checkbox
                        group.GroupLogActivity = chkLogActivity.Checked;
                    }
                    else
                    {
                        // On-line marketing setting is not visible => set flag to TRUE as default value
                        group.GroupLogActivity = true;
                    }

                    // Save Group in the database
                    GroupInfoProvider.SetGroupInfo(group);
                    groupPictureEdit.GroupInfo = group;

                    txtDisplayName.Text = group.GroupDisplayName;
                    txtCodeName.Text = group.GroupName;

                    // Flush cached information
                    DocumentContext.CurrentDocument = null;
                    DocumentContext.CurrentPageInfo = null;
                    DocumentContext.CurrentDocumentStylesheet = null;

                    // Display information on success
                    ShowChangesSaved();

                    // If new group was created
                    if (newGroup)
                    {
                        GroupID = group.GroupID;
                        RaiseOnSaved();
                    }
                }
            }
            catch (Exception ex)
            {
                // Display error message
                ShowError(GetString("general.saveerror"), ex.Message, null);
            }
        }
        else
        {
            // Display error message
            ShowError(errorMessage);
        }
    }
    /// <summary>
    /// Deletes group picture.
    /// </summary>
    /// <param name="gi">GroupInfo</param>
    public static void DeleteOldGroupPicture(GroupInfo gi)
    {
        // Delete old picture if needed
        if (gi.GroupAvatarID != 0)
        {
            // Delete avatar info provider if needed
            AvatarInfo ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(gi.GroupAvatarID);
            if (ai != null)
            {
                if (ai.AvatarIsCustom)
                {
                    AvatarInfoProvider.DeleteAvatarInfo(ai);
                    AvatarInfoProvider.DeleteAvatarFile(ai.AvatarGUID.ToString(), ai.AvatarFileExtension, false, false);
                }

                gi.GroupAvatarID = 0;
                GroupInfoProvider.SetGroupInfo(gi);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Visible)
        {
            EnableViewState = false;
        }

        if (StopProcessing)
        {
            // Do nothing
            Visible = false;
            groupPictureEdit.StopProcessing = true;
            groupPageURLElem.StopProcessing = true;
        }
        else
        {
            string currSiteName = SiteContext.CurrentSiteName;
            plcGroupLocation.Visible = DisplayAdvanceOptions;
            plcAdvanceOptions.Visible = DisplayAdvanceOptions;
            groupPageURLElem.EnableSiteSelection = false;
            plcOnline.Visible = ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currSiteName);

            ctrlSiteSelectStyleSheet.CurrentSelector.ReturnColumnName = "StyleSheetID";
            ctrlSiteSelectStyleSheet.SiteId = SiteContext.CurrentSiteID;
            ctrlSiteSelectStyleSheet.AllowEditButtons = false;
            ctrlSiteSelectStyleSheet.IsLiveSite = IsLiveSite;
            lblStyleSheetName.AssociatedControlClientID = ctrlSiteSelectStyleSheet.CurrentSelector.ClientID;

            // Is allow edit display name is set on live site
            if ((AllowChangeGroupDisplayName) && (IsLiveSite))
            {
                if (!plcAdvanceOptions.Visible)
                {
                    plcCodeName.Visible = false;
                }
                plcAdvanceOptions.Visible = true;
            }

            // Web parts theme selector visibility
            if ((!AllowSelectTheme) && (IsLiveSite))
            {
                plcStyleSheetSelector.Visible = false;
            }

            RaiseOnCheckPermissions(PERMISSION_READ, this);

            if (StopProcessing)
            {
                return;
            }

            if ((GroupID == 0) && HideWhenGroupIsNotSupplied)
            {
                Visible = false;
                return;
            }

            InitializeForm();

            gi = GroupInfoProvider.GetGroupInfo(GroupID);
            if (gi != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    // Handle existing Group editing - prepare the data
                    if (GroupID > 0)
                    {
                        HandleExistingGroup();
                    }
                }

                groupPictureEdit.GroupInfo = gi;

                // UI Tools theme selector visibility
                if ((!IsLiveSite) && (gi.GroupNodeGUID == Guid.Empty))
                {
                    plcStyleSheetSelector.Visible = false;
                }

                // Init theme selector
                if (plcStyleSheetSelector.Visible)
                {
                    if (!URLHelper.IsPostback())
                    {
                        TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
                        if (gi.GroupNodeGUID != Guid.Empty)
                        {
                            TreeNode node = tree.SelectSingleNode(gi.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName);
                            if (node != null)
                            {
                                ctrlSiteSelectStyleSheet.Value = node.DocumentStylesheetID;
                            }
                        }
                    }
                }
            }
            else
            {
                plcStyleSheetSelector.Visible = false;
            }

            txtDescription.IsLiveSite = IsLiveSite;
            groupPictureEdit.IsLiveSite = IsLiveSite;
            groupPageURLElem.IsLiveSite = IsLiveSite;
        }
    }
Beispiel #29
0
        /// <summary>
        /// Retrieve information about the specified groups.
        /// </summary>
        /// <param name="steamids">64-bit SteamIDs of groups</param>
        /// <returns>Information about the specified groups</returns>
        public List<GroupInfo> GetGroupInfo(List<String> steamids)
        {
            if (umqid == null) return null;

            String response = steamRequest("ISteamUserOAuth/GetGroupSummaries/v0001?access_token=" + accessToken + "&steamids=" + String.Join(",", steamids.GetRange(0, Math.Min(steamids.Count, 100)).ToArray()));

            if (response != null)
            {
                JObject data = JObject.Parse(response);

                if (data["groups"] != null)
                {
                    List<GroupInfo> groups = new List<GroupInfo>();

                    foreach (JObject info in data["groups"])
                    {
                        GroupInfo group = new GroupInfo();

                        group.steamid = (String)info["steamid"];
                        group.creationDate = unixTimestamp((long)info["timecreated"]);
                        group.name = (String)info["name"];
                        group.profileUrl = "http://steamcommunity.com/groups/" + (String)info["profileurl"];
                        group.usersOnline = (int)info["usersonline"];
                        group.usersInChat = (int)info["usersinclanchat"];
                        group.usersInGame = (int)info["usersingame"];
                        group.owner = (String)info["ownerid"];
                        group.members = (int)info["users"];

                        group.avatarUrl = (String)info["avatar"];
                        if (group.avatarUrl != null) group.avatarUrl = group.avatarUrl.Substring(0, group.avatarUrl.Length - 4);

                        group.headline = info["headline"] != null ? (String)info["headline"] : "";
                        group.summary = info["summary"] != null ? (String)info["summary"] : "";
                        group.abbreviation = info["abbreviation"] != null ? (String)info["abbreviation"] : "";
                        group.locationCountryCode = info["loccountrycode"] != null ? (String)info["loccountrycode"] : "";
                        group.locationStateCode = info["locstatecode"] != null ? (String)info["locstatecode"] : "";
                        group.locationCityId = info["loccityid"] != null ? (int)info["loccityid"] : -1;
                        group.favoriteAppId = info["favoriteappid"] != null ? (int)info["favoriteappid"] : -1;

                        groups.Add(group);
                    }

                    // Requests are limited to 100 steamids, so issue multiple requests
                    if (steamids.Count > 100)
                        groups.AddRange(GetGroupInfo(steamids.GetRange(100, Math.Min(steamids.Count - 100, 100))));

                    return groups;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
    /// <summary>
    /// Updates picture of current group.
    /// </summary>
    /// <param name="gi">Group info object</param>
    public void UpdateGroupPicture(GroupInfo gi)
    {
        AvatarInfo ai = null;

        if (gi != null)
        {
            // Delete avatar if needed
            if (ValidationHelper.GetBoolean(hiddenDeleteAvatar.Value, false))
            {
                DeleteOldGroupPicture(gi);
            }

            // If some file was uploaded
            if ((uplFilePicture.PostedFile != null) && (uplFilePicture.PostedFile.ContentLength > 0) && ImageHelper.IsImage(Path.GetExtension(uplFilePicture.PostedFile.FileName)))
            {
                // Check if this group has some avatar and if so check if is custom
                ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(gi.GroupAvatarID);
                if ((ai != null) && ai.AvatarIsCustom)
                {
                    ReplaceExistingAvatar(ai);
                }
                else
                {
                    // Delete old picture
                    DeleteOldGroupPicture(gi);
                    ai = CreateNewAvatar();
                }

                AvatarInfoProvider.SetAvatarInfo(ai);

                // Update group info
                gi.GroupAvatarID = ai.AvatarID;
                GroupInfoProvider.SetGroupInfo(gi);

                plcImageActions.Visible = true;
            }
            // If predefined was chosen
            else if (!string.IsNullOrEmpty(hiddenAvatarGuid.Value))
            {
                // Delete old picture
                DeleteOldGroupPicture(gi);

                Guid guid = ValidationHelper.GetGuid(hiddenAvatarGuid.Value, Guid.NewGuid());
                ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(guid);

                // Update group info
                if (ai != null)
                {
                    gi.GroupAvatarID = ai.AvatarID;
                    GroupInfoProvider.SetGroupInfo(gi);
                }

                plcImageActions.Visible = true;
            }
            else
            {
                plcImageActions.Visible = false;
            }
        }
        else
        {
            bool pseudoDelete = ValidationHelper.GetBoolean(hiddenDeleteAvatar.Value, false);
            // Try to get avatar info
            if (avatarID != 0)
            {
                ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(avatarID);
            }

            // If some new picture was uploaded
            if ((uplFilePicture.PostedFile != null) && (uplFilePicture.PostedFile.ContentLength > 0) && ImageHelper.IsImage(Path.GetExtension(uplFilePicture.PostedFile.FileName)))
            {
                // Change delete to false because file will be replaced
                pseudoDelete = false;

                // If some avatar exists and is custom
                if ((ai != null) && (ai.AvatarIsCustom))
                {
                    // Delete file and upload new
                    AvatarInfoProvider.DeleteAvatarFile(ai.AvatarGUID.ToString(), ai.AvatarFileExtension, false, false);
                    ReplaceExistingAvatar(ai);
                }
                else
                {
                    ai = CreateNewAvatar();
                }

                // Update database
                AvatarInfoProvider.SetAvatarInfo(ai);
            }
            // If some predefined avatar was selected
            else if (!string.IsNullOrEmpty(hiddenAvatarGuid.Value))
            {
                // Change delete to false because file will be replaced
                pseudoDelete = false;

                // If some avatar exists and is custom
                if ((ai != null) && (ai.AvatarIsCustom))
                {
                    AvatarInfoProvider.DeleteAvatarFile(ai.AvatarGUID.ToString(), ai.AvatarFileExtension, false, false);
                    AvatarInfoProvider.DeleteAvatarInfo(ai);
                }

                Guid guid = ValidationHelper.GetGuid(hiddenAvatarGuid.Value, Guid.NewGuid());
                ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(guid);
            }

            // If file was deleted - not replaced
            if (pseudoDelete)
            {
                // Delete it
                ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(avatarID);
                if (ai != null)
                {
                    if (ai.AvatarIsCustom)
                    {
                        AvatarInfoProvider.DeleteAvatarInfo(ai);
                    }
                }

                ai = null;
                avatarID = 0;
                plcImageActions.Visible = false;
                GroupPicture.AvatarID = 0;
            }

            // Update avatar id
            if (ai != null)
            {
                GroupPicture.AvatarID = avatarID = ai.AvatarID;
                plcImageActions.Visible = true;
            }
        }
    }