Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class BatchUpdate implements Database.Batchable<sObject>,Database.Stateful {
- global final String Query;
- public Integer total=0;
- global BatchUpdate(String q) {
- Query=q;
- }
- global Database.QueryLocator start(Database.BatchableContext BC){
- return Database.getQueryLocator('SELECT id,b.LastModifiedDate from Base_Catalogue__c b');
- }
- global void execute(Database.BatchableContext BC, list<sObject> scope){
- List<Base_Catalogue__c> bc1 = new List<Base_Catalogue__c>();
- List<BC_Count__c> count = [select BC_count_AP08__c from BC_Count__c];
- system.debug('The total count records from the Ap08 server: '+ count);
- system.debug('Start of the program');
- for (sObject s : scope) {
- Base_Catalogue__c bc2 =(Base_Catalogue__c)s;
- DateTime d=bc2.LastModifiedDate;
- Date lastdate = date.newinstance(d.year(), d.month(), d.day());
- system.debug('Hi2::'+lastdate);
- DateTime dT = System.Today();
- Date today = date.newinstance(dT.year(), dT.month(), dT.day());
- system.debug('Hi3:::'+today);
- if(lastdate==today){
- system.debug('check');
- bc2.Check__c=true;
- total++;
- }
- else
- {
- bc2.Check__c=false;
- }
- bc1.add(bc2);
- system.debug('The total count records from the Ap08 server: '+ count);
- for(BC_Count__c var: count)
- {
- var.BC_count_AP08__c = total;
- update var;
- }
- }
- update bc1;
- }
- global void finish(Database.BatchableContext BC)
- {
- System.debug(LoggingLevel.Info, 'Your info');
- system.debug('COUNT::::'+total);
- if(!Test.isRunningtest()){
- //Updating all the Detail object records to point to Active Base Catalogue
- UpdateDetailReference udr = new UpdateDetailReference();
- Database.executebatch(udr,200);
- }
- }
- }
- global class BatchUpdate implements Database.Batchable<sObject>,Database.Stateful {
- global final String Query;
- public Integer total=0;
- global BatchUpdate(String q) {
- Query=q;
- }
- global Database.QueryLocator start(Database.BatchableContext BC){
- return Database.getQueryLocator('SELECT id,b.LastModifiedDate from Base_Catalogue__c b');
- }
- global void execute(Database.BatchableContext BC, list<sObject> scope){
- List<Base_Catalogue__c> bc1 = new List<Base_Catalogue__c>();
- system.debug('Start of the program');
- for (sObject s : scope) {
- Base_Catalogue__c bc2 =(Base_Catalogue__c)s;
- DateTime d=bc2.LastModifiedDate;
- Date lastdate = date.newinstance(d.year(), d.month(), d.day());
- system.debug('Hi2::'+lastdate);
- DateTime dT = System.Today();
- Date today = date.newinstance(dT.year(), dT.month(), dT.day());
- system.debug('Hi3:::'+today);
- if(lastdate==today){
- system.debug('check');
- bc2.Check__c=true;
- total++;
- }
- else
- {
- bc2.Check__c=false;
- }
- bc1.add(bc2);
- }
- update bc1;
- }
- global void finish(Database.BatchableContext BC)
- {
- List<BC_Count__c> count = [select BC_count_AP08__c from BC_Count__c];
- for(BC_Count__c var: count) {
- var.BC_count_AP08__c = total;
- }
- update count;
- system.debug('The total count records from the Ap08 server: '+ count);
- System.debug(LoggingLevel.Info, 'Your info');
- system.debug('COUNT::::'+total);
- if(!Test.isRunningtest()){
- //Updating all the Detail object records to point to Active Base Catalogue
- UpdateDetailReference udr = new UpdateDetailReference();
- Database.executebatch(udr,200);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement