>local loErr, lcBatch_Process_fk, lcUsGrLink_fk, ; > lcNewStatusCode, lcDept, lnNumber_of_Days, ; > ltTimeToReschedule, lcTrans_pk, lcTrans_Employees_Queues_pk, lcUser, ; > lcAction, lcSubAction, lcDetail, lcOldCode, lcUsGrLink > >=aused(this.arrOriginallyUsed) > >with this > try > .CreateLogfile() >** We want to have a clear log of everything > .WriteToLogFile(chr(13) + chr(10) + replicate("*",75) + chr(13) + chr(10), .t.) > .WriteToLogFile("Started to run " + this.cSearchType + " Name Search process") > > .OpenSearchTables() && Opens related tables with buffering > > lcBatch_Processes_Fk = Get_Batch_Processes_Fk_By_Process_Name('POLICY NUMBER CHECK ') > lcNewStatusCode = "NSR" && Hard Coded > > if vartype(m.goApp) = "O" > lcUsGrLink_fk = m.goApp.cUsGrLink > lcDept = m.goApp.cDept > .nNumber_of_Days = m.goApp.oSystemParametersRecord.iNum_Days_NS_check > .nNum_days_ns_Dos = m.goApp.oSystemParametersRecord.iNum_days_ns_dos > lcUser = m.goApp.cUserID > lcUsGrLink = m.goApp.cUsGrLink > else > lcUsGrLink_fk = Get_System_USGRLink() && This code may produce an error > lcDept = "O" > .nNumber_of_Days = 5 > .nNum_days_ns_Dos = 716 > lcUser = GetUserID() > lcUsGrLink = Get_System_USGRLink() > endif > > =Get_description_from_Viscodes("STATUS","", m.lcDept, ; > "cTempInfo",.f., 1, 'cCode_Value = "' + m.lcNewStatusCode + '"') > lcNewStatusCode = cTempInfo.cVisCodes_pk > > use in select('cTempInfo') > > .SetDateToReschedule(.nNumber_of_Days) > ltTimeToReschedule = dtot(.dRescheduleDate) + 9 * 3600 && 9am > > select curProcess > scan for empty(.cError) and not .lStopProcess > if .CheckRules() > insert into Scheduled_Processes ; > (cPROCESS_NAME_FK, cTrans_fk, cUsGrLink_fk, iBatch_Number, ; > cClient_Code, cDepartment_Code, cProduct_Line_Code, ; > tDate_Process_Scheduled, iStatus_Flag) ; > values ; > (m.lcBatch_Processes_Fk, curProcess.cTrans_pk, m.lcUsGrLink_fk, 0, ; > curProcess.cClient_Code, curProcess.cDepartment_Code, curProcess.cProduct_Line_Code, ; > datetime(), 1) > lcTrans_pk = curProcess.cTrans_pk > lcTrans_Employees_Queues_pk = curProcess.cTrans_Employees_Queues_pk > > update trans set cStatus_Codes_fk = m.lcNewStatusCode, ; > tStatus_Date = datetime(), ; > cLast_Updated_User = m.lcUser, ; > tLast_Updated_Date = datetime() ; > where cTrans_pk = m.lcTrans_pk > > update Trans_Status_Codes set ; > cLast_Updated_User = m.lcUser, ; > tLast_Updated_Date = datetime(), ; > iActive_flag = 0 ; > where cTrans_fk = m.lcTrans_pk > > if _tally = 0 && There were status records already > lcAction = "AD" > lcSubAction = "" > lcDetail = "STATUS WAS ADDED ON " + ; > transform(datetime()) + " BY " + m.lcUser > else > lcAction = "CH" && change > lcSubAction = "FR" > if seek(curProcess.cStatus_Codes_fk, "VisCodes", "cViscod_pk") > lcOldCode = VisCodes.cCode_Description > else > lcOldCode = "OLD CODE" > endif > lcDetail = "STATUS WAS CHANGED FROM " + m.lcOldCode + ; > " ON " + transform(datetime()) + " BY " + m.lcUser > endif > > insert into Trans_Status_Codes ; > (cTrans_fk, cStatus_Codes_fk, cUsGrLink_fk, tAS_OF_DATE, iActive_flag) ; > values ; > (m.lcTrans_pk, curProcess.cStatus_Codes_fk, m.lcUsGrLink, datetime(), 1) > > insert into Trans_Events ; > (cTrans_fk, cFUNCTION_CODE, cACTION_CODE, cSUBACTION_CODE, cDETAIL_INFO) ; > values ; > (m.lcTrans_pk, "ST", m.lcAction, m.lcSubAction, m.lcDetail) > > update Employee_Queue_Schedules set iActive_flag = 0 ; > where cTrans_Employees_Queues_fk = m.lcTrans_Employees_Queues_pk > > insert into Employee_Queue_Schedules (cTrans_Employees_Queues_fk, ; > cDIARY_CODE_FK, ; > tScheduled_Time, iActive_flag, ; > iACTIVE_AT_DAY_START_FLAG, iSUPERVISOR_ASSIGNED_FLAG) ; > values ; > (m.lcTrans_Employees_Queues_pk, null, m.ltTimeToReschedule, 1, 1, 0) > endif > endscan > > if empty(.cError) and not .lStopProcess > .CommitChanges() > endif > > .WriteToLogFile("Finished to run " + this.cSearchType + " Name Search process" + chr(13) + chr(10)) > > catch to loErr > .CustomError(m.loErr) > > finally > release loErr > .CleanUp() > endtry > >endwith > >return