OBJECT Codeunit 123456785 RemainingTime { OBJECT-PROPERTIES { Date=08/11/13; Time=17:17:05; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR ElapsedTime@1000000000 : Integer; RemainingMins@1000000002 : Decimal; RemainingSeconds@1000000003 : Decimal; RoundedRemainingMins@1000000004 : Integer; PROCEDURE RemainingTime@1000000000(ProgressI@1000000001 : Integer;ProgressTotal@1000000002 : Integer;StartTime@1000000000 : Time) TimeLeft : Text[30]; BEGIN // Created by Dan Steele // Mibuso user amadman114 ElapsedTime := ROUND(((TIME - StartTime) / 1000),1); RemainingMins := ROUND((((ElapsedTime / ((ProgressI/ProgressTotal) * 100) * 100)-ElapsedTime)/60),0.1); RoundedRemainingMins := ROUND(RemainingMins,1,'<'); RemainingSeconds := ROUND(((RemainingMins - RoundedRemainingMins)*0.6)*100,01); TimeLeft := FORMAT(RoundedRemainingMins)+':'+FORMAT(RemainingSeconds); //Where ProgressI is the increasing value of the number of records completed ProgressTotal // is the total number of records and StartTime is the time when the process started. END; BEGIN END. } }
OBJECT Codeunit 123456785 RemainingTime { OBJECT-PROPERTIES { Date=08/11/13; Time=17:17:05; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR ElapsedTime@1000000000 : Integer; RemainingMins@1000000002 : Decimal; RemainingSeconds@1000000003 : Decimal; RoundedRemainingMins@1000000004 : Integer; PROCEDURE RemainingTime@1000000000(ProgressI@1000000001 : Integer;ProgressTotal@1000000002 : Integer;StartTime@1000000000 : Time) TimeLeft : Text[30]; BEGIN // Created by Dan Steele // Mibuso user amadman114 ElapsedTime := ROUND(((TIME - StartTime) / 1000),1); RemainingMins := ROUND((((ElapsedTime / ((ProgressI/ProgressTotal) * 100) * 100)-ElapsedTime)/60),0.1); RoundedRemainingMins := ROUND(RemainingMins,1,'<'); RemainingSeconds := ROUND(((RemainingMins - RoundedRemainingMins)*0.6)*100,01); TimeLeft := FORMAT(RoundedRemainingMins)+':'+FORMAT(RemainingSeconds); //Where ProgressI is the increasing value of the number of records completed ProgressTotal // is the total number of records and StartTime is the time when the process started. END; BEGIN END. } } OBJECT Codeunit 123456788 CalcInvAmount { OBJECT-PROPERTIES { Date=08/11/13; Time=17:18:58; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR GrecSalesInvLine@1000000000 : Record 113; GLastYear@1000000001 : Date; GrecSalesInvHeader@1000000002 : Record 112; Total@1000000003 : Decimal; InvAmount@1000000004 : Decimal; intProgressI@1000000005 : Integer; intProgressTotal@1000000006 : Integer; intProgress@1000000007 : Integer; diaProgress@1000000008 : Dialog; timProgress@1000000009 : Time; UpdateForm@1000000010 : Form 123456784; ElapsedTime@1000000011 : Integer; RemainingTime@1000000012 : Text[30]; StartTime@1000000013 : Time; RemainingMins@1000000014 : Decimal; RemainingMinsAndone@1000000015 : Decimal; RoundedRemainingMins@1000000016 : Integer; GRecRange@1000000017 : Date; cduRemainingTime@1000000018 : Codeunit 123456785; TimeLeft@1000000019 : Text[30]; PROCEDURE Update@1000000005(UpdateType@1000000000 : Option); BEGIN CASE UpdateType OF 0 : GRecRange := CALCDATE('-1D',TODAY); 1 : GRecRange := CALCDATE('-1W',TODAY); 2 : GRecRange := CALCDATE('-1M',TODAY); 3 : GRecRange := CALCDATE('-1Y',TODAY); 4 : GRecRange := CALCDATE('-2Y',TODAY); END; intProgressI := 0;diaProgress.OPEN('#1####\#2####\@3@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@',ElapsedTime,TimeLeft,intProgress); GrecSalesInvLine.RESET; GrecSalesInvHeader.RESET; GrecSalesInvHeader.SETRANGE("Posting Date",GRecRange, TODAY); // Only Updates Records in the last year intProgressTotal := GrecSalesInvHeader.COUNT; GrecSalesInvHeader.FINDFIRST; timProgress := TIME; StartTime := TIME; REPEAT CLEAR(InvAmount); GrecSalesInvLine.SETRANGE("Document No.",GrecSalesInvHeader."No."); // Creates a loop too look for all instances of the same // Document No. REPEAT InvAmount := InvAmount + GrecSalesInvLine.Amount; UNTIL GrecSalesInvLine.NEXT = 0; GrecSalesInvHeader.Amount := InvAmount; GrecSalesInvHeader.MODIFY; //Progress bar ----------------- intProgressI := intProgressI + 1; IF timProgress < TIME - 1000 THEN BEGIN // every second timProgress := TIME; intProgress := ROUND(intProgressI / intProgressTotal * 10000,1); diaProgress.UPDATE; END; TimeLeft := cduRemainingTime.RemainingTime(intProgressI,intProgressTotal,StartTime); ElapsedTime := ROUND(((TIME - StartTime) / 1000),1); //Progress bar ---------------- UNTIL GrecSalesInvHeader.NEXT = 0; diaProgress.CLOSE; END; BEGIN { DJS Nov 2013 } END. } }