package com.brilliance.mda.runtime.mda;

import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import org.springframework.util.ResourceUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

public class Constants {
    public static final String NULLSTR = "";
    public static final Date NULLDATE = null;
    public static final Date NULLDATETIME = null;
    public static final String CRLF = "\r\n";
    public static Date EMPDATE = null;
    public static Class<?> Dynamic_class;
    public static Class<?> Platform_class;
    public static Properties packageInfo;
    private static String GLOBAL_PACK_KEY = "global.package";
    static{
        packageInfo = new Properties();
        try {
            packageInfo.load(ResourceUtils.getURL("classpath:package-info.properties").openStream());
            String busipack = packageInfo.getProperty(GLOBAL_PACK_KEY,"");
            Dynamic_class = Class.forName(busipack+".Dynamic");
            Platform_class = Class.forName(busipack+".Platform");
            EMPDATE = new SimpleDateFormat("yyyyMMdd").parse("19900806");
        }catch (Exception e){

        }
    }
    public static final int NO_SUCH_FIELD = 27;
    public static final int NO_ERROR = 0;
    public static final int NO_MORE_ROW = 228;
    public static final int GLOBAL_CURSOR_NOT_SET=249;
    public static final int NO_NAN = -37;
    public static final int ARGUMENT_COUNT_ERROR=205;
    public static final int ERROR_SQL = 200;
    public static final int ERROR_COLUMN = 251;
    public static final int ERROR_LOCK = 225;
    public static final int ERROR_LOCKED = 226;
    public static final int DATE_DAY = 5;
    public static final int DATE_HOUR = 11;
    public static final int DATE_MINUTE = 12;
    public static final int DATE_SECOND = 13;
    public static final String TRUE = "X";
    public static final String FALSE = "";
    public static final String CR = "\n";
    public static final String TAB = "\t";
    public static final String CALLER = "";
    public static final String FIRST = "_1st_";
    public static final String LASTTAG = "_tag_";

//    public static final DecodeType DECODE_BASE64 = DecodeType.DECODE_BASE64;
//    public static final DecodeType DECODE_MD5 = DecodeType.DECODE_MD5;
//    public static final DecodeType DECODE_SHA = DecodeType.DECODE_SHA;
//    public static final DecodeType DECODE_SHA256 = DecodeType.DECODE_SHA256;
//    public static final DecodeType DECODE_SHA384 = DecodeType.DECODE_SHA384;
//    public static final DecodeType DECODE_SHA512 = DecodeType.DECODE_SHA512;


    public static final String SdbEtyColEntity ="ETYEXTKEY";
    public static final String SdbEtyColEntityGroup ="ETGEXTKEY";
    public static final String DbsTypeInformix ="Informix";
    public static final String DbsTypeDB2 ="DB2";
    public static final String DbsTypeSqlServer ="SqlServer";
    public static final String DbsTypeFirebird ="Firebird";
    public static final String tdAttrKeyList ="KeyList";
    public static final int maxDate =99991231;

    public static final int tdDataTypeNumeric=2;
    public static final int tdDataTypeText=1;
    public static final int tdDataTypeBlock=3;
    public static final int tdDataTypeDate=4;
    public static final int tdDataTypeStream=7;
    public static final int tdDataTypeDateTime=20;
    public static final int tdDataTypeControl=5;
    public static final int tdDataTypeNil=25;
    public static final int tdDataParentIsNull=111;
    public static final int tdDataDateOutOfBoundary=36;
    public static final int tdDataDateStreamLineError=117;
    public static final int tdViewTypeDateTime=30;
    public static final int tdViewTypeButton=6;
    public static final int tdViewTypeEdit=0;
    public static final int tdViewTypeTime=26;
    public static final int tdViewTypeLabel=5;

    public static final int tdStrBase36Encoding = 173;
    public static final int tdOdbcLocked = 227;
    public static final int tdOdbcHeld = 247;
    public static final int tdOdbcNotFound=228;
    public static final int tdOdbcNotUnique=-229;
    public static final int tdOdbcNotSelected=-230;
    public static final int TdOdbcSelectGridEmpty=-231;
    public static final int tdCacheNotFound = 166;
    public static final int tdOdbcDuplicateKey=229;
    public static final int tdOdbcRowNotLocked=242;
    public static final int tdOdbcNoTable=0;


    //getModuleInfoStream
    // update by wgc 2021-07-08 from 0 to 2
    public static int tdModuleDatafields = 1;
    public static int tdModuleModules = 2;
    public static int tdModuleRules = 3;
    public static int tdModulePanels = 4;
    public static int tdModuleAllDatafields = 5;
    public static int tdModuleMenus = 6;
    public static int tdModuleVisiblePanels = 7;
    public static int tdModuleSearchDatafields = 8;
    public static int tdModuleAllModules = 9;
    public static int tdModuleDBIndexes = 10;
    public static int tdModuleLockFields = 11;
    public static int tdModuleAllMethods = 12;
    public static int tdModuleAllModifiedFields = 13;
    public static int tdModuleModifiedFields = 14;

    // public static int tdModuleModules = 2;
    // public static int tdModuleLockFields = 0;
    // public static int tdModuleAllModules = 0;
    // public static int tdModuleAllModifiedFields = 13 ;
    // public static int tdModuleVisiblePanels = 7 ;
    // public static int tdModuleAllMethods = 12 ;
    // public static int tdModuleDatafields = 1 ;
    // public static int tdModulePanels = 199 ;


    //getModuleInfo
    public static final int tdModuleInfoClass = 1;
    public static final int tdModuleInfoFullName= 2;

    public static final String tdAttrFullName = "0";
    public static final String tdAttrModified="MODIFIED";
    public static final String tdStringTRUE="TRUE";
    public static final String tdAttrLines="tdAttrLines";
    public static final String tdAttrLength="tdAttrLength";
    public static final String tdAttrContent="tdAttrContent";
    public static final String tdPanelFullName="tdPanelFullName";
    public static final String tdPanelName="tdPanelName";
    public static final String tdAttrConstant="tdAttrConstant";
    public static final String tdAttrEmpty="tdAttrEmpty";
    public static final String tdAttrDatatype="tdAttrDatatype";
    public static final String tdAttrViewtype="tdAttrViewtype";
    public static final String tdAttrCalendar="tdAttrCalendar";
    public static final String tdAttrEnabled="tdAttrEnabled";
    public static final String tdAttrCodeValues="tdAttrCodeValues";
    public static final String tdAttrName="tdAttrName";
    public static final String tdAttrDecpos="tdAttrDecpos";
    public static final String tdAttrFirstValue="tdAttrFirstValue";
    public static final String tdAttrCurrency="tdAttrCurrency";
    public static final String tdAttrFieldViewtype = "tdAttrFieldViewtype";
    public static final String tdAttrInfo = "tdAttrInfo";



    public static final String tdContextAPPLICATIONSTATUS = "tdContextAPPLICATIONSTATUS";

    public static final String tdUnit="tdUnit";
    public static final String tdUnitmm="tdUnitmm";
    public static final String tdUnitem="tdUnitem";
    public static final String tdPosCurrent="R";
    public static final String tdContextCLIENTSERVER="tdContextCLIENTSERVER";
    public static final String tdStringFALSE="tdStringFALSE";
    public static final String tdContextDBSERVICENAME="tdContextDBSERVICENAME";
    public static final String tdContextLANGUAGE="tdContextLANGUAGE";
    public static final String tdContextPOPUPTRIGGER="tdContextPOPUPTRIGGER";
    public static final String tdContextHTMLBASEURL = "tdContextHTMLBASEURL";
    public static final String tdContextBATCHMODE = "tdContextBATCHMODE";
    public static final String tdContextRETURNCODE = "tdContextRETURNCODE";
    public static final String tdContextDSPGENMODE = "tdContextDSPGENMODE";
    public static final String tdContextSERVERTYPE = "tdContextSERVERTYPE";
    public static final String tdContextLASTEXECRESULT = "tdContextLASTEXECRESULT";
    public static final String tdContextCOMMANDLINE = "tdContextCOMMANDLINE";
    public static final String tdContextPOSTQUEUE = "tdContextPOSTQUEUE";
    public static final String tdContextFILEVERSIONINFO = "tdContextFILEVERSIONINFO";
    public static final String tdContextSERVERPROGVER = "tdContextSERVERPROGVER";
    public static final String tdContextPROFILE = "tdContextPROFILE";
    public static final String tdContextPOPUPPANEL = "tdContextPOPUPPANEL";
    public static final String tdContextPAPERBINS = "tdContextPAPERBINS";

    public static final String tdContextDEBUGLEVEL_PROF = "tdContextDEBUGLEVEL_PROF";
    public static final String tdContextDEBUGLEVEL_COMM = "tdContextDEBUGLEVEL_COMM";
    public static final String tdContextDEBUGLEVEL_SQL = "tdContextDEBUGLEVEL_SQL";
    public static final String tdContextDEBUGLEVEL_RULES = "tdContextDEBUGLEVEL_RULES";
    public static final String tdContextDEBUGLEVEL_USER = "tdContextDEBUGLEVEL_USER";
    public static final String tdContextDEBUGLEVEL_BUILTIN = "tdContextDEBUGLEVEL_BUILTIN";
    public static final String tdContextDEBUGLEVEL_BASEXEC = "tdContextDEBUGLEVEL_BASEXEC";
    public static final String tdContextDEBUGLEVEL_FLOW = "tdContextDEBUGLEVEL_FLOW";
    public static final String tdContextDEBUGLEVEL_SQLDATA = "tdContextDEBUGLEVEL_SQLDATA";
    public static final String tdContextDEBUGLEVEL_APPLICATION = "tdContextDEBUGLEVEL_APPLICATION";
    public static final String tdContextDEBUGLEVEL_INFO = "tdContextDEBUGLEVEL_INFO";

    public static final String tdContextDBTransactionInfo = "tdContextDBTransactionInfo";
    //public static final String tdContextTZSYSTEM = "tdContextTZSYSTEM";
    public static final String tdContextTZUSER = "tdContextTZUSER";
    public static final String tdContextTDVCSFILE = "tdContextTDVCSFILE";
    public static final String tdContextSERVERID = "tdContextSERVERID";
    public static final String tdContextDISTRIBUTIONFILE = "tdContextDISTRIBUTIONFILE";
    public static final String tdContextMAXSTEPCOUNT = "tdContextMAXSTEPCOUNT";
    public static final String tdContextSWIFTEMPTYLINE = "tdContextSWIFTEMPTYLINE";
    public static final String tdContextSETTODAY="tdContextSETTODAY";
    public static final String tdContextSAVEDATASKIPEMPTY="SAVEDATASKIPEMPTY";



    public static final String OitDontShow = "OitDontShow";
    public static final String GetLockUID = "GetLockUID";
    public static final String GetLockDate = "GetLockDate";
    public static final double GetLockTime = 0d;
    public static final String GetLockDateTime = "GetLockDateTime";

    public static final String tdContextSESSIONNUMBER = "tdContextSESSIONNUMBER";
    public static final String tdContextSERVERPID = "tdContextSERVERPID";
    public static final String tdContextCLIENTID = "tdContextCLIENTID";
    public static final String tdContextCLIENTPID = "tdContextCLIENTPID";
    public static final String tdContextUSERID = "tdContextUSERID";
    public static final String tdContextDBDRIVERNAME = "tdContextDBDRIVERNAME";
    public static final String tdContextTRIGGER = "tdContextTRIGGER";
    public static final String tdContextCALLSTACK = "CALLSTACK";
    public static final String tdContextLASTUSERACTIONTIME = "tdContextLASTUSERACTIONTIME";

    public static int tdEventButtonPress=0;
    public static int tdEventMouseLeave=1;
    public static int tdEventTabLeave=2;
    public static int tdEventHotkey=3;
    public static int tdEventSelChange=4;
    public static int tdEventGridSel=5;
    public static int tdEventDragDrop=6;
    public static int tdEventDragPrepare=7;
    public static int tdEventGridDelete=8;
    public static int tdEventGridInsert=9;
    public static int tdEventFieldUpdate=10;
    public static int tdEventPosted=11;
    public static int tdEventPanelClose=12;
    public static int tdEventPanelCreate=13;
    public static final String tdPnlXML="tdPnlXML";

    //public static String tdContextTZSYSTEM = "tdContextTZSYSTEM";
    public static String tdContextTZSYSTEM = "TZSYSTEM";
    public static String tdContextAUTHUSERINFO = "TZSYSTEM";
    public static String tdContextEXENAME = "EXENAME";

    public static final int tdPromptOK=1;  //1
    public static final int tdPromptCancel=2; //2
    public static final int tdPromptYes=1;  //1
    public static final int tdPromptNo=0;  //0
    public static boolean IsDesigner=true;
    public static boolean IsAdministrator=false;

    public static final String tdAttrSelectedIdx = "tdAttrSelectedIdx";
    public static final String tdAttrSelected="tdAttrSelected";
    public static final String tdAttrChecked="tdAttrChecked";
    public static final String  tdAttrCheckSwift="tdAttrCheckSwift";
    public static final String  tdAttrExpandedIdx="tdAttrExpandedIdx";
    public static final String  tdAttrCodetable="tdAttrCodetable";

