protected void Page_Load(object sender, EventArgs e)
        {
            SPContext spContext = SPContext.Current;

            _spWeb = spContext.Web;

            SiteId     = _spWeb.Site.ID.ToString();
            SiteUrl    = _spWeb.Site.Url;
            WebFullUrl = _spWeb.Url;
            WebId      = _spWeb.ID.ToString();
            WebUrl     = _spWeb.SafeServerRelativeUrl();
            RootWebId  = spContext.Site.RootWeb.ID.ToString().ToLower();

            ListTitle = string.Empty;
            try
            {
                if (spContext.List != null)
                {
                    ListTitle = HttpUtility.JavaScriptStringEncode(spContext.List.Title);
                }
            }
            catch { }

            ListId = Guid.Empty.ToString();
            try
            {
                if (spContext.List != null)
                {
                    ListId = spContext.ListId.ToString();
                }
            }
            catch { }

            ListViewUrl = string.Empty;
            try
            {
                if (spContext.ViewContext != null && spContext.ViewContext.View != null)
                {
                    ListViewUrl = spContext.ViewContext.View.Url;
                }
            }
            catch { }

            ListViewTitle = string.Empty;
            try
            {
                if (spContext.ViewContext != null && spContext.ViewContext.View != null)
                {
                    ListViewTitle = HttpUtility.JavaScriptStringEncode(spContext.ViewContext.View.Title);
                }
            }
            catch { }

            ItemId = "-1";
            try
            {
                ItemId = (spContext.Item != null) ? spContext.ItemId.ToString(CultureInfo.InvariantCulture) : "-1";
            }
            catch { }

            ItemTitle = string.Empty;
            try
            {
                ItemTitle = (spContext.Item != null)
                    ? HttpUtility.JavaScriptStringEncode(spContext.ListItemDisplayName)
                    : string.Empty;
            }
            catch { }

            CurrentFileIsNull = "True";
            try
            {
                CurrentFileIsNull = (spContext.File == null).ToString();
            }
            catch { }

            CurrentFileTitle = string.Empty;
            try
            {
                CurrentFileTitle = Path.GetFileName(Request.FilePath);
                if (!string.IsNullOrEmpty(CurrentFileTitle))
                {
                    CurrentFileTitle = CurrentFileTitle.Replace(".aspx", "");
                }
            }
            catch { }

            ListIconClass = string.Empty;
            try
            {
                if (spContext.List != null)
                {
                    string sIcon = new GridGanttSettings(SPContext.Current.List).ListIcon;
                    ListIconClass = !string.IsNullOrEmpty(sIcon) ? sIcon : "icon-square";
                }
            }
            catch { }

            CurrentUserId = "-1";
            try
            {
                CurrentUserId = _spWeb.CurrentUser.ID.ToString(CultureInfo.InvariantCulture);
            }
            catch { }

            CurrentUserLoginName = string.Empty;
            try
            {
                CurrentUserLoginName = SPHttpUtility.HtmlEncode(_spWeb.CurrentUser.LoginName);
            }
            catch { }

            CurrentUserName = string.Empty;
            try
            {
                CurrentUserName = CoreFunctions.GetSafeUserTitle(_spWeb.CurrentUser.Name);
            }
            catch { }

            CurrentUrl = string.Empty;
            try
            {
                CurrentUrl = new Uri(new Uri(_spWeb.Url), HttpContext.Current.Request.RawUrl).AbsoluteUri;
            }
            catch { }
        }
Example #2
0
 /// <summary>
 /// Generates the link to list.
 /// </summary>
 /// <param name="path">The folder path.</param>
 /// <returns>Link to view url and passed folder path</returns>
 protected virtual string GenerateLinkToList(string path)
 {
     return(string.Format("{0}?RootFolder={1}",
                          SPHttpUtility.UrlKeyValueEncode(GetView().Url),
                          SPHttpUtility.UrlKeyValueEncode(path)));
 }
