cfloop优化

今天下午接到一个优化的任务,客户反映invite attendee to event 时,会有超时错误。我查了查代码,用的是cfloop,而且套用了3次。能不慢吗?!!


google一下,才知道cfscript 效率很好,(http://www.blue1000.com/bkhtml/2006-09/45939.htm).

 

<cfscript>
		for(i = 1; i lte ArrayLen(oneAccsIdList); i++){
		
			temp = oneAccsIdList[i];
			for(j = 1 ; j lte ArrayLen(accommodationList); j++){
				if(temp eq accommodationList[j]){
					stay = 1;
					break;
				}else{
					stay = 0;
				}
			}		
		
		
			for(j = 1 ; j lte ArrayLen(flightList); j++){
				if(temp eq flightList[j]){
					flight = "Y";
					break;
				}else{
					flight = "N";
				}
			}
			
			hasInvited = false;
			
			for(j=1; j lte cnt_idInEvent.RecordCount; j++)	{
				if (temp == cnt_idInEvent["CNT_ID"][j])
				{
				 	hasInvited = true;
					break;	
				}
			}
			
			if (!hasInvited){
					saveDetailObject(0,
								   eventId,								   
								   attendeeRole,
								   "IVT",					   
								   stay,								   
								   flight,
								   temp,
								   "",
								   "",
								   "",
								   "",
								   "");
					for(k = 1; k < checkSiteUser.recordCount; k++){
						if (temp == checkSiteUser["CNTCT_ID"][k]){
							if((checkSiteUser["CNFRMTN_STS"][k] eq "Y") && (checkSiteUser["ACCNT_STS"][k] eq "Active")){
								sendInvEmailByContactId(temp,eventName,eventDate,eventEndDate,checkSiteUser["email"][k]);
							}
						}						
					}
				
				}else{
						if(message neq ""){
							message = message&","&temp;
						}else{
							message = temp;
						}				
				}
		}
	</cfscript>

 

请注意:cfscript 内不能有任何coldfusion 标签,eg.cfquery,cfif...

但是query.recordCount好用。

 

你可能感兴趣的:(Google,J#,ColdFusion)