本文整理汇总了C#中SPWeb类的典型用法代码示例。如果您正苦于以下问题:C# SPWeb类的具体用法?C# SPWeb怎么用?C# SPWeb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPWeb类属于命名空间,在下文中一共展示了SPWeb类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BatchDeleteItems
public static void BatchDeleteItems(SPList splTask, SPQuery query,SPWeb web)
{
// Set up the variables to be used.
StringBuilder methodBuilder = new StringBuilder();
string batch = string.Empty;
string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Batch onError=\"Return\">{0}</Batch>";
string methodFormat = "<Method ID=\"{0}\">" +
"<SetList Scope=\"Request\">{1}</SetList>" +
"<SetVar Name=\"ID\">{2}</SetVar>" +
"<SetVar Name=\"Cmd\">Delete</SetVar>" +
"</Method>";
// Get the list containing the items to update.
//PList list = WorkFlowUtil.GetWorkflowList(listName);
// Query to get the unprocessed items.
SPListItemCollection unprocessedItems = splTask.GetItems(query);
// Build the CAML delete commands.
foreach (SPListItem item in unprocessedItems)
{
methodBuilder.AppendFormat(methodFormat, "1", item.ParentList.ID, item.ID.ToString());
}
// Put the pieces together.
batch = string.Format(batchFormat, methodBuilder.ToString());
// Process the batch of commands.
string batchReturn = web.ProcessBatchData(batch.ToString());
}
开发者ID:porter1130,项目名称:C-A,代码行数:33,代码来源:Program.cs
示例2: Get_ZUS_ZD
public static void Get_ZUS_ZD(SPWeb web, int okresId, bool isChorobowa, bool isPracownicy, out double skladkaZD, out DateTime terminPlatnosci, out DateTime terminPrzekazania)
{
skladkaZD = -1;
terminPlatnosci = new DateTime();
terminPrzekazania = new DateTime();
SPList list = web.Lists.TryGetList(targetList);
//if (list != null)
//{
SPListItem item = list.GetItemById(okresId);
if (item != null)
{
Get_ZUS_Terminy(isPracownicy, ref terminPlatnosci, ref terminPrzekazania, item);
//składka zdrowotna
skladkaZD = Double.Parse(item["colZUS_D_ZD_Skladka"].ToString());
}
//}
}
开发者ID:fraczo,项目名称:Biuromagda,代码行数:25,代码来源:tabOkresy.cs
示例3: Send
public void Send(SPWeb web, IEnumerable<string> emailTo, string senderDisplayName, string subject, string body)
{
if (web == null) throw new ArgumentNullException("web");
if (emailTo == null || !emailTo.Any()) throw new ArgumentNullException("emailTo");
var webApplication = web.Site.WebApplication;
var from = new MailAddress(webApplication.OutboundMailSenderAddress, senderDisplayName);
var message = new MailMessage
{
IsBodyHtml = true,
Body = body,
From = from
};
var smtpServer = webApplication.OutboundMailServiceInstance;
var smtp = new SmtpClient(smtpServer.Server.Address);
foreach (var email in emailTo)
{
message.To.Add(email);
}
message.Subject = subject;
smtp.Send(message);
}
开发者ID:sergeykhomyuk,项目名称:HumanResources.EventsCalendar,代码行数:27,代码来源:EmailService.cs
示例4: AddNiemUploadEventReceiver
public void AddNiemUploadEventReceiver(SPWeb sysWeb, string spListTitle)
{
SPList spListCustom = null;
spListCustom = sysWeb.Lists.TryGetList(spListTitle);
if (spListCustom != null)
{
// add the TitleFieldUpdateListEventReceiver to specific lists
string assemblyName = "Niem.CaseUpload, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6f7c7006f477a0a5";
string className = "Niem.CaseUpload.NiemUploadCaseHandler.NiemUploadCaseEventHandler";
// When the user is tyring
//SPEventReceiverDefinition erAdding = spListCustom.EventReceivers.Add();
//erAdding.Assembly = assemblyName;
//erAdding.Class = className;
//erAdding.Type = SPEventReceiverType.ItemAdding;
//erAdding.Name = "NiemUploadCaseHandlerEventReceiverItemAdding";
//erAdding.Update();
SPEventReceiverDefinition erUpdating = spListCustom.EventReceivers.Add();
erUpdating.Assembly = assemblyName;
erUpdating.Class = className;
erUpdating.Type = SPEventReceiverType.ItemUpdating;
erUpdating.Name = "NiemUploadCaseHandlerEventReceiverItemUpdating";
erUpdating.Update();
spListCustom.Update();
}
}
开发者ID:NIEM-Web,项目名称:Sharepoint,代码行数:32,代码来源:NiemUploadCaseEventHandlerFeature.EventReceiver.cs
示例5: ImportSecurity
public static void ImportSecurity(XmlDocument xmlDoc, bool includeItemSecurity, SPWeb web)
{
Logger.Write("Start Time: {0}.", DateTime.Now.ToString());
foreach (XmlElement listElement in xmlDoc.SelectNodes("//List"))
{
SPList list = null;
try
{
list = web.GetList(web.ServerRelativeUrl.TrimEnd('/') + "/" + listElement.GetAttribute("Url"));
}
catch (ArgumentException) { }
catch (FileNotFoundException) { }
if (list == null)
{
Console.WriteLine("WARNING: List was not found - skipping.");
continue;
}
ImportSecurity(list, web, includeItemSecurity, listElement);
}
Logger.Write("Finish Time: {0}.\r\n", DateTime.Now.ToString());
}
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:26,代码来源:ImportListSecurity.cs
示例6: Create
internal static void Create(SPWeb web, int klientId, int okresId)
{
SPListItem item = tabKlienci.Get_KlientById(web, klientId);
if (item != null)
{
SPFieldLookupValueCollection kody;
switch (item.ContentType.Name)
{
case "Osoba fizyczna":
case "Firma":
kody = new SPFieldLookupValueCollection(item["selSerwisyWspolnicy"].ToString());
break;
default:
kody = new SPFieldLookupValueCollection(item["selSewisy"].ToString());
break;
}
foreach (SPFieldLookupValue kod in kody)
{
switch (kod.LookupValue)
{
case @"PD-M":
Create_PD_M_Form(web, item.ID, okresId);
break;
case @"PD-KW":
Create_PD_KW_Form(web, item.ID, okresId);
break;
default:
break;
}
}
}
}
开发者ID:fraczo,项目名称:BR5,代码行数:35,代码来源:PD_Forms.cs
示例7: GetSitePagesLibrary
public SPList GetSitePagesLibrary(SPWeb web)
{
SPList wikiList;
try
{
string serverRelativeUrl = web.ServerRelativeUrl;
if (serverRelativeUrl == "/")
{
serverRelativeUrl = "/SitePages";
}
else
{
serverRelativeUrl = serverRelativeUrl + "/SitePages";
}
wikiList = web.GetList(serverRelativeUrl);
}
catch
{
wikiList = null;
}
if ((wikiList != null) && (wikiList.BaseTemplate != SPListTemplateType.WebPageLibrary))
{
wikiList = null;
}
return wikiList;
}
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:28,代码来源:WikiPagesOperations.cs
示例8: assign_roles
protected void assign_roles(SPWeb web, SPListItem item, SPListItem project, string field_name, string field_guid, SPRoleDefinition definition)
{
try
{
string value = project[field_name].ToString();
SPFieldUserValueCollection field_user_value = (SPFieldUserValueCollection)project.Fields[new Guid(field_guid)].GetFieldValue(value);
foreach (SPFieldUserValue user_value in field_user_value)
{
if (user_value.User == null)
{
SPGroup group = web.SiteGroups.GetByID(user_value.LookupId);
bind_role(item, group, definition);
}
else
{
bind_role(item, user_value.User, definition);
}
}
}
catch (Exception ex)
{
log(web.Site, "为项目【" + project["Title"] + "】的【" + field_name + "】的文档授权时发生错误", "错误", ex.ToString());
}
}
开发者ID:ricardocarneiro,项目名称:SharePoint-1,代码行数:25,代码来源:Project+Documents+Library+Event+Receiver.cs
示例9: SendMail
internal static bool SendMail(SPWeb web, System.Net.Mail.MailMessage message)
{
bool result = false;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPWeb web1 = web.Site.OpenWeb())
{
SmtpClient client = new SmtpClient();
client.Host = web1.Site.WebApplication.OutboundMailServiceInstance.Server.Address;
try
{
client.Send(message);
result = true;
}
catch (Exception ex)
{
Logger.LogEvent_Exception(web.Name, ex.ToString());
}
}
});
return result;
}
开发者ID:fraczo,项目名称:STAFix24_Tools,代码行数:25,代码来源:LocalSMTP.cs
示例10: BuildFullMenuStructure
private SiteMapNode BuildFullMenuStructure(SPWeb currentWeb)
{
Clear();
SiteMapNode root = null;
SPWeb webSite = SPContext.Current.Site.RootWeb;
string relativeUrl = webSite.ServerRelativeUrl.ToString();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite currentsite = new SPSite(webSite.Site.Url);
SPWeb rootweb = currentsite.OpenWeb(relativeUrl);
root = new SiteMapNode(this, rootweb.ID.ToString(), rootweb.ServerRelativeUrl, rootweb.Title);
if (rootweb == currentWeb)
{
SiteMapNode root2 = new SiteMapNode(this, "Root", "/", null);
AddNode(root2);
string cacheKey = rootweb.ID.ToString();
AddMenuToCache(cacheKey, root2);
}
foreach (SPWeb web in rootweb.Webs)
{
SiteMapNode node = BuildNodeTree(web);
AddNode(node, root);
}
});
return root;
}
开发者ID:MohitVash,项目名称:TestProject,代码行数:34,代码来源:NCNewssiteTopNavigationProviderLevel2.cs
示例11: UpdateCurrentComposedLookItem
private static void UpdateCurrentComposedLookItem(SPWeb web, ComposedLook composedLook)
{
var catalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
var items = catalog.GetItems(new SPQuery
{
RowLimit = 1u,
Query = "<Where><Eq><FieldRef Name='DisplayOrder'/><Value Type='Number'>0</Value></Eq></Where>",
ViewFields = "<FieldRef Name='DisplayOrder'/>",
ViewFieldsOnly = true
});
// Delete current composed look item
if (items.Count == 1)
{
items[0].Delete();
}
// Create the new composed look item
var item = catalog.AddItem();
item[BuiltInFields.DisplayOrderName] = 0;
item[SPBuiltInFieldId.Name] = SPResource.GetString(web.UICulture, "DesignGalleryCurrentItemName");
item[SPBuiltInFieldId.Title] = SPResource.GetString(web.UICulture, "DesignGalleryCurrentItemName");
item[BuiltInFields.MasterPageUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.MasterPagePath.Url).AbsolutePath);
item[BuiltInFields.ThemeUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.ThemePath.Url).AbsolutePath);
item[BuiltInFields.ImageUrlName] = composedLook.ImagePath == null ? string.Empty : HttpUtility.UrlDecode(new Uri(composedLook.ImagePath.Url).AbsolutePath);
item[BuiltInFields.FontSchemeUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.FontSchemePath.Url).AbsolutePath);
item.Update();
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:28,代码来源:WebExtensions.cs
示例12: GetCurrentWebSiteLevel
private int GetCurrentWebSiteLevel(SPWeb currentWeb)
{
//We can't really work out the level from the URL because the URL
//might contain managed path that is not part of the site collection
//(e.g. http://server/ or http://server/sites/).
int level = 0;
var tempWeb = currentWeb;
while (!tempWeb.IsRootWeb)
{
level++;
tempWeb = tempWeb.ParentWeb;
//Official guidance from MS is that we do not need to call Dispose on SPWeb.ParentWeb.
}
return level;
}
开发者ID:NIEM-Web,项目名称:Sharepoint,代码行数:25,代码来源:NiemPortalSiteMapDataSource.cs
示例13: GetUserByLoginName
/// <summary>
/// попытка получения пользователя по логину
/// </summary>
/// <param name="loginName"></param>
/// <returns></returns>
public static SPUser GetUserByLoginName(SPWeb web, string loginName)
{
SPUser ret = null;
try
{
PortalSecurity.RunWithElevatedPrivileges(web, (elSite, elWeb) =>
{
ret = elWeb.AllUsers[loginName];
});
}
catch
{
// скорее всего не удалось найти юзвера по логину или логин был без домена, попробуем иначе
try
{
PortalSecurity.RunWithElevatedPrivileges(web, (elSite, elWeb) =>
{
SPPrincipalInfo pinfo = SPUtility.ResolvePrincipal(elWeb,
loginName,
SPPrincipalType.User,
SPPrincipalSource.All,
elWeb.AllUsers, false);
if (pinfo != null && !string.IsNullOrEmpty(pinfo.LoginName))
ret = elWeb.AllUsers[pinfo.LoginName];
});
}
catch { }
}
return ret;
}
开发者ID:dzsoft-ru,项目名称:d.SharePoint,代码行数:36,代码来源:PortalUser.cs
示例14: SendMail
public static bool SendMail(
SPWeb web,
MailMessage message,
Models.MailServiceProviders provider = Models.MailServiceProviders.Default)
{
bool result = false;
try
{
switch (provider)
{
case MailServiceProviders.MailGun:
result = Models.MailGun.SendMail(message);
break;
case MailServiceProviders.ElasticEmail:
break;
case MailServiceProviders.SendGrid:
break;
case MailServiceProviders.TurboSMTP:
break;
default:
//wysyłka przez SharePoint
result = Models.LocalSMTP.SendMail(web, message);
break;
}
return result;
}
catch (Exception ex)
{
Logger.LogEvent_Exception(web.Name, ex.ToString());
return false;
}
}
开发者ID:fraczo,项目名称:STAFix24_Tools,代码行数:35,代码来源:MailManager.cs
示例15: Ensure
/// <summary>
/// Na podstawie wprowadzonego tematu zadania sprawdza czy istnieje taka procedura, jeżeli nie istnieje to ją dodaje w statusie nowy,
/// jeżeli istnieje i jest zatwierdzona to zwraca jej ID. W pozostałych przypadkach zwraca 0;
/// </summary>
/// <param name="web"></param>
/// <param name="procName"></param>
/// <returns></returns>
public static int Ensure(SPWeb web, string procName, bool ignorujStatusProcedury)
{
SPList list = web.Lists.TryGetList(targetList);
SPListItem item = list.Items.Cast<SPListItem>()
.Where(i => i.Title.Equals(procName))
.FirstOrDefault();
if (item == null)
{
SPListItem newItem = list.AddItem();
newItem["Title"] = procName;
newItem["enumStatusProcedury"] = "Nowa";
newItem.Update();
return newItem.ID;
}
else
{
if (BLL.Tools.Get_Text(item, "enumStatusProcedury").Equals("Zatwierdzona")
|| ignorujStatusProcedury)
{
return item.ID;
}
else return 0;
}
}
开发者ID:fraczo,项目名称:Animus,代码行数:33,代码来源:tabProcedury.cs
示例16: Operator
public Operator(SPWeb web, int operatorId)
{
SPListItem item = BLL.dicOperatorzy.GetItemById(web, operatorId);
this.Email = Get_Text(item, "colEmail");
this.Telefon = Get_Text(item, "colTelefon");
this.Name = item.Title;
}
开发者ID:fraczo,项目名称:Animus,代码行数:7,代码来源:Operator.cs
示例17: EnsureFile
/// <summary>
/// Method to ensure a file in a document library. Will create if not exist.
/// </summary>
/// <param name="web">The web where the list or library is</param>
/// <param name="listTitle">The list title where to ensure the file</param>
/// <param name="file">The fileinfo containing all the information needed to create the file</param>
/// <returns>The file</returns>
public SPFile EnsureFile(SPWeb web, string listTitle, FileInfo file)
{
if (file == null)
{
throw new ArgumentNullException("file");
}
SPFile sharePointFile = null;
// Locate the list/library
var list = this.listLocator.TryGetList(web, listTitle);
// Go get the file if its url is not null
if (file.Url != null)
{
sharePointFile = web.GetFile(file.Url.ToString());
}
// If the file is not found, create it.
if (sharePointFile == null || file.Overwrite)
{
sharePointFile = list.RootFolder.Files.Add(file.FileName, file.Data, file.Overwrite);
}
return sharePointFile;
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:33,代码来源:FileHelper.cs
示例18: InitializeWebDefaultRegionalSettings
public void InitializeWebDefaultRegionalSettings(SPWeb web)
{
// Web regional settings should en-CA or fr-CA, depending on web default language
var settings = web.Language == (uint)Language.English.Culture.LCID ? this.EnglishCanadianSettings(web, false) : this.FrenchCanadianSettings(web, false);
web.RegionalSettings = settings;
web.Update();
}
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:7,代码来源:RegionalSettingsHelper.cs
示例19: WriteToLog
internal static void WriteToLog(SPWeb web, string message)
{
ASCIIEncoding enc = new ASCIIEncoding();
UnicodeEncoding uniEncoding = new UnicodeEncoding();
string errors = message;
SPFile files = web.GetFile("/" + DocumentLibraryName + "/" + LogFileName);
if (files.Exists)
{
byte[] fileContents = files.OpenBinary();
string newContents = enc.GetString(fileContents) + Environment.NewLine + errors;
files.SaveBinary(enc.GetBytes(newContents));
}
else
{
using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(ms, uniEncoding))
{
sw.Write(errors);
}
SPFolder LogLibraryFolder = web.Folders[DocumentLibraryName];
LogLibraryFolder.Files.Add(LogFileName, ms.ToArray(), false);
}
}
web.Update();
}
开发者ID:JoJo777,项目名称:TTK.SP,代码行数:31,代码来源:Logging.cs
示例20: CreatePermissionLevel
/// <summary>
/// Adds a new permission level to the web.
/// </summary>
/// <param name = "web"></param>
/// <param name = "name"></param>
/// <param name = "description"></param>
/// <param name = "permissions"></param>
public static void CreatePermissionLevel(SPWeb web, string name, string description,
SPBasePermissions permissions)
{
if (!web.IsRootWeb && !web.HasUniqueRoleDefinitions)
{
throw new NotSupportedException("This web must be broken permission before adding new permission level.");
}
var roleDefinition = GetRoleDefinition(web, name);
if (roleDefinition != null)
{
if (roleDefinition.BasePermissions != permissions || roleDefinition.Description != description)
{
roleDefinition.BasePermissions = permissions;
roleDefinition.Description = description;
roleDefinition.Update();
}
}
else
{
roleDefinition = new SPRoleDefinition
{
Name = name,
Description = description,
BasePermissions = permissions
};
web.RoleDefinitions.Add(roleDefinition);
}
}
开发者ID:bebikashg,项目名称:ttqn,代码行数:36,代码来源:SecurityHelper.cs
注:本文中的SPWeb类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论