Example #3
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            bool             inEditMode = false;
            SPWebPartManager swpm       = (SPWebPartManager)SPWebPartManager.GetCurrentWebPartManager(this.Page);

            inEditMode = !swpm.GetDisplayMode().AllowPageDesign;

            if (inEditMode)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ID);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "webpartzone");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                base.RenderBody(writer);
                writer.RenderEndTag();
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-SPButton ms-WPAddButton");
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "CoreInvoke('ShowWebPartAdder', '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.ID) + "');return false;");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                //writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:");
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "CoreInvoke('ShowWebPartAdder', '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.ID) + "');return false;");
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                //writer.Write(SPHttpUtility.HtmlEncode(WebPartPageResource.GetString("WebPartQuickAdd_AddANewWebPart")));
                //base.RenderBody(writer);
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.RenderEndTag();

                base.RenderContents(writer);
            }
        }
 /// <summary>
 /// Call after completing custom logic in the Application Page.
 /// </summary>
 /// <param name="result">Result code to pass to the output. Available results: -1 = invalid; 0 = cancel; 1 = OK</param>
 /// <param name="returnValue">Value to pass to the callback method defined when opening the Modal Dialog.</param>
 public void EndOperation(ModalDialogResult result, string returnValue)
 {
     if (IsPopUI)
     {
         if (string.IsNullOrEmpty(PageToRedirectOnOK))
         {
             Page.Response.Clear();
             Page.Response.Write(String.Format(CultureInfo.InvariantCulture, "<script type=\"text/javascript\">window.frameElement.commonModalDialogClose({0}, {1});</script>",
                                               new object[] {
                 (int)result,
                 String.IsNullOrEmpty(returnValue) ? "null" :  returnValue
             }));
             Page.Response.End();
         }
         else
         {
             ScriptManager.RegisterStartupScript((Page)this, typeof(EnhancedLayoutsPage), "RedirectToCreatedPage", "window.frameElement.navigateParent('" + SPHttpUtility.EcmaScriptStringLiteralEncode(SPHttpUtility.UrlPathEncode(PageToRedirectOnOK, false)) + "');", true);
         }
     }
     else
     {
         RedirectOnOK();
     }
 }
        protected override void OnPreRender(EventArgs e)
        {
            //generate callback script for search field changes
            ClientScriptManager cs = Page.ClientScript;
            string context         = GenerateContextScript();
            string cbr             = cs.GetCallbackEventReference(this, "searchField", "SearchFieldChangedResult", context, false);
            String callbackScript  = "function SearchFieldChanged() {"
                                     + "var searchField= 'searchFieldChangedTo:' + document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.ColumnList.ClientID) + "').value;"
                                     + cbr + "; }";

            cs.RegisterClientScriptBlock(this.GetType(), "SearchFieldChanged",
                                         callbackScript, true);

            ColumnList.Attributes.Add("onchange", "SearchFieldChanged();");

            //HACK: fragment from the base class with query operators hack
            string str = this.Page.ClientScript.GetCallbackEventReference(this, "search", "PickerDialogHandleQueryResult", "ctx", "PickerDialogHandleQueryError", true);

            this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "__SEARCH__", "<script>\r\n                function executeQuery()\r\n                {\r\n   var operators=document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.drpdSearchOperators.ClientID) + "');                 var query=document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.QueryTextBox.ClientID) + "');\r\n                    var list=document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.ColumnList.ClientID) + "');\r\n                    var search='';\r\n                    var multiParts = new Array();\r\n       multiParts.push(operators.value);\r\n             if(list!=null)\r\n                        multiParts.push(list.value);\r\n                    else\r\n                        multiParts.push('');\r\n                    multiParts.push(query.value);\r\n\r\n                    search = ConvertMultiColumnValueToString(multiParts);\r\n                    PickerDialogSetClearState();\r\n                    \r\n                    var ctx = new PickerDialogCallbackContext();\r\n                    ctx.resultTableId = 'resultTable';\r\n                    ctx.queryTextBoxElementId = '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.QueryTextBox.ClientID) + "';\r\n                    ctx.errorElementId = '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.PickerDialog.ErrorLabel.ClientID) + "';\r\n                    ctx.htmlMessageElementId = '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.PickerDialog.HtmlMessageLabel.ClientID) + "';\r\n                    ctx.queryButtonElementId = '" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.QueryButton.ClientID) + "';\r\n                    PickerDialogShowWait(ctx);\r\n                    " + str + ";\r\n                }\r\n                </script>");
            this.QueryTextBox.Text = this.QueryText;
            this.QueryTextBox.Attributes.Add("onKeyDown", "var e=event; if(!e) e=window.event; if(!browseris.safari && e.keyCode==13) { document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.QueryButton.ClientID) + "').click(); return false; }");
            if ((this.QueryTextBox.Text.Length > 0) && !this.Page.IsPostBack)
            {
                string group = string.Empty;
                if (this.ColumnList.SelectedItem != null)
                {
                    group = this.ColumnList.SelectedItem.Value;
                }
                this.ExecuteQuery(group, this.QueryText);
            }
            this.Page.ClientScript.RegisterStartupScript(base.GetType(), "SetFocus", "<script>\r\n                    var objQueryTextBox = document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(this.QueryTextBox.ClientID) + "'); \r\n                    if (objQueryTextBox != null)\r\n                    {\r\n                        try\r\n                        {\r\n                            objQueryTextBox.focus();\r\n                        }\r\n                        catch(e)\r\n                        {\r\n                        }\r\n                    }\r\n                  </script>");
        }
Example #6
0
        private string BuildListItemHTML()
        {
            StringBuilder itemsHtml = new StringBuilder();

            itemsHtml.Append("<ul class=\"ms-core-menu-list\">");
            SPSite site = SPContext.Current.Site;
            SPWeb  web  = SPContext.Current.Web;
            SPList commonActionsList         = web.Lists.TryGetList(COMMON_ACTIONS_LIST_NAME);
            SPListItemCollection sortedItems = null;

            if (commonActionsList != null)
            {
                SPQuery q = new SPQuery();
                q.Query     = "<OrderBy><FieldRef Name=\"Order0\" Ascending=\"True\" /><FieldRef Name=\"LinkTitle\" Ascending=\"True\" /></OrderBy>";
                sortedItems = commonActionsList.GetItems(q);
            }

            if (sortedItems != null)
            {
                for (int i = 0; i < sortedItems.Count; i++)
                {
                    string itemText    = string.Empty;
                    string description = string.Empty;
                    string linkUrl     = string.Empty;
                    string newWindow   = string.Empty;
                    string imageUrl    = string.Empty;
                    string onclick     = string.Empty;

                    bool isPopup = false;

                    // get title
                    if (FieldExists(COMMON_ACTIONS_LIST_NAME, sortedItems[i], COL_TITLE))
                    {
                        object titleField = sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_TITLE).Id];

                        if (titleField != null && !string.IsNullOrEmpty(titleField.ToString()))
                        {
                            itemText = titleField.ToString();
                        }
                    }

                    // get description
                    if (FieldExists(COMMON_ACTIONS_LIST_NAME, sortedItems[i], COL_DESCRIPTION))
                    {
                        description = "Description for common action " + (i + 1).ToString();
                        object descriptionField = sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_DESCRIPTION).Id];

                        if (descriptionField != null && !string.IsNullOrEmpty(SPHttpUtility.ConvertSimpleHtmlToText(descriptionField.ToString(), -1)))
                        {
                            description = SPHttpUtility.ConvertSimpleHtmlToText(descriptionField.ToString(), -1);
                        }
                    }

                    if (FieldExists(COMMON_ACTIONS_LIST_NAME, sortedItems[i], COL_NEW_WINDOW))
                    {
                        string openInNewWindowValue = string.Empty;
                        if (sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_NEW_WINDOW).Id] != null)
                        {
                            openInNewWindowValue = sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_NEW_WINDOW).Id].ToString();
                        }

                        if (!string.IsNullOrEmpty(openInNewWindowValue))
                        {
                            switch (openInNewWindowValue)
                            {
                            case "Same window":
                                newWindow = "_self";
                                break;

                            case "New window":
                                newWindow = "_blank";
                                break;

                            case "Popup":
                                newWindow = "";
                                isPopup   = true;
                                break;

                            default:
                                newWindow = "_self";
                                break;
                            }
                        }
                        else
                        {
                            newWindow = "_self";
                        }
                    }

                    // get link Url
                    if (FieldExists(COMMON_ACTIONS_LIST_NAME, sortedItems[i], COL_URL))
                    {
                        if (sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_URL).Id] != null)
                        {
                            linkUrl = new SPFieldUrlValue(sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_URL).Id].ToString()).Url;
                            if (linkUrl.IndexOf('?') != -1)
                            {
                                linkUrl += ("&source=" + _requestUrl);
                            }
                            else
                            {
                                linkUrl += ("?source=" + _requestUrl);
                            }
                        }

                        if (linkUrl.StartsWith("/", StringComparison.CurrentCultureIgnoreCase))
                        {
                            linkUrl = (SPContext.Current.Web.ServerRelativeUrl == "/" ? "" : SPContext.Current.Web.ServerRelativeUrl) + linkUrl;
                        }

                        if (isPopup)
                        {
                            string popupUrl = linkUrl;
                            onclick = "javascript:var options = { url:'" + linkUrl + "', title: '" + itemText + "' }; SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); return false;";
                            linkUrl = "#";
                        }
                    }

                    // get image url from link field
                    if (FieldExists(COMMON_ACTIONS_LIST_NAME, sortedItems[i], COL_IMAGE_URL))
                    {
                        if (sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_IMAGE_URL).Id] != null)
                        {
                            imageUrl = new SPFieldUrlValue(sortedItems[i][commonActionsList.Fields.GetFieldByInternalName(COL_IMAGE_URL).Id].ToString()).Url;
                        }

                        if (string.IsNullOrEmpty(imageUrl))
                        {
                            imageUrl = "/_layouts/EPMLive/images/WESite.png";
                        }
                    }

                    itemsHtml.Append(String.Format(LIST_ITEM_HTML, "MenuItem" + i, description, itemText, imageUrl, linkUrl, newWindow, onclick));
                }

                itemsHtml.Append("</ul>");
            }

            return(itemsHtml.ToString());
        }
