Пример #1
0
        private void UpdateAssignedUsers()
        {
            try
            {
                ArrayList external_attendee = new ArrayList();

                string[] in_input = HiddenField1.Value.Split(',');
                string[] ex_input = HiddenField2.Value.Split(',');

                for (int inattend = 0; inattend < in_input.Length && inattend < ex_input.Length; inattend++)
                {
                    string in_attend  = in_input[inattend].ToString().ToLower();
                    string ex_attend  = ex_input[inattend].ToString().ToLower();
                    string newExtuser = ex_attend.Replace("[external]", "").Trim();;
                    if (in_attend.Equals(newExtuser))
                    {
                        external_attendee.Add(ex_input[inattend].ToString().Replace("[External]", "").Trim());
                    }

                    else
                    {
                        SPUser requireduser = currentWeb.EnsureUser(in_attend);
                        hiddenPreviousUser.Value = Convert.ToString(requireduser.ID);
                    }
                }


                RedirectOnOK();
            }

            catch (Exception Ex) { ULSLogger.LogErrorInULS("Inside catch in btnOk_Click() in PWC.Process.SixSigma Feature..Error is--" + Ex.Message); }
        }
        private void SendEmailtoSelectedUsers(string EmailComments, string TeamMember, string TeamRole, string SiteTitle, string ToUserName)
        {
            try
            {
                ArrayList toEmail           = new ArrayList();
                string    Subject           = string.Empty;
                string    TeamMemberEmailId = TeamMember;
                toEmail.Add(TeamMemberEmailId);
                StringBuilder strbody = new StringBuilder();
                SPListItem    Item    = GeSixSigmaDataByID(SigmaId);
                Subject = "Notification: You are required to work on Six Sigma #" + SigmaId;
                strbody = new StringBuilder();
                strbody.Append("<p><span style='font-family:Calibri;'>Dear <b>_ToName_</b>,</span></p>");
                strbody.Append("<p><span style='font-family:Calibri;'>You have been selected as a <b> _Role_ </b> to work on project  <b> _SiteTitle_ </b>.</span></p>");
                strbody.Append("<p><a href='_formURL_'><span style='font-family:Calibri;'>Click here</span></a>");
                strbody.Append("<span style='font-family:Calibri;'>&nbsp;to access the project details and take action.</span></p>");
                strbody.Append("<span style='font-family:Calibri;'><b>Comments:</b> _EmailComments_</span></p>");
                strbody.Append("<p><span style='font-family:Calibri;'>Thank you.</span></p>");

                string _id         = HttpUtility.UrlEncode(Encrypt(Convert.ToString(SigmaId)));
                string ItemsiteUrl = SPContext.Current.Web.Url + "/SitePages/BreakThroughProcertProjectsTracking.aspx?ProjectId=" + _id;
                strbody.Replace("_formURL_", ItemsiteUrl);
                strbody.Replace("_FormNumber_", Convert.ToString(SigmaId));
                strbody.Replace("_SiteTitle_", Convert.ToString(Item["ProjectName"]));
                strbody.Replace("_Role_", TeamRole);
                strbody.Replace("_EmailComments_", EmailComments);
                strbody.Replace("_ToName_", ToUserName);
                SendMail(toEmail, Convert.ToString(strbody), Subject, "");
            }
            catch (Exception ex)
            {
                ULSLogger.LogErrorInULS("Error in sending Notification in Six Sigma " + ex.Message, TraceSeverity.Unexpected);
            }
        }
Пример #3
0
 public static void CreateSubSiteGroup(SPWeb web, string groupName, string PermissionLevel, string groupDescription)
 {
     try
     {
         web.AllowUnsafeUpdates = true;
         SPUserCollection  users  = web.AllUsers;
         SPUser            owner  = web.SiteAdministrators[0];
         SPMember          member = web.SiteAdministrators[0];
         SPGroupCollection groups = web.SiteGroups;
         groups.Add(groupName, member, owner, groupDescription);
         SPGroup newSPGroup = groups[groupName];
         newSPGroup.OnlyAllowMembersViewMembership = false;
         newSPGroup.Update();
         SPRoleDefinition role           = web.RoleDefinitions[PermissionLevel];
         SPRoleAssignment roleAssignment = new SPRoleAssignment(newSPGroup);
         roleAssignment.RoleDefinitionBindings.Add(role);
         web.RoleAssignments.Add(roleAssignment);
         web.Update();
         web.AllowUnsafeUpdates = false;
     }
     catch (Exception ex)
     {
         ULSLogger.LogErrorInULS(ex.Message, TraceSeverity.Unexpected);
     }
 }
