unit Define; interface uses Tocsg.Param, CttSchDefine, System.SysUtils, Winapi.Windows, GlobalDefine; const APP_TITLE = 'KvContentSearch'; CLIENT_TYPE = 2; CLIENT_VER = '1'; SIG_DRM: AnsiString = 'ToCSG'; PASS_DRM_HEAD: AnsiString = '#df12mf8(zfq@'; PASS_STRENC = '(skd82_sl9+a'; type TProcessParam = class(TTgParam) private TaskType_: TCttSchTaskType; CttSimpleOpt_: TCttSimpleOpt; CttSchOpt_: TCttSchOpt; sMtx_, sSchPtrns_, sPrtDocId_: String; llTasker_: LONGLONG; nLangID_, nPrtDPI_: Integer; bUseST_, bUseWM_, bExtrTxtOnly_, bIsAdvancePrtProg_, bNoPrtPopup_: Boolean; fSnaptag_: Double; PrtWaterEnt_: TPrtWaterEnt; PrtWaterCfg_: TPrtWaterCfg; sIp_, sLabel_, // for GEC AIP 24_0514 08:41:02 kku sUName_, sEmpNo_, sDeptName_, sMaskStr_, sDefPrtWaterTxt_, sForcePdfPath_: String; dwCustomerType_: DWORD; hRcv_: HWND; public Constructor Create; Destructor Destroy; override; function ProcessParam: Boolean; property TaskType: TCttSchTaskType read TaskType_; property CttSimpleOpt: TCttSimpleOpt read CttSimpleOpt_; property CttSchOpt: TCttSchOpt read CttSchOpt_; property Mutex: String read sMtx_; property Tasker: LONGLONG read llTasker_; property LangID: Integer read nLangID_; property SchPatterns: String read sSchPtrns_; property ExtrTxtOnly: Boolean read bExtrTxtOnly_; property PrtWaterEnt: TPrtWaterEnt read PrtWaterEnt_; property PrtWaterCfg: TPrtWaterCfg read PrtWaterCfg_; property EmpNo: String read sEmpNo_; property UName: String read sUName_; property DeptName: String read sDeptName_; property DefPrtWaterTxt: String read sDefPrtWaterTxt_; property CustomerType: DWORD read dwCustomerType_; property LabelName: String read sLabel_; property MaskStr: String read sMaskStr_; property IP: String read sIp_; property PrtDPI: Integer read nPrtDPI_; property PrtDocId: String read sPrtDocId_; property ForcePdfPath: String read sForcePdfPath_; property RcvWnd: HWND read hRcv_; property UseSnaptag: Boolean read bUseST_; property ValSnaptag: Double read fSnaptag_; property UseWM: Boolean read bUseWM_; property NoPrtPopup: Boolean read bNoPrtPopup_; property IsAdvancePrtProg: Boolean read bIsAdvancePrtProg_; end; function DecText(sText: String): String; inline; var gParam: TProcessParam = nil; implementation uses superobject, Tocsg.Json, Tocsg.Exception, Tocsg.Encrypt; function DecText(sText: String): String; inline; begin Result := ''; if Length(sText) < 2 then exit; if sText[1] = ':' then begin Delete(sText, 1, 1); Result := DecBinStrToStr(ekAes256cbc, PASS_STRENC, sText); end else Result := sText; end; { TProcessParam } Constructor TProcessParam.Create; begin Inherited Create; ASSERT(gParam = nil); gParam := Self; TaskType_ := csttNone; ZeroMemory(@CttSimpleOpt_, SizeOf(CttSimpleOpt_)); ZeroMemory(@CttSchOpt_, SizeOf(CttSchOpt_)); ZeroMemory(@PrtWaterEnt_, SizeOf(PrtWaterEnt_)); ZeroMemory(@PrtWaterCfg_, SizeOf(PrtWaterCfg_)); sMtx_ := ''; sSchPtrns_ := ''; llTasker_ := 0; nLangID_ := 0; bUseST_ := false; bUseWM_ := false; bIsAdvancePrtProg_ := false; fSnaptag_ := 0.0; bExtrTxtOnly_ := false; sUName_ := ''; sEmpNo_ := ''; sDeptName_ := ''; sDefPrtWaterTxt_ := ''; sLabel_ := ''; sMaskStr_ := ''; sIp_ := ''; nPrtDPI_ := 600; sPrtDocId_ := 'Unknown'; end; Destructor TProcessParam.Destroy; begin gParam := nil; Inherited; end; function TProcessParam.ProcessParam: Boolean; var sPath: String; O: ISuperObject; begin Result := false; {$IFDEF DEBUG} if ExistsParam('-testconn') then begin TaskType_ := csttTest; Result := true; exit; end; {$ENDIF} try sPath := GetParamValue('-p'); if sPath = '' then sPath := GetParamValue('/p'); if FileExists(sPath) then begin if not LoadJsonObjFromFile(O, sPath) then exit; TaskType_ := TCttSchTaskType(O.I['CSTT']); case TaskType_ of csttNone : ; csttTest : ; csttPrint : begin if O.O['POpt'] <> nil then PrtWaterEnt_ := TTgJson.GetDataAsType(O.O['POpt']); if O.O['WMCfg'] <> nil then PrtWaterCfg_ := TTgJson.GetDataAsType(O.O['WMCfg']); sEmpNo_ := O.S['EN']; sUName_ := O.S['UN']; sDeptName_ := O.S['DEPT']; sDefPrtWaterTxt_ := O.S['DPW']; dwCustomerType_ := O.I['CT']; bUseST_ := O.B['ST']; bUseWM_ := O.B['WM']; bIsAdvancePrtProg_ := O.B['S2P']; fSnaptag_ := O.D['STV']; sLabel_ := O.S['LB']; sIp_ := O.S['IP']; sMaskStr_ := O.S['MskStr']; nPrtDPI_ := O.I['PrtDPI']; sPrtDocId_ := O.S['PRTID']; if not O.B['IsMask'] then sMaskStr_ := ''; bNoPrtPopup_ := O.B['NoPrtPopup']; sForcePdfPath_ := O.S['FPDF']; hRcv_ := O.I['RcvWnd']; end; csttExtrSimple, csttExtrDocInfo, csttWaterMarkImg : begin if O.O['SOpt'] <> nil then CttSimpleOpt_ := TTgJson.GetDataAsType(O.O['SOpt']); end; csttSchMulti : begin sMtx_ := O.S['Mtx']; llTasker_ := O.I['Tasker']; bExtrTxtOnly_ := O.B['ExtrTxtOnly']; dwCustomerType_ := O.I['CT']; if O.O['Opt'] <> nil then CttSchOpt_ := TTgJson.GetDataAsType(O.O['Opt']); end; csttSchConnect : begin sMtx_ := O.S['Mtx']; llTasker_ := O.I['Tasker']; dwCustomerType_ := O.I['CT']; if O.O['Opt'] <> nil then CttSchOpt_ := TTgJson.GetDataAsType(O.O['Opt']); end; end; nLangID_ := O.I['LangID']; sSchPtrns_ := O.S['SchPtrns']; // {$IFNDEF DEBUG} DeleteFile(PChar(sPath)); // {$ENDIF} end else begin if ExistsParam('-test') then TaskType_ := csttTest; end; Result := TaskType_ <> csttNone; except on E: Exception do ETgException.TraceException(Self, E, 'Fail .. ProcessParam()'); end; end; end.