2

我有一个 CF 计划任务,它通过电子邮件发送管理员用户的电话摘要。我想添加为某些管理员用户发送报告的功能。附加报告是每个管理员用户的动态报告,并存储在表格中。我不能只报告代码,因为它可能会更改或不存在给下一个用户。也许我应该使用 CFHTTP 但我不精通它。

<cfloop query="qGetTelemateEmails">             
  <cfif trim(QGetTime.Call_Email_On_Hour) eq "" or     listfind(#QGetTime.Call_Email_On_Hour#,datepart("h",now()))>
  <cfset TotalTime = 0>
  <cfset NumberOfCalls = 0> 
  <cfmail ........></cfmail>

以下代码是我还想通过电子邮件发送报告的地方。

<cfquery name="QAdditionalReports" datasource="#request.dtsrc#">
Select *
From Admin_Telemate_Additional_Query_Daily as a  LEFT OUTER JOIN
    Admin_Users AS C ON A.AdminID = C.adminID LEFT OUTER JOIN
    Admin_Telemate_Available_Queries AS b ON A.description = b.description
where a.adminid = #val(QGetTime.call_admin_user_id)#
</cfquery>
<cfif QAdditionalReports.recordcount gt 0>
SEE CODE BELOW  -------------------------------------------------------------       
</cfif>

</cfif>
</cfloop>

这是我要“包含/执行”的报告代码。我从查询表条目中获取代码的 url。

    <cfquery name="QGetCommEct" datasource="#request.dsn#">
      select *
      from Q_ES_Communications_by_Search_Number
      where upper(communication_type) = 'T'
        and Date_Entered = '#dateformat(now(),"yyyy/mm/dd")#'
    and consultant_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.adminid#">
      order by date_Entered
    </cfquery>
    <cfmail>
        <div style="text-align:center; font-weight:bold; ">Communications Files Query</div> 
    <table>
     <tr>
      <td>
        <table style="font:Arial, Helvetica, sans-serif x-small; border:1px solid black; ">
         <tr>
      <td><strong>Type</strong></td>
      <td><strong>Cons</strong></td>
      <td><strong>Last Name</strong></td>
         </tr>
     <cfoutput query="QGetCommEct">     
    <tr valign="top">
      <td>#QGetCommEct.Communication_Type#-#QGetCommEct.Category#</td>
          <td>#QGetCommEct.AS400_Initials#</td>
          <td>#QGetCommEct.lastname#</td>
        </tr>
     </cfoutput>      
     </table> 
    </td>
  </tr>
</table> 
</cfmail>

我将 cfif QAdditionalReports.recordcount gt 0 替换为

<cfloop query="QAdditionalReports">
<cfhttp url="#QAdditionalReports.QueryURL##QAdditionalReports.QueryName#?adminid=#val(QGetTime.call_admin_user_id)#&emailto=#qGetTelemateEmails.Telemate_Email#">
<cfmail to="vj@gmail.com" from="server@tt.com" subject="Recap of daily phone calls" type="html" spoolenable="false"><cfdump var="#cfhttp#"></cfmail>
</cfloop>

并且电子邮件包含;

struct
Charset [empty string] 
ErrorDetail [empty string] 
Filecontent [empty string] 
Header  HTTP/1.1 503 Server Error Content-Type: text/html Date: Wed, 13 Feb 2013 15:11:17 GMT Server: Microsoft-IIS/7.0 
Mimetype    text/html 
Responseheader  struct
Content-Type    text/html 
Date    Wed, 13 Feb 2013 15:11:17 GMT 
Explanation Server Error 
Http_Version    HTTP/1.1 
Server  Microsoft-IIS/7.0 
Status_Code 503 

Statuscode  503 Server Error 
Text    YES 

可能是我需要做一个 HTTPS

4

1 回答 1

0

您可以将尝试重用和“远程调用”的代码放在 cfc 中,或者将其包含在 cfinclude 中。

编写 CFC 将是更好的方法。这是一些文档。

<cfcomponent ...>
   <cffunction name = "additionalReports" ...>
      <cfargument name = "adminid" ...>
      <cfargument name = "emailto" ...>

      <!--- dynamic query using your adminid here ---->

      <cfmail to = "#arguments.emailTo#" ...>
         <!--- nicely formated output --->
      </cfmail>
   </cffunction>
<cfcomponent>

你会像这样在你的计划任务中调用 cfc

<!--- make the object. assume the cfc is in the same folder named adminreports.cfc --->
<cfset reportObject = createObject("component", "adminReports")>
<cfset reportObject.additionalReports(val(QGetTime.call_admin_user_id), qGetTelemateEmails.Telemate_Email)>
于 2013-02-13T18:23:44.370 回答