var dataQry = QueryNew("temp"); /* TODO: Determine if we need to filter the buildRecurrenceDateTimeQuery during the build process */ var dateTimeQry = application.ptCalendar.calEventRecurrenceService.buildRecurrenceDateTimeQuery( eventID=arguments.eventID ,recurrenceID=arguments.recurrenceID ,removeExceptions=arguments.removeExceptions ); /*startDate=arguments.startDate ,enddate=arguments.enddate*/ SELECT * FROM dateTimeQry WHERE 1 = 1 AND calEventID = AND recurrenceID = AND CAST( dateTimeQry.eventDate AS DATE ) BETWEEN CAST( AS DATE ) AND CAST( AS DATE ) AND CAST( dateTimeQry.eventDate AS DATE ) >= CAST( AS DATE ) AND dtHashID = ORDER BY eventDate, AllDay DESC, StartTime // Get the data from the Recurrence Properties VIEW var dataQry = QueryNew("temp"); // Get the dateTime field for the query columns var dateTimeColNameStruct = application.ptCalendar.calEventDateTimeDAO.getDateTimeQueryColumnListStruct(); var newQryColList = dateTimeColNameStruct.columnNames; var newQryDataTypes = dateTimeColNameStruct.dataTypes; var newQry = QueryNew(newQryColList,newQryDataTypes); var datetimeQry = QueryNew("temp"); var rcItm = 1; var dtItm = 1; var c = 1; var recID = ""; var temp = ""; var qRowCnt = 0; var createQryRow = true; var startDateCheck = 0; var endDateCheck = 0; // None of the following feilds are required for the getRecurrenceQuery method: // recurrenceID - Creates the standardize date/time query from the returned record // eventID - Creates the standardize date/time query from the returned record (ready if event are allow to have multiple recurrence records) // StartDate - if a startDate is passed in the pass it to the getRecurrenceQuery to set the experationDate and only get back records // that have not expired (rangeEndDate is not passed) and all the records that have a rangeQuantity // EndDate - Not used in the getRecurrenceQuery ... at this time dataQry = application.ptCalendar.calEventRecurrenceDAO.getRecurrenceQuery( recurrenceID=arguments.recurrenceID ,eventID=arguments.eventID ,startDate=arguments.startDate ,endDate=arguments.endDate ); // Loop over the records in the recurrence properties query for ( rcItm=1; rcItm LTE dataQry.RecordCount; rcItm=rcItm+1 ) { // set the recID to the current uniqueID from the recurrence properties recID = dataQry["uniqueID"][rcItm]; // build out the dates/time query set for ONE recurrence properties record datetimeQry = application.ptCalendar.calEventRecurrenceService.buildRecurrenceDateTimeQueryByID( recurrenceID=recID ,removeExceptions=arguments.removeExceptions ); // Loop over the generated data/time records query for ( dtItm=1; dtItm LTE datetimeQry.RecordCount; dtItm=dtItm+1 ) { // Allow all rows to be created unless a startdate and enddate or startdate were provided createQryRow = true; // Filter row creation by the startDate and endDate if ( LEN(TRIM(arguments.startDate)) AND LEN(TRIM(arguments.endDate)) ) { startDateCheck = DateCompare(datetimeQry["eventdate"][dtItm],arguments.startDate); endDateCheck = DateCompare(datetimeQry["eventdate"][dtItm],arguments.endDate); if ( startDateCheck GTE 0 AND endDateCheck LTE 0 ) createQryRow = true; else createQryRow = false; } // Filter row creation by the startDate only else if ( LEN(TRIM(arguments.startDate)) ) { startDateCheck = DateCompare(datetimeQry["eventdate"][dtItm],arguments.startDate); if ( startDateCheck GTE 0 ) createQryRow = true; else createQryRow = false; } // Before creating the next query row make sure the createQryRow is true (does the new record have valid date) if ( createQryRow ) { temp = QueryAddRow( newQry ); qRowCnt = qRowCnt + 1; for ( c=1; c LTE ListLen(newQryColList); c=c+1) { colName = ListGetAt(newQryColList,c); if ( StructKeyExists(datetimeQry,colName) AND LEN(TRIM(datetimeQry[ colName ][ dtItm ])) ) { temp = QuerySetCell(newQry, colName, datetimeQry[ colName ][ dtItm ], qRowCnt); //newQry[ colName ][ qRowCnt ] = datetimeQry[ colName ][ dtItm ]; } else { temp = QuerySetCell(newQry, colName, "", qRowCnt); //newQry[ colName ][ qRowCnt ] = ""; } } } } } return newQry; var recurrenceQry = QueryNew("temp"); var dataQry = QueryNew("temp"); var rowDataStruct = StructNew(); var dateDataArray = ArrayNew(1); var newDateArray = ArrayNew(1); var recurrenceData = StructNew(); var exclHashIDlist = ""; // Get the recurrence data for the passed in recurrenceID if ( LEN(TRIM(arguments.recurrenceID)) ) { // Get the recurrence data by the recurrenceID (uniqueID) recurrenceQry = application.ptCalendar.calEventRecurrenceDAO.getRecurrenceQuery(recurrenceID=arguments.recurrenceID); } // if data exists process it and build recurrence date/time query if ( recurrenceQry.RecordCount ) { // Get the data from the first row of the query as a structure recurrenceData = application.ptCalendar.data.queryRowToStruct(query=recurrenceQry,rowNum=1); // Build a clean tmpData struct from recurrenceData values //recurrenceData = application.ptCalendar.recurrenceBuilderService.buildCleanRecurrenceData(rowDataStruct); // Excluded HashID list if ( StructKeyExists(recurrenceData,"excludedDThashIDlist") AND LEN(TRIM(recurrenceData.excludedDThashIDlist)) ) exclHashIDlist = recurrenceData.excludedDThashIDlist; // Build Event Date array based on patternType switch(recurrenceData.patternType) { case "Daily": dateDataArray = createDailyDateTimeArray(recurrenceData); break; case "Weekly": dateDataArray = createWeeklyDateTimeArray(recurrenceData); break; case "Monthly": dateDataArray = createMonthlyDateTimeArray(recurrenceData); break; case "Yearly": dateDataArray = createYearlyDateTimeArray(recurrenceData); break; } // Send the dateDataArray to the createDateTimeQueryFromDates to build the Query dataQry = createDateTimeQueryFromDates( recurrenceData=recurrenceData ,dateArray=dateDataArray ,startDate=arguments.startDate ,endDate=arguments.endDate ,appdebug=arguments.appdebug ); } SELECT * FROM dataQry WHERE var currData = arguments.recurrenceData; var newDateArray = arguments.dateArray; // Get the dateTime fields for the query columns var dateTimeColNameStruct = application.ptCalendar.calEventDateTimeDAO.getDateTimeQueryColumnListStruct(); var dateTimeQryColList = dateTimeColNameStruct.columnNames; var dateTimeQryDataTypes = dateTimeColNameStruct.dataTypes; var dataQry = QueryNew(dateTimeQryColList,dateTimeQryDataTypes); var itm = 1; var x = 1; var h = 1; var dummyDate = getTimeDummyDate(); var dummyDayBeginTime = getDayBeginTime(); var dummyDayEndTime = getDayEndTime(); var csEventDateTimeStamp = ""; var endDateTimeStamp = ""; var startDateCheck = 0; var endDateCheck = 0; var temp = QueryNew("temp"); var createQryRow = false; var qRowCnt = 0; var recurrenceID = ""; var calEventID = ""; var recurStartTime = ""; var recurEndTime = ""; var recurAllDay = ""; //var exclHashIDlist = ""; // Extra fields for debugging recurrence patterns var debugQueryFields = "EventDateFull,EVENTDATETIMESTAMP"; var debugQueryDataTypes = "varchar,date"; // Add the extra date/time field names and dataTypes for better visualization of the converted data if ( arguments.appdebug ) { for ( x=1; x LTE ListLen(debugQueryFields); x=x+1 ) { dateTimeQryColList = ListAppend(dateTimeQryColList,ListGetAt(debugQueryFields,x)); dateTimeQryDataTypes = ListAppend(dateTimeQryDataTypes,ListGetAt(debugQueryDataTypes,x)); dataQry = QueryNew(dateTimeQryColList,dateTimeQryDataTypes); } } // Set the recurrenceID column to the the recurrence records uniqueID if ( StructKeyExists(currData,"uniqueID") ) recurrenceID = currData.uniqueID; // Set the calEventID column to the the recurrence records calEventID if ( StructKeyExists(currData,"calEventID") ) calEventID = currData.calEventID; // Set the recurAllDay, recurStartTime and recurEndTime based on the recurAllDay value if ( StructKeyExists(currData,"recurAllDay") AND currData.recurAllDay EQ 1 ) { recurAllDay = 1; recurStartTime = ""; recurEndTime = ""; } else { recurAllDay = ""; if ( StructKeyExists(currData,"recurStartTime") ) { recurStartTime = application.ptCalendar.date.csDateFormat(dummyDate,currData.recurStartTime); if ( StructKeyExists(currData,"recurEndTime") AND LEN(TRIM(currData.recurEndTime)) ) recurEndTime = application.ptCalendar.date.csDateFormat(dummyDate,currData.recurEndTime); } } // Moved this FILTER up to the buildRecurrenceDateTimeQueryByID) // Excluded HashID list //if ( StructKeyExists(currData,"excludedDThashIDlist") AND LEN(TRIM(currData.excludedDThashIDlist)) ) //exclHashIDlist = currData.excludedDThashIDlist; // Create Query records from newDateArray for ( itm=1; itm LTE ArrayLen(newDateArray); itm=itm+1 ) { // Format the date as CS dateTime stamps for the start of the date and for the end of the day csEventDateTimeStamp = application.ptCalendar.date.csDateFormat(newDateArray[itm],dummyDayBeginTime); endDateTimeStamp = application.ptCalendar.date.csDateFormat(newDateArray[itm],dummyDayEndTime); // Allow all rows to be created unless a startdate and enddate or startdate were provided... then do filtering createQryRow = true; // Filter row creation by the startDate and endDate if ( LEN(TRIM(arguments.startDate)) AND LEN(TRIM(arguments.endDate)) ) { startDateCheck = DateCompare(csEventDateTimeStamp,arguments.startDate); endDateCheck = DateCompare(endDateTimeStamp,arguments.endDate); if ( startDateCheck GTE 0 AND endDateCheck LTE 0 ) createQryRow = true; else createQryRow = false; } // Filter row creation by the startDate only else if ( LEN(TRIM(arguments.startDate)) ) { startDateCheck = DateCompare(csEventDateTimeStamp,arguments.startDate); if ( startDateCheck GTE 0 ) createQryRow = true; else createQryRow = false; } // NOTE: Moved the following FILTER up to the buildRecurrenceDateTimeQueryByID // - Should be faster do a NOT IN in a QofQs instead of LOOPING over the validateHashID method // Filter row creation by the excluded dtHashID list in the Recurrence Properties list /* if ( LEN(TRIM(exclHashIDlist)) ) { createQryRow = true; for ( h=1; h LTE ListLen(exclHashIDlist); h=h+1 ) { // Check to see if the any of the HashIDs in the list match the current values for the event date/time record // - if an ID is found to not generate the row in the query hashIDcheck = application.ptCalendar.validateHashID(ListGetAt(exclHashIDlist,h), calEventID, recurrenceID, csEventDateTimeStamp, recurStartTime, recurEndTime, recurAllDay); if ( hashIDcheck ) { createQryRow = false; break; } } } */ // Before creating the next query row make sure the createQryRow is true (does the new record have valid date) if ( createQryRow ) { temp = QueryAddRow( dataQry ); qRowCnt = qRowCnt + 1; // Set the dateTimeID column to a new UUID (currData DOES NOT have a dateTimeID to pass in) // TODO: May not be needed since this value is only valid if using the Events Cache value otherwise it updates every time //temp = QuerySetCell( dataQry, "dateTimeID", CreateUUID(), qRowCnt ); // IMPORTANT: DO NOT GIVE RECURRENCE DATETIME RECORDS A DATETIMEID untill are recurrence exceptions and are moved to the DateTime Element // But they need to have the column in the Query for standarized data format for the UNION of Recurrence DateTime and Static DateTime records temp = QuerySetCell( dataQry, "dateTimeID", "", qRowCnt ); // Generate the HashID from specific fields are not dynamic (ie. do not use 'dateTimeID') // - This value should be unique and static even if calling directly and not using the Events Cache newHashID = application.ptCalendar.buildHashID(calEventID, recurrenceID, csEventDateTimeStamp, recurStartTime, recurEndTime, recurAllDay); temp = QuerySetCell( dataQry, "dtHashID", newHashID, qRowCnt ); // Set the recurrenceID column to the recurrence records ( aka. the uniqueID) temp = QuerySetCell( dataQry, "recurrenceID", recurrenceID, qRowCnt ); // Set the calEventID column to the recurrence records calEventID value temp = QuerySetCell( dataQry, "calEventID", calEventID, qRowCnt ); // Set the eventDate column to the csEventDateTimeStamp value temp = QuerySetCell( dataQry, "eventDate", csEventDateTimeStamp, qRowCnt ); // Set the startTime column to the recurStartTime value temp = QuerySetCell( dataQry, "startTime", recurStartTime, qRowCnt ); // Set the endTime column to the recurEndTime value temp = QuerySetCell( dataQry, "endTime", recurEndTime, qRowCnt ); // Set the allDay column to the recurAllDay value temp = QuerySetCell( dataQry, "allDay", recurAllDay, qRowCnt ); // Add in the extra date/time fields (ie, a full data/time stamp for better visualization of the converted recurrence pattern) if ( arguments.appdebug ) { temp = QuerySetCell( dataQry, "EVENTDATEFULL", DateFormat(csEventDateTimeStamp,"full"), qRowCnt ); temp = QuerySetCell( dataQry, "EVENTDATETIMESTAMP", csEventDateTimeStamp, qRowCnt ); } } } return dataQry; var tmpData = arguments.recurrenceData; var newDate = ""; var dateArray = ArrayNew(1); var itm = 1; var r = 1; var errorMsg = ""; var errorData = StructNew(); try { // Make sure we are only processing daily recurrence data if ( tmpData.patternType EQ "Daily") { // daily - pattern options if ( tmpData.patternOption EQ "EveryXDays" ) { // Add the Start Date as the first date in the recurrence newDate = tmpData.rangeStartDate; if ( IsDate(newDate) ) ArrayAppend(dateArray,newDate); // If no patternDayQty is defined the make the event everyday of the week if ( NOT IsNumeric(tmpData.patternDayQty) OR tmpData.patternDayQty LT 1 ) tmpData.patternDayQty = 1; // Create the date Array based on the Range End Type if ( IsDate(newDate) AND tmpData.rangeEndType EQ "EndDate" AND IsDate(tmpData.rangeEndDate) ) { // End Date while ( newDate LT tmpData.rangeEndDate ) { newDate = DateAdd("d",tmpData.patternDayQty,newDate); // Make sure the dates added to the date array are not greater than the enddate if ( newDate LTE tmpData.rangeEndDate ) ArrayAppend(dateArray,newDate); } } else if ( IsDate(newDate) AND tmpData.rangeEndType EQ "EndQuantity" AND IsNumeric(tmpData.rangeQuantity) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { newDate = DateAdd("d",tmpData.patternDayQty,newDate); ArrayAppend(dateArray,newDate); } } } else if ( tmpData.patternOption EQ "EveryWeekday" ) { // Add the Start Date as the first date in the recurrence newDate = tmpData.rangeStartDate; if ( IsDate(newDate) AND DayOfWeek(newDate) GT 1 AND DayOfWeek(newDate) LT 7 ) ArrayAppend(dateArray,newDate); // Create the date Array based on the Range End Type if ( IsDate(newDate) AND tmpData.rangeEndType EQ "EndDate" AND IsDate(tmpData.rangeEndDate) ) { // End Date while (newDate LT tmpData.rangeEndDate) { newDate = DateAdd("d",1,newDate); if ( DayOfWeek(newDate) GT 1 AND DayOfWeek(newDate) LT 7 ) ArrayAppend(dateArray,newDate); } } else if ( IsDate(newDate) AND tmpData.rangeEndType EQ "EndQuantity" AND IsNumeric(tmpData.rangeQuantity) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { newDate = DateAdd("d",1,newDate); if ( DayOfWeek(newDate) GT 1 AND DayOfWeek(newDate) LT 7 ) ArrayAppend(dateArray,newDate);; } } } } //END - createDailyDateTimeArray } catch ( any e ) { errorMsg = "Error: Unable to create the Daily DateTime Array"; errorData.data = arguments.recurrenceData; errorData.details = e; doErrorLogging("calEventRecurrenceService-Daily","createDailyDateTimeArray",errorData,errorMsg,"ptCalendar"); } return dateArray; var tmpData = arguments.recurrenceData; var newDate = ""; var fowDate = ""; var dateArray = ArrayNew(1); var itm = 1; var r = 1; var w = 1; var errorMsg = ""; var errorData = StructNew(); try { // Make sure we are only processing weekly recurrence data if ( tmpData.patternType EQ "Weekly") { // weekly - pattern options // 1) Set the Start Date // 2) Find the first of the week date (from the start date) // 3) Find the First selected Day after the select start date // 4) Loop over rangeQuantity or rangeEndDate // - Loop over the Days of the Week inside the rangeEndType // Set the start date ... but it may not be the start of the dateArray series newDate = tmpData.rangeStartDate; if ( LEN(TRIM(newDate)) AND IsDate(newDate) ) { // Get the First of the Week date from the Start Date fowDate = application.ptCalendar.date.firstDayOfWeek(newDate); // set the First of the Week date as the newDate newDate = fowDate; // Create the date Array based on the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while (newDate LT tmpData.rangeEndDate) { // Loop over the days of the current week for ( w=1; w LTE 7; w=w+1 ) { // if the day is a selected day of the week and is greater than or equal to the start date add it to the array if ( ListFindNoCase(tmpData.patternDOW,DayOfWeek(newDate)) AND newDate GTE tmpData.rangeStartDate AND newDate LTE tmpData.rangeEndDate ) { // Add this Date to the dateArray arrayAppend(dateArray,newDate); } // Create the date for the next day of the week newDate = DateAdd("d",1,newDate); } // Get the next First of the Week date from the last First of the Week date fowDate = application.ptCalendar.date.getNextFirstOfWeekDate(inDate=fowDate,addQty=tmpData.patternWeekQty); // set the next First of the Week date as the newDate for the next loop pass newDate = fowDate; } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { // loop over each day of the current week for ( w=1; w LTE 7; w=w+1 ) { // if the day is a selected day of the week and is greater than or equal to the start date add it to the array if ( ListFindNoCase(tmpData.patternDOW,DayOfWeek(newDate)) AND newDate GTE tmpData.rangeStartDate ) { // Add this Date to the dateArra arrayAppend(dateArray,newDate); } // Create the date for the next day of the week newDate = DateAdd("d",1,newDate); } // Get the next First of the Week date from the last First of the Week date fowDate = application.ptCalendar.date.getNextFirstOfWeekDate(inDate=fowDate,addQty=tmpData.patternWeekQty); // set the next First of the Week date as the newDate for the next loop pass newDate = fowDate; } } } } //END - createWeeklyDateTimeArray } catch ( any e ) { errorMsg = "Error: Unable to create the Weekly DateTime Array"; errorData.data = arguments.recurrenceData; errorData.details = e; doErrorLogging("calEventRecurrenceService-Weekly","createWeeklyDateTimeArray",errorData,errorMsg,"ptCalendar"); } return dateArray; var tmpData = arguments.recurrenceData; var dateArray = ArrayNew(1); var newDate = ""; var fomDate = ""; var lomDate = ""; var errorMsg = ""; var errorData = StructNew(); try { // Make sure we are only processing Monthly recurrence data if ( tmpData.patternType EQ "Monthly") { // Set the start date... but it may not be the start of the dateArray series newDate = tmpData.rangeStartDate; // monthly - pattern options if ( tmpData.patternOption EQ "MonthlyDayX" ) { // Create the date for the first occurrence if ( LEN(TRIM(tmpData.patternMonthlyDayNumber)) ) newDate = CreateDate(Year(newDate),Month(newDate),tmpData.patternMonthlyDayNumber); else newDate = CreateDate(Year(newDate),Month(newDate),1); // Create the date Array based on the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while ( newDate LTE tmpData.rangeEndDate ) { if ( newDate GTE tmpData.rangeStartDate ) //AND newDate LT tmpData.rangeEndDate ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { if ( newDate GTE tmpData.rangeStartDate ) ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); } } } else if ( tmpData.patternOption EQ "MonthlyXY" ) { // Monthly on the XY pattern date creation if ( tmpData.patternMonthlyDayOrdinal EQ "first" ) { // Get the Last day of the month for the selected start date fomDate = application.ptCalendar.date.firstOfMonth(Month(newDate),Year(newDate)); // set the Frist of the Month date as the newDate newDate = fomDate; // Create the date Array based on first of the month dates and the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while ( newDate LTE tmpData.rangeEndDate ) { if ( newDate GTE tmpData.rangeStartDate ) //AND newDate LT tmpData.rangeEndDate ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); newDate = application.ptCalendar.date.firstOfMonth(Month(newDate),Year(newDate)); } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { if ( newDate GTE tmpData.rangeStartDate ) ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); newDate = application.ptCalendar.date.firstOfMonth(Month(newDate),Year(newDate)); } } } else if ( tmpData.patternMonthlyDayOrdinal EQ "last" ) { // Get the Last day of the month for the selected start date lomDate = application.ptCalendar.date.lastOfMonth(Month(newDate),Year(newDate)); // set the Last of the Month date as the newDate newDate = lomDate; // Create the date Array based on last of the month dates and the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while ( newDate LTE tmpData.rangeEndDate ) { if ( newDate GTE tmpData.rangeStartDate ) //AND newDate LT tmpData.rangeEndDate ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); newDate = application.ptCalendar.date.lastOfMonth(Month(newDate),Year(newDate)); } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { if ( newDate GTE tmpData.rangeStartDate ) ArrayAppend(dateArray,newDate); // Create the date for the next month newDate = DateAdd("m",tmpData.patternMonthQty,newDate); newDate = application.ptCalendar.date.lastOfMonth(Month(newDate),Year(newDate)); } } } } } //END - createMonthlyDateTimeArray } catch ( any e ) { errorMsg = "Error: Unable to create the Monthly DateTime Array"; errorData.data = arguments.recurrenceData; errorData.details = e; doErrorLogging("calEventRecurrenceService-Monthly","createMonthlyDateTimeArray",errorData,errorMsg,"ptCalendar"); } return dateArray; var tmpData = arguments.recurrenceData; var dateArray = ArrayNew(1); var newDate = ""; var errorMsg = ""; var errorData = StructNew(); try { // Make sure we are only processing Yearly recurrence data if ( tmpData.patternType EQ "Yearly") { // Set the start date... but it may not be the start of the dateArray series newDate = tmpData.rangeStartDate; // yearly - pattern options if ( tmpData.patternOption EQ "YearlyXY" ) { // Create the date for the first occurrence if ( LEN(TRIM(tmpData.patternYearlyMonth)) AND LEN(TRIM(tmpData.patternYearlyDayNumber)) ) newDate = CreateDate(Year(newDate),tmpData.patternYearlyMonth,tmpData.patternYearlyDayNumber); // Create the date Array based on the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while ( newDate LTE tmpData.rangeEndDate ) { if ( newDate GTE tmpData.rangeStartDate ) //AND newDate LT tmpData.rangeEndDate ArrayAppend(dateArray,newDate); // Create the date for the next year newDate = DateAdd("yyyy",tmpData.patternYearQty,newDate); } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { if ( newDate GTE tmpData.rangeStartDate ) ArrayAppend(dateArray,newDate); // Create the date for the next year newDate = DateAdd("yyyy",tmpData.patternYearQty,newDate); } } } else if ( tmpData.patternOption EQ "YearlyXYofZ" ) { // Yearly on the XY of the Z pattern date creation if ( tmpData.patternYearlyDayOrdinal EQ "first" ) { // set the Frist of the Month date as the newDate newDate = application.ptCalendar.date.firstOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } else if ( tmpData.patternYearlyDayOrdinal EQ "last" ) { // Get the Last day of the month for the selected start date newDate = application.ptCalendar.date.lastOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } // make sure the first newDate is greater than the rangeStartDate if ( newDate LT tmpData.rangeStartDate ) { newDate = application.ptCalendar.date.getNextYearOrdinalDayDate( inYear=Year(newDate) ,inMonth=Month(newDate) ,inDay=Day(newDate) ,ordinalDay=tmpData.patternYearlyDayOrdinal ,addQty=1 ); } // Create the date Array based on the Range End Type if ( tmpData.rangeEndType EQ "EndDate" AND LEN(TRIM(tmpData.rangeEndDate)) ) { // End Date while ( newDate LTE tmpData.rangeEndDate ) { if ( newDate GTE tmpData.rangeStartDate ) //AND newDate LT tmpData.rangeEndDate ArrayAppend(dateArray,newDate); // Create the date for the next X year(s) newDate = application.ptCalendar.date.getNextYearOrdinalDayDate( inYear=Year(newDate) ,inMonth=Month(newDate) ,inDay=Day(newDate) ,ordinalDay=tmpData.patternYearlyDayOrdinal ,addQty=tmpData.patternYearQty ); /* // Create the date for the next year newDate = DateAdd("yyyy",tmpData.patternYearQty,newDate); // before the next loop make sure the next years date is either the first or the last of the month if ( tmpData.patternYearlyDayOrdinal EQ "first" ) { // set the First of the Month date as the newDate newDate = application.ptCalendar.date.firstOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } else if ( tmpData.patternYearlyDayOrdinal EQ "last" ) { // set the Last of the Month date as the newDate newDate = application.ptCalendar.date.lastOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } */ } } else if ( tmpData.rangeEndType EQ "EndQuantity" AND LEN(TRIM(tmpData.rangeQuantity)) ) { // End Quantity while ( ArrayLen(dateArray) LT tmpData.rangeQuantity ) { if ( newDate GTE tmpData.rangeStartDate ) ArrayAppend(dateArray,newDate); // Create the date for the next X year(s) newDate = application.ptCalendar.date.getNextYearOrdinalDayDate( inYear=Year(newDate) ,inMonth=Month(newDate) ,inDay=Day(newDate) ,ordinalDay=tmpData.patternYearlyDayOrdinal ,addQty=tmpData.patternYearQty ); /* // Create the date for the next year newDate = DateAdd("yyyy",tmpData.patternYearQty,newDate); // before the next loop make sure the next years date is either the first or the last of the month if ( tmpData.patternYearlyDayOrdinal EQ "first" ) { // set the First of the Month date as the newDate newDate = application.ptCalendar.date.firstOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } else if ( tmpData.patternYearlyDayOrdinal EQ "last" ) { // set the Last of the Month date as the newDate newDate = application.ptCalendar.date.lastOfMonth(tmpData.patternYearlyWeekDayMonth,Year(newDate)); } */ } } } } //END - createYearlyDateTimeArray } catch ( any e ) { errorMsg = "Error: Unable to create the Yearly DateTime Array"; errorData.data = arguments.recurrenceData; errorData.details = e; doErrorLogging("calEventRecurrenceService-Yearly","createYearlyDateTimeArray",errorData,errorMsg,"ptCalendar"); } return dateArray; var dataArray = ArrayNew(1); var retStatusStruct = StructNew(); var copyStatusStruct = StructNew(); var dataValues = StructNew(); var newData = ""; var itm = 1; if ( LEN(TRIM(arguments.srcUUIDlist)) ) dataArray = application.ptCalendar.recurrenceBuilderDAO.getRecurrence(uniqueID=TRIM(arguments.srcUUIDlist)); for ( itm = 1; itm LTE ArrayLen(dataArray); itm=itm+1 ) { // Reset the dataValues struct dataValues = StructNew(); if ( StructKeyExists(dataArray[itm],"values") ) { // Copy all the values of the existing source record to the destination struct dataValues = dataArray[itm].values; // Update the calEventID of the Destination record with arguments.calEventID from the newly create event dataValues.calEventID = arguments.calEventID; // Create a New UniqueID for the new Destination Record dataValues.uniqueID = CreateUUID(); // Process the CCAPI call to create the new records copyStatusStruct = application.ptCalendar.recurrenceBuilderDAO.recurrenceCCAPI(dataValues); // If the CCAPI create the newEvent record set the newEventID in the return struct if ( copyStatusStruct["CONTENTUPDATED"] IS true ) { // Add the copy status for this iteration to the return struct retStatusStruct[dataValues.uniqueID] = copyStatusStruct; retStatusStruct[dataValues.uniqueID]["calEventID"] = arguments.calEventID; retStatusStruct[dataValues.uniqueID]["newRecurrenceD"] = dataValues.uniqueID; } else { retStatusStruct[dataValues.uniqueID]["msg"] = "failed"; retStatusStruct[dataValues.uniqueID]["CONTENTUPDATED"] = false; retStatusStruct[dataValues.uniqueID]["calEventID"] = arguments.calEventID; retStatusStruct[dataValues.uniqueID]["newRecurrenceD"] = ""; // TODO: Log CCAPI content create failure } } else { // TODO: Log recurrence get issues } } return retStatusStruct; var retStatusStruct = StructNew(); var dataValues = StructNew(); var status = ""; var dataArray = StructNew(); var recurrenceData = StructNew(); retStatusStruct['MSG'] = "failed"; retStatusStruct['CONTENTUPDATED'] = false; retStatusStruct['STATUS'] = status; // Get the Element Record Data for the passed in FeedID dataArray = application.ptCalendar.recurrenceBuilderDAO.getRecurrence( uniqueID=TRIM(arguments.recurrenceID) ); if ( ArrayLen(dataArray) ) recurrenceData = dataArray[1]; if ( StructKeyExists(recurrenceData,"values") ) { // Copy existing values and dataPageID to the dataValues struct dataValues = recurrenceData.values; dataValues.dataPageID = recurrenceData.PageID; if ( StructKeyExists(recurrenceData.values,"excludedDThashIDlist") ) { if ( ListFindNoCase(recurrenceData.values.excludedDThashIDlist,arguments.hashID) EQ 0 ) { dataValues.excludedDThashIDlist = ListAppend(recurrenceData.values.excludedDThashIDlist,arguments.hashID); status = "updated"; } } else { dataValues.excludedDThashIDlist = arguments.hashID; status = "updated"; } } if ( status EQ "updated" ) { // Call the CCAPI to update the element retStatusStruct = application.ptCalendar.recurrenceBuilderDAO.recurrenceCCAPI(dataValues); } if ( retStatusStruct['CONTENTUPDATED'] IS true ) { retStatusStruct['MSG'] = 'success'; retStatusStruct['STATUS'] = status; } return retStatusStruct; var retStatusStruct = StructNew(); var dataValues = StructNew(); var status = ""; var dataArray = StructNew(); var recurrenceData = StructNew(); var idPos = 0; retStatusStruct['MSG'] = "failed"; retStatusStruct['CONTENTUPDATED'] = false; retStatusStruct['STATUS'] = status; // Get the Element Record Data for the passed in FeedID dataArray = application.ptCalendar.recurrenceBuilderDAO.getRecurrence( uniqueID=TRIM(arguments.recurrenceID) ); if ( ArrayLen(dataArray) ) recurrenceData = dataArray[1]; if ( StructKeyExists(recurrenceData,"values") ) { // Copy existing values and dataPageID to the dataValues struct dataValues = recurrenceData.values; dataValues.dataPageID = recurrenceData.PageID; if ( LEN(TRIM(arguments.hashID)) ) { if ( StructKeyExists(recurrenceData.values,"excludedDThashIDlist") ) { idPos = ListFindNoCase(recurrenceData.values.excludedDThashIDlist,arguments.hashID); if ( idPos ) { dataValues.excludedDThashIDlist = ListDeleteAt(recurrenceData.values.excludedDThashIDlist,idPos); status = "removed"; } } } else { dataValues.excludedDThashIDlist = ""; status = "removedAll"; } } if ( status EQ "removed" OR status EQ "removedAll") { // Call the CCAPI to update the element retStatusStruct = application.ptCalendar.recurrenceBuilderDAO.recurrenceCCAPI(dataValues); } if ( retStatusStruct['CONTENTUPDATED'] IS true ) { retStatusStruct['MSG'] = 'success'; retStatusStruct['STATUS'] = status; } return retStatusStruct;