Making Calls and Using Features
See below for information about how to make calls and use the many features included with your Digital Voice service.
public class Worker
{
public Worker()
{
}
private SPSite site = null;
private SPWeb web = null;
private SPFolder folder = null;
/// <summary>
/// This Method is called throug Delegate elevatedGetSite which is definend in cmdOpenCnn_Click
/// </summary>
private void EstablishSharepoint()
{
site = new SPSite("http://srv-moss-tp1:36000");
web = site.OpenWeb();
}
/// <summary>
/// If you click the Button to establish a connection to your SharePoint-Site,
/// you run this code with elevated Privileges.
/// </summary>
private void cmdOpenCnn_Click(object sender, EventArgs e)
{
SPSecurity.CodeToRunElevated elevatedGetSite = new SPSecurity.CodeToRunElevated(EstablishSharepoint);
SPSecurity.RunWithElevatedPrivileges(elevatedGetSite);
// After code execution in EstablishSharepoint(), following code will be executed
// and fills a TreeView (tv in this example) with all First-Level-Folders and their Subfolders
TreeNode MainNode = new TreeNode("Web-Folders");
TreeNode n = null;
int index = 0;foreach (SPFolder f in web.Folders)
{
n = new TreeNode();
n.Text = f.Name;
n.Tag = f.ParentWeb.Url + "/" + f.Url;
n.ToolTipText = f.ParentWeb.Url + "/" + f.Url;
index = MainNode.Nodes.Add(n);
foreach (SPFolder sf in f.SubFolders)
{
n = new TreeNode();
n.Text = sf.Name;
n.Tag = sf.ParentWeb.Url + "/" + sf.Url;
n.ToolTipText = sf.ParentWeb.Url + "/" + sf.Url;
MainNode.Nodes[index].Nodes.Add(n);
}
}
tv.Nodes.Add(MainNode);
}
Examples of ExpandUserField
<ExpandUserField>FALSE</ExpandUserField> looks like:
ows_Author="1;#Admin AdminName"
<ExpandUserField>TRUE</ExpandUserField> looks like:
ows_Author="1;#Admin
AdminName,#login\name,#email@address,#sip@address,#Admin AdminName "
So, you're query in the CAML Builder should look like the following:
<Where>
<Ge>
<FieldRef
Name="EventDate" />
<Value
Type="DateTime">2005-5-27T00:00:00Z</Value>
</Ge>
</Where>
I know, this way your date is static and I
suppose you want it dynamic. If you build your CAML query dynamically in code,
you can use functions like
SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today). This will
convert your date from a DateTime value into a CAML Date format, which is the
ISO8601 format.
try {
UpdateEditionDate(properties);
}
catch (Exception e)
{
throw new Exception("Dispatcher, UpdateEditionDate(): Exception: [" + e.ToString() + "].");
}
This showed up in the 12 hive thusly:
Error loading and running event receiver Conchango.xyzzyEventReceiver in
xyzzy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blahblahblah. Additional
information is below. : Dispatcher, UpdateEditionDate(): Exception:
[System.NullReferenceException: Object reference not set to an instance of an
object. at
Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties
properties) at
Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties
properties, String eventDescription)].
That gave me all the detail I needed to track down that particular
You need to declare that you are using the ID:
<Query>
<Where>
<Eq>
<FieldRef Name='Fruit' LookupId='TRUE' />
<Value Type='Lookup'>15</Value>
</Eq>
</Where>
</Query>
public override void
FeatureActivated(SPFeatureReceiverProperties
properties)
{
using (SPWeb
_SPWeb = properties.Web)
{
// the
name of the list is set in the ListInstance Element
of
// this
Feature
SPList _SPList = (SPList)_SPWeb.Lists["ListName"];if
(_SPList !=
null)
{
// add a new lookup field to the
list
_SPList.Fields.AddLookup("LookupField", _SPList.ID,
false);
// update the
list
_SPList.Update();
// get a reference to the SPFieldLookup we just
added
SPFieldLookup _SPFieldLookup = new SPFieldLookup(_SPList.Fields, "LookupField");
// get a reference to the default
view
SPView _SPView = _SPList.DefaultView;
// add the field to the view if it is not
there
if
(!_SPView.ViewFields.Exists("LookupField"))
{
_SPView.ViewFields.Add(_SPFieldLookup);
}
// update the
view
_SPView.Update();
}
}
}
You can use this method like
this:
SPFieldLookup
lookup = CreateLookupField("CustomLookup",
"Custom fields", false, false, SPContext.Current.Site.RootWeb, SPContext.Current.Site.AllWebs["MyWeb"].Lists["CustomList"], "Title");
The next step is to link the
created Lookup Field to the existing Content Type:
public
static void
LinkFieldToContentType(SPWeb web, string contentType, SPField field)
{
SPContentType ct =
web.ContentTypes[contentType];
ct.FieldLinks.Add(new SPFieldLink(field));
ct.Update();
}
As we have just created a
method returning the created
Items: 40 | Visits: 3362
Created by: Ainis
Items: 27 | Visits: 2041
Created by: Anne Bubnic
Items: 10 | Visits: 889
Created by: Claire Miller
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo