public void InitializeStuff()
        {
            myGroup.RetrieveAllEvents();
            // foreach (System.Collections.Generic.KeyValuePair<string, ScheduledEvent> myEvent in myGroup.ScheduledEvents)
            foreach (var _event in myGroup.ScheduledEvents)
            {
                CrestronConsole.PrintLine("Event Read:{0}, {1}:{2}", _event.Value.Name,
                                                _event.Value.DateAndTime.Hour,
                                                _event.Value.DateAndTime.Minute);

            }
            myEvent1 = new ScheduledEvent("Relay 1", myGroup);
            myEvent1.Description = "Relay 1 Desc";
            myEvent1.DateAndTime.SetRelativeEventTime(0, 5);
            myEvent1.Acknowledgeable = true;
            myEvent1.Persistent = true;
            myEvent1.AcknowledgeExpirationTimeout.Hour = 10;
            myEvent1.UserCallBack += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent1.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent1.Name,
                                                myEvent1.DateAndTime.Hour,
                                                myEvent1.DateAndTime.Minute);

            myEvent2 = new ScheduledEvent("Relay 2", myGroup);
            myEvent2.Description = "Relay 2 Desc";
            myEvent2.DateAndTime.SetRelativeEventTime(0, 7);
            myEvent2.Acknowledgeable = true;
            myEvent2.Persistent = false;
            myEvent2.UserCallBack += new ScheduledEvent.UserEventCallBack(myEvent1_UserCallBack);
            myEvent2.Enable();
            CrestronConsole.PrintLine("Event Created:{0}, {1}:{2}", myEvent2.Name,
                                                myEvent2.DateAndTime.Hour,
                                                myEvent2.DateAndTime.Minute);
        }
        /// <summary>
        /// Adds the specified event to the schedule
        /// </summary>
        /// <param name="scheduledEvent">The event to be scheduled, including the date/times the event fires and the callback</param>
        public void Add(ScheduledEvent scheduledEvent)
        {
            if (_algorithm != null)
            {
                scheduledEvent.SkipEventsUntil(_algorithm.UtcTime);
            }

            _scheduledEvents.AddOrUpdate(scheduledEvent.Name, scheduledEvent);
        }
Ejemplo n.º 3
0
 public static void SScheduledEvent(out ScheduledEvent s)
 {
     s.CreatedUser = "******";
     s.Repository = "Reapository A";
     s.ScheduleDescription = "Sample Schedule";
     s.ScheduleEndTime = DateTime.Now.AddDays(1);
     s.ScheduleName = "Sample schedule one";
     s.ScheduleReminderTime = DateTime.Now;
     s.ScheduleStartTime = DateTime.Now.AddDays(-1);
     s.TargetGroupOrUser = "******";
 }
Ejemplo n.º 4
0
 public List<ScheduledEvent> GetScheduledEvents()
 {
     List<ScheduledEvent> events = new List<ScheduledEvent>();
     for (int i = 0; i < 5; i++)
     {
         ScheduledEvent s = new ScheduledEvent();
         Summa.SScheduledEvent(out s);
         events.Add(s);
     }
     return events;
 }
        /// <summary>
        /// Adds the specified event to the schedule
        /// </summary>
        /// <param name="scheduledEvent">The event to be scheduled, including the date/times the event fires and the callback</param>
        public void Add(ScheduledEvent scheduledEvent)
        {
            if (_algorithm != null)
            {
                scheduledEvent.SkipEventsUntil(_algorithm.UtcTime);
            }

            _scheduledEvents[scheduledEvent.Name] = scheduledEvent;
            if (Log.DebuggingEnabled)
            {
                scheduledEvent.IsLoggingEnabled = true;
            }
        }
Ejemplo n.º 6
0
 public void QueueEvent(ScheduledEvent pending)
 {
     lock (_lock)
     {
         AddScheduledEvent(pending);
         if (_waiter != null)
         {
             _waiter.Set();
         }
         else
         {
             WaitExpired(null, false);
         }
     }
 }
Ejemplo n.º 7
0
 private static bool scheduleClear(ScheduledEvent se)
 {
     return lastTime > se.startTime;
 }
Ejemplo n.º 8
0
 public void Remove(ScheduledEvent scheduledEvent)
 {
 }
