예제 #1
0
 private void WebSitePart_LoadNavigation(object sender, EventArgs e)
 {
     if (inEditMode)
     {
         CreateWebSitePartMenu();
         WebSitePartMenu menu = new WebSitePartMenu(this);
         menuControls.Controls.Add(menu);
         ScriptLink.Register(this.Page, "Hemrika/WebSitePart/Hemrika.SharePresence.WebSitePart.js", false, true);
         this.Controls.Add(menuControls);
         this.EnsureChildControls();
     }
 }
        // Protected Methods (1) 

        protected void Page_Load(object sender, EventArgs e)
        {
            _jobId = Request.Params["jobid"] ?? string.Empty;
            string format            = Request.Params["format"] ?? string.Empty;
            bool   isImportCancelled = Convert.ToBoolean(Request.Params["isCancelImportResourceJob"]);

            if (!isImportCancelled)
            {
                if (!format.Trim().ToLower().Equals("json"))
                {
                    if (string.IsNullOrEmpty(_jobId))
                    {
                        MissingJobIdErrorLabel.Visible = true;
                    }
                    else
                    {
                        Panel.Visible = true;
                        ScriptLink.Register(Page, "/_layouts/epmlive/javascripts/libraries/jquery.min.js", false);
                    }
                }
                else
                {
                    string response = "{warmingUp:true}";

                    if (string.IsNullOrEmpty(_jobId))
                    {
                        response = "{error:\"No Job ID was provided.\"}";
                    }
                    else
                    {
                        XmlNode timerJobStatus = Timer.GetTimerJobStatus(Web, new Guid(_jobId));

                        XmlNode node = timerJobStatus.FirstChild;
                        if (node != null)
                        {
                            response = node.Value;
                        }
                    }

                    Response.Clear();
                    Response.ContentType = "application/json; charset=utf-8";
                    Response.Write(Server.HtmlDecode(response));
                    Response.End();
                }
            }
            else
            {
                Timer.CancelTimerJob(Web, new Guid(_jobId));
            }
        }
예제 #3
0
        // Protected Methods (2) 

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            long ticks = DateTime.Now.Ticks;

            var javascripts = new[] { "treegrid/GridE.js", "javascripts/EPMLive.AssignmentPlanner.js" };

            foreach (string javascript in javascripts)
            {
                ScriptLink.Register(Page,
                                    string.Format("/_layouts/epmlive/{0}?v={1}", javascript,
                                                  InDebugMode ? (object)string.Empty : ticks), false);
            }

            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true;
        }
        //public override Microsoft.SharePoint.WebControls.PickerEntity ValidateEntity(Microsoft.SharePoint.WebControls.PickerEntity entity)
        //{
        //    try
        //    {
        //        if (SPContext.Current.List == null || SPContext.Current.List.Title != "Resources")
        //        {
        //            this.ValidateResolvedEntity = false;
        //            entity = base.ValidateEntity(entity);

        //            XmlDocument docTeam = new XmlDocument();
        //            docTeam.LoadXml(WorkEngineAPI.GetTeam("<Filter Column='SharePointAccount' Value='" + entity.DisplayText + "'/>", SPContext.Current.Web));
        //            if (docTeam.FirstChild.SelectSingleNode("//Team/Member") == null)
        //                entity.IsResolved = false;
        //            else
        //            {
        //                if (docTeam.FirstChild.SelectSingleNode("//Team/Member").Attributes["Username"].Value.ToLower() != entity.EntityData["AccountName"].ToString().ToLower())
        //                {
        //                    entity.IsResolved = false;
        //                }
        //            }
        //        }
        //        else
        //            entity = base.ValidateEntity(entity);

        //    }
        //    catch { }
        //    return entity;
        //}


        protected override void OnPreRender(EventArgs e)
        {
            ScriptLink.Register(Page, "/_layouts/epmlive/CCPeopleEditorAutoComplete.js", false);
            // we are sharing style sheets between this control and GenericEntityPicker
            this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "_WEPeopleEditorStyle_", "<link href=\"/_layouts/epmlive/GenericEntityPickerStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", false);

            if (!Page.ClientScript.IsClientScriptBlockRegistered("_WEPeopleEditorGlobalVariables_"))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "_WEPeopleEditorGlobalVariables_", "<script>var curWebURL = '" + SPContext.Current.Web.Url + "';</script>", false);
            }

            if (!Page.ClientScript.IsClientScriptBlockRegistered("_WEPeopleEditorGlobalObject_"))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "_WEPeopleEditorGlobalObject_", "<script>var _wePeopleEditorControlPropertyArray = new Array();</script>", false);
            }

            if (!Page.ClientScript.IsClientScriptBlockRegistered("_WEPeopleEditorGlobalDataCache_"))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "_WEPeopleEditorGlobalDataCache_", "<script>var _wePeopleEditorControlGlobalDataCache = new Array();</script>", false);
            }

            if (!Page.ClientScript.IsClientScriptBlockRegistered("_WEPeopleEditorControlProperties_" + this.ClientID))
            {
                this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "_WEPeopleEditorControlProperties_" + this.ClientID,
                                                                 "<script>" +
                                                                 "if (_wePeopleEditorControlPropertyArray) { " +
                                                                 "   var controlProps_" + this.ClientID + " = { wePeopleEditorDivIDRoot : '" + this.ClientID + "'," +
                                                                 "                                              wePeopleEditorDivID : '" + this.ClientID + "_upLevelDiv'," +
                                                                 "                                              wePeopleEdtiorCheckNameID : '" + this.ClientID + "_checkNames'," +
                                                                 "                                              ajaxHandlerPage : '" + PEOPLE_EDITOR_AJAX_HANDLER_PAGE + "', " +
                                                                 "                                              curWebURL : '" + SPContext.Current.Web.Url + "'," +
                                                                 "                                              isMultiSelect : " + this.MultiSelect.ToString().ToLower() + "," +
                                                                 "                                              searchText : '', " +
                                                                 "                                              singleSelectLookupVal : '', " +
                                                                 "                                              candidateIndex : '-1', " +
                                                                 "                                              autoCompleteDivID : 'autoCompleteDiv_" + this.ClientID + "', " +
                                                                 "                                              checkNamesOnClick : '', " +
                                                                 "                                              browseOnClick : '' }; " +
                                                                 "  var arrLength = _wePeopleEditorControlPropertyArray.length; " +
                                                                 "  _wePeopleEditorControlPropertyArray[arrLength] = controlProps_" + this.ClientID + "; " +
                                                                 "  }</script>", false);
            }

            // hides the book and validate button
            this.ShowButtons = false;

            base.OnPreRender(e);
        }
예제 #5
0
        protected override void OnPreRender(EventArgs e)
        {
            //ScriptLink.Register(Page, "/_layouts/epmlive/jQueryLibrary/jquery-1.6.2.min.js", false);

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "_ChangeButtonToOpenInModal_",
                                                        "<script>" +
                                                        "var webUrl = '" + Web.Url + "'; " +
                                                        "var btnNewNavId = '" + newNavNode.ClientID + "_LinkText'; " +
                                                        "var btnNewCatId = '" + newCatNode.ClientID + "_LinkText'; " +
                                                        "var btnReorderId = '" + btnReorderNavNodes.ClientID + "_LinkText'; " +
                                                        "var appId = '" + _appId.ToString() + "';" +
                                                        "</script>", false);

            ScriptLink.Register(Page, "/_layouts/epmlive/EPMLiveQuickLaunch.js", false);

            base.OnPreRender(e);
        }
예제 #6
0
        protected override void OnPreRender(EventArgs e)
        {
            Page.ClientScript.RegisterClientScriptBlock(
                Page.GetType(),
                "_LookupFieldsPropsArray_",
                "<script> if (!_LookupFieldsPropsArray) { var _LookupFieldsPropsArray = new Array(); } </script>",
                false);

            var fieldName = LookupData.Field != "none"
                ? LookupData.Field
                : LookupField.InternalName;
            var type = LookupData.Type;

            parent = LookupData.Parent;
            var parentListField = LookupData.ParentListField;

            Page.ClientScript.RegisterClientScriptBlock(
                Page.GetType(),
                "_LookupFieldsPropsArray_Edit_" + ClientID,
                "<script>" +
                "if (_LookupFieldsPropsArray) { " +
                "   var lookupFieldProp_" + fieldName + " = { FieldName : '" + fieldName + "', " +
                "                                             ControlType: '" + type + "', " +
                "                                             FieldInfo: { LookupWebId: '" + LookupField.LookupWebId.ToString() + "', " +
                "                                                          LookupListId: '" + LookupField.LookupList.ToString() + "', " +
                "                                                          LookupField: '" + LookupField.LookupField.ToString() + "' }, " +
                "                                             ControlInfo:  { DropDownClientId: '" + (DropList != null ? DropList.ClientID : string.Empty) + "', " +
                "                                                             TextBoxClientId: '" + (TextField != null ? TextField.ClientID : string.Empty) + "', " +
                "                                                             DropImageClientId: '" + (DropImage != null ? DropImage.ClientID : string.Empty) + "', " +
                "                                                             CurWebURL: '" + SPContext.Current.Web.Url + "', " +
                "                                                             IsMultiSelect: " + propBag.IsMultiSelect.ToLower() + ", " +
                "                                                             SourceControlId: '" + propBag.SourceControlID + "', " +
                "                                                             SearchText: '', " +
                "                                                             SingleSelectLookupVal: '', " +
                "                                                             SingleSelectDisplayVal: ''}, " +
                "                                             Parent: '" + parent + "', " +
                "                                             ParentListField: '" + parentListField + "', " +
                "                                             CachedValue: ''};" +
                "  var arrLength = _LookupFieldsPropsArray.length; " +
                "  _LookupFieldsPropsArray[arrLength] = lookupFieldProp_" + fieldName + "}; " +
                "</script>"
                , false);

            var fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location)
                              .FileVersion;

            if (string.IsNullOrWhiteSpace(fileVersion) || fileVersion.Equals("1.0.0.0"))
            {
                fileVersion = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            }

            ScriptLink.Register(Page, "/_layouts/epmlive/ModifiedDropDown.js?v=" + fileVersion, false);

            base.OnPreRender(e);

            if (!string.IsNullOrWhiteSpace(parent))
            {
                Page.ClientScript.RegisterStartupScript(
                    GetType(),
                    "_HideChildCascadeField_" + ClientID,
                    "function HideControl_" + ClientID + "(){ " +
                    "   if ($('#" + ClientID + "').length > 0){ " +
                    "       $('#" + ClientID + "').prop('disabled', true); " +
                    "   } else { " +
                    "       setTimeout(HideControl_" + ClientID + ", 500); " +
                    "   } " +
                    "} " +
                    "$(document).ready(function () { " +
                    "HideControl_" + ClientID + "();" +
                    "});",
                    true);
            }
        }
