The StatusSheetSender class generates status sheet templates for the current week and sends them out to the managers. For this to work, the resources must provide the ‘Email’ custom attribute with their email address. The actual project data is accessed via tj3client on a tj3 server process.
# File lib/StatusSheetSender.rb, line 25 25: def initialize(appName) 26: super(appName, 'status') 27: 28: # This is a LogicalExpression string that controls what resources should 29: # not be getting a status sheet. 30: @hideResource = '0' 31: # The base directory of the status sheet templates. 32: @templateDir = 'StatusSheetTemplates' 33: # The base directory of the received time sheets. 34: @timeSheetDir = 'TimeSheets' 35: # This file contains the time intervals that the StatusSheetReceiver will 36: # accept as a valid interval. 37: @signatureFile = "#{@templateDir}/acceptable_intervals" 38: # The log file 39: @logFile = 'statussheets.log' 40: 41: @signatureFilter = /^[ ]*statussheet\s[a-z][a-z0-9_]*\s([0-9:\-+]*\s-\s[0-9:\-+]*)/ 42: @introText = Please find enclosed your weekly status report template. Please fill out theform and send it back to the sender of this email. You can either use theattached file or the body of the email. In case you send it in the body of theemail, make sure it only contains the 'statussheet' syntax. It must be plaintext, UTF-8 encoded and the status sheet header from 'statussheet' to the periodend date must be in a single line that starts at the beginning of the line. 43: # tj3ts_summary generates a list of resources that have not submitted 44: # their reports yet. If you want to generate the warning below, make 45: # sure you run tj3ts_summary immediately before you sent the status sheet 46: # templates. 47: defaulters = defaulterList 48: unless defaulters.empty? 49: @introText += =============================== W A R N I N G ==============================The following people have not submitted their report yet. The status reportsfor the work they have done is not included in this template! You can eithermanually add their status to the tasks or asked them to send their time sheetimmediately and re-request this template.#{defaulters.join} 50: end 51: 52: @mailSubject = "Your weekly status report template for %s" 53: end
# File lib/StatusSheetSender.rb, line 73 73: def defaulterList 74: dirs = Dir.glob("#{@timeSheetDir}/????-??-??").sort 75: tsDir = nil 76: # The status sheet intervals and the time sheet intervals are not 77: # identical. The status sheet interval can be smaller and is somewhat 78: # later. But it always includes the end date of the corresponding time 79: # sheet period. To get the file with the IDs of the resources that have 80: # not submitted their report, we need to find the time sheet directory 81: # that is within the status sheet period. 82: repDate = Time.local(*@date.split('-')) 83: dirs.each do |dir| 84: dirDate = Time.local(*dir[10..1].split('-')) 85: if dirDate < repDate 86: tsDir = dir 87: else 88: break 89: end 90: end 91: # Check if there is a time sheet directory. 92: return [] unless tsDir 93: 94: missingFile = "#{tsDir}/missing-reports" 95: # Check if it's got a missing-reports file. 96: return [] if !File.exists?(missingFile) 97: 98: # The sheet could have been submitted after tj3ts_summary was run. We 99: # ignore the entry if a time sheet file now exists. There is a race 100: # condition here. The file may exist, but it may not yet be loaded for 101: # the current project that is used to generate the status report. There 102: # is a race condition here. The file may exist, but it may not yet be 103: # loaded for the current project that is used to generate the status 104: # report. 105: list = File.readlines(missingFile) 106: list.delete_if do |resource| 107: tsDate = tsDir[10..1] 108: File.exists?("#{tsDir}/#{resource.chomp}_#{tsDate}.tji") 109: end 110: 111: # Return the content of the file. 112: list 113: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.