    public static final int tdViewTypeCombobox=2;
    public static final int tdViewTypeDate=7;
    public static final int tdViewTypeAmount=8;
    public static final int tdViewTypeCheckbox=3;
    public static final int tdViewTypeFormatted = 20;

    public static final int SRVTRNNoLock = 0;
    public static final int SRVTRNLockOnly = 1;
    public static final int SRVTRNUpdate = 2;

    public static final String NtfTypWarning = "5";

    public static final String PanStaEdit="E";
    public static final String PanStaInquiry="I";
    public static final String PanStaDelete="D";
    public static final String PanStaAdd="A";
    public static final String PanStaHide="H";
    public static final String PanStaShow="S";
    public static final String PanStaLog="L";

    public static final String SYSWRNTypeFinal="F";
    public static final String SYSWRNTypeWarning="W";
    public static final String SYSWRNTypeInfo="I";
    public static final String SYSWRNTypeStartup="S";
    public static final String SYSWRNTypeStartupInfo="C";
    //public static int tdPromptNo=0;
    //public static int tdPromptOK=1;
    public static final String SptWaitForIncoming="INC";
    public static final String SptWaitForAutoExec="AUT";
    public static final String SptWaitForRecalculation="EXE";
    public static final String SptAfterSentToRepair="COR";
    public static final String SptAfterRejection="REJ";
    public static final String SptAfterBreak="PEN";
    public static final String SptWaitForProcessing="PUP";

    public static final String ClientTypeHtml="ClientTypeHtml";
    public static final String ClientTypeAjax="ClientTypeAjax";

    public static final String TrnmodCancelExitWithPrompt="TrnmodCancelExitWithPrompt";
    public static final String LogmodInfo="LogmodInfo";
    public static final String LogmodWarning="LogmodWarning";
    public static final String LogmodError="LogmodError";

    public static final String Quote = "\"";
    public static final String NtfTypError = "NtfTypError";
    public static final String tdContextDBOpenCursors = "tdContextDBOpenCursors";
    public static final String tdContextSQLCURSOR = "tdContextSQLCURSOR";
    public static final String AppIniFile = "AppIniFile";
    public static final String tdPaperbin1 = "tdPaperbin1";
    public static final String tdPaperbin2 = "tdPaperbin2";
    public static final String TrnmodCancelExitWithoutPrompt = "TrnmodCancelExitWithoutPrompt";

    public static final String LscRejected="LscRejected";
    public static final String LscPending="LscPending";
    public static final String LscAccepted="LscAccepted";


    public static final String tdPageFirst = "tdPageFirst";
    public static final String tdPage = "tdPage";

    public static final String tdContextCLIENTPROGVER="v505";

    public static final String ClientTypeFat="F";
    public static final String ClientTypeWin32="W";
    public static final String ClientTypeJava="J";

    public static final String SptWaitingIncoming="INC";
    public static final String SptWaitingRegistration="RIM";
    public static final String SptWaitForManExec = "MAN";
    public static final String SptWaitForRelease="PUR";


    public static final String tdContextSTARTTRANSACTION="tdContextSTARTTRANSACTION";


    public static final String DiaToWrite="DiaToWrite";
    public static final String DiaToReplace="DiaToReplace";

    public static final String UilSwift = "UilSwift";
    public static final boolean SptIsexeLoaded = false;

//    public static final AttrGetter tdAttrCheckedIdx = new AttrGetter.DefaultAttrGetter();
    public static final String tdAttrCheckedIdx = "tdAttrCheckedIdx";
    public static IStream DDRSTREAM = new StreamImpl();

    public static String DbsTypeAccess = "DbsTypeAccess";
    public static final String FF = "\r\n<FF/>\r\n";
    public static final String tdPosAbsolute = "tdPosAbsolute";
    public static final String tdPosition = "tdPosition";
    public static final String tdAttrVisible = "tdAttrVisible";
    public static final String OitStopPayment = "2";

    public static final String tdContextFORM = "tdContextFORM";

    public static final String tdPnlFrame = "tdPnlFrame";
    public static final String tdPnlDoc = "tdPnlDoc";

    public static final String ATTR_CODE_VALUES="ATTR_CODE_VALUES";
    /** MX 转 MT 后 XML文件存放的文件夹名 */
    public static final String MX_BAK_DIR="MX";
}