예제 #7
0
 private void RegisterScripts()
 {
     ScriptLink.Register(Page, "/_layouts/epmlive/treegrid/GridE.js", false);
 }
예제 #8
0
 protected override void OnPreRender(EventArgs e)
 {
     // Register Script to page
     ScriptLink.Register(Page, "jQuery/jquery.js", false);
     base.OnPreRender(e);
 }
        protected override void CreateChildControls()
        {
            RosterConfigService configProvider = new RosterConfigService();
            var lists = configProvider.GetLists();

            ddlCatalogs          = new DropDownList();
            ddlCatalogs.ID       = "catalogSelector";
            ddlCatalogs.CssClass = "lists_control";
            ddlCatalogs.Attributes.Add("onchange", "UpdateViewsList(this);");
            ddlCatalogs.Items.AddRange(lists.Select(x => new ListItem(x.Name, x.Id.ToString())).ToArray());

            ddlViews          = new DropDownList();
            ddlViews.ID       = "viewSelector";
            ddlViews.CssClass = "views_control";
            ddlViews.Items.AddRange(lists.SelectMany(x => x.ViewMetadatas).Select(v => new ListItem(v.Name, v.Id.ToString())).ToArray());

            hidAllViewsInfo       = new HiddenField();
            hidAllViewsInfo.ID    = "hidAllViewsHierarchy";
            hidAllViewsInfo.Value = new JavaScriptSerializer().Serialize(lists.Select(x => new { list = x.Id, views = x.ViewMetadatas.Select(v => new { viewId = v.Id, viewName = v.Name }) }));

            txtRelationFld    = new TextBox();
            txtRelationFld.ID = "txtRelationField";

            txtFilterOperators    = new TextBox();
            txtFilterOperators.ID = "txtFilterOperators";

            txtCalendarWidth    = new TextBox();
            txtCalendarWidth.ID = "txtCalendarWidth";

            txtCalendarHeight    = new TextBox();
            txtCalendarHeight.ID = "txtCalendarHeight";

            chEditMode      = new CheckBox();
            chEditMode.ID   = "chEditMode";
            chEditMode.Text = "Edit mode? (GridView only)";

            chDisplayPrepopulated      = new CheckBox();
            chDisplayPrepopulated.ID   = "chDisplayPrepopulated";
            chDisplayPrepopulated.Text = "Display pre-populated? (CalendarView only)";

            this.Controls.Add(ddlCatalogs);
            this.Controls.Add(ddlViews);
            this.Controls.Add(hidAllViewsInfo);
            this.Controls.Add(txtRelationFld);
            this.Controls.Add(txtFilterOperators);
            this.Controls.Add(txtCalendarWidth);
            this.Controls.Add(txtCalendarHeight);
            this.Controls.Add(chEditMode);
            this.Controls.Add(chDisplayPrepopulated);
            ScriptLink.Register(this.Page, "/_layouts/15/Roster.Presentation/js/cascadeSelection.view.js", true);

            //setting the last set values as current values on custom toolpart
            ExternalListViewWebPart wp = (ExternalListViewWebPart)this.ParentToolPane.SelectedWebPart;

            if (wp != null)
            {
                this.ddlCatalogs.SelectedValue     = wp.CatalogId;
                this.ddlViews.SelectedValue        = wp.ViewName;
                this.txtRelationFld.Text           = wp.RelationField;
                this.txtFilterOperators.Text       = wp.FilterOperators;
                this.txtCalendarWidth.Text         = wp.CalendarWidth;
                this.txtCalendarHeight.Text        = wp.CalendarHeight;
                this.chEditMode.Checked            = wp.EditMode;
                this.chDisplayPrepopulated.Checked = wp.DisplayPrepopulated;
            }

            base.CreateChildControls();
        }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     ScriptLink.Register(this.Page, jqueryScript, false);
     ScriptLink.Register(this.Page, jqueryUIScript, false);
     CssRegistration.Register(jqueryCss);
 }
