Ejemplo n.º 1
0
 private function BuildRepeatOptions($repeatType, $configurationString)
 {
     $configuration = RepeatConfiguration::Create($repeatType, $configurationString);
     $factory = new RepeatOptionsFactory();
     return $factory->Create($repeatType, $configuration->Interval, $configuration->TerminationDate, $configuration->Weekdays, $configuration->MonthlyType);
 }
Ejemplo n.º 2
0
 /**
  * @param int $instanceId
  * @param Date $startDate
  * @param Date $endDate
  * @param int $resourceId
  * @param int $ownerId
  * @param int $scheduleId
  * @param string $title
  * @param string $description
  * @param string $firstName
  * @param string $lastName
  * @param string $resourceName
  * @param int $seriesId
  * @param string $repeatOptions
  * @param string $repeatType
  */
 public function __construct($instanceId, Date $startDate, Date $endDate, $resourceId, $ownerId, $scheduleId, $title, $description, $firstName, $lastName, $resourceName, $seriesId, $repeatOptions, $repeatType)
 {
     $this->InstanceId = $instanceId;
     $this->StartDate = $startDate;
     $this->EndDate = $endDate;
     $this->ResourceId = $resourceId;
     $this->OwnerId = $ownerId;
     $this->ScheduleId = $scheduleId;
     $this->Title = $title;
     $this->Description = $description;
     $this->FirstName = $firstName;
     $this->LastName = $lastName;
     $this->ResourceName = $resourceName;
     $this->SeriesId = $seriesId;
     $this->Date = new DateRange($startDate, $endDate);
     $this->RepeatConfiguration = RepeatConfiguration::Create($repeatType, $repeatOptions);
     $this->IsRecurring = !empty($repeatType) && $repeatType != RepeatType::None;
 }
Ejemplo n.º 3
0
 public function testConfigurationStringCanBeDeserialized()
 {
     $terminationDate = Date::Parse('2010-12-12 01:06:07', 'UTC');
     $dateString = $terminationDate->ToDatabase();
     $interval = 10;
     // none
     $config = RepeatConfiguration::Create(RepeatType::None, '');
     $this->assertEquals(RepeatType::None, $config->Type);
     // daily
     $daily = new RepeatDaily($interval, $terminationDate);
     $config = RepeatConfiguration::Create($daily->RepeatType(), $daily->ConfigurationString());
     $this->assertEquals(RepeatType::Daily, $config->Type);
     $this->assertEquals(10, $config->Interval);
     $this->assertEquals($terminationDate, $config->TerminationDate);
     // weekly
     $weekdays = array(1, 3, 4, 5);
     $weekly = new RepeatWeekly($interval, $terminationDate, $weekdays);
     $config = RepeatConfiguration::Create($weekly->RepeatType(), $weekly->ConfigurationString());
     $this->assertEquals(RepeatType::Weekly, $config->Type);
     $this->assertEquals($terminationDate, $config->TerminationDate);
     $this->assertEquals($weekdays, $config->Weekdays);
     // day of month
     $dayOfMonth = new RepeatDayOfMonth($interval, $terminationDate);
     $config = RepeatConfiguration::Create($dayOfMonth->RepeatType(), $dayOfMonth->ConfigurationString());
     $this->assertEquals(RepeatType::Monthly, $config->Type);
     $this->assertEquals($terminationDate, $config->TerminationDate);
     $this->assertEquals(RepeatMonthlyType::DayOfMonth, $config->MonthlyType);
     // weekday of month
     $weekOfMonth = new RepeatWeekDayOfMonth($interval, $terminationDate);
     $config = RepeatConfiguration::Create($weekOfMonth->RepeatType(), $weekOfMonth->ConfigurationString());
     $this->assertEquals(RepeatType::Monthly, $config->Type);
     $this->assertEquals($terminationDate, $config->TerminationDate);
     $this->assertEquals(RepeatMonthlyType::DayOfWeek, $config->MonthlyType);
     // yearly
     $yearly = new RepeatYearly($interval, $terminationDate);
     $config = RepeatConfiguration::Create($yearly->RepeatType(), $yearly->ConfigurationString());
     $this->assertEquals(RepeatType::Yearly, $config->Type);
     $this->assertEquals(10, $config->Interval);
     $this->assertEquals($terminationDate, $config->TerminationDate);
 }
Ejemplo n.º 4
0
 /**
  * @param string[] $row
  * @return BlackoutSeries
  */
 public static function FromRow($row)
 {
     $series = new BlackoutSeries($row[ColumnNames::OWNER_USER_ID], $row[ColumnNames::BLACKOUT_TITLE]);
     $series->WithId($row[ColumnNames::BLACKOUT_SERIES_ID]);
     $series->SetCurrentBlackout(new DateRange(Date::FromDatabase($row[ColumnNames::BLACKOUT_START]), Date::FromDatabase($row[ColumnNames::BLACKOUT_END])));
     $series->WithCurrentBlackoutId($row[ColumnNames::BLACKOUT_INSTANCE_ID]);
     $configuration = RepeatConfiguration::Create($row[ColumnNames::REPEAT_TYPE], $row[ColumnNames::REPEAT_OPTIONS]);
     $factory = new RepeatOptionsFactory();
     $options = $factory->Create($row[ColumnNames::REPEAT_TYPE], $configuration->Interval, $configuration->TerminationDate, $configuration->Weekdays, $configuration->MonthlyType);
     $series->WithRepeatOptions($options);
     return $series;
 }
Ejemplo n.º 5
0
 /**
  * @param string $repeatType
  * @param string $configurationString
  * @return RepeatConfiguration
  */
 public static function Create($repeatType, $configurationString)
 {
     $allparts = explode('|', $configurationString);
     $configParts = array();
     if (!empty($allparts[0])) {
         foreach ($allparts as $part) {
             $keyValue = explode('=', $part);
             if (!empty($keyValue[0])) {
                 $configParts[$keyValue[0]] = $keyValue[1];
             }
         }
     }
     $config = new RepeatConfiguration();
     $config->Type = empty($repeatType) ? RepeatType::None : $repeatType;
     $config->Interval = self::Get($configParts, 'interval');
     $config->SetTerminationDate(self::Get($configParts, 'termination'));
     $config->SetWeekdays(self::Get($configParts, 'days'));
     $config->MonthlyType = self::Get($configParts, 'type');
     return $config;
 }