public static void RaiseSaved(SharepointList list, TemplateDataBase item) { if (Saved != null) { Saved(null, new SharepointItemEventArgs(item, list, null)); } }
public static bool Validate(SharepointList list, TemplateDataBase item) { if (IsValid != null) { var cancelArgs = new CancelSharepointItemEventArgs(item, list) { Cancel = false }; IsValid(null, cancelArgs); return !cancelArgs.Cancel; } return true; }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (ReadListItems != null ? ReadListItems.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SharepointServerResourceId.GetHashCode(); hashCode = (hashCode * 397) ^ (SharepointList != null ? SharepointList.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FilterCriteria != null ? FilterCriteria.GetHashCode() : 0); hashCode = (hashCode * 397) ^ RequireAllCriteriaToMatch.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SharepointServerResourceId.GetHashCode(); hashCode = (hashCode * 397) ^ (SharepointList != null ? SharepointList.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReadListItems != null ? ReadListItems.GetHashCode() : 0); return(hashCode); } }
public static void RaisePrepareForSaveAsync(SharepointList list, TemplateDataBase item, Action callback) { if (PrepareForSave != null) { var asyncManager = new asyncManager(PrepareForSave.GetInvocationList().OfType<EventHandler<SharepointItemEventArgs>>(), callback, list, item); asyncManager.Start(); } else { if (callback != null) { callback(); } } }
public override string[] GetList(string filter = "*.*") { List <string> resultList = new List <string>(); try { SP.ListItemCollection spListItems = SharepointList.GetItems(SP.CamlQuery.CreateAllItemsQuery(20, "Title")); SharepointClientContext.Load(spListItems); SharepointClientContext.ExecuteQuery(); foreach (SP.ListItem spListItem in spListItems) { string fileName = spListItem.FieldValues["FileLeafRef"].ToString(); if (Operators.LikeString(fileName, filter, CompareMethod.Text)) { resultList.Add(fileName); } } } catch { } return(resultList.ToArray()); }
public static void CreateNewItem(SharepointList list, Dictionary<string, object> item, Action<bool, ICollection<TemplateDataBase>, Exception> callback) { TemplateDataBase tditem = new TemplateDataBase { ListName = list.Name, Data = item }; SharepointEvents.RaisePrepareForSaveAsync(list, tditem, () => { var wslist = CreateListSoapClient(list); Action doCreateItem = () => { SharepointListWrapper wrapper = new SharepointListWrapper(); wrapper.List = list; wrapper.Callback = (success, spList, data) => { if (callback != null) { callback(success, data, wrapper.Exception); } }; wslist.UpdateListItemsCompleted += new EventHandler<UpdateListItemsCompletedEventArgs>(wslist_UpdateListItemsCompleted); var batch = CreateBatch(false); AddBatchMethod(batch, "New", GetFieldValue(list, item, false)); wrapper.Batch = batch; wslist.UpdateListItemsAsync(list.Name, batch, wrapper); }; EnsureSharepointListColumnsCreated(list, (ex) => { if (callback != null) callback(false, null, ex); }, wslist, doCreateItem); }); }
private void appendForSynchro(SharepointList spl) { if (spl != null //&& (spl.LastSyncTime == null || (DateTime.Now - spl.LastSyncTime) > SyncRefresh) && spl.Name != SynchronizingListName) { pendingSynchro.Enqueue(spl); } }
public SharepointItemEventArgs(TemplateDataBase item, SharepointList list, Action asyncCallback) { this.Item = item; this.List = list; this.asyncCallback = asyncCallback; }
//public void SyncData(SharepointList sharepointList, // Action<IEnumerable<TemplateDataBase>> callback) //{ // if (pendingSynchro.Contains(sharepointList)) // { // SharepointSite.DownloadListChanges(sharepointList, (success, list, data) => // { // HandleSyncResult(callback, success, list, data); // }); // } // else // { // if (callback != null) // { // callback(Store.ReadListData(sharepointList)); // } // } //} private void HandleSyncResult(Action<IEnumerable<TemplateDataBase>> callback, bool success, SharepointList list, ICollection<TemplateDataBase> data) { if (!success) { if (callback != null) callback(Store.ReadListData(list)); } else { list.SaveListData(data); if (callback != null) { callback(data); } } }
/// <summary> /// Download list changes /// </summary> /// <param name="list">The SharepointList to be downloaded</param> /// <param name="callback">The callback fucntion to be called. bool : true when succes, SharepointList : the list synchronized </param> public static void DownloadListChanges(SharepointList list, Action<bool, SharepointList, ICollection<TemplateDataBase>> callback, bool checkOffline) { DownloadListChanges(new SharepointListWrapper { List = list, Callback = callback, CheckOffline = checkOffline }); }
public CancelSharepointItemEventArgs(TemplateDataBase item, SharepointList list) { this.Item = item; this.List = list; }
public static XElement[] GetFieldValue(SharepointList list, Dictionary<string, object> newValue, bool update) { List<XElement> values = new List<XElement>(); foreach (var column in list.Columns) { object value; if (newValue.TryGetValue(column.StaticName, out value)) { if (column.IsReadOnly && !(update && column.StaticName == TemplateDataBase.ColumnId)) continue; var field = new XElement("Field", new XAttribute("Name", column.StaticName)); column.SetFieldValue(field, value); values.Add(field); } } return values.ToArray(); }
public asyncManager(IEnumerable<EventHandler<SharepointItemEventArgs>> delegates, Action endCallback, SharepointList list, TemplateDataBase item) { queue = new Queue<EventHandler<SharepointItemEventArgs>>(delegates); this.endCallback = endCallback; this.list = list; this.item = item; }
public static void GetListItem(SharepointList list, string id, Action<bool, Exception, TemplateDataBase> callback) { GetListItems(list, new XElement("Query", new XElement("Where", new XElement("Eq", new XElement("FieldRef", new XAttribute("Name", "ID")), new XElement("Value", new XAttribute("Type", "Number"), id) ) ) ), (success, ex, data) => { if (callback != null) callback(success, ex, data != null ? data.FirstOrDefault() : null); }); }
public static void GetList(SharepointList list, Action<bool, Exception> callback) { var wslist = CreateListSoapClient(list); EnsureSharepointListColumnsCreated(list, (ex) => { if (callback != null) { callback(false, ex); } }, wslist, () => { if (callback != null) { callback(true, null); } }); }
public static void DownloadListChanges(SharepointList list, Action<bool, SharepointList, ICollection<TemplateDataBase>> callback) { DownloadListChanges(list, callback, true); }
private static void EnsureSharepointListColumnsCreated(SharepointList list, Action<Exception> exceptionCallback, ListsSoapClient wslist, Action doAction) { if (list.Columns == null) { wslist.GetListCompleted += (o, args) => { if (args.Error != null) { if (exceptionCallback != null) exceptionCallback(args.Error); } else { list.ParseColumns(args.Result); doAction(); } }; wslist.GetListAsync(list.Name); } else { doAction(); } }
private static ListsSoapClient CreateListSoapClient(SharepointList list) { if (list.ServerUri == null) throw new NullReferenceException("ServerUri for list " + list.Name + " is null"); return CreateListSoapClient(list.ServerUri); }
public static void GetListItems(SharepointList list, XElement query, Action<bool, Exception, IEnumerable<TemplateDataBase>> callback , string rowLimit, XElement queryOptions) { var wslist = CreateListSoapClient(list); Action action = () => { wslist.GetListItemsCompleted += (o, e) => { if (e.Error != null) { if (callback != null) { callback(false, e.Error, null); } } else { var data = (from r in e.Result.Elements(XName.Get("data", Xmlnsrs)) from d in r.Elements(XName.Get("row", Xmlnsz)) let item = list.ParseData(d) where item != null select item); if (callback != null) { callback(true, null, data); } } }; var view = new XElement("ViewFields"); foreach (var item in list.Columns) { view.Add(new XElement("FieldRef", new XAttribute("Name", item.StaticName))); } wslist.GetListItemsAsync(list.Name, null, query, view, rowLimit, queryOptions, null); }; EnsureSharepointListColumnsCreated(list, (ex) => { if (callback != null) callback(false, ex, null); }, wslist, action); }
public static void GetListItems(SharepointList list, XElement query, Action<bool, Exception, IEnumerable<TemplateDataBase>> callback) { GetListItems(list, query, callback, null, null); }