예제 #11
0
        protected override void OnPreRender(EventArgs e)
        {
            //ScriptLink.Register(Page, "/_layouts/epmlive/jQueryLibrary/jquery-1.6.2.min.js", false);

            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_",
                                                             "<script>if (!_LookupFieldsPropsArray) { var _LookupFieldsPropsArray = new Array(); }</script>", false);

            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_Edit_" + this.ClientID,
                                                             "<script>" +
                                                             "if (_LookupFieldsPropsArray) { " +
                                                             "   var lookupFieldProp_" + LookupData.Field + " = { FieldName : '" + LookupData.Field + "', " +
                                                             "                                                    ControlType: '" + LookupData.Type + "', " +
                                                             "                                                    FieldInfo: { LookupWebId: '" + LookupField.LookupWebId.ToString() + "', " +
                                                             "                                                                 LookupListId: '" + LookupField.LookupList.ToString() + "', " +
                                                             "                                                                 LookupFieldId: '" + LookupField.Id.ToString() + "', " +
                                                             "                                                                 LookupField: '" + LookupField.LookupField.ToString() + "'}, " +
                                                             "                                                    ControlInfo: { SelectCandidateId: '" + TemplateContainer.ClientID + "_SelectCandidate', " +
                                                             "                                                                   AddButtonId: '" + TemplateContainer.ClientID + "_AddButton'," +
                                                             "                                                                   RemoveButtonId: '" + TemplateContainer.ClientID + "_RemoveButton'," +
                                                             "                                                                   SelectResultId: '" + TemplateContainer.ClientID + "_SelectResult', " +
                                                             "                                                                   SourceSelectCandidateID: '" + propBag.SelectCandidateID + "', " +
                                                             "                                                                   SourceAddButtonID: '" + propBag.AddButtonID + "', " +
                                                             "                                                                   SourceRemoveButtonID: '" + propBag.RemoveButtonID + "', " +
                                                             "                                                                   SourceSelectResultID: '" + propBag.SelectResultID + "', " +
                                                             "                                                                   CurWebURL: '" + SPContext.Current.Web.Url + "', " +
                                                             "                                                                   IsMultiSelect: " + LookupField.AllowMultipleValues.ToString().ToLower() + ", " +
                                                             "                                                                   SearchText: '', " +
                                                             "                                                                   CandidateIndex: '-1', " +
                                                             "                                                                   AutoCompleteDivID : 'autoCompleteDiv_" + this.ClientID + "'}, " +
                                                             "                                                    Parent: '" + LookupData.Parent + "', " +
                                                             "                                                    ParentListField: '" + LookupData.ParentListField + "', " +
                                                             "                                                    CachedValue: ''};" +
                                                             "  var arrLength = _LookupFieldsPropsArray.length; " +
                                                             "  _LookupFieldsPropsArray[arrLength] = lookupFieldProp_" + LookupData.Field + "; " +
                                                             "} " +
                                                             "</script>"
                                                             , false);

            string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (string.IsNullOrEmpty(fileVersion) || fileVersion.Equals("1.0.0.0"))
            {
                fileVersion = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            }
            ScriptLink.Register(Page, "/_layouts/epmlive/ModifiedDropDown.js?v=" + fileVersion, false);


            object fv  = null;
            string sfv = string.Empty;

            try
            {
                fv = ListItem[LookupField.InternalName];
            }
            catch { }

            if (fv != null)
            {
                sfv = fv.ToString();
            }

            if (LookupData != null && LookupData.Parent != "" && string.IsNullOrEmpty(sfv))
            {
                this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "_hideControls_",
                                                                 "function HideControl_" + this.ClientID + "(){ " +
                                                                 "   if ($('#" + TemplateContainer.ClientID + "_SelectCandidate').length > 0){ " +
                                                                 "       $('#" + TemplateContainer.ClientID + "_SelectCandidate').prop('disabled', true); " +
                                                                 "       $('#" + TemplateContainer.ClientID + "_AddButton').prop('disabled', true); " +
                                                                 "       $('#" + TemplateContainer.ClientID + "_RemoveButton').prop('disabled', true); " +
                                                                 "       $('#" + TemplateContainer.ClientID + "_SelectResult').prop('disabled', true); " +
                                                                 "   } else { " +
                                                                 "       setTimeout(HideControl_" + this.ClientID + ", 500); " +
                                                                 "   } " +
                                                                 "} " +

                                                                 "$(document).ready(function () { " +
                                                                 "HideControl_" + this.ClientID + "();" +
                                                                 "});", true);
            }

            base.OnPreRender(e);
        }
