Ejemplo n.º 1
0
        protected override void OnInit(EventArgs e)
        {
            act        = new EPMLiveCore.Act(Web);
            activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.Timesheets);

            if (activation != 0)
            {
                return;
            }

            base.OnInit(e);

            _listId     = new Guid(Request.QueryString["ListId"]);
            _listItemId = int.Parse(Request.QueryString["ItemId"]);

            ConfigureControls();

            if (!IsPostBack)
            {
                var web = SPContext.Current.Web;
                TSItem.PopulateDDLUsers(ddlUsers, web, web.CurrentUser);
                if (ddlUsers.Items.Count > 1)
                {
                    pnlUsers.Visible = true;
                }
                else
                {
                    pnlUsers.Visible = false;
                }
            }
        }
        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.buildData2();

            if (ret != "")
            {
                output.Write("Error: " + ret);
            }
            else
            {
                pjData.gvPJSummary2.RenderControl(output);
            }
        }
Ejemplo n.º 3
0
        protected override void CreateChildControls()
        {
            act        = new EPMLiveCore.Act(SPContext.Current.Web);
            activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                return;
            }

            base.CreateChildControls();

            // TODO: add custom rendering code here.
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
0
        protected override void CreateChildControls()
        {
            buildParams();

            if (SPContext.Current.ViewContext.View != null)
            {
                try
                {
                    typeof(ListTitleViewSelectorMenu).GetField("m_wpSingleInit", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true);
                }
                catch { }
                try
                {
                    typeof(ListTitleViewSelectorMenu).GetField("m_wpSingle", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true);
                }
                catch { }
            }

            EnsureChildControls();

            EPMLiveCore.Act act = new EPMLiveCore.Act(web);
            activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);
            if (activation != 0)
            {
                return;
            }

            try
            {
                toolbar = new ViewToolBar();
                toolbar.EnableViewState = false;

                list = SPContext.Current.List;
                view = SPContext.Current.ViewContext.View;

                SPContext context = SPContext.GetContext(this.Context, view.ID, list.ID, web);
                toolbar.RenderContext = context;

                Controls.Add(toolbar);
            }
            catch { }
        }
Ejemplo n.º 7
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>");
            }
        }
Ejemplo n.º 8
0
        protected override void CreateChildControls()
        {
            try
            {
                act        = new EPMLiveCore.Act(SPContext.Current.Web);
                activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.Timesheets);
                if (activation != 0)
                {
                    return;
                }

                base.CreateChildControls();

                // TODO: add custom rendering code here.
                // Label label = new Label();
                // label.Text = "Hello World";
                // this.Controls.Add(label);
            }
            catch (Exception ex)
            {
                error = "Error Creating Controls: " + ex.Message;
            }
        }
