Ejemplo n.º 1
0
        protected ListDictionary CreateScheduleEventParam(ScheduleEvent scheduleEvent, bool modify)
        {
            if (scheduleEvent.EventType != ScheduleEventType.Normal && scheduleEvent.EventType != ScheduleEventType.Banner)
            {
                return(null);
            }
            if (scheduleEvent.MemberCount == 0)
            {
                return(null);
            }

            ListDictionary schedule_event = new ListDictionary();

            schedule_event["xmlns"]       = "";
            schedule_event["id"]          = modify ? scheduleEvent.ID : "dummy";
            schedule_event["event_type"]  = scheduleEvent.EventType.ToString().ToLowerInvariant();
            schedule_event["version"]     = modify ? scheduleEvent.Version : "dummy";
            schedule_event["public_type"] = scheduleEvent.PublicType.ToString().ToLowerInvariant();
            schedule_event["plan"]        = scheduleEvent.Plan;
            schedule_event["detail"]      = scheduleEvent.Detail;
            schedule_event["description"] = scheduleEvent.Description;
            schedule_event["allday"]      = scheduleEvent.AllDay;
            schedule_event["start_only"]  = scheduleEvent.StartOnly;

            schedule_event["members"] = PrepareMembers(scheduleEvent);

            schedule_event["when"] = CreateWhen(scheduleEvent);

            return(schedule_event);
        }
Ejemplo n.º 2
0
        protected ListDictionary CreateWhen(ScheduleEvent scheduleEvent)
        {
            ListDictionary when = new ListDictionary();

            if (scheduleEvent.AllDay || scheduleEvent.EventType == ScheduleEventType.Banner)
            {
                ListDictionary date = new ListDictionary();
                date["start"] = Utility.FormatXSDDate(scheduleEvent.Start);
                if (!scheduleEvent.StartOnly)
                {
                    date["end"] = Utility.FormatXSDDate(scheduleEvent.End);
                }
                when["date"] = date;
            }
            else
            {
                ListDictionary datetime = new ListDictionary();
                datetime["start"] = Utility.FormatISO8601(scheduleEvent.Start.ToUniversalTime());
                if (!scheduleEvent.StartOnly)
                {
                    datetime["end"] = Utility.FormatISO8601(scheduleEvent.End.ToUniversalTime());
                }
                when["datetime"] = datetime;
            }
            return(when);
        }
Ejemplo n.º 3
0
        public ScheduleEventCollection AddEvents(ScheduleEventCollection scheduleEvents)
        {
            ListDictionary parameters          = new ListDictionary();
            ArrayList      schedule_event_list = new ArrayList();

            foreach (ScheduleEvent scheduleEvent in scheduleEvents)
            {
                ListDictionary schedule_event = CreateScheduleEventParam(scheduleEvent, false);
                if (schedule_event == null)
                {
                    continue;
                }
                schedule_event_list.Add(schedule_event);
            }
            parameters["schedule_event"] = schedule_event_list;

            XmlElement  result        = this.App.Exec("Schedule", "ScheduleAddEvents", parameters);
            XmlNodeList eventNodeList = result.SelectNodes("//schedule_event");

            ScheduleEventCollection eventList = new ScheduleEventCollection();

            foreach (XmlNode eventNode in eventNodeList)
            {
                try
                {
                    ScheduleEvent scheduleEvent = new ScheduleEvent(eventNode);
                    eventList.Add(scheduleEvent);
                }
                catch (Exception)
                {
                }
            }

            return(eventList);
        }
Ejemplo n.º 4
0
        public ScheduleEventCollection GetEventsByTarget(DateTime start, DateTime end, TargetType targetType, string targetId)
        {
            if (string.IsNullOrEmpty(targetId))
            {
                throw new CybozuException("Target ID is not specified.");
            }

            ListDictionary parameters = new ListDictionary();

            parameters["start"] = Utility.FormatXSDDateTime(start);
            parameters["end"]   = Utility.FormatXSDDateTime(end);
            ListDictionary idParam = new ListDictionary();

            idParam["id"] = targetId;
            parameters[targetType.ToString().ToLowerInvariant()] = idParam;

            XmlElement  resultNode    = this.App.Query("Schedule", "ScheduleGetEventsByTarget", parameters);
            XmlNodeList eventNodeList = resultNode.SelectNodes("//schedule_event");

            ScheduleEventCollection eventList = new ScheduleEventCollection();

            foreach (XmlNode eventNode in eventNodeList)
            {
                try
                {
                    ScheduleEvent scheduleEvent = new ScheduleEvent(eventNode);
                    eventList.Add(scheduleEvent);
                }
                catch (Exception)
                {
                }
            }

            return(eventList);
        }
Ejemplo n.º 5
0
        public ScheduleEvent AddEvent(ScheduleEvent scheduleEvent)
        {
            if (scheduleEvent.EventType != ScheduleEventType.Normal && scheduleEvent.EventType != ScheduleEventType.Banner)
            {
                throw new CybozuException("Cannot add the event of the specified type.");
            }

            if (scheduleEvent.MemberCount == 0)
            {
                throw new CybozuException("No participants.");
            }

            ListDictionary parameters = new ListDictionary();

            parameters["schedule_event"] = CreateScheduleEventParam(scheduleEvent, false);

            XmlElement result = this.App.Exec("Schedule", "ScheduleAddEvents", parameters);

            return(new ScheduleEvent(result.SelectSingleNode("//schedule_event")));
        }
Ejemplo n.º 6
0
        protected ListDictionary PrepareMembers(ScheduleEvent scheduleEvent)
        {
            ArrayList memberList = new ArrayList();

            foreach (string userId in scheduleEvent.UserIds)
            {
                ListDictionary user = new ListDictionary();
                user["id"] = userId;
                ListDictionary member = new ListDictionary();
                member["user"] = user;
                memberList.Add(member);
            }

            foreach (string orgId in scheduleEvent.OrganizaitonIds)
            {
                ListDictionary org = new ListDictionary();
                org["id"] = orgId;
                ListDictionary member = new ListDictionary();
                member["organization"] = org;
                memberList.Add(member);
            }

            foreach (string facilityId in scheduleEvent.FacilityIds)
            {
                ListDictionary facility = new ListDictionary();
                facility["id"] = facilityId;
                ListDictionary member = new ListDictionary();
                member["facility"] = facility;
                memberList.Add(member);
            }

            ListDictionary members = new ListDictionary();

            members["member"] = memberList;
            return(members);
        }
Ejemplo n.º 7
0
        public void ModifyEvent(ScheduleEvent scheduleEvent)
        {
            if (scheduleEvent.EventType != ScheduleEventType.Normal && scheduleEvent.EventType != ScheduleEventType.Banner)
            {
                throw new CybozuException("Cannot modify the event of the specified type.");
            }

            if (scheduleEvent.MemberCount == 0)
            {
                throw new CybozuException("No participants.");
            }

            ListDictionary parameters     = new ListDictionary();
            ListDictionary schedule_event = new ListDictionary();

            parameters["schedule_event"] = CreateScheduleEventParam(scheduleEvent, true);

            XmlElement result = this.App.Exec("Schedule", "ScheduleModifyEvents", parameters);

            if (result.SelectSingleNode("//schedule_event") == null)
            {
                throw new CybozuException("Fail to modify the specified event.");
            }
        }