Example #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                var debugIniDir  = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
                var debugIniPath = debugIniDir + "\\Debug.ini";
                if (File.Exists(debugIniPath))
                {
                    string debugIniArgsStr = IniFileHelper.ReadIniString(debugIniPath, "setting", "args", "");
                    args = debugIniArgsStr.Split(' ');
                }
            }

            if (args.Length < 2)
            {
                goto End;
            }
            //# appArgStr format
            //appCode ^formTitle^commonParams^startPassword^usrCode^userPassword^usrToken^invisibleFlag ^ isRedirectedFlag

            //#ov-
            //# appArgStr = EncryptionHelper.SmDecrypt(args[0],EncryptionHelper.GlobalKey1,EncryptionHelper.GlobalKey2);
            var appArgStrArry = args[0].GetParamArray(true, false);

            var appCode          = appArgStrArry[0];
            var formTitle        = "";
            var commonParams     = "";
            var startPassword    = "";
            var usrCode          = "";
            var usrPassword      = "";
            var usrToken         = "";
            var invisibleFlag    = "";
            var isRedirectedFlag = "";

            if (appArgStrArry.Length > 1)
            {
                formTitle = appArgStrArry[1];
            }
            if (appArgStrArry.Length > 2)
            {
                commonParams = appArgStrArry[2];
            }
            if (appArgStrArry.Length > 3)
            {
                startPassword = appArgStrArry[3];
            }
            if (appArgStrArry.Length > 4)
            {
                usrCode = appArgStrArry[4];
            }
            if (appArgStrArry.Length > 5)
            {
                usrToken = appArgStrArry[5];
            }
            if (appArgStrArry.Length > 6)
            {
                usrPassword = appArgStrArry[6];
            }
            if (appArgStrArry.Length > 7)
            {
                invisibleFlag = appArgStrArry[7];
            }
            if (appArgStrArry.Length > 8)
            {
                isRedirectedFlag = appArgStrArry[8];
            }

            var passedCultureName = "";

            if (args.Length > 2)
            {
                passedCultureName = args[2];
            }

            try
            {
                ConsoleHelper.DisbleQuickEditMode();
                var startup          = new Startup(appCode);
                var appStartParamSet = startup.ApplicationStartParamSet;
                if (appStartParamSet.SupportMultiCultures)
                {
                    startup.SetCultures(passedCultureName.IsNullOrEmpty() ? appStartParamSet.DefaultCulture : passedCultureName);
                }
                CentralData.InitApplicationSettings(appCode, appStartParamSet.SupportMultiCultures, CultureHelper.DefaultLanguageCode, CultureHelper.CurrentLanguageCode, commonParams
                                                    , appStartParamSet.ApplicationLibDir, appStartParamSet.ApplicationDataDir, appStartParamSet.PhythonExecPath);
                BootStrapper.Init(appStartParamSet);
                appStartParamSet.Invisible = invisibleFlag;

                var winCnslArgStr = args[1];

                var winCnslArgStrArry = winCnslArgStr.GetParamArray(true, false);

                if (winCnslArgStrArry.Length < 1)
                {
                    goto End;
                }

                //## funcArgs format
                //startScenarioRelativeLocation^startScenarioProcessParams
                var startScenarioRelativeLocation = winCnslArgStrArry[0];
                if (FileHelper.IsAbsolutePath(startScenarioRelativeLocation))
                {
                    throw new ArgumentException("startScenarioRelativeLocation can't be an absolute path! ");
                }
                if (startScenarioRelativeLocation.StartsWith("~"))
                {
                    throw new ArgumentException("startScenarioRelativeLocation can't contain \"~\"! ");
                }

                var startScenarioProcessParams = "";
                if (winCnslArgStrArry.Length > 1)
                {
                    startScenarioProcessParams = winCnslArgStrArry[1];
                }

                startup.SetApplicationStartPolicy(startScenarioRelativeLocation);

                //##VerifyStartPassword
                if (appStartParamSet.VerifyPasswordAtStart)
                {
                    if (appStartParamSet.PasswordVerificationRule.IsNullOrEmpty())
                    {
                        throw new ArgumentException("PasswordVerificationRule in ApplicationSetting config file can not be empty! ");
                    }
                    if (!startPassword.IsNullOrEmpty())
                    {
                        if (!startup.VerifyStartPassword(false, appStartParamSet.PasswordVerificationRule, startPassword))
                        {
                            goto End;
                        }
                    }
                    else
                    {
                        if (!startup.VerifyStartPassword(true, appStartParamSet.PasswordVerificationRule, startPassword))
                        {
                            goto End;
                        }
                    }
                    Console.Clear();
                }

                //##set formInitParamSet
                var formInitParamSet = new FormInitParamSet();

                formInitParamSet.ArchitectureCode      = CentralData.ArchitectureCode;
                formInitParamSet.ArchitectureName      = CentralData.ArchitectureName;
                formInitParamSet.ArchitectureVersion   = CentralData.ArchitectureVersion;
                formInitParamSet.OrganizationCode      = CentralData.OrganizationCode;
                formInitParamSet.OrganizationShortName = CentralData.OrganizationShortName;
                formInitParamSet.OrganizationName      = CentralData.OrganizationName;

                formInitParamSet.InvisibleFlag      = appStartParamSet.Invisible;
                formInitParamSet.ApplicationCode    = appCode;
                formInitParamSet.ApplicationVersion = appStartParamSet.ApplicationVersion ?? "";

                formInitParamSet.StartScenarioRelativeLocation = startScenarioRelativeLocation;
                //formInitParamSet.StartCommonParams = startCommonParams; //? required? it can be get from CentralData
                formInitParamSet.StartScenarioProcessParams = startScenarioProcessParams;

                formInitParamSet.StartPassword        = startup.StartPassword;
                formInitParamSet.FormTitle            = formTitle;
                formInitParamSet.HelpdeskEmail        = appStartParamSet.HelpdeskEmail;
                formInitParamSet.SupportMultiCultures = appStartParamSet.SupportMultiCultures;
                formInitParamSet.IsRedirected         = isRedirectedFlag.ToLower() == "true" ? true : false;

                formInitParamSet.ApplicationLibDir  = appStartParamSet.ApplicationLibDir;
                formInitParamSet.ApplicationDataDir = appStartParamSet.ApplicationDataDir;
                formInitParamSet.ApplicationTempDir = appStartParamSet.ApplicationTempDir;

                formInitParamSet.RunBootStrapperTasksAtStart = appStartParamSet.RunBootStrapperTasksAtStart;
                formInitParamSet.HasCblpComponent            = appStartParamSet.HasCblpComponent;
                //var cblpDllPath = appStartParamSet.CblpDllPath;
                //if (!cblpDllPath.IsNullOrEmpty()) ApplicationAdapter.Init1(debug, cblpDllPath, appStartParamSet.CblpAdapterClassFullName);

                //##ShowSoftwareCover
                if (appStartParamSet.ShowSoftwareCoverAtStart)
                {
                    bool showSoftwareCover = isRedirectedFlag.ToLower() != "true";
                    if (showSoftwareCover)
                    {
                        var isOk = startup.ShowSoftwareCover(formInitParamSet);
                        if (!isOk)
                        {
                            goto End;
                        }
                    }
                }

                var logon = false;
                if (appStartParamSet.LogonAtStart)
                {
                    logon = true;
                }

                //##VerifyUserToken
                if (logon & !usrCode.IsNullOrEmpty() & !usrToken.IsNullOrEmpty())
                {
                    if (startup.VerifyUserToken(usrCode, usrToken))
                    {
                        logon = false;
                    }
                }

                //##VerifyUserPassword
                else if (logon & !usrCode.IsNullOrEmpty() & !usrPassword.IsNullOrEmpty())
                {
                    if (startup.VerifyUserPassword(usrCode, usrToken))
                    {
                        logon = false;
                    }
                }

                //##Logon
                if (logon)
                {
                    if (logon)
                    {
                        if (!startup.Logon(formInitParamSet))
                        {
                            goto End;
                        }
                    }
                }

                var form = new FunctionForm(formInitParamSet);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(EasyWinAppRes.PressAnyKeyToExit + " !");
                Console.ReadKey();
                ConsoleHelper.CloseConsole();
            }
            End :;
        }