Example #7
0
        public static string GetFieldValueAsTextOrHtml(this SPFieldCalculated calcField, object value, bool asHtml)
        {
            if (value == null)
            {
                return(string.Empty);
            }


            string strType = string.Empty;
            string str2    = string.Empty;
            string str3    = value as string;

            if (str3 == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            str2 = str3;
            int length = StsBinaryCompareIndexOf(str2, ";#");

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            strType = str2.Substring(0, length).ToUpper(CultureInfo.InvariantCulture);
            str2    = str2.Substring(length + ";#".Length);
            if (((calcField.OutputType == SPFieldType.Invalid) || (calcField.OutputType == SPFieldType.Error)) || (strType == "ERROR"))
            {
                string formattedErrorValue = GetFormattedErrorValue(strType, str2);
                if (asHtml)
                {
                    return(SPHttpUtility.HtmlEncode(formattedErrorValue));
                }
                return(formattedErrorValue);
            }
            try
            {
                bool flag = false;;
                switch (strType)
                {
                case "FLOAT":
                {
                    //double data = Convert.ToDouble(str2, CultureInfo.InvariantCulture);
                    //CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
                    //if (calcField.OutputType == SPFieldType.Currency)
                    //{
                    //    string valueToEncode = FormatValue(data, calcField.Currency..DisplayFormat);
                    //    if (asHtml)
                    //    {
                    //        valueToEncode = SPHttpUtility.HtmlEncode(valueToEncode);
                    //    }
                    //    return valueToEncode;
                    //}
                    //if (asHtml)
                    //{
                    //    return SPFieldNumber.GetFieldValueAsHtml(data, currentCulture, calcField.ShowAsPercentage, calcField.DisplayFormat);
                    //}
                    //return SPFieldNumber.GetFieldValueAsText(data, currentCulture, calcField.ShowAsPercentage, calcField.DisplayFormat);
                }
                break;

                case "DATETIME":
                {
                    //SPDateFormat dateTime;
                    //if (base.IsXLVWPConnection)
                    //{
                    //    return str2;
                    //}
                    //DateTime time = SPUtility.CreateSystemDateTimeFromXmlDataDateTimeFormat(str2);
                    //if (this.DateFormat == SPDateTimeFieldFormatType.DateTime)
                    //{
                    //    dateTime = SPDateFormat.DateTime;
                    //}
                    //else
                    //{
                    //    dateTime = SPDateFormat.DateOnly;
                    //}
                    //if (asHtml)
                    //{
                    //    return SPFieldDateTime.GetFieldValueAsHtml(time, base.Fields.Web, dateTime);
                    //}
                    //return SPFieldDateTime.GetFieldValueAsText(time, base.Fields.Web, dateTime);
                }
                break;

                default:
                    if (!(strType == "BOOLEAN"))
                    {
                        goto Label_01FA;
                    }
                    switch (str2)
                    {
                    case "TRUE":
                    case "-1":
                    case "1":
                        flag = true;
                        break;
                    }
                    flag = false;
                    break;
                }
                //if (asHtml)
                //{
                //    return SPFieldBoolean.GetFieldValueAsHtml(flag);
                //}
                return(SPFieldBoolean.GetFieldValueAsText(flag));

Label_01FA:
                if (asHtml)
                {
                    return(SPHttpUtility.HtmlEncode(str2));
                }
                return(str2);
            }
            catch (ArgumentOutOfRangeException)
            {
                if (asHtml)
                {
                    return(SPHttpUtility.HtmlEncode(str2));
                }
                return(str2);
            }

            //return string.Empty;
        }
Example #8
0
        private void ManageFields()
        {
            SPWeb  currentWeb  = SPContext.Current.Web;
            SPSite currentSite = SPContext.Current.Site;

            if (!string.IsNullOrEmpty(Request.Params["listId"]))
            {
                _listId         = Request.Params["listId"];
                hdnListId.Value = _listId;
            }

            if (!string.IsNullOrEmpty(Request.Params["itemid"]))
            {
                _itemId                = Request.Params["itemid"];
                hdnItemId.Value        = _itemId.ToString();
                hdnCommentItemId.Value = _itemId.ToString();
            }

            if (!string.IsNullOrEmpty(Request.Params["listId"]))
            {
                SPList     list = currentWeb.Lists[new Guid(_listId)];
                SPListItem item = list.GetItemById(int.Parse(_itemId));
                _listTitle = SPHttpUtility.HtmlEncode(list.Title);
                _itemTitle = (item[item.Fields.GetFieldByInternalName("Title").Id] != null) ? SPHttpUtility.HtmlEncode(item[item.Fields.GetFieldByInternalName("Title").Id].ToString()) : string.Empty;
            }

            if (!string.IsNullOrEmpty(_listId) && !string.IsNullOrEmpty(_itemId))
            {
                SPList     list = currentWeb.Lists[new Guid(_listId)];
                SPListItem item = list.GetItemById(int.Parse(_itemId));
                _authorId    = GetItemAuthorId(item);
                _assigneeIds = GetItemAssigneeIds(item);
            }

            hdnUserId.Value = Web.CurrentUser.ID.ToString();
            string currentWebUrl = SPContext.Current.Web.Url;

            _webUrl = currentSite.MakeFullUrl(currentWeb.ServerRelativeUrl) + "/_layouts/EPMLive/CommentsProxy.aspx?";
            _currentUserLoginName = SPHttpUtility.HtmlEncode(Web.CurrentUser.Name);
            //_userProfileUrl = currentWebUrl + "/my/person.aspx?accountname=" + Web.CurrentUser.Name;
            _userProfileUrl = currentSite.MakeFullUrl(currentWeb.ServerRelativeUrl) + "/_layouts/userdisp.aspx?Force=True&ID=" + Web.CurrentUser.ID + "&source=" + HttpContext.Current.Request.UrlReferrer;
            // user picture url
            SPList     userInfoList = Web.SiteUserInfoList;
            SPListItem userItem     = userInfoList.GetItemById(Web.CurrentUser.ID);

            _userEmail      = !string.IsNullOrEmpty(Web.CurrentUser.Email) ? Web.CurrentUser.Email : string.Empty;
            _userPictureUrl = currentSite.MakeFullUrl(currentWeb.ServerRelativeUrl) + "/_layouts/epmlive/images/O14_person_placeHolder_32.png";

            SPField fldPicture = null;

            try
            {
                fldPicture = userItem.Fields.GetFieldByInternalName("Picture");
            }
            catch (ArgumentException x)
            {
                fldPicture = null;
            }

            if (fldPicture != null)
            {
                try
                {
                    string[] picUrls = userItem[userItem.Fields.GetFieldByInternalName("Picture").Id].ToString().Split(',');
                    _userPictureUrl = picUrls[0];
                }
                catch
                {
                    _userPictureUrl = currentSite.MakeFullUrl(currentWeb.ServerRelativeUrl) + "/_layouts/epmlive/images/O14_person_placeHolder_32.png";
                }
            }
        }
        private void CreateTable()
        {
            resultTable = new Table
            {
                Width       = Unit.Percentage(100.0),
                ID          = "resultTable",
                CssClass    = "ms-pickerresulttable",
                CellSpacing = 0,
                CellPadding = 0,
                BackColor   = Color.White
            };
            resultTable.ID = "resultTable";
            resultTable.Attributes.Add("hideFocus", "true");
            resultTable.Attributes.Add("EditorControlClientId", PickerDialog.EditorControl.ClientID);

            //Create Table Header Row
            TableRow child = null;

            if (PickerDialog.Results != null)
            {
                dt = PickerDialog.Results;


                child = new TableRow
                {
                    CssClass = "ms-pickerresultheadertr"
                };

                foreach (string column in columns)
                {
                    TableHeaderCell cell = new TableHeaderCell
                    {
                        CssClass = "ms-ph"
                    };
                    cell.Attributes.Add("UNSELECTABLE", "on");
                    Literal literal = new Literal
                    {
                        Text = SPHttpUtility.HtmlEncode(column)
                    };

                    cell.Controls.Add(literal);
                    child.Controls.Add(cell);
                }

                resultTable.Controls.Add(child);


                if (dt.Rows.Count == 0)
                {
                    child = new TableRow
                    {
                        CssClass = "ms-pickeremptyresulttexttr"
                    };

                    TableCell cell2 = new TableCell
                    {
                        CssClass   = "ms-descriptiontext",
                        ColumnSpan = columns.Length
                    };
                    Literal literal2 = new Literal
                    {
                        Text = SPHttpUtility.HtmlEncode("No search was given")
                    };
                    cell2.Controls.Add(literal2);
                    child.Controls.Add(cell2);
                    resultTable.Controls.Add(child);
                }
                else
                {
                    int    num          = 0;
                    string selectSingle = "PickerResultsSingleSelectOnClick(this);";
                    string selectDouble = "PickerResultsSingleSelectOnDblClick(this);";

                    foreach (HTML5ImageDataSet.HTML5ImagesRow row in dt.Rows)
                    {
                        HTML5ImagePickerEntity entity = PickerDialog.QueryControl.GetEntity(row);

                        if (entity != null)
                        {
                            child = new TableRow
                            {
                                ID = string.Format(CultureInfo.InvariantCulture, "row{0}", new object[] { num })
                            };

                            child.Attributes.Add("tabindex", "-1");
                            child.Attributes.Add("resultRow", "resultRow");

                            if ((num % 2) == 0)
                            {
                                child.CssClass = "ms-alternating";
                            }

                            ArrayList entities = new ArrayList();

                            entities.Add(entity);

                            string callback = PickerDialog.EditorControl.GenerateCallbackData(entities, false);
                            child.Attributes.Add("entityXml", callback);
                            child.Attributes.Add("onmousedown", "return singleselectevent(event);");
                            child.Attributes.Add("onclick", selectSingle);
                            child.Attributes.Add("ondblclick", selectDouble);
                            child.Attributes.Add("onkeydown", "PickerResultsNameOnKeyDown(this, event,false);");
                            child.Attributes.Add("onfocus", "PickerResultsNameOnFocus(this, event, false);");

                            child.Attributes.Add("key", entity.Key);

                            for (int i = 0; i < columns.Length; i++)
                            {
                                this.RenderRowColumn(row, i, child);
                            }
                            resultTable.Controls.Add(child);
                            num++;
                        }
                    }

                    if (base.PickerDialog.Results.Rows.Count > 1)
                    {
                        child = new TableRow
                        {
                            CssClass = "ms-pickersearchsummarytr",
                            ID       = "PickerSearchResultSummaryRow"
                        };
                        TableCell cell3 = new TableCell
                        {
                            CssClass   = "ms-descriptiontext",
                            ColumnSpan = dt.Columns.Count
                        };
                        cell3.Controls.Add(new LiteralControl(SPHttpUtility.HtmlEncode(String.Format("{0} results found.", new object[] { base.PickerDialog.Results.Rows.Count }))));
                        child.Controls.Add(cell3);
                        resultTable.Controls.Add(child);
                    }

                    this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "__SELECTION__HELPER__", "<script type=\"text/javascript\">\r\n                // <![CDATA[\r\n                function " + SPHttpUtility.EcmaScriptStringLiteralEncode(PickerDialog.GetSelectedClientSideFunctionName) + "()\r\n                {\r\n                    var selKeys=new Array(selected.length);\r\n                    for(i=0;i<selected.length;i++)\r\n                    {\r\n                        var uniquekey=selected[i].getAttribute('key').toString();\r\n                        selKeys[i]=uniquekey;\r\n                    }\r\n                    return selKeys;\r\n                }\r\n                // ]]>\r\n                </script>");
                }
            }
        }
