예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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();
                }
            }
        }
예제 #3
0
        /// <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();
            }
        }
예제 #4
0
        /// <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());
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
 public CalendarFolderLink(int primaryKeyId)
     : base(CalendarFolderLink.GetAssignedMetaClass(), primaryKeyId)
 {
 }
예제 #7
0
파일: CalendarInfo.cs 프로젝트: 0anion0/IBN
 /// <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;
 }
예제 #8
0
        /// <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();
            }
        }
예제 #9
0
 public CalendarFolderLink(CustomTableRow row, MetaObjectOptions options)
     : base(CalendarFolderLink.GetAssignedMetaClass(), row, options)
 {
 }
예제 #10
0
 public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), filters));
 }
예제 #11
0
 public static CalendarFolderLink[] List()
 {
     return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass()));
 }
예제 #12
0
 public CalendarFolderLink(CustomTableRow row)
     : base(CalendarFolderLink.GetAssignedMetaClass(), row)
 {
 }
예제 #13
0
 public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), sorting));
 }
예제 #14
0
 public CalendarFolderLink(MetaObjectOptions options)
     : base(CalendarFolderLink.GetAssignedMetaClass(), options)
 {
 }
예제 #15
0
 public CalendarFolderLink()
     : base(CalendarFolderLink.GetAssignedMetaClass())
 {
 }
예제 #16
0
 public static int GetTotalCount(params FilterElement[] filters)
 {
     return(MetaObject.GetTotalCount(CalendarFolderLink.GetAssignedMetaClass(), filters));
 }
예제 #17
0
 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));
 }
예제 #18
0
 public CalendarFolderLink(int primaryKeyId, MetaObjectOptions options)
     : base(CalendarFolderLink.GetAssignedMetaClass(), primaryKeyId, options)
 {
 }
예제 #19
0
 /// <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;
 }