#region
add signaturefolder
//Buttonimg_Click
protected void Buttonimg_Click(object sender, EventArgs e)
{
SPWeb oWeb1 = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(oWeb1.Site.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
//get the curent folder where search is happening
string siteUrl = Request.Url.ToString();
string region = SPContext.Current.List.Title;
//"Atlantic Region Client Portfolios";
SPDocumentLibrary docLib = (SPDocumentLibrary)oWeb.Lists[region];
foreach (SPFolder subfoldername in docLib.RootFolder.SubFolders)
{
foreach (SPFolder nsub in subfoldername.SubFolders)
{
if ((nsub.Name == foldername) || (nsub.Name == alternateurl) || (nsub.Name == foldernameaftertrim) || (nsub.Name == foldernameaftertrimurl))
{
foreach (SPFolder clientfolder in nsub.SubFolders)
{
string names = clientfolder.Name.ToString();
string name = "1-Annual Review and New Deals";
string folder2 = "2-Credit Correspondence";
String folder3 = "3-Overruns";
string s = clientfolder.Item.Name;
if ((name == names) || (folder2 == names) || (folder3 == names))
{
SPFolder ofolder = null;
oWeb.AllowUnsafeUpdates = true;
ofolder = clientfolder.SubFolders.Add("1-Signatures");
//modified by christine on 11 June 2013
#region
code for adding permission
//clientfolder.SubFolders.Delete("1-Signatures");
SPGroup ngroup = oWeb1.SiteGroups[System.Configuration.ConfigurationSettings.AppSettings["GRMgroup"].ToString()];
SPGroup auditgroup = oWeb1.SiteGroups[System.Configuration.ConfigurationSettings.AppSettings["AuditUsersgroup"].ToString()];
oWeb.AllowUnsafeUpdates = true;
ofolder.Item.BreakRoleInheritance(false);
oWeb.AllowUnsafeUpdates = true;
//Role Assignments and Definition order changed by srikar 13-June-2013
SPRoleAssignment roleAssignmentGRM = new SPRoleAssignment(ngroup);
SPRoleAssignment roleAssignmentaudituserss = new SPRoleAssignment(auditgroup);
SPRoleDefinition roleDefinationAudit = oWeb.RoleDefinitions["Read"];
SPRoleDefinition roleDefinationGRM = oWeb.RoleDefinitions["Contribute"];
roleAssignmentGRM.RoleDefinitionBindings.Add(roleDefinationGRM);
roleAssignmentaudituserss.RoleDefinitionBindings.Add(roleDefinationAudit);
ofolder.Item.RoleAssignments.Add(roleAssignmentGRM);
ofolder.Item.RoleAssignments.Add(roleAssignmentaudituserss);
oWeb.AllowUnsafeUpdates = true;
ofolder.Update();
SPGroupCollection gc = oWeb.SiteGroups;
foreach (SPGroup sgrop in gc)
{
string gname = sgrop.ToString();
string grname = ngroup.ToString();
string aname = auditgroup.ToString();
if ((gname == grname) || (gname == aname))
{
}
else
{
ofolder.Item.RoleAssignments.Remove((SPPrincipal)sgrop);
}
}
#endregion
docLib.Update();
//Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(),true);
}//1st if
}//3rd
Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(),true);
}//2nd
}
}
} //forst for llop
}
});
}
# endregion
No comments:
Post a Comment