Compile function Notes_Services(@Service, @Params) Declare function Database_Services,obj_Notes_Sent, Get_Status, Error_Services, Obj_Tables, Datetime, SRP_Datetime Declare subroutine Obj_Tables, Obj_Notes_Sent, Update_Index, Errmsg, Database_Services, Btree.Extract, Error_Services Declare subroutine Notes_Services #pragma precomp SRP_PreCompiler $insert LOGICAL $insert NOTE_PTRS_EQU $insert MSG_EQUATES $Insert NOTES_EQU *$Insert NOTES_EQUATES GoToService Return Response or "" //----------------------------------------------------------------------------- // SERVICES //----------------------------------------------------------------------------- Service SnoozeNewMessageNotifications(UserID) Open 'NOTE_PTRS' to hTable then SnoozeTime = Datetime() WriteV SnoozeTime to hTable, UserID, NOTE_PTRS_SNOOZE$ else Errmsg('Error setting snooze.') end end else Errmsg('Error setting snooze.') end end service Service AllowNewMessageNotifications(UserID) Open 'NOTE_PTRS' to hTable then SnoozeTime = '' WriteV SnoozeTime to hTable, UserID, NOTE_PTRS_SNOOZE$ else Errmsg('Error setting snooze.') end end else Errmsg('Error setting snooze.') end end service Service CheckForNotificationSnooze(UserID) SnoozeRow = '' Snoozed = FALSE$ UserRec = Database_Services('ReadDataRow','NOTE_PTRS', @USER4, '', '', '') CurrentTime = Datetime() SnoozeRow = UserRec If SnoozeRow NE '' then CutoffTime = SRP_DateTime("AddMinutes", SnoozeRow, 30) If CurrentTime LE CutoffTime then Snoozed = TRUE$ end else Notes_Services('AllowNewMessageNotifications', @USER4) end end Response = Snoozed end service Service GetInboxMessages(UserID) //debug InboxList = '' UserRec = Database_Services('ReadDataRow','NOTE_PTRS', @USER4, '', '', '') MessageCount = Dcount(UserRec<1>, @VM) For index = 1 to MessageCount ArchiveFlag = UserRec If ArchiveFlag = '' or ArchiveFlag = False$ then InboxList = UserRec InboxList = UserRec InboxList = UserRec InboxList = UserRec InboxList = UserRec InboxList = UserRec InboxList = UserRec end Next index Response = InboxList end service Service GetArchivedMessages(UserID) //debug ArchiveList = '' UserRec = Database_Services('ReadDataRow','NOTE_PTRS', @USER4, '', '', '') MessageCount = Dcount(UserRec<1>, @VM) For index = 1 to MessageCount ArchiveFlag = UserRec If ArchiveFlag = True$ then ArchiveList = UserRec ArchiveList = UserRec ArchiveList = UserRec ArchiveList = UserRec ArchiveList = UserRec ArchiveList = UserRec ArchiveList = UserRec end Next index Response = ArchiveList end service Service UpdateNotes(UserID) ErrorMsg = '' IF UserID = '' THEN ErrorMsg = 'Unassigned Parameter "UserID" passed to object. (':Method:')' IF ErrorMsg NE '' THEN RETURN //OtParms = 'NOTE_PTRS':@RM:UserID //NPRec = obj_Tables('ReadRec',OtParms) ;* If not found then returns null, otherwise reads and sets the lock NPRec = Database_Services('ReadDataRow', 'NOTE_PTRS', UserID) IF LEN(NPRec) > 60000 THEN * Dump the oldest note pointers PtrCnt = COUNT(NPRec, @vm) + (NPRec NE '') FOR N = PtrCnt TO (PtrCnt - 100) STEP -1 NPRec = Delete(NPRec, note_ptrs_subject$, N, 0) NPRec = Delete(NPRec, note_ptrs_from$, N, 0) NPRec = Delete(NPRec, note_ptrs_date$, N, 0) NPRec = Delete(NPRec, note_ptrs_time$, N, 0) NPRec = Delete(NPRec, note_ptrs_new$, N, 0) NPRec = Delete(NPRec, note_ptrs_note_ids$, N, 0) NPRec = Delete(NPRec, note_ptrs_attachment$, N, 0) NPRec = Delete(NPRec, note_ptrs_archived$, N, 0) NEXT N TLen = LEN(NPRec) END NotesSentKeys = obj_Notes_Sent('GetUserKeys',UserID) IF NotesSentKeys NE '' THEN FOR I = 1 TO COUNT(NotesSentKeys,@VM) + (NotesSentKeys NE '') NotesSentKey = NotesSentKeys<1,I> NoteID = FIELD(NotesSentKey,'*',2) LOCATE NoteID IN NPRec USING @VM SETTING POS ELSE NoteRec = XLATE('NOTES',NoteID,'','X') SentFrom = NoteRec SentDate = NoteRec SentTime = NoteRec AttachWindow = NoteRec AttachKeys = NoteRec Subject = NoteRec IF AttachWindow NE '' AND AttachKeys NE '' THEN Attachment = 'Yes' END ELSE Attachment = 'No' END NPRec = INSERT( NPRec, note_ptrs_subject$, 1, 0, Subject ) ;* Add the subject ConvSentFrom = OCONV(SentFrom,'[XLATE_CONV,LSL_USERS*FIRST_LAST]') IF ConvSentFrom NE '' THEN SentFrom = ConvSentFrom NPRec = INSERT( NPRec, note_ptrs_from$, 1, 0, SentFrom ) NPRec = INSERT( NPRec, note_ptrs_date$, 1, 0, OCONV(SentDate,'D2/') ) NPRec = INSERT( NPRec, note_ptrs_time$, 1, 0, OCONV(SentTime,'MTH') ) NPRec = INSERT( NPRec, note_ptrs_new$, 1, 0, 'Yes' ) NPRec = INSERT( NPRec, note_ptrs_note_ids$, 1, 0, NoteID ) NPRec = INSERT( NPRec, note_ptrs_attachment$, 1, 0, Attachment ) NPRec = INSERT( NPRec, note_ptrs_archived$, 1, 0, '0' ) END Database_Services('WriteDataRow', 'NOTE_PTRS', UserID, NPRec, True$, False$, True$) NEXT I IF Get_Status(errCode) THEN ErrMsg(errCode) END ELSE obj_Notes_Sent('Delete',NotesSentKeys) Update_Index('NOTES_SENT','USER_ID','') END END ELSE //obj_Tables('UnlockRec',OtParms) END end service Service GetUnreadMessageCount(UserID) unreadMessageCount = 0 IF UserID NE '' then if xlate( 'NOTE_PTRS', @user4, 'NEW_MESSAGES', 'X' ) then NotePtrRec = xlate( 'NOTE_PTRS', @user4, '', 'X' ) LOCATE 'Yes' in NotePtrRec using @VM setting mPos then *If any are marked as yes, that means there are unread messages for each messageRead in NotePtrRec using @VM if messageRead EQ 'Yes' then unreadMessageCount += 1 Next message end end end Response = unreadMessageCount end service Service GetNewMessages(UserId) NotesSentKeys = '' IF UserId NE '' THEN OPEN 'DICT.NOTES_SENT' TO DictVar THEN SearchString = 'USER_ID':@VM:UserId:@FM Flag = '' Btree.Extract(SearchString,'NOTES_SENT',DictVar,NotesSentKeys,'',Flag) IF Get_Status(errCode) THEN ErrMsg(errCode) RETURN END END end Response = NotesSentKeys end service Service MarkAllAsRead(UserId) if UserID NE '' then NotePtrsRec = Database_Services('ReadDataRow', 'NOTE_PTRS', UserId) NotePtrsStatus = NotePtrsRec for each NotePtrsRead in NotePtrsStatus using @VM setting nPos NotePtrsRec = 'No' Next NotePtrsRead isNPRecCurrent = NotePtrsRec EQ Database_Services('ReadDataRow', 'NOTE_PTRS', UserId) if isNPRecCurrent then Database_Services('WriteDataRow','NOTE_PTRS', UserId, NotePtrsRec, '','', true$) end end else Error_Services('Set', 'Error in Notes Service, MarkAllAsRead. UserId parameter not supplied') end end service