Example #2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                var debugIniDir  = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                var debugIniPath = debugIniDir + "\\Debug.ini";
                if (File.Exists(debugIniPath))
                {
                    string debugIniArgsStr = IniFileHelper.ReadIniString(debugIniPath, "setting", "args", "");
                    args = debugIniArgsStr.Split(' ');
                }
            }

            if (args.Length < 2)
            {
                goto End;
            }
            //# appArgsStr format
            //appCode ^formTitle^commonParams^startPassword^usrCode^userPassword^usrToken^invisibleFlag ^ isRedirectedFlag
            //#ov-
            //# appArgsStr = EncryptionHelper.SmDecrypt(args[0],EncryptionHelper.GlobalKey1,EncryptionHelper.GlobalKey2);
            var appArgStrArry = args[0].GetParamArray(true, false);
            //if (appArgStrArry.Length < 1) goto End;

            var appCode          = appArgStrArry[0];
            var formTitle        = "";
            var commonParams     = "";
            var startPassword    = "";
            var usrCode          = "";
            var usrPassword      = "";
            var usrToken         = "";
            var invisibleFlag    = "";
            var isRedirectedFlag = "";

            if (appArgStrArry.Length > 1)
            {
                formTitle = appArgStrArry[1];
            }
            if (appArgStrArry.Length > 2)
            {
                commonParams = appArgStrArry[2];
            }
            if (appArgStrArry.Length > 3)
            {
                startPassword = appArgStrArry[3];
            }
            if (appArgStrArry.Length > 4)
            {
                usrCode = appArgStrArry[4];
            }
            if (appArgStrArry.Length > 5)
            {
                usrToken = appArgStrArry[5];
            }
            if (appArgStrArry.Length > 6)
            {
                usrPassword = appArgStrArry[6];
            }
            if (appArgStrArry.Length > 7)
            {
                invisibleFlag = appArgStrArry[7];
            }
            if (appArgStrArry.Length > 8)
            {
                isRedirectedFlag = appArgStrArry[8];
            }

            var passedCultureName = "";

            if (args.Length > 2)
            {
                passedCultureName = args[2];
            }

            try
            {
                var startup          = new Startup(appCode);
                var appStartParamSet = startup.ApplicationStartParamSet;
                if (appStartParamSet.SupportMultiCultures)
                {
                    startup.SetCultures(passedCultureName.IsNullOrEmpty() ? appStartParamSet.DefaultCulture : passedCultureName);
                }
                CentralData.InitApplicationSettings(appCode, appStartParamSet.SupportMultiCultures, CultureHelper.DefaultLanguageCode, CultureHelper.CurrentLanguageCode, commonParams,
                                                    appStartParamSet.ApplicationLibDir, appStartParamSet.ApplicationDataDir, appStartParamSet.PhythonExecPath);
                BootStrapper.Init(appStartParamSet);

                var uiType = UiType.Winform;
                if (uiType == UiType.Winform) //--winform starts
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    var winformArgsStr = args[1];

                    var funcArgsArry = winformArgsStr.GetParamArray(true, false);
                    if (funcArgsArry.Length < 2)
                    {
                        goto End;
                    }

                    //##formArgsStr format
                    //###formTypeFlag=0, SviOfZone, SingViewInterfaceOfZone,指单个Zone组成一个窗体
                    //formTypeFlag^startSviZoneRelativeLocation^startZoneProcessParams

                    //###formTypeFlag=1, SviOfView, SingViewInterfaceOfView, 指单个View组成一个窗体
                    //formTypeFlag^startSviViewRelativeLocation

                    //###formTypeFlag=2, Mvi, MultipleViewInterface,指多个View组成一个窗体
                    //formTypeFlag^startFuncCode|startViewName


                    var formTypeFlag = funcArgsArry[0];
                    var formType     = FormType.SviOfZone;
                    if (formTypeFlag == "1" | formTypeFlag.ToLower() == "SviView".ToLower())
                    {
                        formType = FormType.SviOfView;
                    }
                    else if (formTypeFlag == "2" | formTypeFlag.ToLower() == "Mvi".ToLower())
                    {
                        formType = FormType.Mvi;
                    }

                    var startSviZoneRelativeLocation = "";
                    var startZoneProcessParams       = "";
                    var startSviViewRelativeLocation = "";
                    //--mvi
                    var startFuncCode = "";
                    var startViewName = "";
                    if (formType == FormType.SviOfZone)
                    {
                        startSviZoneRelativeLocation = funcArgsArry[1];
                        if (funcArgsArry.Length > 2)
                        {
                            startZoneProcessParams = funcArgsArry[2];
                        }

                        if (FileHelper.IsAbsolutePath(startSviZoneRelativeLocation))
                        {
                            throw new ArgumentException("startSviZoneRelativeLocation can't be an absolute path! ");
                        }
                        if (startSviZoneRelativeLocation.StartsWith("~"))
                        {
                            throw new ArgumentException("startSviZoneRelativeLocation can't contain \"~\"! ");
                        }
                    }
                    else if (formType == FormType.SviOfView)
                    {
                        startSviViewRelativeLocation = funcArgsArry[1];
                        if (FileHelper.IsAbsolutePath(startSviViewRelativeLocation))
                        {
                            throw new ArgumentException("startSviViewRelativeLocation can't be an absolute path! ");
                        }
                        if (startSviViewRelativeLocation.StartsWith("~"))
                        {
                            throw new ArgumentException("startSviViewRelativeLocation can't contain \"~\"!  ");
                        }
                    }
                    else//--mvi
                    {
                        var tmpArry = funcArgsArry[1].GetSubParamArray(true, false);
                        startFuncCode = tmpArry[0];
                        startViewName = tmpArry.Length > 1 ? tmpArry[1] : "";

                        if (startFuncCode.IsNullOrEmpty())
                        {
                            throw new ArgumentException("startFuncCode can't be empty ");
                        }
                        if (!startFuncCode.IsAlphaNumeralAndHyphen())
                        {
                            throw new ArgumentException("startFuncCode Name can only includes alpha, numeral and hyphen! ");
                        }

                        if (!startViewName.IsNullOrEmpty() & !startViewName.IsAlphaNumeralAndHyphen())
                        {
                            throw new ArgumentException("startViewName can only includes alpha numeral and hyphen! ");
                        }
                    }

                    //#subsequent actions by winformArgStr
                    startup.SetApplicationStartPolicy(formType, formType == FormType.Mvi ? startFuncCode : funcArgsArry[1]);


                    if (!appStartParamSet.StyleSheetCode.IsNullOrEmpty())
                    {
                        //init Ligg.EasyWinApp.WinForm.StyleSheet
                    }

                    //##VerifyStartPassword
                    if (appStartParamSet.VerifyPasswordAtStart)
                    {
                        if (appStartParamSet.PasswordVerificationRule.IsNullOrEmpty())
                        {
                            throw new ArgumentException("PasswordVerificationRule in ApplicationSettings config file can not be empty! ");
                        }
                        if (!startPassword.IsNullOrEmpty())
                        {
                            if (!startup.VerifyStartPassword(false, appStartParamSet.PasswordVerificationRule, startPassword))
                            {
                                goto End;
                            }
                        }
                        else
                        {
                            if (!startup.VerifyStartPassword(true, appStartParamSet.PasswordVerificationRule, startPassword))
                            {
                                goto End;
                            }
                        }
                    }

                    //##set formInitParamSet
                    var formInitParamSet = new FormInitParamSet();

                    formInitParamSet.FormType        = formType;
                    formInitParamSet.IsFormInvisible = invisibleFlag.GetJudgementFlag() == "true"?true : false;

                    formInitParamSet.ArchitectureCode      = CentralData.ArchitectureCode;
                    formInitParamSet.ArchitectureName      = CentralData.ArchitectureName;
                    formInitParamSet.ArchitectureVersion   = CentralData.ArchitectureVersion;
                    formInitParamSet.OrganizationCode      = CentralData.OrganizationCode;
                    formInitParamSet.OrganizationShortName = CentralData.OrganizationShortName;
                    formInitParamSet.OrganizationName      = CentralData.OrganizationName;

                    formInitParamSet.ApplicationCode    = appCode;
                    formInitParamSet.ApplicationVersion = appStartParamSet.ApplicationVersion;

                    formInitParamSet.FunctionCode                 = startFuncCode;
                    formInitParamSet.StartViewName                = startViewName;
                    formInitParamSet.StartZoneProcessParams       = startZoneProcessParams;
                    formInitParamSet.StartSviZoneRelativeLocation = startSviZoneRelativeLocation;
                    formInitParamSet.StartSviViewRelativeLocation = startSviViewRelativeLocation;


                    formInitParamSet.StartPassword        = startup.StartPassword;
                    formInitParamSet.FormTitle            = formTitle;
                    formInitParamSet.HelpdeskEmail        = appStartParamSet.HelpdeskEmail;
                    formInitParamSet.SupportMultiCultures = appStartParamSet.SupportMultiCultures;
                    formInitParamSet.IsRedirected         = isRedirectedFlag.ToLower() == "true" ? true : false;

                    formInitParamSet.ApplicationLibDir  = appStartParamSet.ApplicationLibDir;
                    formInitParamSet.ApplicationDataDir = appStartParamSet.ApplicationDataDir;
                    formInitParamSet.ApplicationTempDir = appStartParamSet.ApplicationTempDir;

                    formInitParamSet.RunBootStrapperTasksAtStart = appStartParamSet.RunBootStrapperTasksAtStart;
                    formInitParamSet.HasCblpComponent            = appStartParamSet.HasCblpComponent;

                    //##ShowSoftwareCover
                    if (appStartParamSet.ShowSoftwareCoverAtStart)
                    {
                        bool showSoftwareCover = isRedirectedFlag.ToLower() != "true";
                        if (showSoftwareCover)
                        {
                            var isOk = startup.ShowSoftwareCover(formInitParamSet);
                            if (!isOk)
                            {
                                goto End;
                            }
                        }
                    }
                    else
                    {
                    }

                    var logon = false;
                    if (appStartParamSet.LogonAtStart)
                    {
                        logon = true;
                    }

                    //##VerifyUserToken
                    if (logon & !usrCode.IsNullOrEmpty() & !usrToken.IsNullOrEmpty())
                    {
                        if (startup.VerifyUserToken(usrCode, usrToken))
                        {
                            logon = false;
                        }
                    }

                    //##VerifyUserPassword
                    else if (logon & !usrCode.IsNullOrEmpty() & !usrPassword.IsNullOrEmpty())
                    {
                        if (startup.VerifyUserPassword(usrCode, usrToken))
                        {
                            logon = false;
                        }
                    }

                    //##Logon
                    if (logon)
                    {
                        if (logon)
                        {
                            if (!startup.Logon(formInitParamSet))
                            {
                                goto End;
                            }
                        }
                    }

                    var form = new StartForm(formInitParamSet);
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                MessageHelper.PopupError(EasyWinAppRes.ApplicationStartError, EasyWinAppRes.ApplicationStartError + ": " + ex.Message);
            }
            End :;
        }