Example #10
0
        protected override void CreateChildControls()
        {
            //Copied from base class
            SPWeb contextWeb = SPControl.GetContextWeb(this.Context);

            Table child = new Table();

            child.Width = Unit.Percentage(100.0);
            child.Attributes.Add("cellspacing", "0");
            child.Attributes.Add("cellpadding", "0");
            TableRow row = new TableRow();

            row.Width = Unit.Percentage(100.0);
            Label     label = new Label();
            TableCell cell  = new TableCell();

            cell.CssClass = "ms-descriptiontext";
            cell.Attributes.Add("style", "white-space:nowrap");
            string str = SPHttpUtility.HtmlEncode(SPResource.GetString("PickerDialogDefaultSearchLabel", new object[0]));

            str        = string.Format(CultureInfo.InvariantCulture, "<b>{0}</b>&nbsp;", new object[] { str });
            label.Text = str;
            cell.Controls.Add(label);
            this.ColumnList          = new DropDownList();
            this.ColumnList.ID       = "columnList";
            this.ColumnList.CssClass = "ms-pickerdropdown";
            cell.Controls.Add(this.ColumnList);
            row.Cells.Add(cell);

            //Punches-in the search operators dropdown
            cell = new TableCell();
            drpdSearchOperators    = new HtmlSelect();
            drpdSearchOperators.ID = "queryOperators";
            drpdSearchOperators.Attributes.Add("class", "ms-pickerdropdown");

            cell.Controls.Add(drpdSearchOperators);
            row.Cells.Add(cell);

            cell                        = new TableCell();
            cell.Width                  = Unit.Percentage(100.0);
            this.QueryTextBox           = new InputFormTextBox();
            this.QueryTextBox.ID        = "queryTextBox";
            this.QueryTextBox.CssClass  = "ms-pickersearchbox";
            this.QueryTextBox.AccessKey = SPResource.GetString("PickerDialogSearchAccessKey", new object[0]);
            this.QueryTextBox.Width     = Unit.Percentage(100.0);
            this.QueryTextBox.MaxLength = 0x3e8;
            this.QueryTextBox.Text      = QueryText;
            cell.Controls.Add(this.QueryTextBox);
            row.Cells.Add(cell);
            label.AssociatedControlID = "queryTextBox";
            cell                           = new TableCell();
            this.QueryButton               = new ImageButton();
            this.QueryButton.ID            = "queryButton";
            this.QueryButton.OnClientClick = "executeQuery();return false;";
            this.QueryButton.ToolTip       = SPResource.GetString("PickerDialogSearchToolTip", new object[0]);
            this.QueryButton.AlternateText = SPResource.GetString("PickerDialogSearchToolTip", new object[0]);
            if (!contextWeb.RegionalSettings.IsRightToLeft)
            {
                this.QueryButton.ImageUrl = "/_layouts/images/gosearch.gif";
            }
            else
            {
                this.QueryButton.ImageUrl = "/_layouts/images/gortl.gif";
            }
            HtmlGenericControl control = new HtmlGenericControl("div");

            control.Attributes.Add("class", "ms-searchimage");
            control.Controls.Add(this.QueryButton);
            cell.Controls.Add(control);
            row.Cells.Add(cell);
            child.Rows.Add(row);
            this.Controls.Add(child);

            //fills the search fields initially
            if (!Page.IsPostBack)
            {
                SPWeb  web  = SPContext.Current.Site.OpenWeb(propertyBag.WebId);
                SPList list = web.Lists[propertyBag.ListId];

                foreach (SPField field in list.Fields)
                {
                    List <string> searchFields = propertyBag.SearchFields;

                    if (searchFields.Contains(field.Id.ToString()))
                    {
                        mColumnList.Items.Add(new ListItem(field.Title, field.Id.ToString()));
                    }
                }

                //fills the search operators initally
                FillSearchOperators(ColumnList.SelectedValue);
            }
        }
        /// <summary>
        /// Internals the render.
        /// Make the Xslt transformation
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderControlInternal(HtmlTextWriter writer)
        {
            Debug.WriteLine("SPSXsltChartControl RenderControlInternal");

            StringWriter stringWriter = Transform();
            string       xml          = stringWriter.ToString();

            xml = xml.Replace("'", string.Empty);
            xml = xml.Replace('"', '\'');

            DebugRender(writer, xml);

            writer.Write("<div id=\"{0}Xml\" style=\"display:none\">{1}</div>", UniqueID, SPHttpUtility.UrlKeyValueEncode(xml));
            writer.Write("<div id=\"{0}chart\"></div>", UniqueID);

            writer.Write("\n<script language=\"javascript\">\n");
            writer.Write(GetShowChartScriptReference());
            writer.Write("</script>\n");
        }
        /// <summary>
        /// Click event.
        /// </summary>
        /// <param name="sender">The Sender.</param>
        /// <param name="e">The EventArgs.</param>
        protected void ButtonOk_Click(object sender, EventArgs e)
        {
            // Validate
            this.Validate();

            if (!this.IsValid)
            {
                return;
            }

            ContentDatabaseSection databaseSectionControl = this.databaseSection as ContentDatabaseSection;

            // We are valid
            // Register the database
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "DatabaseSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "DatabaseSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();

                if (databaseSectionControl.DisplayMode == ContentDatabaseSectionMode.AuthenticationEdit)
                {
                    // We are only changing credentials here, do not reprovision.
                    if (string.Equals(this.ServiceApplication.Database.DatabaseConnectionString, databaseSectionControl.ConnectionString, StringComparison.OrdinalIgnoreCase))
                    {
                        // No change made, exit the application.
                        operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
                    }
                    else
                    {
                        if (databaseSectionControl.UseWindowsAuthentication)
                        {
                            // Switching to windows authentication.
                            this.ServiceApplication.Database.Username = string.Empty;
                            this.ServiceApplication.Database.Password = string.Empty;
                        }
                        else
                        {
                            this.ServiceApplication.Database.Username = databaseSectionControl.DatabaseUserName;
                            this.ServiceApplication.Database.Password = databaseSectionControl.DatabasePassword;
                        }

                        this.ServiceApplication.Database.GrantOwnerAccessToDatabaseAccount();
                    }

                    // Set the failover instance
                    this.ServiceApplication.Database.AddFailoverServiceInstance(databaseSectionControl.FailoverDatabaseServer);

                    this.ServiceApplication.Database.Update();
                    operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
                }

                // Create the database
                ClubCloudDatabase database = new ClubCloudDatabase(this.databaseParameters);

                // Provision the database (runs the Create scripts)
                database.Provision();

                // Grant the database the proper permissions
                database.GrantApplicationPoolAccess(this.ServiceApplication.ApplicationPool.ProcessAccount.SecurityIdentifier);

                // Add the failover server instance (the base class does not do this for you)
                if (!string.IsNullOrEmpty(this.databaseParameters.FailoverPartner))
                {
                    database.AddFailoverServiceInstance(this.databaseParameters.FailoverPartner);
                }

                // Establish a relationship between the service application and the database
                this.ServiceApplication.Database = database;
                this.ServiceApplication.Update();

                operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
            }
        }
Example #13
0
 public static string GetListSettingsURL(SPList list)
 {
     return(SPUtility.GetFullUrl(list.ParentWeb.Site, list.ParentWebUrl.TrimEnd('/') + "/_layouts/listedit.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(list.ID.ToString())));
 }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            UrlViewNew = "ViewNew.aspx?List=" + SPHttpUtility.UrlKeyValueEncode(Request.QueryString["List"]);
            string sourceParameter = Request.QueryString["Source"];

            if (!String.IsNullOrEmpty(sourceParameter))
            {
                UrlViewNew += "&amp;Source=" + SPHttpUtility.HtmlUrlAttributeEncode(SPHttpUtility.UrlKeyValueEncode(sourceParameter));
            }
            string nameParameter = Request.QueryString["viewname"];

            if (!String.IsNullOrEmpty(nameParameter))
            {
                UrlViewNew += "&amp;viewname=" + SPHttpUtility.HtmlUrlAttributeEncode(SPHttpUtility.UrlKeyValueEncode(nameParameter));
            }
            string mapViewStatusParameter = Request.QueryString["mapview"];

            if (!String.IsNullOrEmpty(mapViewStatusParameter))
            {
                return;
            }



            if (IsMapViewPage)
            {
                var viewctx = SPContext.Current.ViewContext;
                ConfigureMapView(viewctx.View);
                var viewUrl = String.Format("{0}?mapview=true", viewctx.View.ServerRelativeUrl);
                Response.Redirect(viewUrl);
            }
        }
Example #15
0
        /// <summary>
        /// Click event.
        /// </summary>
        /// <param name="sender">The Sender.</param>
        /// <param name="e">The EventArgs.</param>
        protected void ButtonVerenigingen_Click(object sender, EventArgs e)
        {
            // Validate
            this.Validate();

            if (!this.IsValid)
            {
                return;
            }

            // We are valid
            // Register the database
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();


                int  pageNum     = 1;
                bool moreRecords = true;

                while (moreRecords)
                {
                    try
                    {
                        moreRecords = ServiceClient.AccommodatiesUpdate("12073385", pageNum, true);
                        pageNum++;
                    }
                    catch (Exception)
                    {
                        moreRecords = true;
                    }
                }

                try
                {
                }
                catch { }

                pageNum     = 1;
                moreRecords = true;
                while (moreRecords)
                {
                    try
                    {
                        moreRecords = ServiceClient.VerenigingenUpdate("12073385", pageNum, true);
                        pageNum++;
                    }
                    catch (Exception)
                    {
                        moreRecords = true;
                    }
                }

                try
                {
                    ServiceClient.BestuursOrganenUpdate("12073385", false);
                }
                catch { }

                operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
            }
        }
