protected override void RenderWebPart(HtmlTextWriter output)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            ProjectData pjData = new ProjectData();

            pjData.site = Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(Context);
            string ret = pjData.buildData(true, true, true);

            if (ret != "")
            {
                output.Write("Error: " + ret);
            }
            else
            {
                pjData.gvPJSummary.RenderControl(output);
            }
        }
Example #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                writer.Write(act.translateStatus(activation));
                return;
            }

            UpdateContextSoWeCanGetDataFromSiteUserInfoList();

            var currentUser        = SPContext.Current.Web.CurrentUser;
            var loginName          = SPContext.Current.Web.CurrentUser.LoginName;
            var profilePicturePath = "";

            WriteStylesToOutput(writer);

            if (currentUser != null)
            {
                currentUser = GetProfileUser(SPContext.Current.Site, SPContext.Current.Web.CurrentUser.LoginName, true, currentUser);
                var spListItem = SPContext.Current.Web.Site.RootWeb.SiteUserInfoList.GetItemById(currentUser.ID);
                profilePicturePath = GetProfilePicturePath(spListItem);
                loginName          = spListItem.DisplayName;
            }

            //NOTE: This will automatically redirect to the users profile page if they are on server and not foundation.
            var userDisplayUrl = SPContext.Current.Web.Url + "/_layouts/userdisp.aspx";

            WriteJavascriptToOutput(writer);

            var userProfileManagementClass = GetUserProfileManagerClass();
            var isSharepointServer         = userProfileManagementClass != null ? true : false;

            var hasMySite = HasMySite(userProfileManagementClass);

            if (!LargeImage)
            {
                WriteSmallImageHtmlToOutput(writer, loginName, profilePicturePath, userDisplayUrl, isSharepointServer, hasMySite);
            }
            else
            {
                WriteLargeImageHtmlToOutput(writer, profilePicturePath, loginName, currentUser, userDisplayUrl, isSharepointServer, hasMySite);
            }
        }
Example #3
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            ProjectData pjData = new ProjectData();

            pjData.site = Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(Context);
            pjData.buildData(false, false, true);

            output.Write(pjData.buildIssueSummary());
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (activation != 0)
            {
                pnlActivate.Visible = true;
                pnlMain.Visible     = false;
                lblActivate.Text    = act.translateStatus(activation);
                return;
            }

            if (IsPostBack)
            {
                return;
            }

            PopulateForm();
            dtcDate.SelectedDate   = DateTime.Now;
            ddlUsers.SelectedIndex = 0;
        }