예제 #12
0
        protected override void OnPreRender(System.EventArgs e)
        {
            SPWeb      Web      = SPContext.Current.Web;
            SPList     List     = SPContext.Current.List;
            SPListItem ListItem = SPContext.Current.ListItem;

            CssRegistration.Register("/_layouts/epmlive/modal/modal.css");
            ScriptLink.Register(Page, "/_layouts/epmlive/modal/modal.js", false);


            SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

            RegisterArchiveRestoreFormButtons(Web, List, ListItem, ribbon);

            ribbon.TrimById("Ribbon.ListForm.Display.Manage.EditItem");

            XmlDocument ribbonExtensions = new XmlDocument();


            if (NavigationService.LPPFEPermissionCheck(List, SPBasePermissions.EditListItems))
            {
                ribbonExtensions.LoadXml(@"<Button
                    Id=""Ribbon.ListForm.Display.Manage.EditItem2""
                    Sequence=""10""
                    Command=""Ribbon.ListForm.Display.Manage.EditItem2""
                    Image16by16=""/_layouts/" + Web.Language + @"/images/formatmap16x16.png"" Image16by16Top=""-128"" Image16by16Left=""-224""
                    Image32by32=""/_layouts/" + Web.Language + @"/images/formatmap32x32.png"" Image32by32Top=""-128"" Image32by32Left=""-96""
                    LabelText=""Edit Item""
                    TemplateAlias=""o1""/>");

                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
            }

            if (!NavigationService.LPPFEPermissionCheck(List, SPBasePermissions.DeleteListItems))
            {
                ribbon.TrimById("Ribbon.ListForm.Display.Manage.DeleteItem");
            }

            EPMLiveCore.GridGanttSettings gSettings = API.ListCommands.GetGridGanttSettings(List);

            ArrayList arrAssoc = API.ListCommands.GetAssociatedLists(List);

            if (gSettings.AssociatedItems)
            {
                StringBuilder sbLists = new StringBuilder();

                foreach (EPMLiveCore.API.AssociatedListInfo ali in arrAssoc)
                {
                    //sbLists.Append("<Button Id=\"Ribbon.ListForm.Display.Manage.LinkedItemsButton\" Sequence=\"20\" Command=\"");
                    sbLists.Append("<Button Sequence=\"20\" Command=\"");
                    sbLists.Append("Ribbon.ListForm.Display.Associated.LinkedItemsButton");
                    sbLists.Append("\" Id=\"Ribbon.ListForm.Display.Associated.");
                    sbLists.Append(HttpUtility.HtmlEncode(ali.Title));
                    sbLists.Append(".");
                    sbLists.Append(ali.LinkedField);
                    sbLists.Append("\" LabelText=\"");
                    sbLists.Append(HttpUtility.HtmlEncode(ali.Title));
                    sbLists.Append("\" TemplateAlias=\"o1\" Image16by16=\"");
                    sbLists.Append(ali.icon);
                    sbLists.Append("\"/>");
                }


                if (sbLists.Length > 0)
                {
                    StringBuilder sbLinkedItems = new StringBuilder();

                    sbLinkedItems.Append("<Group Id=\"Ribbon.ListForm.Display.Associated\" Sequence=\"41\" Command=\"Ribbon.ListForm.Display.Associated.LinkedItems\" Description=\"\" Title=\"Associated Items\" Template=\"Ribbon.Templates.Flexible2\">");
                    sbLinkedItems.Append("<Controls Id=\"Ribbon.ListForm.Display.Associated.Controls\">");

                    sbLinkedItems.Append(sbLists);

                    sbLinkedItems.Append("</Controls>");
                    sbLinkedItems.Append("</Group>");

                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml(sbLinkedItems.ToString());
                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Groups._children");

                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml("<MaxSize Id=\"Ribbon.ListForm.Display.Associated.MaxSize\" Sequence=\"10\" GroupId=\"Ribbon.ListForm.Display.Associated\" Size=\"MediumMedium\" />");
                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Scaling._children");



                    //StringBuilder sbLinkedItems = new StringBuilder();
                    //sbLinkedItems.Append("<FlyoutAnchor Id=\"Ribbon.ListForm.Display.Manage.LinkedItems\" Sequence=\"39\" Command=\"");
                    //sbLinkedItems.Append("Ribbon.ListForm.Display.Manage.LinkedItems");
                    //sbLinkedItems.Append("\" Image32by32=\"/_layouts/epmlive/images/linkeditems.gif\" LabelText=\"Associated Items\" TemplateAlias=\"o1\">");
                    //sbLinkedItems.Append("<Menu Id=\"Ribbon.List.EPMLive.LinkedItems.Menu\">");
                    //sbLinkedItems.Append("<MenuSection Id=\"Ribbon.List.EPMLive.LinkedItems.Menu.Scope\" Sequence=\"10\" DisplayMode=\"Menu16\">");
                    //sbLinkedItems.Append("<Controls Id=\"Ribbon.List.EPMLive.LinkedItems.Menu.Scope.Controls\">");
                    //sbLinkedItems.Append(sbLists);
                    //sbLinkedItems.Append("</Controls>");
                    //sbLinkedItems.Append("</MenuSection>");
                    //sbLinkedItems.Append("</Menu>");
                    //sbLinkedItems.Append("</FlyoutAnchor>");


                    //ribbonExtensions.LoadXml(sbLinkedItems.ToString());

                    //ribbon.RegisterDataExtension(ribbonExtensions.FirstChild,
                    //"Ribbon.ListForm.Display.Manage.Controls._children");
                }
            }
            //======================Planner==================

            API.ListPlannerProps p = API.ListCommands.GetListPlannerInfo(List);

            if (p.PlannerV2Menu != "")
            {
                ribbonExtensions.LoadXml(p.PlannerV2Menu.Replace("EPMLivePlanner", "Ribbon.ListForm.Display.Manage.EPMLivePlanner").Replace("TaskPlanner", "Ribbon.ListForm.Display.Manage.TaskPlanner"));

                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild,
                                             "Ribbon.ListForm.Display.Manage.Controls._children");


                //if(bPlanner == 1)
                //{
                //    EPMLiveWorkPlanner.WorkPlannerAPI.PlannerProps props = EPMLiveWorkPlanner.WorkPlannerAPI.getSettings(Web, sPlannerID);
                //    bUseTeam = props.bUseTeam;
                //    ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.BuildTeam\" Sequence=\"41\" Command=\"Ribbon.ListForm.Display.Manage.BuildTeam\" LabelText=\"Build Team\" TemplateAlias=\"o1\" Image32by32=\"/_layouts/epmlive/images/editteam32.gif\"/>");

                //    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
                //}
            }

            //=====================Create Workspace===========

            if (gSettings.EnableRequests)
            {
                string childitem = "";
                try
                {
                    childitem = ListItem["WorkspaceUrl"].ToString();
                }
                catch { }

                if ((ListItem.ModerationInformation == null || ListItem.ModerationInformation.Status == SPModerationStatusType.Approved) && childitem == "")
                {
                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.CreateWorkspace\" Sequence=\"50\" Command=\"Ribbon.ListForm.Display.Manage.CreateWorkspace\" LabelText=\"Create Workspace\" TemplateAlias=\"o2\" Image16by16=\"_layouts/images/epmlivelogosmall.gif\"/>");
                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
                }
            }

            //=====================Favorite

            if (Web.Features[new Guid("046f0200-30e5-4545-b00f-c8c73aef9f0e")] != null)
            {
                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.FavoriteStatus\" Sequence=\"100\" Command=\"Ribbon.ListForm.Display.Actions.Favorite\" LabelText=\"Favorite\" TemplateAlias=\"o1\" Image32by32=\"_layouts/epmlive/images/star32.png\" Image16by16=\"_layouts/epmlive/images/star16.png\"/>");
                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Actions.Controls._children");

                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.FavoriteStatus\" Sequence=\"100\" Command=\"Ribbon.ListForm.Display.Actions.Favorite\" LabelText=\"Favorite\" TemplateAlias=\"o1\" Image32by32=\"_layouts/epmlive/images/star32.png\" Image16by16=\"_layouts/epmlive/images/star16.png\"/>");
                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Edit.Actions.Controls._children");

                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.FavoriteStatus\" Sequence=\"100\" Command=\"Ribbon.ListForm.Display.Actions.Favorite\" LabelText=\"Favorite\" TemplateAlias=\"o1\" Image32by32=\"_layouts/epmlive/images/star32.png\" Image16by16=\"_layouts/epmlive/images/star16.png\"/>");
                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.DocLibListForm.Edit.Actions.Controls._children");
            }

            EPMLiveCore.API.RibbonProperties rp = (EPMLiveCore.API.RibbonProperties)EPMLiveCore.Infrastructure.CacheStore.Current.Get("GR-" + Web.CurrentUser.ID, "GridSettings-" + List.ID, () =>
            {
                return(EPMLiveCore.API.ListCommands.GetRibbonProps(List));
            }).Value;

            //=====================Build Team===========

            try
            {
                if (rp.bBuildTeam)
                {
                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.BuildTeam\" Sequence=\"50\" Command=\"Ribbon.ListForm.Display.Manage.BuildTeam\" LabelText=\"Edit Team\" TemplateAlias=\"o2\" Image16by16=\"_layouts/epmlive/images/buildteam16.gif\"/>");
                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
                }
            }
            catch { }
            //==========Go To Workspace=================

            string workspaceurl = "";

            try
            {
                workspaceurl = ListItem["WorkspaceUrl"].ToString();
            }
            catch { }

            if (workspaceurl != "")
            {
                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml("<Button Id=\"Ribbon.ListItem.EPMLive.GoToWorkspace\" Sequence=\"55\" Command=\"Ribbon.ListForm.Display.Manage.GoToWorkspace\" LabelText=\"Go To Workspace\" TemplateAlias=\"o1\" Image32by32=\"_layouts/images/spgraphic.gif\" Image32by32Top=\"7\" Image32by32Left=\"4\"/>");
                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
            }

            //================EPK===================



            if (rp.aEPKButtons.Contains("costs"))
            {
                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml(@"<Button
                    Id=""Ribbon.ListItem.Manage.EPKCosts""
                    Sequence=""101""
                    Command=""Ribbon.ListForm.Display.Manage.EPKCost""
                    Image32by32=""/_layouts/epmlive/images/editcosts.png""
                    LabelText=""Edit Costs""
                    TemplateAlias=""o1""
                    />");

                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
            }

            if (rp.aEPKButtons.Contains("resplan"))
            {
                if (rp.aEPKActivex.Contains("resplan"))
                {
                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml(@"<Button
                        Id=""Ribbon.ListItem.Manage.EPKResourcePlanner""
                        Sequence=""103""
                        Command=""Ribbon.ListForm.Display.Manage.EPKRP""
                        Image32by32=""/_layouts/epmlive/images/ribbon32.png"" Image32by32Top=""-65""
                        LabelText=""Edit Resource Plan""
                        TemplateAlias=""o1""
                        />");

                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
                }
                else
                {
                    ribbonExtensions = new XmlDocument();
                    ribbonExtensions.LoadXml(@"<Button
                        Id=""Ribbon.ListItem.Manage.EPKResourcePlanner""
                        Sequence=""103""
                        Command=""Ribbon.ListForm.Display.Manage.EPKRPM""
                        Image16by16=""/_layouts/1033/images/formatmap16x16.png"" Image16by16Top=""-64"" Image16by16Left=""-128""
                        LabelText=""Resource Planner""
                        TemplateAlias=""o2""
                        />");

                    ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
                }
            }

            API.Integration.IntegrationCore core = new API.Integration.IntegrationCore(Web.Site.ID, Web.ID);
            string Errors = "";

            int seq = 130;

            var commands = new List <IRibbonCommand>();

            List <EPMLiveIntegration.IntegrationControl> ics = core.GetItemButtons(ListItem.ParentList.ID, ListItem, out Errors);

            foreach (EPMLiveIntegration.IntegrationControl ic in ics)
            {
                ribbonExtensions = new XmlDocument();
                ribbonExtensions.LoadXml(@"<Button
                        Id=""EPMINT." + ic.Control + @"." + (int)ic.Window + @"""
                        Sequence=""" + (seq++).ToString() + @"""
                        Command=""Ribbon.ListForm.Display.Manage.EPMINT""
                        Image32by32=""/_layouts/15/images/" + ic.Image + @"""
                        LabelText=""" + ic.Title + @"""
                        TemplateAlias=""o1""
                        />");

                ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListForm.Display.Manage.Controls._children");
            }



            //===============================================



            // register the command at the ribbon. Include the callback to the server     // to generate the xml
            //commands.Add(new SPRibbonCommand("Ribbon.ListForm.Display.Manage.EditItem2", "alert('test');", "true"));

            var manager = new SPRibbonScriptManager();

            var methodInfo = typeof(SPRibbonScriptManager).GetMethod("RegisterInitializeFunction", BindingFlags.Instance | BindingFlags.NonPublic);



            methodInfo.Invoke(manager, new object[] { Page, "InitPageComponent", "/_layouts/epmlive/WEDispFormPageComponent.js", false, "WEDispFormPageComponent.PageComponent.initialize()" });


            manager.RegisterGetCommandsFunction(Page, "getGlobalCommands", commands);
            manager.RegisterCommandEnabledFunction(Page, "commandEnabled", commands);
            manager.RegisterHandleCommandFunction(Page, "handleCommand", commands);
        }
        //protected override void Render(HtmlTextWriter writer)
        //{
        //    this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_",
        //        "if (!_LookupFieldsPropsArray) { var _LookupFieldsPropsArray = new Array(); }", true);
        //    string sSingleSelectLookupVal = string.Empty;
        //    if (!this.MultiSelect && this.Entities.Count == 1)
        //    {
        //        sSingleSelectLookupVal = (this.Entities[0] as PickerEntity).Key;
        //    }
        //    this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_Edit_" + this.ClientID,
        //        "<script>" +
        //        "if (_LookupFieldsPropsArray) { " +
        //        "   var lookupFieldProp_" + propBag.Field + " = { FieldName : '" + propBag.Field + "', " +
        //        "                                                    ControlType: '" + propBag.ControlType + "', " +
        //        "                                                    FieldInfo:    { LookupWebId: '" + propBag.LookupWebID.ToString() + "', " +
        //        "                                                                    LookupListId: '" + propBag.LookupListID.ToString() + "', " +
        //        "                                                                    LookupFieldId: '" + propBag.LookupFieldSourceFieldID.ToString() + "', " +
        //        "                                                                    LookupField: '" + propBag.LookupFieldInternalName + "'}, " +
        //        "                                                    Required: '" + propBag.Required.ToString() + "', " +
        //        "                                                    RequiredErrorTextAreaId: '" + requiredErrTxtId + "', " +
        //        "                                                    ControlInfo:  { GenericEntityDivId: '" + this.ClientID + "_upLevelDiv', " +
        //        "                                                                    GenericEntityDivIdRoot: '" + this.ClientID + "'," +
        //        "                                                                    GenericEntityCheckNameId: '" + this.ClientID + "_checkNames'," +
        //        "                                                                    CurWebURL: '" + SPContext.Current.Web.Url + "', " +
        //        "                                                                    IsMultiSelect: " + propBag.IsMultiSelect.ToLower() + ", " +
        //        "                                                                    SourceDropDownID: '" + propBag.SourceDropDownID + "', " +
        //        "                                                                    SourceControlId: '" + propBag.SourceControlID + "', " +
        //        "                                                                    SelectCandidateId: '" + propBag.SelectCandidateID + "', " +
        //        "                                                                    AddButtonId: '" + propBag.AddButtonID + "', " +
        //        "                                                                    RemoveButtonId: '" + propBag.RemoveButtonID + "', " +
        //        "                                                                    SelectResultId: '" + propBag.SelectResultID + "', " +
        //        "                                                                    SearchText: '', " +
        //        "                                                                    SingleSelectLookupVal: '" + sSingleSelectLookupVal + "', " +
        //        "                                                                    SingleSelectDisplayVal: '', " +
        //        "                                                                    CandidateIndex: '-1', " +
        //        "                                                                    AutoCompleteDivId : 'autoCompleteDiv_" + this.ClientID + "', " +
        //        "                                                                    BrowseLinkOnClick : '', " +
        //        "                                                                    AddItemLinkOnClick : '', " +
        //        "                                                                    ShowAllDdlOnClick: '' }, " +
        //        "                                                    Parent: '" + propBag.Parent + "', " +
        //        "                                                    ParentListField: '" + propBag.ParentListField + "', " +
        //        "                                                    CachedValue: ''};" +
        //        "  var arrLength = _LookupFieldsPropsArray.length; " +
        //        "  _LookupFieldsPropsArray[arrLength] = lookupFieldProp_" + propBag.Field + "; " +
        //        "  }</script>", false);

        //    this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_GenericEntityEditorJS_", "<script src='/_layouts/epmlive/javascripts/GenericEntityEditor.js'></script>", false);
        //    this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_GenericEntityPickerStyle_", "<link href=\"/_layouts/epmlive/GenericEntityPickerStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", false);

        //    if (this.Entities.Count == 0 && propBag.Parent != "")
        //    {
        //        this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "_hideControls_",
        //            "function HideControl_" + this.ClientID + "(){ " +
        //            "   if ($('#" + this.ClientID + "_upLevelDiv').length > 0){ " +
        //            "       $('#" + this.ClientID + "_upLevelDiv').prop('disabled', true); " +
        //            "   } else { " +
        //            "       setTimeout(HideControl_" + this.ClientID + ", 500); " +
        //            "   } " +
        //            "} " +

        //            "$(document).ready(function () { " +
        //                "HideControl_" + this.ClientID + "();" +
        //            "});", true);
        //    }

        //    base.Render(writer);
        //}

        protected override void OnPreRender(EventArgs e)
        {
            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_" + this.ClientID,
                                                             "<script>if (!_LookupFieldsPropsArray) { var _LookupFieldsPropsArray = new Array(); }</script>", false);
            string sSingleSelectLookupVal = string.Empty;

            if (!this.MultiSelect && this.Entities.Count == 1)
            {
                sSingleSelectLookupVal = (this.Entities[0] as PickerEntity).Key;
            }
            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_LookupFieldsPropsArray_Edit_" + this.ClientID,
                                                             "<script>" +
                                                             "if (_LookupFieldsPropsArray) { " +
                                                             "   var lookupFieldProp_" + propBag.Field + " = { FieldName : '" + propBag.Field + "', " +
                                                             "                                                    ControlType: '" + propBag.ControlType + "', " +
                                                             "                                                    FieldInfo:    { LookupWebId: '" + propBag.LookupWebID.ToString() + "', " +
                                                             "                                                                    LookupListId: '" + propBag.LookupListID.ToString() + "', " +
                                                             "                                                                    LookupFieldId: '" + propBag.LookupFieldSourceFieldID.ToString() + "', " +
                                                             "                                                                    LookupField: '" + propBag.LookupFieldInternalName + "'}, " +
                                                             "                                                    Required: '" + propBag.Required.ToString() + "', " +
                                                             "                                                    RequiredErrorTextAreaId: '" + requiredErrTxtId + "', " +
                                                             "                                                    ControlInfo:  { GenericEntityDivId: '" + this.ClientID + "_upLevelDiv', " +
                                                             "                                                                    GenericEntityDivIdRoot: '" + this.ClientID + "'," +
                                                             "                                                                    GenericEntityCheckNameId: '" + this.ClientID + "_checkNames'," +
                                                             "                                                                    CurWebURL: '" + SPContext.Current.Web.Url + "', " +
                                                             "                                                                    IsMultiSelect: " + propBag.IsMultiSelect.ToLower() + ", " +
                                                             "                                                                    SourceDropDownID: '" + propBag.SourceDropDownID + "', " +
                                                             "                                                                    SourceControlId: '" + propBag.SourceControlID + "', " +
                                                             "                                                                    SelectCandidateId: '" + propBag.SelectCandidateID + "', " +
                                                             "                                                                    AddButtonId: '" + propBag.AddButtonID + "', " +
                                                             "                                                                    RemoveButtonId: '" + propBag.RemoveButtonID + "', " +
                                                             "                                                                    SelectResultId: '" + propBag.SelectResultID + "', " +
                                                             "                                                                    SearchText: '', " +
                                                             "                                                                    SingleSelectLookupVal: '" + sSingleSelectLookupVal + "', " +
                                                             "                                                                    SingleSelectDisplayVal: '', " +
                                                             "                                                                    CandidateIndex: '-1', " +
                                                             "                                                                    IsEditable: '" + IsFieldEditable().ToString().ToLower() + "', " +
                                                             "                                                                    AutoCompleteDivId : 'autoCompleteDiv_" + this.ClientID + "', " +
                                                             "                                                                    BrowseLinkOnClick : '', " +
                                                             "                                                                    AddItemLinkOnClick : '', " +
                                                             "                                                                    ShowAllDdlOnClick: '' }, " +
                                                             "                                                    Parent: '" + propBag.Parent + "', " +
                                                             "                                                    ParentListField: '" + propBag.ParentListField + "', " +
                                                             "                                                    CachedValue: ''};" +
                                                             "  var arrLength = _LookupFieldsPropsArray.length; " +
                                                             "  _LookupFieldsPropsArray[arrLength] = lookupFieldProp_" + propBag.Field + "; " +
                                                             "  }</script>", false);

            string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (string.IsNullOrEmpty(fileVersion) || fileVersion.Equals("1.0.0.0"))
            {
                fileVersion = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            }

            if (HttpContext.Current.Request.Browser.Type.ToUpper().Contains("IE") && HttpContext.Current.Request.Browser.MajorVersion < 9)
            {
                ScriptLink.Register(Page, "/_layouts/epmlive/javascripts/GenericEntityEditor-ie8.js?v=" + fileVersion, false);
            }
            else
            {
                ScriptLink.Register(Page, "/_layouts/epmlive/javascripts/GenericEntityEditor.js?v=" + fileVersion, false);
            }

            //this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_GenericEntityEditorJS_", "<script src='/_layouts/epmlive/javascripts/GenericEntityEditor.js'></script>", false);
            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "_GenericEntityPickerStyle_", "<link href=\"/_layouts/epmlive/GenericEntityPickerStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", false);

            base.OnPreRender(e);

            if (this.Entities.Count == 0 && propBag.Parent != "")
            {
                this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "_hideControls_",
                                                                 "function HideControl_" + this.ClientID + "(){ " +
                                                                 "   if ($('#" + this.ClientID + "_upLevelDiv').length > 0){ " +
                                                                 "       $('#" + this.ClientID + "_upLevelDiv').prop('disabled', true); " +
                                                                 "   } else { " +
                                                                 "       setTimeout(HideControl_" + this.ClientID + ", 500); " +
                                                                 "   } " +
                                                                 "} " +

                                                                 "$(document).ready(function () { " +
                                                                 "HideControl_" + this.ClientID + "();" +
                                                                 "});", true);
            }
        }