Пример #4
0
        private void DeletecolumninDiscussion(SPWeb web)
        {
            SPList list = web.Lists.TryGetList("BreakThroughProcertProjectsTrackingDiscussions");

            try
            {
                web.AllowUnsafeUpdates = true;
                if (list != null)
                {
                    list.EnableAttachments = false;
                    SPField field = list.Fields["Contains Technical Data?"];
                    if (field != null)
                    {
                        list.Fields.Delete(field.StaticName);

                        list.Update();
                    }
                }
                web.AllowUnsafeUpdates = false;
            }
            catch (Exception ex)
            {
                ULSLogger.LogErrorInULS("Inside outer catch in deletecolumninDiscussion in PWC MeetingSpace..Error is--" + ex.Message);
            }
        }
        private void TasksVariables()
        {
            try
            {
                string script = string.Format("var culture = '{0}';", culture);
                //ClientScript.re
                ClientScript.RegisterStartupScript(Page.GetType(), "myScript", script, true);
            }

            catch (Exception ex)
            {
                ULSLogger.LogErrorInULS("Error On  TasksVariables: " + ex.Message, TraceSeverity.Unexpected);
            }
        }
Пример #6
0
 protected bool ContainsGroup(SPGroupCollection groupCollection, string index)
 {
     try
     {
         SPGroup testGroup = groupCollection[index];
         return(true);
     }
     catch (SPException e)
     {
         e.Message.ToString();
         ULSLogger.LogErrorInULS("Inside catch in ContainsGroup() in PWC Secure Folder Feature----" + e.Message);
         return(false);
     }
 }
Пример #7
0
 protected bool ContainsPermLevel(SPWeb web, string permLevel)
 {
     try
     {
         SPRoleDefinition roleDef = web.RoleDefinitions[permLevel];
         return(true);
     }
     catch (SPException e)
     {
         e.Message.ToString();
         ULSLogger.LogErrorInULS("Inside catch in ContainsPermLevel() in PWC Secure Folder Feature----" + e.Message);
         return(false);
     }
 }
        public static bool SendMail(ArrayList To, string Body, string Subject, string CCUser)
        {
            bool mailSent = false;

            try
            {
                SmtpClient smtpClient = new SmtpClient();
                smtpClient.Host = SPContext.Current.Site.WebApplication.
                                  OutboundMailServiceInstance.Server.Address;
                MailMessage mailMessage      = new MailMessage();
                string      CurrentUserEmail = SPContext.Current.Web.CurrentUser.Email;
                if (!string.IsNullOrEmpty(CurrentUserEmail))
                {
                    mailMessage.From = new MailAddress(CurrentUserEmail);
                }
                else
                {
                    mailMessage.From = new MailAddress("*****@*****.**");
                }
                mailMessage.Subject = Subject;
                mailMessage.Body    = Body;
                foreach (string toemail in To)
                {
                    if (toemail != null)
                    {
                        mailMessage.To.Add(toemail);
                    }
                    if (!string.IsNullOrEmpty(CCUser))
                    {
                        mailMessage.CC.Add(CCUser);
                    }
                }
                mailMessage.IsBodyHtml = true;
                smtpClient.Send(mailMessage);
                mailSent = true;
            }
            catch (Exception ex) { ULSLogger.LogErrorInULS("Error On  SendMail: " + ex.Message, TraceSeverity.Unexpected); return(mailSent); }
            return(mailSent);
        }
Пример #9
0
        private void CreateDiscussionList(SPWeb web)
        {
            SPList list = web.Lists.TryGetList("BreakThroughProcertProjectsTrackingDiscussions");

            try
            {
                web.AllowUnsafeUpdates = true;
                if (list == null)
                {
                    web.AllowUnsafeUpdates = true;


                    web.Lists.Add("BreakThroughProcertProjectsTrackingDiscussions", "This List Is used In BreakThroughProcertProjectsTracking", SPListTemplateType.DiscussionBoard);


                    web.AllowUnsafeUpdates = false;
                }
            }
            catch (Exception ex)
            {
                ULSLogger.LogErrorInULS("Inside outer catch in createDiscussionList in PWC Six Sigma..Error is--" + ex.Message);
            }
        }