Example #3
0
        public static string GetText(string funcName, string[] funcParamArray)
        {
            //*common
            if (funcName.ToLower() == "empty" | funcName.ToLower() == "null")
            {
                return(string.Empty);
            }
            else if (funcName.ToLower() == "DateTime".ToLower())
            {
                var customFormat = "yyyy-MM-dd HH:mm:ss";
                if (funcParamArray[0].ToLower() == "UtcNow".ToLower())
                {
                    var time = SystemTimeHelper.UtcNow(); //
                    return(time.ToString(customFormat, DateTimeFormatInfo.InvariantInfo));
                }
                else if (funcParamArray[0].ToLower() == "Now".ToLower())
                {
                    var time = SystemTimeHelper.Now(); //
                    return(time.ToString(customFormat, DateTimeFormatInfo.InvariantInfo));
                }
                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param " + funcParamArray[0] + "! ");
                }
            }
            else if (funcName.ToLower() == "UniqueCode".ToLower())
            {
                if (funcParamArray[0] == "ByNow")
                {
                    var baseStr   = funcParamArray.Length > 1 ? funcParamArray[1] : "";
                    var separator = funcParamArray.Length > 2 ? funcParamArray[2] : "";
                    return(baseStr.ToUniqueStringByNow(separator));
                }
                else if (funcName.ToLower() == "ShortGuid".ToLower())
                {
                    var baseStr   = funcParamArray.Length > 1 ? funcParamArray[1] : "";
                    var separator = funcParamArray.Length > 2 ? funcParamArray[2] : "";
                    return(baseStr.ToUniqueStringByShortGuid(separator));
                }
                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param '" + funcParamArray[0] + "'! ");
                }
            }

            else if (funcName.ToLower() == "Format".ToLower())
            {
                if (funcParamArray[0].ToLower() == "upper")
                {
                    return(funcParamArray[1].ToUpper());
                }
                else if (funcParamArray[0].ToLower() == "lower")
                {
                    return(funcParamArray[1].ToLower());
                }
                else if (funcParamArray[0].ToLower() == "timespan")
                {
                    return(SystemTimeHelper.GetTimeSpanString(Convert.ToDouble(funcParamArray[1]), funcParamArray[2],
                                                              false));
                }
                else if (funcParamArray[0].ToLower() == "real")
                {
                    return(string.Format(funcParamArray[2], Convert.ToDouble(funcParamArray[1])));
                }

                else if (funcParamArray[0].ToLower() == "FormatString")
                {
                    return(string.Format(funcParamArray[1], funcParamArray[2]));
                }
                else
                {
                    throw new ArgumentException(funcName + " has no param '" + funcParamArray[0] + "'! ");
                }
            }
            else if (funcName.ToLower() == "Replace".ToLower())
            {
                return(funcParamArray[1].Length == 0 ? funcParamArray[0]
                    : funcParamArray[0].Replace(funcParamArray[1], funcParamArray[2]));
            }
            else if (funcName.ToLower() == "Split".ToLower())
            {
                var separator   = funcParamArray[1][0];
                var tmpStrArray = funcParamArray[0].Split(separator);
                var index       = Convert.ToInt16(funcParamArray[2]);
                if (index > tmpStrArray.Length || index == tmpStrArray.Length)
                {
                    return("");
                }
                else
                {
                    return(tmpStrArray[index]);
                }
            }
            else if (funcName.ToLower() == "Combine".ToLower())
            {
                var tmpStrArray = funcParamArray[0].GetSubParamArray(false, false);
                var rtStr       = "";
                if (funcParamArray.Length > 1)
                {
                    var joinSeparator = funcParamArray[1].Length == 1 ? Convert.ToChar(funcParamArray[1]) : ' ';
                    rtStr = Ligg.Infrastructure.Base.Helpers.StringHelper.UnwrapStringArrayBySeparator(tmpStrArray, joinSeparator);
                }
                else
                {
                    foreach (var tmpStr in tmpStrArray)
                    {
                        rtStr = rtStr + tmpStr;
                    }
                }
                return(rtStr);
            }
            else if (funcName.ToLower() == "SubString".ToLower())
            {
                var   tmStr    = funcParamArray[0];
                Int16 sttIndex = Convert.ToInt16(funcParamArray[1]);
                Int16 len      = Convert.ToInt16(funcParamArray[2]);
                return(tmStr.Substring(sttIndex, len));
            }
            else if (funcName.ToLower() == "AddOrRemoveSubParam".ToLower())
            {
                var separator = ',';
                if (funcParamArray[0].ContainsSubParamSeparator())
                {
                    separator = funcParamArray[0].GetSubParamSeparator();
                }

                var add = funcParamArray[2].ToLower() == "true" ? true : false;
                return(funcParamArray[0].AddOrDelToSeparatedStrings(funcParamArray[1], add, separator));
            }

            //*get
            else if (funcName.ToLower() == "GetLineQty".ToLower())
            {
                int qty = funcParamArray[0].Split('\n').Length;
                return(Convert.ToString(qty));
            }
            else if (funcName.ToLower() == "GetLinesBySearch".ToLower())
            {
                var strArry    = funcParamArray[0].Split('\n');
                var schStrArry = funcParamArray[1].Split(',');
                var strList    = new List <string>();
                foreach (var v in strArry)
                {
                    foreach (var s in schStrArry)
                    {
                        if (v.ToLower().Contains(s.ToLower()))
                        {
                            strList.Add(v);
                        }
                    }
                }

                var strList1 = strList.Distinct();
                var strBlder = new StringBuilder();
                foreach (var v in strList1)
                {
                    if (!string.IsNullOrEmpty(v))
                    {
                        strBlder.AppendLine(v);
                    }
                }

                return(strBlder.ToString());
            }

            //*convert
            else if (funcName.ToLower() == "ConvertJsonToRichText".ToLower())
            {
                var  jsonStr = funcParamArray[0];
                var  dt      = JsonHelper.ConvertToDataTable(jsonStr);
                bool hasHead = false;
                if (funcParamArray.Length > 1)
                {
                    if (funcParamArray[1].ToLower() == "true")
                    {
                        hasHead = true;
                    }
                }

                String[] strArray = null;
                if (funcParamArray.Length > 2)
                {
                    if (!funcParamArray[2].IsNullOrEmpty())
                    {
                        strArray = funcParamArray[2].GetSubParamArray(true, true);
                    }
                }
                var rtStr = DataTableHelper.ConvertToRichText(dt, hasHead, strArray);

                return(rtStr);
            }

            //*file
            else if (funcName.ToLower() == "FileDetail".ToLower())
            {
                if (funcParamArray[1].IsNullOrEmpty())
                {
                    throw new ArgumentException("file path can't be empty! ");
                }
                if (funcParamArray[0].ToLower() == "Directory".ToLower())
                {
                    return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Directory));
                }
                else if (funcParamArray[0].ToLower() == "FileName".ToLower())
                {
                    return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.FileName));
                }
                else if (funcParamArray[0].ToLower() == "FileTitle".ToLower())
                {
                    return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.FileTitle));
                }
                else if (funcParamArray[0].ToLower() == "Suffix".ToLower())
                {
                    return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Suffix));
                }
                else if (funcParamArray[0].ToLower() == "Postfix".ToLower())
                {
                    return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Postfix));
                }
                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param '" + funcParamArray[0] + "'! ");
                }
            }
            //*no use yet
            else if (funcName.ToLower() == "CompareFile".ToLower())
            {
                //var result = FileHelper.Compare2Files(funcParamArray[1], funcParamArray[2]).ToString();
                return(string.Empty);
            }


            else if (funcName.ToLower() == "GetContentFromTextFile".ToLower() | funcName.ToLower() == "GetCttFrTextFile".ToLower())
            {
                return(FileHelper.GetContentFromTextFile(funcParamArray[0]));
            }

            else if (funcName.ToLower() == "GetIniFileSetting".ToLower())
            {
                var filePath = funcParamArray[0];
                FileHelper.CheckFilePathExistence(filePath);
                var key    = funcParamArray[1];
                var defVal = funcParamArray.Length > 2 ? funcParamArray[2] : "";
                return(IniFileHelper.ReadIniString(filePath, "setting", key, defVal));
            }

            //*Json

            //*calc
            else if (funcName.ToLower() == "Calc".ToLower())
            {
                if (funcParamArray[0].ToLower() == "add".ToLower())
                {
                    return((Convert.ToDouble(funcParamArray[1]) + Convert.ToDouble(funcParamArray[2])).ToString());
                }
                else if (funcParamArray[0].ToLower() == "sub".ToLower())
                {
                    return((Convert.ToDouble(funcParamArray[1]) - Convert.ToDouble(funcParamArray[2])).ToString());
                }
                else if (funcParamArray[0].ToLower() == "mtp".ToLower())
                {
                    return((Convert.ToDouble(funcParamArray[1]) * Convert.ToDouble(funcParamArray[2])).ToString());
                }
                else if (funcParamArray[0].ToLower() == "div".ToLower())
                {
                    return((Convert.ToDouble(funcParamArray[1]) / Convert.ToDouble(funcParamArray[2])).ToString());
                }
                else if (funcParamArray[0].ToLower() == "rnd".ToLower())
                {
                    return((Math.Round(Convert.ToDouble(funcParamArray[1]))).ToString());
                }
                else if (funcParamArray[0].ToLower() == "spls".ToLower())
                {
                    return((Convert.ToDouble(funcParamArray[1]) % (Convert.ToDouble(funcParamArray[2]))).ToString());
                }
                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                }
            }

            //*Status
            else if (funcName.ToLower() == "GetFinalStatus".ToLower())
            {
                if (funcParamArray.All(v => v.ToLower() == "true"))
                {
                    return("true");
                }
                if (funcParamArray.Any(v => v.ToLower() == "unknown"))
                {
                    return("unknown");
                }
                return("false");
            }

            //*bool
            else if (funcName.ToLower() == "GetBool".ToLower())
            {
                if (funcParamArray[0].ToLower() == "TotalStatus".ToLower())
                {
                    var returnStr         = "true";
                    var subfuncParamArray = funcParamArray[1].Split(',');
                    if (subfuncParamArray.Any(v => v.ToLower() != "1"))
                    {
                        returnStr = "false";
                    }
                    return(returnStr);
                }
                else if (funcParamArray[0].ToLower() == "And".ToLower())
                {
                    var returnStr         = "true";
                    var subfuncParamArray = funcParamArray[1].Split(',');
                    if (subfuncParamArray.Any(v => v.ToLower() != "true"))
                    {
                        returnStr = "false";
                    }
                    return(returnStr);
                }
                else if (funcParamArray[0].ToLower() == "Or".ToLower())
                {
                    var returnStr         = "false";
                    var subfuncParamArray = funcParamArray[1].Split(',');
                    if (subfuncParamArray.Any(v => v.ToLower() == "true"))
                    {
                        returnStr = "true";
                    }
                    return(returnStr);
                }
                else if (funcParamArray[0].ToLower() == "Not".ToLower())
                {
                    var returnStr = "true";
                    if (funcParamArray[1].ToLower() == "true")
                    {
                        returnStr = "false";
                    }
                    return(returnStr);
                }

                else if (funcParamArray[0].ToLower() == "IsDirectoryExisting".ToLower())
                {
                    var returnStr = "false";
                    if (Directory.Exists(funcParamArray[1]))
                    {
                        returnStr = "true";
                    }
                    return(returnStr);
                }
                else if (funcParamArray[0].ToLower() == "IsDirectoryHidden".ToLower())
                {
                    if (!Directory.Exists(funcParamArray[1]))
                    {
                        return("false");
                    }
                    var returnStr = "false";
                    var di        = new DirectoryInfo(funcParamArray[1]);
                    if ((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        returnStr = "true";
                    }
                    return(returnStr);
                }
                else if (funcParamArray[0].ToLower() == "IsFileExisting".ToLower())
                {
                    var returnStr = "false";
                    if (File.Exists(funcParamArray[1]))
                    {
                        returnStr = "true";
                    }
                    return(returnStr);
                }

                else if (funcParamArray[0].ToLower() == "IfElse".ToLower())
                {
                    var con        = funcParamArray[1];
                    var conArry    = con.GetSubParamArray(true, false);
                    var judgedText = conArry[0];
                    var judgeFlag  = conArry[1];
                    var val        = "";
                    if (conArry.Length > 2)
                    {
                        val = conArry[2];
                    }
                    if (GetHelper.Judge(judgeFlag, judgedText, val))
                    {
                        return("true");
                    }
                    return("false");
                }

                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                }
            }

            //*if
            else if (funcName.ToLower() == "IfElse".ToLower())
            {
                var con        = funcParamArray[0];
                var returnVal  = funcParamArray[1];
                var returnVal1 = funcParamArray[2];
                var conArry    = con.GetSubParamArray(true, false);
                var judgedText = conArry[0];
                var judgeFlag  = conArry[1];
                var val        = "";
                if (conArry.Length > 2)
                {
                    val = conArry[2];
                }
                if (GetHelper.Judge(judgeFlag, judgedText, val))
                {
                    return(returnVal);
                }
                return(returnVal1);
            }
            //*encrypt
            else if (funcName.ToLower() == "EncryptText".ToLower())
            {
                if (funcParamArray[0].ToLower() == "Md5".ToLower())
                {
                    return(EncryptionHelper.Md5Encrypt(funcParamArray[1]));
                }

                else
                {
                    throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                }
            }


            else if (funcName.ToLower() == "Validate".ToLower())
            {
                var retStr = Validator.Validate(funcParamArray[0], funcParamArray[1]);
                if (retStr == "OutOfScopeOfValidator")
                {
                    return("OutOfScope");
                }
                else
                {
                    return(retStr);
                }
            }

            else
            {
                return("OutOfScope");
            }
        }