Ejemplo n.º 9
0
        protected override void CreateChildControls()
        {
            tb.AddTimer();
            act        = new EPMLiveCore.Act(SPContext.Current.Web);
            activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.Timesheets);

            if (activation != 0)
            {
                return;
            }

            if (SPContext.Current.ViewContext.View != null)
            {
                try
                {
                    typeof(ListTitleViewSelectorMenu).GetField("m_wpSingleInit", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true);
                }
                catch { }
                try
                {
                    typeof(ListTitleViewSelectorMenu).GetField("m_wpSingle", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true);
                }
                catch { }
            }

            try
            {
                sPeriodId = Page.Request["NewPeriod"].ToString();
            }
            catch { }
            try
            {
                sUserId = Page.Request["Delegate"].ToString();
            }
            catch { }

            ///

            SPWeb web = SPContext.Current.Web;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                settings = new TimesheetSettings(web);

                SqlConnection cn = new SqlConnection(EPMLiveCore.CoreFunctions.getConnectionString(web.Site.WebApplication.Id));
                cn.Open();

                SqlCommand cmd  = new SqlCommand("spTSGetPeriodsForSite", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@siteid", web.Site.ID);

                DataSet ds = new DataSet();

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                DataTable dtPeriods = ds.Tables[0];

                DataRow[] drCur = dtPeriods.Select("CurPeriod='1'");
                if (drCur.Length > 0)
                {
                    iCurPeriodId   = int.Parse(drCur[0]["period_id"].ToString());
                    sCurPeriodName = ((DateTime)drCur[0]["period_start"]).ToShortDateString() + " - " + ((DateTime)drCur[0]["period_end"]).ToShortDateString();
                }
                if (dtPeriods.Rows.Count > 0)
                {
                    if (sPeriodId == "")
                    {
                        DataRow[] dr = dtPeriods.Select("CurPeriod='1'");
                        if (dr.Length > 0)
                        {
                            sPeriodId   = dr[0]["period_id"].ToString();
                            sPeriodName = ((DateTime)dr[0]["period_start"]).ToShortDateString() + " - " + ((DateTime)dr[0]["period_end"]).ToShortDateString();
                            bIsCurrentTimesheetPeriod = true;
                        }
                        else
                        {
                            sPeriodId   = dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_id"].ToString();
                            sPeriodName = ((DateTime)dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_start"]).ToShortDateString() + " - " + ((DateTime)dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_end"]).ToShortDateString();
                        }
                    }
                    else
                    {
                        DataRow[] dr = ds.Tables[0].Select("period_id='" + sPeriodId + "'");
                        if (dr.Length > 0)
                        {
                            sPeriodName = ((DateTime)dr[0]["period_start"]).ToShortDateString() + " - " + ((DateTime)dr[0]["period_end"]).ToShortDateString();
                            try
                            {
                                if (dr[0]["curPeriod"].ToString() == "1")
                                {
                                    bIsCurrentTimesheetPeriod = true;
                                }
                            }
                            catch { }
                        }
                        else
                        {
                            DataRow[] dr2 = ds.Tables[0].Select("CurPeriod='1'");
                            if (dr2.Length > 0)
                            {
                                sPeriodId   = dr2[0]["period_id"].ToString();
                                sPeriodName = ((DateTime)dr2[0]["period_start"]).ToShortDateString() + " - " + ((DateTime)dr2[0]["period_end"]).ToShortDateString();
                                bIsCurrentTimesheetPeriod = true;
                            }
                            else
                            {
                                sPeriodId   = dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_id"].ToString();
                                sPeriodName = ((DateTime)dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_start"]).ToShortDateString() + " - " + ((DateTime)dtPeriods.Rows[dtPeriods.Rows.Count - 1]["period_end"]).ToShortDateString();
                            }
                        }
                    }

                    string itmpprev = "";
                    bool bNext      = false;

                    foreach (DataRow dr in dtPeriods.Rows)
                    {
                        sPeriodList += "," + dr["period_id"].ToString() + "|" + ((DateTime)dr["period_start"]).ToShortDateString() + " - " + ((DateTime)dr["period_end"]).ToShortDateString();

                        if (bNext)
                        {
                            bNext = false;

                            iNextPeriod = int.Parse(dr["period_id"].ToString());
                        }

                        if (dr["period_id"].ToString() == sPeriodId)
                        {
                            if (itmpprev != "")
                            {
                                iPreviousPeriod = int.Parse(itmpprev);
                            }
                            bNext = true;
                        }

                        itmpprev = dr["period_id"].ToString();
                    }

                    sPeriodList = sPeriodList.Trim(',');

                    TSNotes = settings.AllowNotes.ToString().ToLower();


                    cmd = new SqlCommand("SELECT TSTYPE_ID, TSTYPE_NAME FROM TSTYPE where SITE_UID=@siteid", cn);
                    cmd.Parameters.AddWithValue("@siteid", web.Site.ID);

                    SqlDataReader drTypes = cmd.ExecuteReader();
                    while (drTypes.Read())
                    {
                        int id = drTypes.GetInt32(0);

                        TSColType = 2;

                        TSTypeObject += ",T" + id + ": '" + drTypes.GetString(1) + "'";
                    }
                    drTypes.Close();


                    TSTypeObject = "{" + TSTypeObject.Trim(',') + "}";

                    ArrayList arrPeriods = TimesheetAPI.GetPeriodDaysArray(cn, settings, web, sPeriodId);

                    foreach (DateTime dtStart in arrPeriods)
                    {
                        TSCols += "\"P" + dtStart.Ticks + "\": true,";
                    }

                    foreach (DateTime dtStart in arrPeriods)
                    {
                        TSDCols += "\"P" + dtStart.Ticks + "\": \"" + settings.DayDef.Split('|')[(int)dtStart.DayOfWeek * 3 + 1] + "|" + settings.DayDef.Split('|')[(int)dtStart.DayOfWeek * 3 + 2] + "\",";
                    }

                    TSCols  = "{" + TSCols.Trim(',') + "}";
                    TSDCols = "{" + TSDCols.Trim(',') + "}";

                    if (GridType == 0)
                    {
                        SPUser user = TimesheetAPI.GetUser(web, sUserId);

                        cmd = new SqlCommand("SELECT submitted, approval_status, locked FROM TSTIMESHEET where SITE_UID=@siteid and period_id=@period and username=@username", cn);
                        cmd.Parameters.AddWithValue("@siteid", web.Site.ID);
                        cmd.Parameters.AddWithValue("@period", sPeriodId);
                        cmd.Parameters.AddWithValue("@username", user.LoginName);

                        SqlDataReader drTS = cmd.ExecuteReader();
                        if (drTS.Read())
                        {
                            //Locked
                            if (drTS.GetBoolean(2))
                            {
                                bTsLocked = true;
                            }

                            //Submitted
                            if (drTS.GetBoolean(0))
                            {
                                if (drTS.GetInt32(1) == 1)
                                {
                                    sStatus = "Approved";
                                    if (!settings.DisableApprovals)
                                    {
                                        bTsLocked = true;
                                    }
                                }
                                else if (drTS.GetInt32(1) == 2)
                                {
                                    sStatus = "Rejected";
                                }
                                else
                                {
                                    sStatus = "Submitted";
                                }
                            }
                        }
                        drTS.Close();
                    }
                    else
                    {
                        bTsLocked = true;
                    }


                    cn.Close();

                    bHasPeriods = true;
                }
            });



            sDataParam   = "<Param GridId=\"" + sFullGridId + "\" Period=\"" + sPeriodId + "\" UserId=\"" + sUserId + "\"/>";
            sLayoutParam = "<Param GridId=\"" + sFullGridId + "\" Period=\"" + sPeriodId + "\" UserId=\"" + sUserId + "\" Editable=\"" + iEditable + "\" GridType=\"" + GridType + "\"/>";

            sDataParam   = System.Web.HttpUtility.HtmlEncode(System.Web.HttpUtility.HtmlEncode(sDataParam));
            sLayoutParam = System.Web.HttpUtility.HtmlEncode(System.Web.HttpUtility.HtmlEncode(sLayoutParam));
            ///


            DataTable dtTsDelegates = EPMLiveCore.API.APITeam.GetResourcePool("<Resources FilterField=\"TimesheetDelegates\" FilterFieldValue=\"" + web.CurrentUser.Name + "\" ><Columns>SimpleColumns</Columns></Resources>", web);

            foreach (DataRow dr in dtTsDelegates.Rows)
            {
                if (sUserId == dr["SPID"].ToString())
                {
                    sCurrentDelegate = dr["Title"].ToString();
                }

                sDelegates += dr["SPID"].ToString() + "|" + dr["Title"].ToString() + "^";
            }

            sDelegates = sDelegates.Trim('^');

            string serviceUrl = ((SPContext.Current.Web.ServerRelativeUrl == "/")
                                     ? ""
                                     : SPContext.Current.Web.ServerRelativeUrl) + "/_vti_bin/Workengine.asmx";

            ScriptManager scriptManager = ScriptManager.GetCurrent(Page);

            if (scriptManager != null)
            {
                scriptManager.Services.Add(new ServiceReference(serviceUrl));
            }
            else
            {
                scriptManager = new ScriptManager();
                scriptManager.Services.Add(new ServiceReference(serviceUrl));

                Page.Form.Controls.Add(scriptManager);
            }

            views = TimesheetAPI.GetViews(web);

            tb.StopTimer();
        }
