Beispiel #1
0
 public static void LoadLangFromCache()
 {
     try
     {
         AllCaches.LanguageInfo = (Dictionary <string, string>)CommonUtils.GetCache(CONSTANTS.CACHED_LANG_FILENAME);
     }
     catch
     {
         throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_GET_DEFINED_LANGUAGE_FAIL);
     }
 }
Beispiel #2
0
        public static ModuleInfo GetModuleInfo(string moduleID, string subModule)
        {
            var module = (from item in AllCaches.ModulesInfo
                          where item.ModuleID == moduleID && (string.IsNullOrEmpty(subModule) || subModule == item.SubModule)
                          select item).ToList();

            if (module.Count == 0)
            {
                throw ErrorUtils.CreateErrorWithSubMessage(ERR_SYSTEM.ERR_SYSTEM_MODULE_NOT_FOUND, moduleID + "." + subModule);
            }

            if (module.Count > 1)
            {
                throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_MODULE_HAVE_TO_CALL_SUB, moduleID + "." + subModule);
            }

            return(NewCopyModule(module[0]));
        }
Beispiel #3
0
        public static ModuleInfo GetModuleInfo(string moduleID)
        {
            var module = (from item in AllCaches.ModulesInfo
                          where
                          item.ModuleID == moduleID &&
                          ((item.SubModule == CODES.DEFMOD.SUBMOD.MAINTAIN_ADD) ||
                           (item.SubModule == CODES.DEFMOD.SUBMOD.MODULE_MAIN))
                          select item).ToList();

            if (module.Count == 0)
            {
                throw ErrorUtils.CreateErrorWithSubMessage(ERR_SYSTEM.ERR_SYSTEM_MODULE_NOT_FOUND, moduleID);
            }

            if (module.Count > 1)
            {
                throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_MODULE_HAVE_TO_CALL_SUB, moduleID);
            }

            return(NewCopyModule(module[0]));
        }
Beispiel #4
0
        public static ProcExpression ParseScript(string source)
        {
            if (!string.IsNullOrEmpty(source))
            {
                var procExpression = new ProcExpression();
                var match          = Regex.Match(source, "([^\\(]+)\\(([^\\)]*)\\)");

                if (match.Success)
                {
                    procExpression.StoreProcName = match.Groups[1].Value;
                    //
                    var strParams = match.Groups[2].Value + ",";
                    if (!string.IsNullOrEmpty(match.Groups[2].Value))
                    {
                        var    cur    = 0;
                        var    opened = false;
                        string param  = null;
                        string value  = null;

                        while (cur < strParams.Length)
                        {
                            if (strParams[cur] == '\'')
                            {
                                if (cur + 1 < strParams.Length && strParams[cur + 1] == '\'' && opened)
                                {
                                    value += '\'';
                                    cur++;
                                }
                                else
                                {
                                    opened = !opened;
                                }
                            }
                            else if (strParams[cur] == ',')
                            {
                                if (opened)
                                {
                                    value += ',';
                                }
                                else
                                {
                                    decimal num;
                                    param = param == null ? param : param.Trim();
                                    if (string.IsNullOrEmpty(param))
                                    {
                                        procExpression.Operands.Add(new Operand(OperandType.VALUE, value));
                                    }
                                    else if (decimal.TryParse(param, out num))
                                    {
                                        procExpression.Operands.Add(new Operand(OperandType.VALUE, num.ToString()));
                                    }
                                    else if (value == null)
                                    {
                                        procExpression.Operands.Add(new Operand(OperandType.NAME, param));
                                    }
                                    else
                                    {
                                        throw ErrorUtils.CreateErrorWithSubMessage(ERR_SYSTEM.ERR_SYSTEM_PARSE_SQL_SCRIPT_ERROR,
                                                                                   "ParseScript", source);
                                    }

                                    param = null;
                                    value = null;
                                }
                            }
                            else
                            {
                                if (opened)
                                {
                                    value += strParams[cur];
                                }
                                else
                                {
                                    param += strParams[cur];
                                }
                            }
                            cur++;
                        }
                    }

                    return(procExpression);
                }

                throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_PARSE_SQL_SCRIPT_ERROR,
                                             "ParseScript", source);
            }
            return(null);
        }