Example #5
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.MyWork);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            if (error != "")
            {
                output.Write(error);
            }
            else
            {
                rv.RenderControl(output);
                output.WriteLine("<script language=\"javascript\">document.getElementById('" + rv.ClientID + "_fixedTable').style.width='100%';</script>");
            }
        }
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            tb.AddTimer();



            if (SPContext.Current.ViewContext.View != null)
            {
                foreach (System.Web.UI.WebControls.WebParts.WebPart wp in WebPartManager.WebParts)
                {
                    try
                    {
                        if (wp.ToString() == "Microsoft.SharePoint.WebPartPages.XsltListViewWebPart" || wp.ToString() == "Microsoft.SharePoint.WebPartPages.ListViewWebPart")
                        {
                            wp.Visible = false;
                        }
                    }
                    catch { }
                }
            }

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            if (!bHasPeriods)
            {
                output.WriteLine("There are no periods setup for this TimeSheet. Please contact your system administrator");
                return;
            }

            output.WriteLine(@"<style>
                .GMBodyRight
                {
	                border-right: 1px solid #DDD!important;	
                }
                .GMBodyRight .GMCell
                {
	                border-left: 1px solid #DDD!important;
	                border-bottom: 1px solid #DDD!important;
                    overflow: visible;
                }

                .GMCellHeader, .GMCellHeaderPanel, .GMCell, .GMCellPanel
                {
                    border-bottom: 1px solid #DDD!important;
                }
                .Totals 
                {
                    font-weight: bold;
                }
                .GMFootRight
                {
                    border-left: 2px solid #ccc
                }
                .GMFootRight .GMCell
                {
	                border-left: 1px solid #DDD!important;
	                border-bottom: 1px solid #DDD!important;
                }
                .HideCol0StopWatch
                {
	                background-position: 0px center !important;
                }
                .TSBold 
                {
                    font-weight: bold !important;
                }
                .GMPx0xx 
                {
                background: none;
                opacity: 1;
                }
                #ddlFilterControl .caret {display:none;}
                </style>");

            string sUserId = "";

            if (!string.IsNullOrEmpty(Page.Request["Delegate"]))
            {
                SPUser user = TimesheetAPI.GetUser(SPContext.Current.Web, Page.Request["Delegate"]);
                sUserId = user.ID.ToString();
            }

            bCanEditViews = SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.ManageWeb);

            string url = SPContext.Current.Web.Url;

            if (url == "/")
            {
                url = "";
            }

            string curUrl = Page.Request.RawUrl.ToString();

            if (curUrl.Contains("?"))
            {
                curUrl = curUrl.Substring(0, curUrl.IndexOf("?") + 1);
            }

            foreach (string key in Page.Request.QueryString.AllKeys)
            {
                if (key.ToString().ToLower() != "newperiod" && key.ToString().ToLower() != "delegate")
                {
                    curUrl += key + "=" + Page.Request.QueryString[key] + "&";
                }
            }

            int counter = 0;

            bool IsDefaultAvailable = false;

            foreach (KeyValuePair <string, Dictionary <string, string> > key in views.Views)
            {
                try
                {
                    if (key.Value["Default"].ToLower() == "true")
                    {
                        sCurrentView       = key.Key;
                        sCurrentViewId     = "V" + counter;
                        IsDefaultAvailable = true;
                    }
                }
                catch { }
                counter++;
            }
            if (!IsDefaultAvailable)
            {
                counter = 0;
                foreach (KeyValuePair <string, Dictionary <string, string> > key in views.Views)
                {
                    try
                    {
                        sCurrentView   = key.Key;
                        sCurrentViewId = "V" + counter;
                    }
                    catch { }
                    counter++;
                }
            }

            curUrl = curUrl.Trim('&').Trim('?');
            System.Globalization.CultureInfo cInfo = new System.Globalization.CultureInfo(1033);
            IFormatProvider culture = new System.Globalization.CultureInfo(cInfo.Name, true);

            System.Globalization.CultureInfo nInfo = new System.Globalization.CultureInfo(SPContext.Current.Web.Locale.LCID);

            output.WriteLine(@"<script language=""javascript"">
                                    var TSObject" + sFullGridId + @" = new Object();
                                    TSObject" + sFullGridId + @".canSave = true;
                                    TSObject" + sFullGridId + @".id = '" + sFullGridId + @"';
                                    TSObject" + sFullGridId + @".Periods = '" + sPeriodList + @"';
                                    TSObject" + sFullGridId + @".PeriodName = '" + sPeriodName + @"';
                                    TSObject" + sFullGridId + @".PeriodId = " + sPeriodId + @";
                                    TSObject" + sFullGridId + @".UserId = '" + sUserId + @"';

                                    TSObject" + sFullGridId + @".DecimalSeparator='" + nInfo.NumberFormat.NumberDecimalSeparator + @"';
                                    TSObject" + sFullGridId + @".GroupSeparator='" + nInfo.NumberFormat.NumberGroupSeparator + @"';
            

                                    TSObject" + sFullGridId + @".IsCurPeriod = " + bIsCurrentTimesheetPeriod.ToString().ToLower() + @";
                                    TSObject" + sFullGridId + @".CurPeriodId = " + iCurPeriodId + @";
                                    TSObject" + sFullGridId + @".CurPeriodName = '" + sCurPeriodName + @"';

                                    TSObject" + sFullGridId + @".PreviousPeriod = " + iPreviousPeriod + @";
                                    TSObject" + sFullGridId + @".NextPeriod = " + iNextPeriod + @";

                                    TSObject" + sFullGridId + @".TSURL = '" + curUrl + @"';
                                    TSObject" + sFullGridId + @".Status = '" + sStatus + @"';
                                    TSObject" + sFullGridId + @".Locked = " + bTsLocked.ToString().ToLower() + @";
                                    TSObject" + sFullGridId + @".DisableApprovals = " + settings.DisableApprovals.ToString().ToLower() + @";
                                    TSObject" + sFullGridId + @".Delegates = '" + sDelegates.Replace("'", @"`") + @"';
                                    TSObject" + sFullGridId + @".DelegateId = '" + Page.Request["Delegate"] + @"';
                                    TSObject" + sFullGridId + @".Views = " + views.ToJSON() + @";
                                    TSObject" + sFullGridId + @".CurrentView = '" + sCurrentView + @"';
                                    TSObject" + sFullGridId + @".Qualifier = '" + Qualifier + @"';
                                    TSObject" + sFullGridId + @".CurrentViewId = '" + sCurrentViewId + @"';
                                    TSObject" + sFullGridId + @".CanEditViews = " + bCanEditViews.ToString().ToLower() + @";                                    

                                    TSColType = " + TSColType + @";
                                    TSNotes = " + TSNotes + @";
                                    TSTypeObject = " + TSTypeObject + @";
                                    TSCols = " + TSCols + @";
                                    TSDCols = " + TSDCols + @";
                                    siteId = '" + SPContext.Current.Web.ID + @"';
                                    siteUrl = '" + url + @"';
                                    siteColUrl = '" + (SPContext.Current.Site.ServerRelativeUrl == "/" ? "" : SPContext.Current.Site.ServerRelativeUrl) + @"';
                                    periodId = '" + sPeriodId + @"';
                                    GridType = '" + GridType + @"';

                                    curServerDate = (new Date()).getTime() - (new Date('" + DateTime.Now.ToString("MMMM dd, yyyy H:mm:ss", culture) + @"')).getTime();

                                    TGSetEvent('OnRenderFinish', 'TS" + sFullGridId + @"', TSRenderFinish);
                                    TGSetEvent('OnReady', 'TS" + sFullGridId + @"', TSReady);
                                    TGSetEvent('OnLoaded', 'TS" + sFullGridId + @"', TSOnLoaded);
                            </script>
                            ");


            //output.WriteLine(@"<div align=""center"" id=""TSLoader" + sFullGridId + @""" width=""100%""><img style=""vertical-align:middle;"" src=""/_layouts/images/gears_anv4.gif""/>&nbsp;Loading Items...</div>");

            StringBuilder sb = new StringBuilder("<select class=\"form-control\" onchange=\"changePeriodCommand('" + curUrl + "',this,'" + Page.Request["Delegate"] + "')\">");

            var arrPeriods = sPeriodList.Split(',');

            for (var i = 0; i < arrPeriods.Length; i++)
            {
                var arrPeriod = arrPeriods[i].Split('|');
                if (arrPeriod[1] != sPeriodName)
                {
                    sb.Append("<option value=" + arrPeriod[0] + ">" + arrPeriod[1] + "</option>");
                }
                else
                {
                    sb.Append("<option value=" + arrPeriod[0] + " selected>" + arrPeriod[1] + "</option>");
                }
            }
            sb.Append("</select>");

            var str = new HtmlString(sb.ToString());



            if (GridType == 0)
            {
                output.WriteLine(@"
                <div id=""tsnav"" style=""display:none"">
                    <nav class=""navbar navbar-default navbar-static"" role=""navigation"">
                        <div>
                            <div class=""collapse navbar-collapse"">
                                <ul class=""nav navbar-nav"" class=""ts-nav-list"">
                                    <li class=""nav-btn nav-text-wrapper"" style=""float:left;padding-right:20px;padding: 0px"">
                                        <div class=""nav-label"">Status:</div>
                                            <div class=""text"" id=""mytimesheetstatus"">" + sStatus + @"</div>
                                    </li>
                                    <li class=""nav-btn nav-text-wrapper"" style=""padding: 0px; float:left"">
                                        <div class=""nav-label"">Current Period:
                                        </div>");
                if (iPreviousPeriod != 0)
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-left-17 icon"" onclick=""javascript:previousPeriodCommand('" + curUrl + "','" + iPreviousPeriod + "','" + Page.Request["Delegate"] + @"')""></span>                
                ");
                }
                else
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-left-17 icon disabled""></span>                
                ");
                }

                output.WriteLine(@"<div class=""nav-select"">" + str.ToHtmlString() + @" </div>");


                if (iNextPeriod != 0)
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-right-17 icon"" onclick=""javascript:nextPeriodCommand('" + curUrl + "','" + iNextPeriod + "','" + Page.Request["Delegate"] + @"')""></span>                
                ");
                }
                else
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-right-17 icon disabled""></span>                
                ");
                }
                output.WriteLine(@"</li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </div>");
                output.Write("<div style=\"height:300px;width:100%;overflow:hidden;display:inline-block\" id=\"gridouter\">");
                output.WriteLine("<div style=\"width:100%;height:100%\">");
                output.WriteLine(@"<treegrid Data_Url=""" + url + @"/_vti_bin/WorkEngine.asmx"" Data_Timeout=""0"" Data_Method=""Soap"" Data_Function=""Execute"" Data_Namespace=""workengine.com"" Data_Param_Function=""timesheet_GetTimesheetGrid"" Data_Param_Dataxml=""" + sDataParam + @""" 
                                Layout_Url=""" + url + @"/_vti_bin/WorkEngine.asmx"" Layout_Timeout=""0"" Layout_Method=""Soap"" Layout_Function=""Execute"" Layout_Namespace=""workengine.com"" Layout_Param_Function=""timesheet_GetTimesheetGridLayout"" Layout_Param_Dataxml=""" + sLayoutParam + @""" 
                                Check_Url=""" + url + @"/_vti_bin/WorkEngine.asmx"" Check_Timeout=""0"" Check_Method=""Soap"" Check_Function=""Execute"" Check_Namespace=""workengine.com"" Check_Param_Function=""timesheet_GetTimesheetUpdates"" Check_Param_Dataxml=""" + sLayoutParam + @""" Check_Interval=""0"" Check_Repeat=""0""
                                Upload_Url=""" + url + @"/_layouts/epmlive/savemytimesheet.aspx" + (Page.Request["Delegate"] != null? "?Delegate=" + Page.Request["Delegate"]:"") + @""" Upload_Type=""Body,Cfg"" Upload_Flags=""AllCols,Accepted"" Debug="""" SuppressMessage=""3""></treegrid>");
                output.WriteLine("</div>");
                output.WriteLine("</div>");
            }
            else if (GridType == 1)
            {
                RenderApprovalToolbar(output);

                output.WriteLine(@"
                <div id=""tsnav"" style=""display:none"">
                    <nav class=""navbar navbar-default navbar-static"" role=""navigation"">
                        <div>
                            <div class=""collapse navbar-collapse"">
                                <ul class=""nav navbar-nav"" style=""list-style-type: none;padding-top: 10px; margin:0px;padding: 0px; "">
                                    <li class=""nav-btn nav-text-wrapper"" style=""float:left;padding: 0px; "">
                                        <div class=""nav-label"">Current Period:
                                        </div>");
                if (iPreviousPeriod != 0)
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-left-17 icon"" onclick=""javascript:previousPeriodCommand('" + curUrl + "','" + iPreviousPeriod + "','" + Page.Request["Delegate"] + @"')""></span>                
                ");
                }
                else
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-left-17 icon disabled""></span>                
                ");
                }

                output.WriteLine(@"<div class=""nav-select"">" + str.ToHtmlString() + @" </div>");


                if (iNextPeriod != 0)
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-right-17 icon"" onclick=""javascript:nextPeriodCommand('" + curUrl + "','" + iNextPeriod + "','" + Page.Request["Delegate"] + @"')""></span>                
                ");
                }
                else
                {
                    output.WriteLine(@"
                <span class=""icon-arrow-right-17 icon disabled""></span>                
                ");
                }
                output.WriteLine(@"</li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </div>");
                output.Write("<div style=\"height:300px;width:100%;overflow:hidden;display:inline-block\" id=\"gridouter\">");
                output.WriteLine("<div style=\"width:100%;height:100%\">");
                output.WriteLine(@"<treegrid Data_Url=""" + url + @"/_vti_bin/WorkEngine.asmx"" Data_Timeout=""0"" Data_Method=""Soap"" Data_Function=""Execute"" Data_Namespace=""workengine.com"" Data_Param_Function=""timesheet_GetTimesheetApprovalsGrid"" Data_Param_Dataxml=""" + sDataParam + @""" 
                                Layout_Url=""" + url + @"/_vti_bin/WorkEngine.asmx"" Layout_Timeout=""0"" Layout_Method=""Soap"" Layout_Function=""Execute"" Layout_Namespace=""workengine.com"" Layout_Param_Function=""timesheet_GetTimesheetGridLayout"" Layout_Param_Dataxml=""" + sLayoutParam + @""" 
                                Page_Url=""" + url + @"/_layouts/15/epmlive/timesheetapprovalpage.aspx?Period=" + sPeriodId + @""" SuppressMessage=""3""
                                 ></treegrid>");
                output.WriteLine("</div>");
                output.WriteLine("</div>");
            }



            output.WriteLine(@"<div align=""center"" id=""divMessage" + sFullGridId + @""" width=""100%"" class=""dialog""><img style=""vertical-align:middle;"" src=""/_layouts/images/gears_anv4.gif""/>&nbsp;<span id=""spnMessage" + sFullGridId + @""">Saving Timesheet...</span></div>");

            output.Write("<div id='NotesDiv' style='z-index:999;position: absolute; margin-left: 65px; display:none; width:150px;height:110px;border: 1px solid #666;background-color:#FFFFFF;cursor:pointer' onClick='stopProp(event);'><textarea id='txtNotes' style='z-index:999;width:140px;height:60px;border:0px;margin-bottom:5px;resize: none; outline: 0;' onkeyup='stopProp(event);' onclick='stopProp(event);' onkeypress='stopProp(event);'");
            if (bTsLocked)
            {
                output.Write(" disabled='disabled'");
            }

            output.Write("></textarea><br><input type=\"button\" value=\"OK\" onCLick=\"SaveNotes(event);stopProp(event);\" style=\"float:right\"></div>");

            output.WriteLine(@"<div id=""viewNameDiv"" style=""display:none;width:200;padding:10px"">

                View Name:<br />
                <input type=""text"" class=""ms-input"" name=""viewname"" id=""viewname""/><br /><br />
                <div><input type=""checkbox"" name=""chkViewDefault"" id=""chkViewDefault"" /> Default View </div><br /><br />
                <input type=""button"" value=""OK"" onclick=""validate()"" class=""ms-ButtonHeightWidth"" style=""width:100px"" target=""_self"" /> &nbsp;

               <input type=""button"" value=""Cancel"" onclick=""SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancel clicked'); return false;"" class=""ms-ButtonHeightWidth"" style=""width:100px"" target=""_self"" />  
    
            </div>");


            output.WriteLine(@"<script language=""javascript"">");

            output.WriteLine("function LoadTSGrid" + sFullGridId + "(){ LoadTSGrid('" + sFullGridId + "');}");

            output.WriteLine("SP.SOD.executeOrDelayUntilScriptLoaded(LoadTSGrid" + sFullGridId + ", 'EPMLive.js');");

            output.WriteLine("initmb();");

            output.WriteLine("function clickTab(){");
            output.WriteLine("SelectRibbonTab('Ribbon.MyTimesheetTab', true);");
            //output.WriteLine("var wp = document.getElementById('MSOZoneCell_WebPart" + this.Qualifier + "');");
            //output.WriteLine("fireEvent(wp, 'mouseup');");
            output.WriteLine("}");

            output.WriteLine("function validate(){");
            output.WriteLine("if(document.getElementById('viewname').value.replace(/^\\s+|\\s+$/, '') == ''){");
            output.WriteLine("alert('Please enter a view name - view names cannot be blank.')");
            output.WriteLine("return false;");
            output.WriteLine("}");
            output.WriteLine("else{");
            output.WriteLine("SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, document.getElementById('viewname').value + '|' + document.getElementById('chkViewDefault').checked); return false;");
            output.WriteLine("}");
            output.WriteLine("}");

            //output.Write("SP.SOD.executeOrDelayUntilScriptLoaded(clickTab, \"MyTimesheetContextualTabPageComponent.js\");");
            output.WriteLine(@"var viewNameDiv = document.getElementById(""viewNameDiv"");");
            output.WriteLine("</script>");

            tb.StopTimer();
            tb.WriteTimers(output);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            EPMLiveCore.Act act = new EPMLiveCore.Act(SPContext.Current.Web);

            int activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                pnlMain.Visible = false;
                pnlAct.Visible  = true;
                lblAct.Text     = act.translateStatus(activation);
                return;
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            try
            {
                string sLists = "";
                using (currWeb = SPContext.Current.Web)
                {
                    if (currWeb.CurrentUser.IsSiteAdmin)
                    {
                        sSiteUrl = (currWeb.ServerRelativeUrl == "/") ? "" : currWeb.ServerRelativeUrl;
                        siteid   = currWeb.Site.ID.ToString();
                        webid    = currWeb.ID.ToString();
                        //if (!IsPostBack)
                        {
                            SPSecurity.RunWithElevatedPrivileges(delegate()
                            {
                                if (currWeb.Properties.ContainsKey("EPMLiveSynchLists"))
                                {
                                    sLists = currWeb.Properties["EPMLiveSynchLists"];
                                }
                            });

                            ddlLists.Items.Clear();
                            foreach (SPList lst in currWeb.Lists)
                            {
                                if (!lst.Hidden)
                                {
                                    ListItem li = new ListItem(lst.Title, lst.ID.ToString());
                                    if (!sLists.Contains(lst.ID.ToString()))
                                    {
                                        ddlLists.Items.Add(li);
                                    }
                                }
                            }

                            SPList liTemplate = currWeb.Lists.TryGetList("Template Gallery");
                            if (liTemplate != null)
                            {
                                pnlTemplates.Visible = false;
                            }

                            if (Request["TrnxType"] != null && Request["TrnxType"].ToString() == "clear")
                            {
                                // clear Template ID property
                                currWeb.AllowUnsafeUpdates = true;

                                currWeb.Properties["EPMLiveTemplateID"] = ""; // clear
                                currWeb.Properties.Update();

                                currWeb.AllowUnsafeUpdates = false;

                                Response.Redirect(currWeb.Url + "/_layouts/epmlive/setsitetemplate.aspx");
                            }
                            else if (Request["TrnxType"] != null && Request["TrnxType"].ToString() == "set")
                            {
                                if (Request["TemplateID"] != null && Request["TemplateID"].ToString().Trim() != "")
                                {
                                    // update Template ID property
                                    currWeb.AllowUnsafeUpdates = true;

                                    currWeb.Properties["EPMLiveTemplateID"] = Request["TemplateID"].ToString(); // overwrite with new ID
                                    currWeb.Properties.Update();

                                    currWeb.AllowUnsafeUpdates = false;

                                    Response.Redirect(currWeb.Url + "/_layouts/epmlive/setsitetemplate.aspx");
                                }
                            }
                            else if (Request["TrnxType"] != null && Request["TrnxType"].ToString() == "add")
                            {
                                if (Request["List"] != null && Request["List"].ToString().Trim().Length != 0)
                                {
                                    AddList(Request["List"].ToString());
                                    Response.Redirect(currWeb.Url + "/_layouts/epmlive/templates.aspx");
                                }
                                else if (Request["TemplateID"] != null && Request["TemplateID"].ToString().Trim() != "")
                                {
                                    using (SPSite site = SPContext.Current.Site)
                                    {
                                        // add Template ID property
                                        Guid webGUID = new Guid(Request["TemplateID"].ToString());
                                        using (SPWeb oSelectedWeb = site.AllWebs[webGUID])
                                        {
                                            if (currWeb.ID != oSelectedWeb.ID)
                                            {
                                                oSelectedWeb.AllowUnsafeUpdates = true;

                                                string sGUID = System.Guid.NewGuid().ToString();
                                                if (!oSelectedWeb.Properties.ContainsKey("EPMLiveTemplateID"))
                                                {
                                                    oSelectedWeb.Properties.Add("EPMLiveTemplateID", sGUID);
                                                }
                                                else
                                                {
                                                    oSelectedWeb.Properties["EPMLiveTemplateID"] = sGUID;
                                                }
                                                oSelectedWeb.Properties.Update();

                                                using (SPWeb rootWeb = site.RootWeb)
                                                {
                                                    AddAsSynchedTemplate(rootWeb, Request["TemplateID"].ToString());
                                                }

                                                //SPFeature oFT = null;
                                                //try
                                                //{
                                                //    oFT = oSelectedWeb.Features[new Guid("dfb82bdd-a86c-4314-a0f2-654526c7814e")];
                                                //}
                                                //catch { }
                                                //if (oFT == null)
                                                //{
                                                //    try
                                                //    {
                                                //        oSelectedWeb.Features.Add(new Guid("dfb82bdd-a86c-4314-a0f2-654526c7814e"));
                                                //    }
                                                //    catch { }
                                                //}

                                                oSelectedWeb.AllowUnsafeUpdates = false;
                                            }
                                        }
                                    }

                                    Response.Redirect(currWeb.Url + "/_layouts/epmlive/templates.aspx");
                                }
                            }
                            else if (Request["TrnxType"] != null && Request["TrnxType"].ToString() == "delete")
                            {
                                if (Request["List"] != null && Request["List"].ToString().Trim() != "")
                                {
                                    SPSecurity.RunWithElevatedPrivileges(delegate()
                                    {
                                        DeleteList("|" + Request["List"].ToString());
                                    });
                                }
                                else if (Request["Template"] != null && Request["Template"].ToString().Trim() != "")
                                {
                                    SPSecurity.RunWithElevatedPrivileges(delegate()
                                    {
                                        RemoveTemplate(Request["Template"].ToString());
                                    });
                                }
                                Response.Redirect(currWeb.Url + "/_layouts/epmlive/templates.aspx");
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect(currWeb.Url + "/_layouts/AccessDenied.aspx");
                    }

                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        loadListGrid(sLists, currWeb.Site);
                        loadTemplateListBox();
                    });
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            if (PropList != "" && PropView != "" && PropStatus != "")
            {
                try
                {
                    getData();
                    SPWeb   web   = SPContext.Current.Web;
                    SPList  list  = web.GetListFromUrl(PropList);
                    SPField field = list.Fields.GetFieldByInternalName(PropStatus);

                    output.Write("<table border=\"0\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\">");

                    foreach (string status in slStatus.Keys)
                    {
                        int val     = slStatus[status];
                        int percent = 0;
                        if (totalItems > 0)
                        {
                            percent = val * 100 / totalItems;
                        }
                        output.Write("<tr><td class=\"ms-formbody\" width=\"180px\" style=\"vertical-align:middle\">");

                        string fstatus = "";
                        try
                        {
                            fstatus = field.GetFieldValueAsText(status);
                        }
                        catch { }

                        if (PropUrl != null && PropUrl != "")
                        {
                            if (SPContext.Current.Web.ServerRelativeUrl == "/")
                            {
                                output.Write("<a href=\"" + PropUrl.Replace("{SiteUrl}", "") + "?filterfield1=" + PropStatus + "&filtervalue1=" + fstatus + "\">");
                            }
                            else
                            {
                                output.Write("<a href=\"" + PropUrl.Replace("{SiteUrl}", SPContext.Current.Web.ServerRelativeUrl) + "?filterfield1=" + PropStatus + "&filtervalue1=" + fstatus + "\">");
                            }
                        }

                        output.Write(fstatus);

                        if (PropUrl != "")
                        {
                            output.Write("</a>");
                        }

                        output.Write(": " + val.ToString() + " ( " + (percent).ToString() + "% ) </td>");
                        output.Write("<td><table width=\"100%\"><tr><td width=\"" + (percent).ToString() + "%\" height=\"15px\" style=\"background-color: rgb(0, 144, 202)\"></td><td width=\"100%\"></td></tr></table></td></tr>");
                    }

                    output.Write("</tr></table>");
                }
                catch (Exception ex)
                {
                    output.Write("Error: " + ex.Message);
                }
            }

            output.Write(sErrors);
        }
Example #9
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite s = new SPSite(SPContext.Current.Site.ID))
                {
                    try
                    {
                        string dbCon = s.ContentDatabase.DatabaseConnectionString;
                        cn           = new SqlConnection(dbCon);
                        cn.Open();
                    }
                    catch { }
                }
            });

            arrSites = new SortedList();

            bool dupsFound = false;

            web = SPContext.Current.Web;



            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(MyXml);
                foreach (XmlNode nSections in doc.SelectSingleNode("Sections").SelectNodes("Section"))
                {
                    foreach (XmlNode nItem in nSections.SelectSingleNode("Items").SelectNodes("Item"))
                    {
                        string id = "";
                        try
                        {
                            id = nItem.Attributes["ID"].Value;
                        }
                        catch { }
                        if (id != "")
                        {
                            if (!hshNodes.Contains(id))
                            {
                                hshNodes.Add(id, nItem);
                                hshCounts.Add(id, 0);
                            }
                            else
                            {
                                dupsFound = true;
                            }
                        }
                    }
                }

                if (strRollupSites == null || strRollupSites.Length <= 0)
                {
                    processWeb(web);
                }
                else
                {
                    foreach (string strRollupSite in strRollupSites.Split('\n'))
                    {
                        //SPSecurity.RunWithElevatedPrivileges(delegate()
                        //{
                        try
                        {
                            if (web.Url.ToLower() == strRollupSite.ToLower())
                            {
                                processWeb(web);
                            }
                            else
                            {
                                using (SPSite procSite = new SPSite(strRollupSite))
                                {
                                    using (SPWeb ww = procSite.OpenWeb())
                                    {
                                        processWeb(ww);
                                    }
                                }
                            }
                        }
                        catch { }
                        //});
                    }
                }
                //string curSite = "";
                //SPSite site = null;
                //SPWeb procWeb = null;
                //foreach(DictionaryEntry de in arrSites)
                //{
                //    if (curSite != de.Value.ToString())
                //    {
                //        if (site != null)
                //            site.Close();
                //        site = new SPSite(de.Key.ToString());
                //        curSite = de.Key.ToString();
                //    }

                //    string sWeb = de.Key.ToString().Replace(de.Value.ToString(), "");
                //    if (sWeb == "")
                //        procWeb = site.RootWeb;
                //    else
                //        procWeb = site.OpenWeb(sWeb.Substring(1));
                //    processWeb(procWeb);
                //    procWeb.Close();
                //    if (site != null)
                //        site.Close();
                //}

                foreach (XmlNode n in doc.SelectSingleNode("Sections"))
                {
                    processSection(n);
                }
                cn.Close();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("Root element is missing") > -1 || ex.Message.IndexOf("Value cannot be null") > -1)
                {
                    output.Write("This webpart XML is Missing.");
                }
                else
                {
                    output.Write("Failed to load XML: " + ex.Message);
                }
                return;
            }
            if (dupsFound)
            {
                output.Write("Warning: Duplicate Item ID's Found");
            }

            output.Write("<table cellpadding=\"1\" cellspacing=\"1\" style=\"margin:10px;\" class=\"ms-stdtxt\">");
            output.Write(sb.ToString());
            output.Write("</table>");
        }
Example #10
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            output.Write(error);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            output.Write("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\">");

            SPWeb web = SPContext.Current.Web;

            string resUrl = EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveResourceURL", true, false);

            if (resUrl != "")
            {
                SPWeb resWeb = null;
                try
                {
                    if (resUrl.ToLower() != web.Url.ToLower())
                    {
                        using (SPSite tempSite = new SPSite(resUrl))
                        {
                            resWeb = tempSite.OpenWeb();
                            if (resWeb.Url.ToLower() != resUrl.ToLower())
                            {
                                resWeb = null;
                            }
                        }
                    }
                    else
                    {
                        resWeb = web;
                    }
                }
                catch { }

                if (resWeb != null)
                {
                    try
                    {
                        SPList list = resWeb.Lists["Resources"];

                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='TimesheetManager'/><Value Type='User'><UserID/></Value></Eq></Where>";

                        SPListItemCollection lic = list.GetItems(query);

                        bool hasReports = false;

                        if (lic.Count > 0)
                        {
                            hasReports = true;
                            output.Write("<tr><td><img src=\"/_layouts/images/XLS16.GIF\"></td><td><a href=\"#\" onclick=\"window.open('" + web.Url + "/_layouts/epmlive/gettsreport.aspx?report=1','', config='height=270,width=340, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');\">Timesheet Manager Report</a></td></tr>");
                        }

                        query       = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='SharePointAccount'/><Value Type='User'><UserID/></Value></Eq></Where>";

                        lic = list.GetItems(query);

                        if (lic.Count > 0)
                        {
                            try
                            {
                                if (lic[0]["TimesheetAdministrator"].ToString().ToLower() == "true")
                                {
                                    hasReports = true;
                                    output.Write("<tr><td><img src=\"/_layouts/images/XLS16.GIF\"></td><td><a href=\"#\" onclick=\"window.open('" + web.Url + "/_layouts/epmlive/gettsreport.aspx?report=2','', config='height=270,width=340, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');\">Administrative Report</a></td></tr>");
                                }
                            }
                            catch { }
                        }

                        query       = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='SharePointAccount'/><Value Type='User'><UserID/></Value></Eq></Where>";

                        lic = list.GetItems(query);

                        if (lic.Count > 0)
                        {
                            try
                            {
                                hasReports = true;
                                output.Write("<tr><td><img src=\"/_layouts/images/XLS16.GIF\"></td><td><a href=\"#\" onclick=\"window.open('" + web.Url + "/_layouts/epmlive/gettsreport.aspx?report=3','', config='height=270,width=340, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');\">My Timesheet Report</a></td></tr>");
                            }
                            catch { }
                        }

                        if (!hasReports)
                        {
                            output.Write("<tr><td>No Available Reports.</td></tr>");
                        }
                    }
                    catch (Exception ex1)
                    {
                        output.Write("<tr><td>Error: + " + ex1.Message + "</td></tr>");
                    }
                    if (resWeb.ID != SPContext.Current.Web.ID)
                    {
                        resWeb.Close();
                    }
                }
                else
                {
                    output.Write("<tr><td>Failed to open Resource Pool.</td></tr>");
                }
            }
            else
            {
                output.Write("<tr><td>Resource Pool Not Configured.</td></tr>");
            }
            output.Write("</table>");
        }