Exemplo n.º 1
0
        public void getConfig(string pathConfig = null, string pathNames = null, string projectName = null)
        {
            string path;

            if (pathConfig == null && pathNames == null && projectName == null)
            {
                path = PathDef.PhysicalPath + @"\JSONconfig\" + Session["ProjectName"].ToString() + "_" + Session["pathConfig"].ToString().Substring(Session["pathConfig"].ToString().LastIndexOf(@"\") + 1) + ".json";
            }
            else
            {
                path = PathDef.PhysicalPath + @"\JSONconfig\" + projectName + "_" + pathConfig.Substring(pathConfig.LastIndexOf(@"\") + 1) + ".json";
            }
            string json;

            if (System.IO.File.Exists(path))
            {
                json = System.IO.File.ReadAllText(path);
                json = new string((from c in json
                                   where !char.IsWhiteSpace(c) || c.ToString().Contains(" ")
                                   select c).ToArray());
                int jsonLength = json.Length;
                configSer              = new JavaScriptSerializer().Deserialize <Config>(json);
                config.LangEnbList     = configSer.LangEnbList;
                config.NameDefList     = configSer.NameDef;
                config.TableDefList    = configSer.TableDef;
                config.TextlistDefList = configSer.TextlistDef;
            }
            else
            {
                if (config.ViewList.Count == 0)
                {
                    if (Session != null)
                    {
                        pathConfig = Session["pathConfig"].ToString();
                        pathNames  = Session["pathNames"].ToString();
                    }
                    Iniparser ini = new Iniparser(pathConfig, pathNames);
                    ini.ParseLangs(config);
                    ini.ParseNames(config, Const.separators);
                    ini.ParseCfg(config, Const.separators, config);
                    Iniparser.FindTableName(config); //Only to find missing(all are missing) tableName
                }
                json = config.toJSON(config);
                Directory.CreateDirectory(PathDef.PhysicalPath + @"\JSONconfig");
                System.IO.File.WriteAllText(path, json);
            }
            if (pathConfig == null && pathNames == null && projectName == null)
            {
                Response.ContentType = "application /json";
                Response.Write(json);
            }
        }
Exemplo n.º 2
0
        public JsonResult Config()
        {
            if (config.ViewList.Count == 0)
            {
                ViewData["pathConfig"] = Session["pathConfig"];
                ViewData["pathNames"]  = Session["pathNames"];
                Iniparser ini = new Iniparser(ViewData["pathConfig"].ToString(), ViewData["pathNames"].ToString());
                ini.ParseNames(config, Const.separators);
                ini.ParseCfg(config, Const.separators, config);
            }
            object data = new object();

            data = config;
            var json = Json(data, "application/json", JsonRequestBehavior.AllowGet);

            return(Json(data, "application/json", JsonRequestBehavior.AllowGet));
        }