Beispiel #5
0
        private static string Translate(LangType type, bool returnEmpty, params string[] @params)
        {
            string langName     = null;
            var    defaultValue = @params[0];

            switch (type)
            {
            case LangType.DEFINE_ERROR:
                langName     = string.Format("DEFERROR${0}", @params);
                defaultValue = "ERR{0}: " + @params[0];
                break;

            case LangType.ROLE_NAME:
                langName = string.Format("ROLE${0}", @params);
                break;

            case LangType.DEFINE_CODE:
                langName     = string.Format("DEFCODE${0}${1}.{2}", @params);
                defaultValue = string.Format("{1}.{2}", @params);
                break;

            case LangType.MENU_CAPTION:
                langName = string.Format("MENU${0}.Caption", @params);
                break;

            case LangType.MENU_ICON:
                langName = string.Format("MENU${0}.Icon", @params);
                break;

            case LangType.MENU_HOTKEY:
                langName = string.Format("MENU${0}.Hotkey", @params);
                break;

            case LangType.BUTTON_CAPTION:
                langName     = string.Format("{0}${1}.Caption", @params);
                defaultValue = string.Format("{1}", @params);
                break;

            case LangType.BUTTON_ICON:
                langName = string.Format("{0}${1}.Icon", @params);
                break;

            case LangType.BUTTON_HOTKEY:
                langName = string.Format("{0}${1}.Hotkey", @params);
                break;

            case LangType.BUTTON_TIP:
                langName     = string.Format("{0}${1}.Tip", @params);
                defaultValue = string.Format("{1}.Tip", @params);
                break;

            case LangType.LABEL_FIELD:
                langName     = string.Format("{0}${1}.Label", @params);
                defaultValue = string.Format("{1}", @params);
                break;

            case LangType.ICON_FIELD:
                langName = string.Format("{0}${1}.Icon", @params);
                break;

            case LangType.MODULE_TITLE:
                langName     = string.Format("{0}.Title", @params);
                defaultValue = string.Format("{0}.Title", @params);
                break;

            case LangType.MODULE_STATUS:
                if (@params.Length == 1)
                {
                    langName = string.Format("{0}.Status", @params);
                }
                else
                {
                    langName = string.Format("{0}.Status[{1}]", @params);
                }
                defaultValue = langName;
                break;

            case LangType.PAGE_INFO:
                if (@params.Length == 1)
                {
                    langName = string.Format("{0}.PageInfo", @params);
                }
                else
                {
                    langName = string.Format("{0}.PageInfo[{1}]", @params);
                }
                defaultValue = langName;
                break;

            case LangType.MODULE_ICON:
                if (@params.Length == 1)
                {
                    langName = string.Format("{0}.Icon", @params);
                }
                else
                {
                    langName = string.Format("{0}.Icon[{1}]", @params);
                }
                break;

            case LangType.MODULE_TEXT:
                langName     = string.Format("{0}.Text[{1}]", @params);
                defaultValue = langName;
                break;

            case LangType.MODULE_LAYOUT:
                if (@params.Length == 1)
                {
                    langName = string.Format("{0}.Layout", @params);
                }
                else
                {
                    langName = string.Format("{0}.Layout[{1}]", @params);
                }
                break;

            case LangType.VALID_ERROR:
                langName     = string.Format("{0}.Validate[{1}]", @params);
                defaultValue = langName;
                break;

            case LangType.VALID_NULL:
                langName     = string.Format("{0}.IsNull", @params);
                defaultValue = langName;
                break;

            case LangType.SIZE:
                langName     = string.Format("{0}.Size", @params);
                defaultValue = "640,480";
                break;
            }

            switch (type)
            {
            case LangType.DEFINE_ERROR:
            case LangType.ROLE_NAME:
            case LangType.DEFINE_CODE:
            case LangType.MENU_CAPTION:
            case LangType.BUTTON_CAPTION:
            case LangType.LABEL_FIELD:
            case LangType.MODULE_TITLE:
            case LangType.MODULE_STATUS:
            case LangType.PAGE_INFO:
            case LangType.MODULE_TEXT:
            case LangType.VALID_ERROR:
            case LangType.VALID_NULL:
            case LangType.SIZE:
                if (returnEmpty)
                {
                    return(TranslateBasic(null, langName));
                }
                return(TranslateBasic(defaultValue, langName));

            case LangType.MENU_ICON:
            case LangType.MENU_HOTKEY:
            case LangType.BUTTON_ICON:
            case LangType.BUTTON_HOTKEY:
            case LangType.BUTTON_TIP:
            case LangType.ICON_FIELD:
            case LangType.MODULE_ICON:
            case LangType.MODULE_LAYOUT:
                return(TranslateBasic(null, langName));
            }

            throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_LANGUAGE_NOT_SUPPORTED);
        }