Пример #10
0
        protected void CreateSFGroup(SPWeb web, string grpName, string permName, string member_visitor)
        {
            web.AllowUnsafeUpdates = true;
            SPMember bronzeAdminMember = null;

            try
            {
                ULSLogger.LogErrorInULS("Inside try in createGroup() in PWC Secure Folder Feature");
                if (ContainsPermLevel(web, permName))
                {
                    SPGroupCollection sgc          = web.SiteGroups;
                    string            adminGrpName = string.Empty;
                    foreach (SPGroup grp in sgc)
                    {
                        adminGrpName = grp.Name;
                        if (adminGrpName.EndsWith("Bronze Admin"))
                        {
                            ULSLogger.LogErrorInULS("Inside foreach if in createGroup() in PWC Secure Folder Feature.. Found Bronze Admin group---name is---" + adminGrpName);
                            bronzeAdminMember = grp;
                        }
                    }
                    if (member_visitor.Equals("member"))
                    {
                        web.SiteGroups.Add(grpName, bronzeAdminMember, null, "Members for the folder " + grpName);
                    }
                    if (member_visitor.Equals("visitor"))
                    {
                        web.SiteGroups.Add(grpName, bronzeAdminMember, null, "Visitors for the folder " + grpName);
                    }
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
                ULSLogger.LogErrorInULS("Inside catch in createGroup() in PWC Secure Folder Feature---" + e.Message);
            }
        }
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["SigmaId"])))
                {
                    PassportCategoryId = Convert.ToInt32(Convert.ToString(Request.QueryString["SigmaId"]));
                    MeetingCat         = Convert.ToString(Request.QueryString["Group"]);
                    Usr = Convert.ToString(Request.QueryString["User"]);
                }

                SPGroup          testingOwnersGroup = SPContext.Current.Web.SiteGroups[MeetingCat];
                SPUserCollection userColl           = testingOwnersGroup.Users;
                DataTable        dtUsers            = new DataTable();
                DataColumn       dcName             = new DataColumn("Name", typeof(string));
                DataColumn       dcLoginName        = new DataColumn("LoginName", typeof(string));
                dtUsers.Columns.Add(dcName);
                dtUsers.Columns.Add(dcLoginName);
                dtUsers.AcceptChanges();
                foreach (SPUser user in userColl)
                {
                    if (!(user.Name == "NT AUTHORITY\\Authenticated Users") && !(user.IsDomainGroup) && !(user.Name == "System Account"))
                    {
                        DataRow dr = dtUsers.NewRow();
                        dr["Name"]      = user.Name;
                        dr["LoginName"] = user.LoginName;
                        dtUsers.Rows.Add(dr);
                        dtUsers.AcceptChanges();
                    }
                }

                LB_MainSelection.DataSource     = dtUsers;
                LB_MainSelection.DataTextField  = "Name";
                LB_MainSelection.DataValueField = "LoginName";
                LB_MainSelection.DataBind();

                LB_CentralData.DataSource     = dtUsers;
                LB_CentralData.DataTextField  = "Name";
                LB_CentralData.DataValueField = "LoginName";
                LB_CentralData.DataBind();


                if (!Page.IsPostBack)
                {
                    if (!(string.IsNullOrEmpty(Usr)) && !(Usr.Equals("undefined")))
                    {
                        SPUser     myUser            = currentWeb.EnsureUser(Usr);
                        DataTable  SelectedUsers     = new DataTable();
                        DataColumn SelctddcName      = new DataColumn("Name", typeof(string));
                        DataColumn SelctddcLoginName = new DataColumn("LoginName", typeof(string));
                        SelectedUsers.Columns.Add(SelctddcName);
                        SelectedUsers.Columns.Add(SelctddcLoginName);
                        SelectedUsers.AcceptChanges();
                        DataRow dr = SelectedUsers.NewRow();
                        dr["Name"]      = myUser.Name;
                        dr["LoginName"] = myUser.LoginName;
                        SelectedUsers.Rows.Add(dr);
                        SelectedUsers.AcceptChanges();
                        LB_SelectedUserList.DataSource     = SelectedUsers;
                        LB_SelectedUserList.DataTextField  = "Name";
                        LB_SelectedUserList.DataValueField = "LoginName";
                        LB_SelectedUserList.DataBind();
                    }

                    var hdnhidden1 = HiddenField1.ClientID;
                    var hdnhidden2 = HiddenField2.ClientID;

                    string script = string.Format("var hdn1 = '{0}';var hdn2 = '{1}';", hdnhidden1, hdnhidden2);

                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "myScript", script, true);
                }
            }
            catch (Exception ex)
            {
                ULSLogger.LogErrorInULS("Inside catch in Page_Load() in PWC.Process.SixSigma Feature..Error is--" + ex.Message);
            }
        }
        // Uncomment the method below to handle the event raised when a feature is upgrading.

        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
        //{
        //}
        #endregion

        #region ULSLogger methods

        private static void RegisterULSLogger()
        {
            ULSLogger.WriteTraceStandalone(TraceSeverity.Verbose, "Registering ULSLogger");
            // Add logging

            ULSLogger service = ULSLogger.Local;
            if (service == null)
            {
                service = new ULSLogger();
                service.Update();

                if (service.Status != SPObjectStatus.Online)
                {
                    service.Provision();
                }
            }

            ULSLogger.WriteTraceStandalone(TraceSeverity.Verbose, "Done registering ULSLogger");
        }