Example #16
0
        protected override void RenderFieldForInput(HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            writer.AddAttribute(HtmlTextWriterAttribute.Title, Field.Title);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            if (!Width.IsEmpty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.ToString());
            }

            if (!AllowFillIn)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
            }

            if (Rows == 1)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Value, Convert.ToString(Value));
                writer.RenderBeginTag(HtmlTextWriterTag.Input);
                writer.RenderEndTag(); // input
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Rows, Rows.ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.Textarea);
                writer.Write(Value);
                writer.RenderEndTag(); // textarea
            }


            writer.RenderEndTag(); // td

            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingLeft, "3px");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
            writer.AddAttribute(HtmlTextWriterAttribute.Title, "Browser");
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("__Dialog__{0}()", ClientID));
            writer.RenderBeginTag(HtmlTextWriterTag.A);

            writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Browser");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Src, "/_layouts/images/addressbook.gif");
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag(); // img

            writer.RenderEndTag(); // a
            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            RenderValidationMessage(writer);

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);

            var serverRelativeUrl = GetContextWeb(Context).ServerRelativeUrl;

            if (!serverRelativeUrl.EndsWith("/"))
            {
                serverRelativeUrl += "/";
            }
            var urlToEncode = SPHttpUtility.UrlPathEncode(serverRelativeUrl, false);

            writer.Write(string.Format("function __Dialog__{0}(){{", ClientID));
            writer.Write(string.Format("var dialogUrl = '{0}_layouts/Picker.aspx?MultiSelect={1}&CustomProperty={5}&DefaultSearch=&DialogTitle={2}&DialogImage={3}&PickerDialogType={4}&ForceClaims=False&DisableClaims=False&EnabledClaimProviders=&EntitySeparator=\u00253B\u0025EF\u0025BC\u00259B\u0025EF\u0025B9\u002594\u0025EF\u0025B8\u002594\u0025E2\u00258D\u0025AE\u0025E2\u002581\u00258F\u0025E1\u00258D\u0025A4\u0025D8\u00259B';",
                                       urlToEncode,
                                       AllowMultipleValues ? "True" : "False",
                                       SPHttpUtility.UrlKeyValueEncode(DialogTitle),
                                       SPHttpUtility.UrlKeyValueEncode(DialogImage),
                                       SPHttpUtility.UrlKeyValueEncode(typeof(PeoplePickerDialog).AssemblyQualifiedName),
                                       SelectPeopleOnly ? "User;;15;;;False" : "User,SecGroup,SPGroup;;15;;;False"));
            writer.Write(string.Format("var features = 'resizable: yes; status: no; scroll: no; help: no; center: yes; dialogWidth : {0}px; dialogHeight : {1}px; zoominherit : 1';", DialogWidth, DialogHeight));
            writer.Write(string.Format("commonShowModalDialog(dialogUrl, features, CallbackWrapper_{0});", ClientID));
            writer.Write("}");

            writer.WriteLine();

            writer.Write(string.Format("function CallbackWrapper_{0}(result){{", ClientID));
            writer.Write("var entities = GetEntities(result);");
            writer.Write("if (entities == null) return;");
            writer.Write("var values = [];");
            writer.Write("for(var x = 0; x < entities.childNodes.length; x++){"); // begin for
            writer.Write("var entity = entities.childNodes[x];");
            writer.Write("var accountName = entity.getAttribute(\"Key\");");
            writer.Write("var displayName = entity.getAttribute(\"DisplayText\");");
            writer.Write("var email = '';");

            writer.Write("var extraData = EntityEditor_SelectSingleNode(entity, \"ExtraData\");");
            writer.Write("if(extraData){");                                                     // begin if
            writer.Write("var arrayOfDictionaryEntry = EntityEditor_SelectSingleNode(extraData, \"ArrayOfDictionaryEntry\");");
            writer.Write("if(arrayOfDictionaryEntry){");                                        // begin if
            writer.Write("for(var y = 0; y < arrayOfDictionaryEntry.childNodes.length; y++){"); // begin for
            writer.Write("var key = EntityEditor_SelectSingleNode(arrayOfDictionaryEntry.childNodes[y], \"Key\");");
            writer.Write("if(key.childNodes[0].nodeValue == 'Email'){");
            writer.Write("var value = EntityEditor_SelectSingleNode(arrayOfDictionaryEntry.childNodes[y], \"Value\");");
            writer.Write("if(value){email = value.childNodes[0].nodeValue;}");
            writer.Write("}"); // end if
            writer.Write("}"); // end for

            // Append data
            switch (Format)
            {
            case ExtraUserFieldFormat.DisplayName:
                writer.Write("values.push(displayName);");
                break;

            case ExtraUserFieldFormat.AccountName:
                writer.Write("values.push(accountName);");
                break;

            case ExtraUserFieldFormat.Email:
                writer.Write("values.push(email);");
                break;

            case ExtraUserFieldFormat.Custom:
                writer.Write(string.Format("values.push(__Dialog_CustomFormat_{0}(displayName, accountName, email));", ClientID));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            writer.Write("}"); // end if
            writer.Write("}"); // end if
            writer.Write("}"); // end for

            // Set value for textbox
            if (OverrideValue)
            {
                writer.Write(string.Format("document.getElementById('{0}').value = values.join('; ');", ClientID));
            }
            else
            {
                writer.Write(string.Format("var element = document.getElementById('{0}');", ClientID));
                writer.Write("var oldValue = element.value + '';");
                writer.Write("var separate = ' ';");
                writer.Write("if(oldValue  == ''){separate = '';}");
                writer.Write("element.value = oldValue + separate + values.join('; ');");
            }

            writer.Write("}"); // end function
            writer.WriteLine();

            if (Format == ExtraUserFieldFormat.Custom)
            {
                writer.Write(string.Format("function __Dialog_CustomFormat_{0}(displayName, accountName, email){{", ClientID));
                writer.Write("var str = '{0}';", CustomFormat);
                writer.Write("str = str.replace(new RegExp(\"\\\\{0\\\\}\", \"gm\"), displayName);");
                writer.Write("str = str.replace(new RegExp(\"\\\\{1\\\\}\", \"gm\"), accountName);");
                writer.Write("str = str.replace(new RegExp(\"\\\\{2\\\\}\", \"gm\"), email);");
                writer.Write("return str;");
                writer.Write("}"); // end function
            }

            writer.RenderEndTag(); // script
        }
