0

我正在开发一个应用程序,在该应用程序中,我从一个对象中检索记录,然后想要将(的某些字段)记录插入到不同的对象中。下面是我的代码,我无法弄清楚为什么我的对象没有被填充并且看不到新记录。

//调度器相关类1

public with sharing class ScheduleBatchLauncher{
public static String scheduleBatch(Datetime batchTime){
    CreateAndModifyScheduler batchSched = new CreateAndModifyScheduler();
    String cron = '20 25 * * * ?';
    String schedId = System.schedule('Create and Modify Batch 1', cron, batchSched);       
    return schedId;
}
}

//调度器相关类2

global class CreateAndModifyScheduler implements Schedulable{
global void execute(SchedulableContext sc) {
  CreateAndModify scBatch = new CreateAndModify(); 
  database.executebatch(scBatch);
}
}

// 批量 Apex 相关类 1

global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{

global CreateAndModifyProcessor processor;
global CreateAndModify(){
        this.processor = new CreateAndModifyProcessor();
    }

global Database.queryLocator start
    (Database.BatchableContext BC){
        return Database.getQueryLocator([Select Agreement_ID__c, Begining__c,
                                        Contact_Email__c, Contact_Name__c,
                                        Country_Code__c, Currency__c,
                                        Customer_Address__c, Customer_ID__c,
                                        Customer_Name__c,Customer_Postal_Code__c,
                                        Ending__c,Price__c FROM Unprocessed_Agreement__c]);
        }

global void execute(
    Database.BatchableContext BC, 
    List<sObject> listObj){

        list <Account__c> inAcc = new list<Account__c>();

        for (sObject lo : listObj){
            Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;

            inAcc.add(processor.processAccountRecord(temp));    
            }
        insert(inAcc);
        update(inAcc)
      }

global void finish(
    Database.BatchableContext BC){
    }
}

// 批量 Apex 相关类 2

global class CreateAndModifyProcessor {
global Account__c processAccountRecord( Unprocessed_Agreement__c temp){
    Account__c tempAcc = new Account__c();
    tempAcc.Customer_Name__c = temp.Customer_Name__c;
    tempAcc.Customer_Address__c = temp.Customer_Address__c;
    tempAcc.Postal_Code__c = temp.Customer_Postal_Code__c;
    return tempAcc;
}   
}

请如果有人可以看看它。另外,如果有人想看我的 build.xml 或 package.xml 请告诉..谢谢

4

1 回答 1

1

您正在运行计划的批处理作业,因此系统会监控每次执行。检查设置 - 管理设置 - 监控 - 顶点作业是否有错误。另一个调试选项是使用匿名执行(在 eclipse 或 ui 中)手动执行您的作业并检查日志。

于 2012-06-25T19:28:01.050 回答