Ejemplo n.º 10
0
        protected override void CreateChildControls()
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                return;
            }

            try
            {
                site = Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(Context);

                base.CreateChildControls();

                ddlProject = new DropDownList();
                ddlProject.Items.Add(new ListItem("All Projects", ""));
                ddlProject.SelectedIndexChanged += new EventHandler(ddlProject_SelectedIndexChanged);
                ddlProject.AutoPostBack          = true;
                Controls.Add(ddlProject);

                ddl = new DropDownList();

                try
                {
                    SPList  list  = site.Lists["Project Center"];
                    SPField field = list.Fields.GetFieldByInternalName(MyState);
                    strStateField = field.Title;
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(field.SchemaXml);

                    string defaultSelect = "";
                    try
                    {
                        defaultSelect = doc.SelectSingleNode("//Default").InnerText;
                    }
                    catch { }
                    try
                    {
                        XmlNode ndChoices = doc.SelectSingleNode("//CHOICES");
                        foreach (XmlNode nd in ndChoices.ChildNodes)
                        {
                            ddl.Items.Add(nd.InnerText);
                        }
                    }
                    catch { }

                    ddl.Text = defaultSelect;
                }
                catch (Exception ex)
                {
                    sError = "ERROR: " + ex.Message + "<br>";
                }

                ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
                ddl.AutoPostBack          = true;

                popProject(ddl.SelectedItem.Text);

                Controls.Add(ddl);
                //ddl_SelectedIndexChanged(this, EventArgs.Empty);
            }
            catch (Exception ex)
            {
                sError = sError + "ERROR: " + ex.Message + "<br>";
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.Timesheets);

            if (activation != 0)
            {
                pnlActivation.Visible = true;
                pnlTs.Visible         = false;
            }

            try
            {
                SPWeb web = SPContext.Current.Web;
                {
                    weburl = web.Url;
                    if (!SPContext.Current.Web.UserIsSiteAdmin)
                    {
                        Response.Redirect(SPContext.Current.Web.Url + "/_layouts/accessdenied.aspx");
                    }

                    SqlConnection cn = null;
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        cn = new SqlConnection(EPMLiveCore.CoreFunctions.getConnectionString(web.Site.WebApplication.Id));
                        cn.Open();
                    });

                    SqlCommand cmd = new SqlCommand("select period_start,period_end from tsperiod where period_id=@period_id and site_id=@site_id", cn);
                    cmd.Parameters.AddWithValue("@period_Id", Request["period_id"]);
                    cmd.Parameters.AddWithValue("@site_id", web.Site.ID);
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        lblTitle.Text = "View Timesheets for Period: " + dr.GetDateTime(0).ToShortDateString() + " - " + dr.GetDateTime(1).ToShortDateString();
                    }
                    dr.Close();

                    sTimeEditor     = "";
                    cmd             = new SqlCommand("SELECT tstype_id,tstype_name from TSTYPE where site_uid=@site_id", cn);
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@site_id", SPContext.Current.Site.ID);
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            sTimeEditor += "<tr><td class=\"ms-descriptiontext\">" + dr.GetString(1) + "</td><td align=\"right\"><input class=\"ms-input\" size=\"5\" type=\"text\" id=\"timeeditor-" + dr.GetInt32(0).ToString() + "\" disabled=true></td></tr>";
                        }
                    }
                    else
                    {
                        sTimeEditor += "<tr><td class=\"ms-descriptiontext\">Work</td><td align=\"right\"><input class=\"ms-input\" size=\"5\" type=\"text\" id=\"timeeditor-0\" disabled=true></td></tr>";
                    }
                    dr.Close();

                    if (EPMLiveCore.CoreFunctions.getConfigSetting(web.Site.RootWeb, "EPMLiveTSAllowNotes").ToLower() == "true")
                    {
                        sTimeEditor += "<tr><td class=\"ms-descriptiontext\" colspan=\"2\">&nbsp;</td></tr>";
                        sTimeEditor += "<tr><td class=\"ms-descriptiontext\" colspan=\"2\">Notes</td></tr>";
                        sTimeEditor += "<tr><td  class=\"ms-descriptiontext\" colspan=\"2\"><textarea class=\"ms-input\" id=\"timeeditor-N\" rows=\"5\" cols=\"25\" disabled=true></textarea></td></tr>";
                    }

                    loadUrl = web.Url + "/_layouts/epmlive/getts.aspx?period_id=" + Request["period_id"];

                    cn.Close();
                }

                ToolBarButton tbDelete = (ToolBarButton)Page.LoadControl("~/_controltemplates/ToolBarButton.ascx");
                tbDelete.Text        = "Delete Timesheet(s)";
                tbDelete.ImageUrl    = "../_layouts/epmlive/images/delete.gif";
                tbDelete.NavigateUrl = "Javascript:deleteTimesheets();";
                tbDelete.ToolTip     = "Delete";
                ToolBar toolbar = (ToolBar)Page.LoadControl("~/_controltemplates/ToolBar.ascx");
                toolbar.Buttons.Controls.Add(tbDelete);

                pnlActionsToolbar.Controls.Add(toolbar);
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.Timesheets);

            if (activation != 0)
            {
                pnlActivation.Visible = true;
                pnlTs.Visible         = false;
            }


            using (SPWeb web = SPContext.Current.Web)
            {
                dtSpStart.DatePickerFrameUrl = web.Url + "/_layouts/iframe.aspx";
                dtSpEnd.DatePickerFrameUrl   = web.Url + "/_layouts/iframe.aspx";

                try
                {
                    if (!SPContext.Current.Web.UserIsSiteAdmin)
                    {
                        Response.Redirect(SPContext.Current.Web.Url + "/_layouts/accessdenied.aspx");
                    }

                    siteUrl = SPContext.Current.Web.Url;

                    if (!IsPostBack)
                    {
                        //using (SPWeb web = SPContext.Current.Web)
                        {
                            if (!web.IsRootWeb)
                            {
                                pnlTL.Visible       = true;
                                hlAdmin.NavigateUrl = SPContext.Current.Site.Url + "/_layouts/epmlive/timesheetadmin.aspx";
                                pnlMain.Visible     = false;
                            }
                            else
                            {
                                TimesheetSettings settings = new TimesheetSettings(Web);

                                SPList oMyWork = web.Lists.TryGetList("My Work");

                                string sFields = "";

                                if (oMyWork != null)
                                {
                                    SortedList sl = new SortedList();

                                    foreach (SPField field in oMyWork.Fields)
                                    {
                                        if (field.Reorderable && field.InternalName != "Title")
                                        {
                                            sl.Add(field.Title, field.InternalName);
                                        }
                                    }

                                    foreach (DictionaryEntry de in sl)
                                    {
                                        if (settings.TimesheetFields.Contains(de.Value.ToString()))
                                        {
                                            sFields += "," + de.Value.ToString();
                                            ListItem li = new ListItem(de.Key.ToString(), de.Value.ToString());
                                            ddlTSFieldsS.Items.Add(li);
                                        }
                                        else
                                        {
                                            ListItem li = new ListItem(de.Key.ToString(), de.Value.ToString());
                                            ddlTSFieldsA.Items.Add(li);
                                        }
                                    }
                                }

                                sFields = sFields.Trim(',');

                                hdnTSFields.Value = sFields;

                                chkAllowStopWatch.Checked = settings.AllowStopWatch;



                                //using (SPSite site = SPContext.Current.Site)
                                SPSite site = SPContext.Current.Site;
                                {
                                    //using (SPWeb rweb = site.RootWeb)
                                    SPWeb rweb = site.RootWeb;
                                    {
                                        try
                                        {
                                            chkAllowUnassigned.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveTSAllowUnassigned"));
                                        }
                                        catch { }
                                        try
                                        {
                                            chkAllowNotes.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveTSAllowNotes"));
                                        }
                                        catch { }

                                        ddlFlagField.SelectedValue = EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveTSFlag");
                                        txtLists.Text = EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveTSLists");

                                        string dayDef = EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveDaySettings");

                                        if (dayDef != "")
                                        {
                                            string[] daySettings = dayDef.Split('|');

                                            chkSunday.Checked = bool.Parse(daySettings[0]);
                                            txtSundayMin.Text = daySettings[1];
                                            txtSundayMax.Text = daySettings[2];

                                            chkMonday.Checked = bool.Parse(daySettings[3]);
                                            txtMondayMin.Text = daySettings[4];
                                            txtMondayMax.Text = daySettings[5];

                                            chkTuesday.Checked = bool.Parse(daySettings[6]);
                                            txtTuesdayMin.Text = daySettings[7];
                                            txtTuesdayMax.Text = daySettings[8];

                                            chkWednesday.Checked = bool.Parse(daySettings[9]);
                                            txtWednesdayMin.Text = daySettings[10];
                                            txtWednesdayMax.Text = daySettings[11];

                                            chkThursday.Checked = bool.Parse(daySettings[12]);
                                            txtThursdayMin.Text = daySettings[13];
                                            txtThursdayMax.Text = daySettings[14];

                                            chkFriday.Checked = bool.Parse(daySettings[15]);
                                            txtFridayMin.Text = daySettings[16];
                                            txtFridayMax.Text = daySettings[17];

                                            chkSaturday.Checked = bool.Parse(daySettings[18]);
                                            txtSaturdayMin.Text = daySettings[19];
                                            txtSaturdayMax.Text = daySettings[20];
                                        }
                                        chkCurrentData.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveTSUseCurrent"));
                                        try { chkEnableNonTeamNotf.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMLiveEnableNonTeamNotf")); }
                                        catch { }
                                        txtPortManagerColumn.Text = EPMLiveCore.CoreFunctions.getConfigSetting(rweb, "EPMPortManagerColumn");
                                    }
                                }
                                SqlConnection cn = null;
                                SPSecurity.RunWithElevatedPrivileges(delegate()
                                {
                                    cn = new SqlConnection(EPMLiveCore.CoreFunctions.getConnectionString(web.Site.WebApplication.Id));
                                    cn.Open();
                                });

                                SqlCommand cmd = new SqlCommand("select top 1 period_end,period_id from tsperiod where site_id = @siteid order by period_id desc", cn);
                                cmd.Parameters.AddWithValue("@siteid", SPContext.Current.Site.ID);
                                SqlDataReader dr = cmd.ExecuteReader();
                                if (dr.Read())
                                {
                                    lastPeriod = (dr.GetInt32(1) + 1).ToString();
                                    DateTime dtEnd = dr.GetDateTime(0);
                                    nextStart = dtEnd.AddDays(1).ToShortDateString();
                                    int stWeek = Microsoft.VisualBasic.DateAndTime.DatePart(Microsoft.VisualBasic.DateInterval.WeekOfYear, dtEnd.AddDays(1), Microsoft.VisualBasic.FirstDayOfWeek.Sunday, Microsoft.VisualBasic.FirstWeekOfYear.System);
                                    int enWeek = Microsoft.VisualBasic.DateAndTime.DatePart(Microsoft.VisualBasic.DateInterval.WeekOfYear, dtEnd.AddDays(7), Microsoft.VisualBasic.FirstDayOfWeek.Sunday, Microsoft.VisualBasic.FirstWeekOfYear.System);
                                    if (stWeek != enWeek && !(enWeek == 1 && stWeek == 53))
                                    {
                                        nextStartEnd = dtEnd.AddDays(6 - (int)dtEnd.DayOfWeek).ToShortDateString();
                                    }
                                    else if (dtEnd.AddDays(1).Month != dtEnd.AddDays(7).Month)
                                    {
                                        dtEnd        = dtEnd.AddDays(7);
                                        dtEnd        = dtEnd.AddDays(-1 * dtEnd.Day);
                                        nextStartEnd = dtEnd.ToShortDateString();
                                    }
                                    else
                                    {
                                        nextStartEnd = dtEnd.AddDays(7).ToShortDateString();
                                    }
                                    dtSpStart.SelectedDate       = DateTime.Parse(nextStart);
                                    dtSpStart.DatePickerFrameUrl = web.Url + "/_layouts/iframe.aspx";
                                    dtSpEnd.SelectedDate         = DateTime.Parse(nextStartEnd);
                                    dtSpEnd.DatePickerFrameUrl   = web.Url + "/_layouts/iframe.aspx";
                                }
                                dr.Close();

                                loadTypes(cn);

                                ddlNonWork.Items.Add(new ListItem("-- Select List --", ""));

                                foreach (SPList list in web.Lists)
                                {
                                    if (!list.Hidden)
                                    {
                                        ddlNonWork.Items.Add(new ListItem(list.Title, list.Title));
                                    }
                                }

                                ddlNonWork.SelectedValue        = EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveTSNonWork");
                                ddlTimesheetHours.SelectedValue = EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveTSTimesheetHours");
                                try
                                {
                                    chkDisableApprovals.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveTSDisableApprovals"));
                                }
                                catch { }
                                try
                                {
                                    chkShowLiveHours.Checked = bool.Parse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveTSLiveHours"));
                                }
                                catch { }
                                /////////
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                }
                ddlFieldLists.Items.Clear();
                //ddlFieldLists.Items.Add(new ListItem("Resources", "Resources"));
                string[] lists = txtLists.Text.Replace("\r\n", "\n").Split('\n');

                inputData = "";
                foreach (string list in lists)
                {
                    if (list != "Project Center")
                    {
                        addListFieldData(web, web, list);
                    }
                }



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

                if (resUrl != "")
                {
                    try
                    {
                        SPWeb resWeb;
                        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;
                        }
                        if (resWeb != null)
                        {
                            addListFieldData(resWeb, web, "Resources");
                            if (resWeb.ID != SPContext.Current.Web.ID)
                            {
                                resWeb.Close();
                            }
                        }
                    }
                    catch { }
                }
                addListFieldData(web, web, "Project Center");
            }
            ddlFieldLists.Attributes.Add("onchange", "switchList();");
        }
Ejemplo n.º 14
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>");
        }