Example #17
0
        protected void ButtonGebruikers_Click(object sender, EventArgs e)
        {
            // Validate
            this.Validate();

            if (!this.IsValid)
            {
                return;
            }

            // We are valid
            // Register the database
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();

                string nummer = tbx_verenigingsnummer.Text;
                if (!string.IsNullOrWhiteSpace(nummer))
                {
                    int  pageNum     = 1;
                    bool moreRecords = true;
                    while (moreRecords)
                    {
                        try
                        {
                            moreRecords = ServiceClient.GebruikersUpdate("12073385", nummer, pageNum, true);
                            pageNum++;
                        }
                        catch (Exception)
                        {
                            moreRecords = true;
                        }
                    }

                    try
                    {
                        ClubCloud_Vereniging vereniging = ServiceClient.GetVerenigingByNummer("12073385", nummer, true);
                        ServiceClient.LidmaatschappenUpdate("12073385", vereniging.Id, true);
                    }
                    catch { }
                }

                operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
            }
        }
        protected bool ShowRecords()
        {
            if (webpart.currentBoardWithMetadata != null)
            {
                using (SPWeb boardSubWeb = getSPWeb(webpart.currentBoardWithMetadata.subWebID))
                {
                    if (boardSubWeb != null)
                    {
                        _discussionBoard = boardSubWeb.Lists.GetList(webpart.currentBoardWithMetadata.boardID, false);
                    }


                    /// LINQ Way
                    using (DataContext dataContext = new DataContext(boardSubWeb.Url))
                    {
                        EntityList <Discussion> allDiscussions = dataContext.GetList <Discussion>(_discussionBoard.Title);

                        var topics = from discussion in allDiscussions
                                     orderby discussion.LastUpdated descending
                                     select discussion;


                        int numberOfDiscussionsToDisplay = topics.Count <Discussion>() < webpart.NumberOfDiscussionsToDisplay ? topics.Count <Discussion>() : webpart.NumberOfDiscussionsToDisplay;

                        // _sbRecords.AppendLine("<div id=\"discussion_zone\">");

                        try
                        {
                            for (int i = 0; i < numberOfDiscussionsToDisplay; i++)
                            {
                                System.Nullable <int> replyId;
                                string          correctBodyToShow;
                                System.DateTime lastModified;

                                Discussion discussion      = topics.ElementAt <Discussion>(i);
                                SPListItem discussionTopic = _discussionBoard.GetItemById((int)discussion.Id);  // workaround for having a url

                                var allReplies = dataContext.GetList <Message>(_discussionBoard.Title)
                                                 .ScopeToFolder(SPHttpUtility.UrlPathEncode(discussionTopic.Folder.Url, true), false);

                                if (allReplies.Count <Message>() == 0)
                                {
                                    replyId           = discussion.Id;
                                    correctBodyToShow = discussion.Post;
                                    lastModified      = discussion.LastModified;
                                }
                                else
                                {
                                    // this is a really shitty code, but how else can I get the missing Item attributes from an spmetal-wrapped class. Any ideas?
                                    foreach (Message reply in allReplies)
                                    {
                                        SPListItem discussionReply = _discussionBoard.GetItemById((int)reply.Id);

                                        reply.LastModified = (DateTime)discussionReply["Modified"];

                                        try
                                        {
                                            reply.CorrectBodyToShow = (string)discussionReply["CorrectBodyToShow"].ToString();
                                        }
                                        catch (Exception ex)
                                        {
                                            reply.CorrectBodyToShow = (string)reply.Post;
                                        }

                                        reply.Xml = (string)discussionReply.Xml;
                                    }

                                    var latestReply = (from reply in allReplies
                                                       orderby reply.LastModified descending
                                                       select reply).FirstOrDefault();

                                    replyId           = latestReply.Id;
                                    correctBodyToShow = latestReply.CorrectBodyToShow;
                                    lastModified      = latestReply.LastModified;
                                }

                                correctBodyToShow = Microsoft.SharePoint.Utilities.SPHttpUtility.ConvertSimpleHtmlToText(correctBodyToShow, webpart.DigestLength);

                                //{$SubWebUrl}{$DisplayForm}?PageType={$PageType}&ListId={$ListID}&ID={&ItemID}
                                string replyUrl    = string.Format("http://{0}{1}?PageType={2}&ListId={{{3}}}&ID={4}", SPContext.Current.Site.HostName, _discussionBoard.DefaultDisplayFormUrl, _pageId, _discussionBoard.ID, replyId);
                                string onClickHref = string.Format(@"<a  onclick=""ShowReplyInDialog('{0}','{1}');return false;"" href='{0}' target=_self><NOBR>{2}... </NOBR>", replyUrl, Server.HtmlEncode(discussion.Title), correctBodyToShow);

                                string arrowHref;

                                if (webpart.UrlForArrow.IndexOf("http://") == -1)
                                {
                                    arrowHref = "http://" + SPContext.Current.Site.HostName + webpart.UrlForArrow;
                                }
                                else
                                {
                                    arrowHref = webpart.UrlForArrow;
                                }

                                if ((i == 0) & (!webpart.EnableTopLine))
                                {
                                    _sbRecords.Append("<div class=\"discussion_post first\">");
                                }
                                else
                                {
                                    _sbRecords.Append("<div class=\"discussion_post\">");
                                }

                                _sbRecords.Append("<h3>");
                                _sbRecords.Append("<a href=\"" + boardSubWeb.Url + "//" + discussionTopic.Url + "\">" + discussion.Title + "</a>");
                                _sbRecords.Append("</h3>");
                                _sbRecords.Append("<div class=\"discussion_timestamp\">");
                                _sbRecords.Append(lastModified.ToString("dd.MM hh:mm  "));
                                _sbRecords.Append("</div>"); //Discussion timestamp
                                _sbRecords.Append(onClickHref);
                                _sbRecords.Append("</a>");
                                _sbRecords.Append("<img width=\"9\" height=\"7\" src=\"" + arrowHref + "\">");
                                _sbRecords.Append("</div>"); //Discussion post
                            }
                        }
                        catch (Exception ex)
                        {
                            _sbRecords.AppendLine(Properties.Resources.textExceptionQueryingDiscussionBoard + ex.Message);
                        }


                        //_sbRecords.Append("</div>");//Discussion Zone
                    } //using datacontext
                }     // using board subweb
            }
            else
            {
                _sbRecords.Append(Properties.Resources.messagePleaseSelectDiscussionBoard);
            }

            literalDiscussionRecords.Text = _sbRecords.ToString();
            return(true);
        }
