/// <summary> /// Adds the calendar link. /// </summary> /// <param name="folder">The folder.</param> /// <param name="calendar">The calendar.</param> /// <returns></returns> public static CalendarInfo AddCalendarLink(CalendarFolder folder, Calendar calendar) { if (folder == null) { throw new ArgumentNullException("CalendarFolder"); } if (calendar == null) { throw new ArgumentNullException("Calendar"); } if (!folder.GetTreeService().CurrentNode.IsAttached) { throw new ArgumentException("The folder is detached from tree.", "folder"); } //Step 1. Determine for already exist link CalendarFolderLink[] links = CalendarFolderLink.List(new FilterElement("CalendarId", FilterElementType.Equal, calendar.PrimaryKeyId.Value), new FilterElement("FolderId", FilterElementType.Equal, folder.PrimaryKeyId.Value)); if (links.Length != 0) { Calendar cal = new Calendar(links[0].CalendarId); return(new CalendarInfo(cal, links[0])); } CalendarFolderLink link = null; using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Step 2. Create New CalendarFolderLink link = new CalendarFolderLink(); link.CalendarId = calendar.PrimaryKeyId.Value; link.FolderId = folder.PrimaryKeyId.Value; // Raise List Creating Event RaiseEvent(CalendarLinkCreating, link, EventArgs.Empty); // Add additional parameters link.Save(); // Raise List Created Event RaiseEvent(CalendarLinkCreated, link, EventArgs.Empty); // Step. Commit Transaction Return new list info tran.Commit(); } return(new CalendarInfo(calendar, link)); }
/// <summary> /// Deletes the link directly. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> internal static void DeleteLinkDirectly(object sender, EventArgs args) { Calendar calendar = sender as Calendar; if (calendar != null) { CalendarFolderLink[] links = CalendarFolderLink.List(new FilterElement("CalendarId", FilterElementType.Equal, calendar.PrimaryKeyId.Value)); foreach (CalendarFolderLink link in links) { link.Delete(); } } }
/// <summary> /// Deletes the link. /// </summary> /// <param name="link">The link.</param> public static void DeleteLink(CalendarFolderLink link) { if (link == null) { throw new ArgumentNullException("link"); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Raise Calendar link Delete Event RaiseEvent(CalendarLinkDeleting, link, EventArgs.Empty); link.Delete(); RaiseEvent(CalendarLinkDeleted, link, EventArgs.Empty); tran.Commit(); } }
/// <summary> /// Lists the specified folder id. /// </summary> /// <param name="folderId">The folder id.</param> /// <returns></returns> public static CalendarInfo[] GetCalendars(int folderId) { List <CalendarInfo> retVal = new List <CalendarInfo>(); // Load primary list Calendar [] calendars = Calendar.List(new FilterElement("CalendarFolderId", FilterElementType.Equal, folderId)); List <CalendarFolderLink> links = new List <CalendarFolderLink> (CalendarFolderLink.List(new FilterElement("FolderId", FilterElementType.Equal, folderId))); //Get primary calendar foreach (Calendar calendar in calendars) { CalendarInfo newItem = new CalendarInfo(calendar, null); foreach (CalendarFolderLink link in new List <CalendarFolderLink>(links)) { //remove duplicate if (link.CalendarId == calendar.PrimaryKeyId.Value) { links.Remove(link); } } retVal.Add(newItem); } //Get links foreach (CalendarFolderLink link in links) { Calendar calendar = new Calendar(link.CalendarId); CalendarInfo newItem = new CalendarInfo(calendar, link); retVal.Add(newItem); } return(retVal.ToArray()); }
/// <summary> /// Adds the calendar link. /// </summary> /// <param name="folder">The folder.</param> /// <param name="calendar">The calendar.</param> /// <returns></returns> public static CalendarInfo AddCalendarLink(CalendarFolder folder, Calendar calendar) { if (folder == null) throw new ArgumentNullException("CalendarFolder"); if (calendar == null) throw new ArgumentNullException("Calendar"); if (!folder.GetTreeService().CurrentNode.IsAttached) throw new ArgumentException("The folder is detached from tree.", "folder"); //Step 1. Determine for already exist link CalendarFolderLink[] links = CalendarFolderLink.List(new FilterElement("CalendarId", FilterElementType.Equal, calendar.PrimaryKeyId.Value), new FilterElement("FolderId", FilterElementType.Equal, folder.PrimaryKeyId.Value)); if (links.Length != 0) { Calendar cal = new Calendar(links[0].CalendarId); return new CalendarInfo(cal, links[0]); } CalendarFolderLink link = null; using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Step 2. Create New CalendarFolderLink link = new CalendarFolderLink(); link.CalendarId = calendar.PrimaryKeyId.Value; link.FolderId = folder.PrimaryKeyId.Value; // Raise List Creating Event RaiseEvent(CalendarLinkCreating, link, EventArgs.Empty); // Add additional parameters link.Save(); // Raise List Created Event RaiseEvent(CalendarLinkCreated, link, EventArgs.Empty); // Step. Commit Transaction Return new list info tran.Commit(); } return new CalendarInfo(calendar, link); }
public CalendarFolderLink(int primaryKeyId) : base(CalendarFolderLink.GetAssignedMetaClass(), primaryKeyId) { }
/// <summary> /// Initializes a new instance of the <see cref="CalendarInfo"/> class. /// </summary> /// <param name="calendar">The calendar.</param> /// <param name="link">The link.</param> public CalendarInfo(Calendar calendar, CalendarFolderLink link) { _calendarLink = link; _calendar = calendar; }
/// <summary> /// Deletes the link. /// </summary> /// <param name="link">The link.</param> public static void DeleteLink(CalendarFolderLink link) { if (link == null) throw new ArgumentNullException("link"); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Raise Calendar link Delete Event RaiseEvent(CalendarLinkDeleting, link, EventArgs.Empty); link.Delete(); RaiseEvent(CalendarLinkDeleted, link, EventArgs.Empty); tran.Commit(); } }
public CalendarFolderLink(CustomTableRow row, MetaObjectOptions options) : base(CalendarFolderLink.GetAssignedMetaClass(), row, options) { }
public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.FilterElement[] filters) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), filters)); }
public static CalendarFolderLink[] List() { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass())); }
public CalendarFolderLink(CustomTableRow row) : base(CalendarFolderLink.GetAssignedMetaClass(), row) { }
public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.SortingElement[] sorting) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), sorting)); }
public CalendarFolderLink(MetaObjectOptions options) : base(CalendarFolderLink.GetAssignedMetaClass(), options) { }
public CalendarFolderLink() : base(CalendarFolderLink.GetAssignedMetaClass()) { }
public static int GetTotalCount(params FilterElement[] filters) { return(MetaObject.GetTotalCount(CalendarFolderLink.GetAssignedMetaClass(), filters)); }
public static CalendarFolderLink[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), filters, sorting, start, count)); }
public CalendarFolderLink(int primaryKeyId, MetaObjectOptions options) : base(CalendarFolderLink.GetAssignedMetaClass(), primaryKeyId, options) { }