Ejemplo n.º 9
0
 public void Add(ScheduledEvent scheduledEvent)
 {
 }
 private void OnEventScheduled(object sender, ScheduledEvent @event)
 {
     LbxScheduledEvents.Items.Add(@event);
 }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!Page.User.Identity.IsAuthenticated)
            {
                throw new MyFlightbookException("Unauthorized!");
            }

            int idClub = util.GetIntParam(Request, "c", 0);
            if (idClub == 0)
            {
                throw new MyFlightbookException("Invalid club");
            }

            Club c = Club.ClubWithID(idClub);

            if (c == null)
            {
                throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid club: {0}", idClub));
            }

            string   szIDs  = util.GetStringParam(Request, "sid");
            string[] rgSIDs = szIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (rgSIDs.Length == 0)
            {
                throw new MyFlightbookException("No scheduled events to download specified");
            }

            bool fIsAdmin = c.HasAdmin(Page.User.Identity.Name);

            using (iCalendar ic = new iCalendar())
            {
                ic.AddTimeZone(c.TimeZone);

                string szTitle = string.Empty;

                foreach (string sid in rgSIDs)
                {
                    ScheduledEvent se = ScheduledEvent.AppointmentByID(sid, c.TimeZone);

                    if (se == null)
                    {
                        throw new MyFlightbookException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid scheduled event ID: {0}", sid));
                    }

                    if (!fIsAdmin && Page.User.Identity.Name.CompareOrdinal(se.OwningUser) != 0)
                    {
                        throw new MyFlightbookException("Attempt to download appointment that you don't own!");
                    }

                    ClubAircraft ca = c.MemberAircraft.FirstOrDefault(ca2 => ca2.AircraftID.ToString(System.Globalization.CultureInfo.InvariantCulture).CompareOrdinal(se.ResourceID) == 0);

                    Event ev = ic.Create <Event>();
                    ev.UID           = se.ID;
                    ev.IsAllDay      = false;
                    ev.Start         = new iCalDateTime(se.StartUtc, TimeZoneInfo.Utc.Id);
                    ev.End           = new iCalDateTime(se.EndUtc, TimeZoneInfo.Utc.Id);
                    ev.Start.HasTime = ev.End.HasTime = true;   // has time is false if the ultimate time is midnight.
                    szTitle          = ev.Description = ev.Summary = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}{1}", ca == null ? string.Empty : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - ", ca.DisplayTailnumber), se.Body);
                    ev.Location      = c.HomeAirport == null ? c.HomeAirportCode : String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - {1}", c.HomeAirportCode, c.HomeAirport.Name);

                    Alarm a = new Alarm();
                    a.Action           = AlarmAction.Display;
                    a.Description      = ev.Summary;
                    a.Trigger          = new Trigger();
                    a.Trigger.DateTime = ev.Start.AddMinutes(-30);
                    ev.Alarms.Add(a);

                    ic.Method = "PUBLISH";
                }

                iCalendarSerializer s = new iCalendarSerializer();

                string output = s.SerializeToString(ic);
                Page.Response.Clear();
                Page.Response.ContentType = "text/calendar";
                Response.AddHeader("Content-Disposition", String.Format(System.Globalization.CultureInfo.InvariantCulture, "inline;filename={0}", Branding.ReBrand(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}appt.ics", szTitle)).Replace(" ", "-")));
                Response.Write(output);
                Response.Flush();
                Response.End();
            }
        }
    }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.actMyClubs;

        if (Request.PathInfo.Length > 0 && Request.PathInfo.StartsWith("/", StringComparison.OrdinalIgnoreCase))
        {
            if (!IsPostBack)
            {
                try
                {
                    CurrentClub = Club.ClubWithID(Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture));
                    if (CurrentClub == null)
                    {
                        throw new MyFlightbookException(Resources.Club.errNoSuchClub);
                    }

                    Master.Title       = CurrentClub.Name;
                    lblClubHeader.Text = CurrentClub.Name;

                    ClubMember cm = CurrentClub.GetMember(Page.User.Identity.Name);

                    DateTime dtClub = ScheduledEvent.FromUTC(DateTime.UtcNow, CurrentClub.TimeZone);
                    lblCurTime.Text      = String.Format(CultureInfo.InvariantCulture, Resources.LocalizedText.LocalizedJoinWithSpace, dtClub.ToShortDateString(), dtClub.ToShortTimeString());
                    lblTZDisclaimer.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.TimeZoneDisclaimer, CurrentClub.TimeZone.StandardName);

                    bool fIsAdmin = util.GetIntParam(Request, "a", 0) != 0 && (MyFlightbook.Profile.GetUser(Page.User.Identity.Name)).CanManageData;
                    if (fIsAdmin && cm == null)
                    {
                        cm = new ClubMember(CurrentClub.ID, Page.User.Identity.Name, ClubMember.ClubMemberRole.Admin);
                    }
                    bool fIsManager = fIsAdmin || (cm != null && cm.IsManager);
                    lnkManageClub.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/ClubManage.aspx/{0}", CurrentClub.ID);
                    mvMain.SetActiveView(cm == null ? vwMainGuest : vwSchedules);
                    mvTop.SetActiveView(cm == null ? vwTopGuest : (fIsManager ? vwTopAdmin : vwTopMember));
                    pnlLeaveGroup.Visible = (cm != null && !cm.IsManager);

                    switch (CurrentClub.Status)
                    {
                    case Club.ClubStatus.Promotional:
                        mvPromoStatus.SetActiveView(vwPromotional);
                        string szTemplate = (Page.User.Identity.Name.CompareOrdinal(Page.User.Identity.Name) == 0) ? Resources.Club.clubStatusTrialOwner : Resources.Club.clubStatusTrial;
                        lblPromo.Text = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(szTemplate), CurrentClub.ExpirationDate.Value.ToShortDateString());
                        break;

                    case Club.ClubStatus.Expired:
                    case Club.ClubStatus.Inactive:
                        mvPromoStatus.SetActiveView(vwInactive);
                        lblInactive.Text = Branding.ReBrand(CurrentClub.Status == Club.ClubStatus.Inactive ? Resources.Club.errClubInactive : Resources.Club.errClubPromoExpired);
                        break;

                    default:
                        mvPromoStatus.Visible = false;
                        break;
                    }

                    // Initialize from the cookie, if possible.
                    rbScheduleMode.SelectedValue = SchedulePreferences.DefaultScheduleMode.ToString();

                    RefreshAircraft();
                }
                catch (MyFlightbookException ex)
                {
                    lblErr.Text = ex.Message;
                }
            }

            // Do this every time - if it's a postback in an update panel, it's a non-issue, but if it's full-page, this keeps things from going away.
            RefreshSummary();
        }
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Removes the specified event from the schedule
        /// </summary>
        /// <param name="scheduledEvent">The event to be removed</param>
        public void Remove(ScheduledEvent scheduledEvent)
        {
            _scheduledEvents.TryRemove(scheduledEvent, out scheduledEvent);

            _scheduledEventsSortedByTime = GetScheduledEventsSortedByTime();
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Removes the specified event from the schedule
 /// </summary>
 /// <param name="scheduledEvent">The event to be removed</param>
 public void Remove(ScheduledEvent scheduledEvent)
 {
     _scheduledEvents.TryRemove(scheduledEvent, out scheduledEvent);
 }
Ejemplo n.º 15
0
 public Task AddScheduledEvent(ScheduledEvent @event)
 => _events.InsertOneAsync(@event);
Ejemplo n.º 16
0
        public async Task Setup_ActionRule_Sample_OnceEveryHour_And_between9and11_SendPictureToEmail()
        {
            //Create the hourly recurrence first and add to device
            ScheduledEvent  myHourlyRecurrence = new ScheduledEvent("HourlyRecurrence", new ICalendar(PulseInterval.HOURLY, 1));
            ServiceResponse deviceResponse     = await eventService.Add_ScheduledEventAsync(VALID_IP, VALID_USER, VALID_PASS, myHourlyRecurrence);

            if (deviceResponse.IsSuccess) //Recurrence added
            {
                //Create the Weekdays evening schedule annd add to device
                ScheduledEvent myWeeklyEveningSchedule = new ScheduledEvent("WorkingDays", new ICalendar(new ScheduleTime(17, 30), new ScheduleTime(21), new ScheduleDay[] { ScheduleDay.MO, ScheduleDay.TU, ScheduleDay.WE, ScheduleDay.TH, ScheduleDay.FR }));
                deviceResponse = await eventService.Add_ScheduledEventAsync(VALID_IP, VALID_USER, VALID_PASS, myWeeklyEveningSchedule);

                if (deviceResponse.IsSuccess) //Schedule added
                {
                    //First get the possible templates for the device
                    GetActionTemplatesResponse aTemplates = await actionService.GetActionTemplatesAsync(VALID_IP, VALID_USER, VALID_PASS);

                    if (aTemplates.IsSuccess)
                    {
                        //Now create the action template based on template instance- Send SMTP with picture attached
                        ActionConfiguration SendSMTP = new ActionConfiguration(aTemplates.Templates["com.axis.action.fixed.notification.smtp"]);
                        //Set the action config paramters
                        SendSMTP.Parameters["subject"]    = "Week evenings timeLapse";
                        SendSMTP.Parameters["message"]    = "Photo %d";
                        SendSMTP.Parameters["email_to"]   = "*****@*****.**";
                        SendSMTP.Parameters["email_from"] = "*****@*****.**";
                        SendSMTP.Parameters["host"]       = "smtp-relay.gmail.com";
                        SendSMTP.Parameters["port"]       = "587";
                        SendSMTP.Parameters["login"]      = "";
                        SendSMTP.Parameters["password"]   = "";

                        //Add the action config to the device
                        deviceResponse = await actionService.AddActionConfigurationAsync(VALID_IP, VALID_USER, VALID_PASS, SendSMTP);

                        if (deviceResponse.IsSuccess)
                        {
                            //Get the event instances suppported by the device, the collection will also contain our previously created schedule and recurrence event this way
                            GetEventInstancesResponse eInstances = await eventService.GetEventsInstancesAsync(VALID_IP, VALID_USER, VALID_PASS);

                            ActionRule OnEveryWeekDayEveningHourSendPicture = new ActionRule()
                            {
                                Name          = "OnEveryWeekDayEveningHourSendPicture",
                                Enabled       = true,
                                Trigger       = eInstances.EventInstances.Find(x => x.TopicExpression == "tns1:UserAlarm/tnsaxis:Recurring/Pulse"), //See GetEventInstances output for the correct event name
                                Configuration = SendSMTP,
                            };

                            OnEveryWeekDayEveningHourSendPicture.Trigger.Parameters["id"].Value = myHourlyRecurrence.EventID;
                            //Create and add extra condition to Action Rule
                            EventTrigger OnWeekDayEveningSchedule = eInstances.EventInstances.Find(x => x.TopicExpression == "tns1:UserAlarm/tnsaxis:Recurring/Interval");
                            OnWeekDayEveningSchedule.Parameters["id"].Value     = myWeeklyEveningSchedule.EventID;
                            OnWeekDayEveningSchedule.Parameters["active"].Value = "1";
                            OnEveryWeekDayEveningHourSendPicture.AddExtraCondition(OnWeekDayEveningSchedule);

                            //Create action rule on device
                            deviceResponse = await actionService.AddActionRuleAsync(VALID_IP, VALID_USER, VALID_PASS, OnEveryWeekDayEveningHourSendPicture);

                            Assert.IsTrue(deviceResponse.IsSuccess);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 public void Schedule(ScheduledEvent scheduledEvent)
 {
     _scheduler.Schedule(scheduledEvent.Event, scheduledEvent.Interval);
 }
Ejemplo n.º 18
0
 public async Task HandleScheduledEvent(ScheduledEvent evnt, ILambdaContext context)
 {
     await _queueProcessor.ProcessQueue(context).ConfigureAwait(false);
 }
Ejemplo n.º 19
0
 void myEvent1_UserCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
 {
     if (SchEvent.Name == "Relay 1")
     {
         CrestronConsole.PrintLine("Hitting Relay 1, {0}", DateTime.Now.ToString());
         RelayEvent(1);
     }
     else if (SchEvent.Name == "Relay 2")
     {
         CrestronConsole.PrintLine("Hitting Relay 2, {0}", DateTime.Now.ToString());
         CrestronConsole.PrintLine("Snooze Result: {0}", SchEvent.Snooze(2).ToString());
         RelayEvent(2);
     }
 }
        public async Task <ScheduledEvent[]> FetchScheduledEventsAsync(string[] targetKinds, DateTime from, DateTime to)
        {
            // アクセストークン取得
            var credential = await CredentialProvider.GetUserCredentialAsync();

            if (credential == null)
            {
                return(new ScheduledEvent[0]);
            }

            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "TaskRecorder",
            });

            // Define parameters of request.
            var request = service.Events.List("primary");

            request.TimeMin      = from;
            request.TimeMax      = to;
            request.ShowDeleted  = false;
            request.SingleEvents = true;
            request.MaxResults   = 10;
            request.OrderBy      = EventsResource.ListRequest.OrderByEnum.StartTime;

            // List events.
            var events = await request.ExecuteAsync();

            if (events.Items == null)
            {
                return(new ScheduledEvent[0]);
            }

            var list = new List <ScheduledEvent>(events.Items.Count);

            foreach (var eventItem in events.Items)
            {
                // 時間未定のイベントは無視する
                if (string.IsNullOrEmpty(eventItem.Start.Date) == false)
                {
                    continue;
                }

                // 指定された種別以外は無視する
                var kind = eventItem.GetScheduleKind() ?? "";
                if (targetKinds.Any() &&
                    targetKinds.Contains(kind) == false)
                {
                    continue;
                }

                // 開始時間=終了時間のイベントは無視する
                if (eventItem.Start.DateTime.HasValue &&
                    eventItem.End.DateTime.HasValue &&
                    eventItem.Start.DateTime == eventItem.End.DateTime)
                {
                    continue;
                }

                var e = new ScheduledEvent
                {
                    Id        = eventItem.Id,
                    Kind      = kind,
                    Source    = "GoogleCalendar",
                    Title     = eventItem.Summary,
                    Remarks   = eventItem.Description,
                    StartTime = eventItem.Start.DateTime.Value,
                    EndTime   = eventItem.End.DateTime.Value,
                };

                list.Add(e);
            }

            return(list.ToArray());
        }
Ejemplo n.º 21
0
        public void NextEventTimeIsMaxValueWhenNoEvents()
        {
            var sevent = new ScheduledEvent("test", new DateTime[0], (n, t) => { });

            Assert.AreEqual(DateTime.MaxValue, sevent.NextEventUtcTime);
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.SelectedTab = tabID.actMyClubs;

            if (Request.PathInfo.Length > 0 && Request.PathInfo.StartsWith("/", StringComparison.OrdinalIgnoreCase))
            {
                if (!IsPostBack)
                {
                    try
                    {
                        CurrentClub = Club.ClubWithID(Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture));
                        if (CurrentClub == null)
                        {
                            throw new MyFlightbookException(Resources.Club.errNoSuchClub);
                        }

                        Master.Title = lblClubHeader.Text = HttpUtility.HtmlEncode(CurrentClub.Name);

                        ClubMember cm = CurrentClub.GetMember(Page.User.Identity.Name);

                        DateTime dtClub = ScheduledEvent.FromUTC(DateTime.UtcNow, CurrentClub.TimeZone);
                        lblCurTime.Text      = String.Format(CultureInfo.InvariantCulture, Resources.LocalizedText.LocalizedJoinWithSpace, dtClub.ToShortDateString(), dtClub.ToShortTimeString());
                        lblTZDisclaimer.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.TimeZoneDisclaimer, CurrentClub.TimeZone.StandardName);

                        bool fIsAdmin = util.GetIntParam(Request, "a", 0) != 0 && Profile.GetUser(Page.User.Identity.Name).CanManageData;
                        if (fIsAdmin && cm == null)
                        {
                            cm = new ClubMember(CurrentClub.ID, Page.User.Identity.Name, ClubMember.ClubMemberRole.Admin);
                        }
                        bool fIsManager = fIsAdmin || (cm != null && cm.IsManager);
                        lnkManageClub.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/ClubManage.aspx/{0}", CurrentClub.ID);
                        mvMain.SetActiveView(cm == null ? vwMainGuest : vwSchedules);
                        mvTop.SetActiveView(cm == null ? vwTopGuest : (fIsManager ? vwTopAdmin : vwTopMember));

                        if (cm == null)
                        {
                            accClub.SelectedIndex = 0;
                            acpMembers.Visible    = acpSchedules.Visible = false;
                        }

                        pnlLeaveGroup.Visible = (cm != null && !cm.IsManager);

                        InitStatusDisplay();

                        // Initialize from the cookie, if possible.
                        rbScheduleMode.SelectedValue = SchedulePreferences.DefaultScheduleMode.ToString();

                        if (CurrentClub.PrependsScheduleWithOwnerName)
                        {
                            mfbEditAppt1.DefaultTitle = Profile.GetUser(Page.User.Identity.Name).UserFullName;
                        }

                        RefreshAircraft();

                        if (cm != null)
                        {
                            gvMembers.DataSource = CurrentClub.Members;
                            gvMembers.DataBind();
                            // Hack - trim the last column if not showing mobiles.  This is fragile.
                            if (CurrentClub.HideMobileNumbers)
                            {
                                gvMembers.Columns[gvMembers.Columns.Count - 1].Visible = false;
                            }
                        }

                        InitDownload();
                    }
                    catch (MyFlightbookException ex)
                    {
                        lblErr.Text = ex.Message;
                    }
                }

                // Do this every time - if it's a postback in an update panel, it's a non-issue, but if it's full-page, this keeps things from going away.
                RefreshSummary();
            }
        }
Ejemplo n.º 23
0
 private void AddScheduledEvent(ScheduledEvent pending)
 {
     List<ScheduledEvent> list;
     if (!_pending.TryGetValue(pending.ScheduledTime, out list))
     {
         list = new List<ScheduledEvent>(2);
         _pending[pending.ScheduledTime] = list;
     }
     list.Add(pending);
 }
 private void OnEventFinished(object sender, ScheduledEvent @event)
 {
     LbxScheduledEvents.Items.Remove(@event);
 }