Example #19
0
        /// <summary>
        /// Click event.
        /// </summary>
        /// <param name="sender">The Sender.</param>
        /// <param name="e">The EventArgs.</param>
        protected void ButtonTrigger_Click(object sender, EventArgs e)
        {
            // Validate
            this.Validate();

            if (!this.IsValid)
            {
                return;
            }

            // We are valid
            // Register the database
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();

                try
                {
                    ServiceClient.TriggerMetaData("12073385", true);
                }
                catch { };

                operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
            }
        }
        protected override void CreateChildControls()
        {
            dataTable = new DataTable();

            Table htmlTable = new Table();

            htmlTable.Width = Unit.Percentage(100.0);
            htmlTable.Attributes.Add("cellspacing", "0");
            htmlTable.Attributes.Add("cellpadding", "0");
            TableRow row = new TableRow();

            row.Width = Unit.Percentage(100.0);
            Label     label = new Label();
            TableCell cell  = new TableCell();

            cell.CssClass = "ms-descriptiontext";
            cell.Attributes.Add("style", "white-space:nowrap");
            string str = SPHttpUtility.HtmlEncode(SPResource.GetString("PickerDialogDefaultSearchLabel", new object[0]));

            str        = string.Format(CultureInfo.InvariantCulture, "<b>{0}</b>&nbsp;", new object[] { str });
            label.Text = str;
            cell.Controls.Add(label);
            this.ColumnList          = new DropDownList();
            this.ColumnList.ID       = "columnList";
            this.ColumnList.CssClass = "ms-pickerdropdown";
            cell.Controls.Add(this.ColumnList);
            row.Cells.Add(cell);

            //Punches-in the search operator dropdown
            cell = new TableCell();
            cell.Style.Add("padding-right", "20px");
            drpdSearchOperators    = new HtmlSelect();
            drpdSearchOperators.ID = "queryOperators";
            drpdSearchOperators.Attributes.Add("class", "ms-pickerdropdown");

            cell.Controls.Add(drpdSearchOperators);
            row.Cells.Add(cell);

            cell                        = new TableCell();
            cell.Width                  = Unit.Percentage(100.0);
            this.QueryTextBox           = new InputFormTextBox();
            this.QueryTextBox.ID        = "queryTextBox";
            this.QueryTextBox.CssClass  = "ms-pickersearchbox";
            this.QueryTextBox.AccessKey = SPResource.GetString("PickerDialogSearchAccessKey", new object[0]);
            this.QueryTextBox.Width     = Unit.Percentage(100.0);
            this.QueryTextBox.MaxLength = 0x3e8;
            this.QueryTextBox.Text      = QueryText;
            cell.Controls.Add(this.QueryTextBox);
            row.Cells.Add(cell);
            label.AssociatedControlID = "queryTextBox";
            cell                           = new TableCell();
            this.QueryButton               = new ImageButton();
            this.QueryButton.ID            = "queryButton";
            this.QueryButton.OnClientClick = "executeQuery();return false;";
            this.QueryButton.ToolTip       = SPResource.GetString("PickerDialogSearchToolTip", new object[0]);
            this.QueryButton.AlternateText = SPResource.GetString("PickerDialogSearchToolTip", new object[0]);
            if (!web.RegionalSettings.IsRightToLeft)
            {
                this.QueryButton.ImageUrl = "/_layouts/images/gosearch.gif";
            }
            else
            {
                this.QueryButton.ImageUrl = "/_layouts/images/gortl.gif";
            }
            HtmlGenericControl control = new HtmlGenericControl("div");

            control.Attributes.Add("class", "ms-searchimage");
            control.Controls.Add(this.QueryButton);
            cell.Controls.Add(control);
            row.Cells.Add(cell);
            htmlTable.Rows.Add(row);
            this.Controls.Add(htmlTable);


            //fills the search fields initially

            foreach (SPField field in list.Fields)
            {
                List <string> searchFields = propertyBag.SearchFields;

                // add table columns
                if (searchFields.Contains(field.InternalName.ToString()) || field.Id == propertyBag.FieldId)
                {
                    if (!Page.IsPostBack)
                    {
                        mColumnList.Items.Add(new ListItem(field.Title, field.Id.ToString()));
                    }

                    DataColumn col = dataTable.Columns.Add();
                    col.ColumnName = field.Id.ToString();
                    col.Caption    = field.Title;
                    col.ExtendedProperties.Add("InternalName", field.InternalName);
                }
            }

            if (!dataTable.Columns.Contains(SPBuiltInFieldId.ID.ToString()))
            {
                SPField idField = list.Fields[SPBuiltInFieldId.ID];

                DataColumn col = dataTable.Columns.Add();
                col.ColumnName = idField.Id.ToString();
                col.Caption    = idField.Title;
                col.ExtendedProperties.Add("InternalName", idField.InternalName);
            }

            if (mColumnList.Items.Count == 0)
            {
                SPField field = list.Fields[propertyBag.FieldId];
                mColumnList.Items.Add(new ListItem(field.Title, field.Id.ToString()));
            }

            //fills the search operators initally
            FillSearchOperators(ColumnList.SelectedValue);
        }
Example #21
0
 /// <summary>
 /// Click event.
 /// </summary>
 /// <param name="sender">The Sender.</param>
 /// <param name="e">The EventArgs.</param>
 protected void ButtonCancel_Click(object sender, EventArgs e)
 {
     Response.Redirect(string.Format(CultureInfo.InvariantCulture, "ManageUsers.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
 }
Example #22
0
 protected void OnDeleteUser(object sender, EventArgs e)
 {
     SPUtility.Redirect(string.Format("FBA/Management/UserDelete.aspx?UserName={0}&Source={1}", this.Request.QueryString["USERNAME"], SPHttpUtility.UrlKeyValueEncode(SPUtility.OriginalServerRelativeRequestUrl)), SPRedirectFlags.RelativeToLayoutsPage, this.Context);
 }
Example #23
0
        /// <summary>
        /// Click event.
        /// </summary>
        /// <param name="sender">The Sender.</param>
        /// <param name="e">The EventArgs.</param>
        protected void ButtonOk_Click(object sender, EventArgs e)
        {
            // Validate
            this.Validate();

            if (!this.IsValid)
            {
                return;
            }

            // We are valid
            // Register the database
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();

                //TODO Save
                string nummer     = tbx_bondsnummer.Text.Trim();
                string voornaam   = tbx_voornaam.Text.Trim();
                string achternaam = tbx_achternaam.Text.Trim();
                string email      = tbx_email.Text.Trim();
                string vereniging = ddl_vereniging.SelectedItem.Value;
                ClubCloud.Model.ClubCloud_Gebruiker gebruiker = new Model.ClubCloud_Gebruiker {
                    Bondsnummer = nummer, Volledigenaam = voornaam + achternaam, Voornaam = voornaam, Achternaam = achternaam, EmailKNLTB = email, VerenigingId = Guid.Parse(vereniging)
                };

                ServiceClient.CreateGebruiker(gebruiker);


                operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageUsers.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id)));
            }
        }
Example #24
0
 /// <summary>
 /// ECMAs the script encode.
 /// </summary>
 /// <param name="stringToEncode">The string to encode.</param>
 /// <returns>The encoded string</returns>
 public string EcmaScriptEncode(string stringToEncode)
 {
     return(SPHttpUtility.EcmaScriptStringLiteralEncode(stringToEncode));
 }
Example #25
0
 /// <summary>
 /// Gets the current URL.
 /// </summary>
 /// <returns>The current full Url</returns>
 public static string GetCurrentUrl()
 {
     return
         (SPHttpUtility.UrlKeyValueEncode(
              SPContext.Current.Web.Site.MakeFullUrl(SPUtility.OriginalServerRelativeRequestUrl)));
 }