Example #1
0
        /*private void RegisterActivityOpenNotification(PushManager pm, List<NormalActivityInstanceTemplate> activitys)
         * {
         *  foreach (NormalActivityInstanceTemplate activity in activitys)
         *  {
         *      SpecialActivityTemplate specialActivityTemplate = EventTemplateManager.Instance.GetSpecialActivity(activity.activity_id);
         *      if (string.IsNullOrEmpty(specialActivityTemplate.notification_title) || string.IsNullOrEmpty(specialActivityTemplate.notification_content))
         *      {
         *          continue;
         *      }
         *
         *      try
         *      {
         *          string[] start = activity.s.Split(':');
         *          string cronFormat = string.Format("{0} {1} * * {2}", start[1], start[0], specialActivityTemplate.open_time);
         *          TimerScheduler timerScheduler = new TimerScheduler();
         *          timerScheduler.m_TimerRegular = cronFormat;
         *          timerScheduler.ParseTimerRegular();
         *          if (!timerScheduler.isLegalTimer)
         *          {
         *              EB.Debug.LogError("ScheduleActivityLocalNotification: activity cronFormat is illegal");
         *              continue;
         *          }
         *          System.DateTime date = EB.Time.LocalNow;
         *          for (int i = 0; i < 7; ++i)
         *          {
         *              timerScheduler.GetNext(date, out date);
         *              ScheduleActivityLocalNotification(pm, specialActivityTemplate.display_name, specialActivityTemplate.notification_title, specialActivityTemplate.notification_content, date);
         *          }
         *      }
         *      catch
         *      {
         *          EB.Debug.LogError("ScheduleActivityLocalNotification: exception activityid = {0}", activity.activity_id);
         *      }
         *  }
         * }*/

        /*private void RegisterActivityOpenNotification(PushManager pm, LTDailyData activity)
         * {
         *  try
         *  {
         *      System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // ����ʱ��
         *      DateTime dt = startTime.AddSeconds(activity.OpenTimeValue);
         *      string[] WeekStr = activity.OpenTimeWeek.Split(',');
         *      for (int i = 0; i < WeekStr.Length; i++)
         *      {
         *          string cronFormat = string.Format("{0} {1} * * {2}", dt.Minute, dt.Hour, WeekStr[i]);
         *          TimerScheduler timerScheduler = new TimerScheduler();
         *          timerScheduler.m_TimerRegular = cronFormat;
         *          timerScheduler.ParseTimerRegular();
         *          if (!timerScheduler.isLegalTimer)
         *          {
         *              EB.Debug.LogError("ScheduleActivityLocalNotification: activity cronFormat is illegal,index = {0}" , i );
         *              return;
         *          }
         *          DateTime date = EB.Time.LocalNow;
         *          for (int j = 0; j < 7; ++j)
         *          {
         *              timerScheduler.GetNext(date, out date);
         *              ScheduleActivityLocalNotification(pm, activity.ActivityData.display_name, activity.ActivityData.notification_title, activity.ActivityData.notification_content, date);
         *          }
         *      }
         *  }
         *  catch
         *  {
         *      EB.Debug.LogError("ScheduleActivityLocalNotification: exception activityid = {0}", activity.ActivityData.id);
         *  }
         * }*/


        private void ScheduleActivityLocalNotification(PushManager pm, string displayName, string title, string content, System.DateTime time)
        {
            if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(content))
            {
                //EB.Debug.Log("ScheduleActivityLocalNotification: notification activity title={0},time={1}", displayName, time.ToString());
                pm.ScheduleOnceLocalNotification(title, content, time);
            }
            else
            {
                EB.Debug.LogError("ScheduleActivityLocalNotification: activity notification = empty displayName={0}", displayName);
            }
        }