Пример #13
0
        public static void GrantPermissionOnSitePages(SPWeb web)
        {
            try
            {
                ULSLogger.LogErrorInULS("Inside try in GrantPermissionOnSitePages in PWC SixSigma Solution..");
                SPGroup BlackbeltGroup = web.SiteGroups["BlackBelt"];
                SPGroup GreenbeltGroup = web.SiteGroups["GreenBelt"];


                string path         = SPContext.Current.Web.ServerRelativeUrl;
                int    pos          = path.LastIndexOf("/") + 1;
                string grpStartName = path.Substring(pos, path.Length - pos);

                SPGroup BronzeAdminGroup = web.SiteGroups[grpStartName + " Bronze Admin"];
                SPGroup ownersGroup      = web.SiteGroups[grpStartName + " Owners"];
                SPList  sitePageslist    = web.Lists["Site Pages"];

                SPRoleDefinition pwcContribute = web.RoleDefinitions["PWC Contribute"];
                SPRoleDefinition viewOnly      = web.RoleDefinitions["View Only"];
                SPRoleDefinition fullControl   = web.RoleDefinitions["Full Control"];
                SPRoleDefinition pwclimited    = web.RoleDefinitions["Limited Access"];

                SPListItemCollection spColl = sitePageslist.Items;


                string WelcomePage = web.RootFolder.WelcomePage;
                string SplitedPage = WelcomePage.Split('/')[1];

                foreach (SPListItem oSPListItem in spColl)
                {
                    try
                    {
                        if (oSPListItem.Name == "BreakThroughProcertProjectsTracking.aspx" || oSPListItem.Name == SplitedPage)
                        {
                            oSPListItem.BreakRoleInheritance(true);
                            ULSLogger.LogErrorInULS("Inside try in GrantPermissionOnSitePages in PWC SixSigma Solution..Got the item with the name--" + oSPListItem.Name);

                            SPRoleAssignment BronzeAdminRoleAssignment = new SPRoleAssignment(BronzeAdminGroup);

                            BronzeAdminRoleAssignment.RoleDefinitionBindings.Add(pwcContribute);
                            BronzeAdminRoleAssignment.RoleDefinitionBindings.Remove(pwclimited);
                            BronzeAdminRoleAssignment.RoleDefinitionBindings.Remove(viewOnly);
                            oSPListItem.RoleAssignments.Add(BronzeAdminRoleAssignment);
                            oSPListItem.Update();



                            SPRoleAssignment BlackbeltRoleAssignment = new SPRoleAssignment(BlackbeltGroup);

                            BlackbeltRoleAssignment.RoleDefinitionBindings.Add(pwcContribute);
                            BlackbeltRoleAssignment.RoleDefinitionBindings.Remove(pwclimited);
                            BlackbeltRoleAssignment.RoleDefinitionBindings.Remove(viewOnly);
                            oSPListItem.RoleAssignments.Add(BlackbeltRoleAssignment);
                            oSPListItem.Update();

                            SPRoleAssignment GreenbeltRoleAssignment = new SPRoleAssignment(GreenbeltGroup);

                            GreenbeltRoleAssignment.RoleDefinitionBindings.Add(pwcContribute);
                            GreenbeltRoleAssignment.RoleDefinitionBindings.Remove(pwclimited);
                            GreenbeltRoleAssignment.RoleDefinitionBindings.Remove(viewOnly);
                            oSPListItem.RoleAssignments.Add(GreenbeltRoleAssignment);
                            oSPListItem.Update();
                        }
                    }
                    catch (Exception gpPermExc)
                    {
                        ULSLogger.LogErrorInULS("Inside foreach catch in GrantPermissionOnSitePages in PWC WorkReleaseManagement Solution. Error adding permission----" + gpPermExc);
                    }
                }
            }
            catch (Exception gpExc)
            {
                ULSLogger.LogErrorInULS("Inside catch in GrantPermissionOnSitePages in PWC WorkReleaseManagement Solution. Error is----" + gpExc.Message);
            }
        }