Пример #1
0
        /// <summary>
        /// Creates the folder.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static CalendarFolder CreateFolder(CalendarFolder parent, string name)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }


            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Create Detached Folder
                CalendarFolder newRoot = new CalendarFolder();

                newRoot.Title     = name;
                newRoot.ProjectId = parent.ProjectId;
                newRoot.Owner     = parent.Owner;
                newRoot.Save();

                // Append to
                TreeNode node = parent.GetTreeService().AppendChild(newRoot);
                parent.Save();

                tran.Commit();

                return(newRoot);
            }
        }
Пример #2
0
        /// <summary>
        /// Deletes the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        public static void DeleteFolder(CalendarFolder folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                TreeService treeService = folder.GetTreeService();

                //Erase all child folders
                foreach (TreeNode node in TreeManager.GetAllChildNodes(treeService.CurrentNode))
                {
                    CalendarFolder childFolder = (CalendarFolder)node.InnerObject;
                    EraseFolder(childFolder);
                    treeService.RemoveChild(node.ObjectId);
                    childFolder.Delete();
                }

                //Erase current folder
                EraseFolder(folder);
                folder.Delete();

                tran.Commit();
            }
        }
Пример #3
0
        /// <summary>
        /// Moves the calendar.
        /// </summary>
        /// <param name="calendar">The calendar.</param>
        /// <param name="newFolder">The new folder.</param>
        public static void MoveCalendar(Calendar calendar, CalendarFolder newFolder)
        {
            if (calendar == null)
            {
                throw new ArgumentNullException("calendar");
            }
            if (newFolder == null)
            {
                throw new ArgumentNullException("newFolder");
            }

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Raise Calendar Moving
                RaiseEvent(CalendarMoving, calendar, EventArgs.Empty);

                calendar.CalendarFolderId = newFolder.PrimaryKeyId.Value;
                calendar.Owner            = newFolder.Owner;

                calendar.Save();

                RaiseEvent(CalendarMoved, calendar, EventArgs.Empty);

                tran.Commit();
            }
        }
Пример #4
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));
        }
Пример #5
0
        /// <summary>
        /// Lists the specified folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <returns></returns>
        public static CalendarInfo[] GetCalendars(CalendarFolder folder)
        {
            CalendarInfo[] retVal = new CalendarInfo[] { };

            if (folder != null)
            {
                retVal = GetCalendars(folder.PrimaryKeyId.Value);
            }

            return(retVal);
        }
Пример #6
0
        /// <summary>
        /// Gets the public root.
        /// </summary>
        /// <returns></returns>
        public static CalendarFolder GetPublicRoot()
        {
            CalendarFolder[] nodes = CalendarFolder.List(FilterElement.IsNullElement(TreeService.ParentIdFieldName),
                                                         FilterElement.IsNullElement("ProjectId"));

            if (nodes.Length > 0)
            {
                return(nodes[0]);
            }

            // Create Public Root
            return(CreateRootNode("Public", null, null));
        }
Пример #7
0
        /// <summary>
        /// Gets the private root.
        /// </summary>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        public static CalendarFolder GetPrivateRoot(int ownerId)
        {
            CalendarFolder[] nodes = CalendarFolder.List(FilterElement.IsNullElement(TreeService.ParentIdFieldName),
                                                         FilterElement.EqualElement("Owner", ownerId),
                                                         FilterElement.IsNullElement("ProjectId"));

            if (nodes.Length > 0)
            {
                return(nodes[0]);
            }

            // Create Private Root
            return(CreateRootNode(string.Format(CultureInfo.InvariantCulture, "Private_{0}", ownerId), null, ownerId));
        }
Пример #8
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);
        }
Пример #9
0
        /// <summary>
        /// Erases the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        private static void EraseFolder(CalendarFolder folder)
        {
            CalendarInfo[] calendarsInfo = GetCalendars(folder);

            foreach (CalendarInfo calInfo in calendarsInfo)
            {
                if (calInfo.IsLink())
                {
                    DeleteLink(calInfo.CalendarLink);
                }
                else
                {
                    DeleteCalendar(calInfo.Calendar);
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Creates the calendar.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="name">The name.</param>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        public static CalendarInfo CreateCalendar(CalendarFolder folder, string name, int?ownerId)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            if (!folder.GetTreeService().CurrentNode.IsAttached)
            {
                throw new ArgumentException("The folder is dettached from tree.", "folder");
            }

            Calendar newItem = null;

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Step 1. Create New Calendar
                newItem = new Calendar();
                newItem.CalendarFolderId = folder.PrimaryKeyId.Value;
                newItem.Title            = name;
                newItem.Owner            = ownerId;

                // Raise List Creating Event
                RaiseEvent(CalendarCreating, newItem, EventArgs.Empty);

                // Add additional parameters
                newItem.Save();

                // Raise List Created Event
                RaiseEvent(CalendarCreated, newItem, EventArgs.Empty);


                // Step. Commit Transaction Return new list info
                tran.Commit();
            }

            return(new CalendarInfo(newItem, null));
        }
Пример #11
0
        /// <summary>
        /// Creates the root.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="projectId">The project id.</param>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        private static CalendarFolder CreateRootNode(string title, int?projectId, int?ownerId)
        {
            if (title == null)
            {
                throw new ArgumentNullException("title");
            }

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Step 1. Create List Folder
                CalendarFolder newRoot = new CalendarFolder();
                newRoot.Title     = title;
                newRoot.ProjectId = projectId;
                newRoot.Owner     = ownerId;
                newRoot.Save();

                // Step 2. Assign Root
                TreeNode retVal = TreeManager.AppendRootNode(Calendar.GetAssignedMetaClass(), newRoot);

                tran.Commit();

                return(newRoot);
            }
        }
Пример #12
0
 public CalendarFolder(int primaryKeyId, MetaObjectOptions options)
     : base(CalendarFolder.GetAssignedMetaClass(), primaryKeyId, options)
 {
 }
Пример #13
0
 public static CalendarFolder[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count)
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass(), filters, sorting, start, count));
 }
Пример #14
0
 public CalendarFolder()
     : base(CalendarFolder.GetAssignedMetaClass())
 {
 }
Пример #15
0
        /// <summary>
        /// Creates the folder.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static CalendarFolder CreateFolder(CalendarFolder parent, string name)
        {
            if (parent == null)
                throw new ArgumentNullException("parent");
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Create Detached Folder
                CalendarFolder newRoot = new CalendarFolder();

                newRoot.Title = name;
                newRoot.ProjectId = parent.ProjectId;
                newRoot.Owner = parent.Owner;
                newRoot.Save();

                // Append to
                TreeNode node = parent.GetTreeService().AppendChild(newRoot);
                parent.Save();

                tran.Commit();

                return newRoot;
            }
        }
Пример #16
0
        /// <summary>
        /// Deletes the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        public static void DeleteFolder(CalendarFolder folder)
        {
            if (folder == null)
                throw new ArgumentNullException("folder");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                TreeService treeService = folder.GetTreeService();

                //Erase all child folders
                foreach (TreeNode node in TreeManager.GetAllChildNodes(treeService.CurrentNode))
                {
                    CalendarFolder childFolder = (CalendarFolder)node.InnerObject;
                    EraseFolder(childFolder);
                    treeService.RemoveChild(node.ObjectId);
                    childFolder.Delete();
                }

                //Erase current folder
                EraseFolder(folder);
                folder.Delete();

                tran.Commit();
            }
        }
Пример #17
0
 /// <summary>
 /// Creates the calendar.
 /// </summary>
 /// <param name="folder">The folder.</param>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public static CalendarInfo CreateCalendar(CalendarFolder folder, string name)
 {
     return CreateCalendar(folder, name, (int?)folder.Owner);
 }
Пример #18
0
        /// <summary>
        /// Creates the calendar.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="name">The name.</param>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        public static CalendarInfo CreateCalendar(CalendarFolder folder, string name, int? ownerId)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (folder == null)
                throw new ArgumentNullException("folder");
            if (!folder.GetTreeService().CurrentNode.IsAttached)
                throw new ArgumentException("The folder is dettached from tree.", "folder");

            Calendar newItem = null;

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Step 1. Create New Calendar
                newItem = new Calendar();
                newItem.CalendarFolderId = folder.PrimaryKeyId.Value;
                newItem.Title = name;
                newItem.Owner = ownerId;

                // Raise List Creating Event
                RaiseEvent(CalendarCreating, newItem, EventArgs.Empty);

                // Add additional parameters
                newItem.Save();

                // Raise List Created Event
                RaiseEvent(CalendarCreated, newItem, EventArgs.Empty);

                // Step. Commit Transaction Return new list info
                tran.Commit();
             }

             return new CalendarInfo(newItem, null);
        }
Пример #19
0
        /// <summary>
        /// Creates the calendar.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static CalendarInfo CreateCalendar(int folderId, string name)
        {
            CalendarFolder folder = new CalendarFolder(folderId);

            return CreateCalendar(folder, name);
        }
Пример #20
0
 public CalendarFolder(CustomTableRow row, MetaObjectOptions options)
     : base(CalendarFolder.GetAssignedMetaClass(), row, options)
 {
 }
Пример #21
0
 public CalendarFolder(CustomTableRow row)
     : base(CalendarFolder.GetAssignedMetaClass(), row)
 {
 }
Пример #22
0
        /// <summary>
        /// Creates the calendar.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static CalendarInfo CreateCalendar(int folderId, string name)
        {
            CalendarFolder folder = new CalendarFolder(folderId);

            return(CreateCalendar(folder, name));
        }
Пример #23
0
 public CalendarFolder(MetaObjectOptions options)
     : base(CalendarFolder.GetAssignedMetaClass(), options)
 {
 }
Пример #24
0
 /// <summary>
 /// Creates the calendar.
 /// </summary>
 /// <param name="folder">The folder.</param>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public static CalendarInfo CreateCalendar(CalendarFolder folder, string name)
 {
     return(CreateCalendar(folder, name, (int?)folder.Owner));
 }
Пример #25
0
 public static CalendarFolder[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass(), filters));
 }
Пример #26
0
        /// <summary>
        /// Adds the calendar link.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="calendar">The calendar.</param>
        /// <returns></returns>
        public static CalendarInfo AddCalendarLink(int folderId, Calendar calendar)
        {
            CalendarFolder folder = new CalendarFolder(folderId);

            return(AddCalendarLink(folder, calendar));
        }
Пример #27
0
        /// <summary>
        /// Creates the root.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="projectId">The project id.</param>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        private static CalendarFolder CreateRootNode(string title, int? projectId, int? ownerId)
        {
            if (title == null)
                throw new ArgumentNullException("title");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Step 1. Create List Folder
                CalendarFolder newRoot = new CalendarFolder();
                newRoot.Title = title;
                newRoot.ProjectId = projectId;
                newRoot.Owner = ownerId;
                newRoot.Save();

                // Step 2. Assign Root
                TreeNode retVal = TreeManager.AppendRootNode(Calendar.GetAssignedMetaClass(), newRoot);

                tran.Commit();

                return newRoot;
            }
        }
Пример #28
0
 public static int GetTotalCount(params FilterElement[] filters)
 {
     return(MetaObject.GetTotalCount(CalendarFolder.GetAssignedMetaClass(), filters));
 }
Пример #29
0
        /// <summary>
        /// Adds the calendar link.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="calendar">The calendar.</param>
        /// <returns></returns>
        public static CalendarInfo AddCalendarLink(int folderId, Calendar calendar)
        {
            CalendarFolder folder = new CalendarFolder(folderId);

            return AddCalendarLink(folder, calendar);
        }
Пример #30
0
 public static CalendarFolder[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass(), sorting));
 }
Пример #31
0
        /// <summary>
        /// Erases the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        private static void EraseFolder(CalendarFolder folder)
        {
            CalendarInfo[] calendarsInfo = GetCalendars(folder);

            foreach (CalendarInfo calInfo in calendarsInfo)
            {
                if (calInfo.IsLink())
                    DeleteLink(calInfo.CalendarLink);
                else
                    DeleteCalendar(calInfo.Calendar);

            }
        }
Пример #32
0
        /// <summary>
        /// Lists the specified folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <returns></returns>
        public static CalendarInfo[] GetCalendars(CalendarFolder folder)
        {
            CalendarInfo[] retVal = new CalendarInfo[] { };

               if(folder != null)
               {
               retVal = GetCalendars(folder.PrimaryKeyId.Value);
               }

               return retVal;
        }
Пример #33
0
 public CalendarFolder(int primaryKeyId)
     : base(CalendarFolder.GetAssignedMetaClass(), primaryKeyId)
 {
 }
Пример #34
0
        /// <summary>
        /// Moves the calendar.
        /// </summary>
        /// <param name="calendar">The calendar.</param>
        /// <param name="newFolder">The new folder.</param>
        public static void MoveCalendar(Calendar calendar, CalendarFolder newFolder)
        {
            if (calendar == null)
                throw new ArgumentNullException("calendar");
            if (newFolder == null)
                throw new ArgumentNullException("newFolder");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Raise Calendar Moving
                RaiseEvent(CalendarMoving, calendar, EventArgs.Empty);

                calendar.CalendarFolderId = newFolder.PrimaryKeyId.Value;
                calendar.Owner = newFolder.Owner;

                calendar.Save();

                RaiseEvent(CalendarMoved, calendar, EventArgs.Empty);

                tran.Commit();
            }
        }
Пример #35
0
 public static CalendarFolder[] List()
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass()));
 }