private void GetComponent()
    {
        string componentPath = Server.MapPath(@"~\Modules\WebBuilder\js\components.js");

        if (!File.Exists(componentPath))
        {
            int userModuleID = 1317;
            WebBuilderController        objWebbuilderController = new WebBuilderController();
            List <BuilderComponentJson> objComponentList        = objWebbuilderController.GetComponentValue(userModuleID.ToString());
            componentList = JsonConvert.SerializeObject(objComponentList);
            //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "StartupViewScript", "var storedComponent=" + componentList.ToString(), true);
            SaveComponentToJS("var storedComponent=" + componentList.ToString() + ";", componentPath);
        }
    }
Esempio n. 2
0
 private void SaveComponentToJS(string componentPath)
 {
     try
     {
         string componentList = string.Empty;
         WebBuilderController        objWebbuilderController = new WebBuilderController();
         List <BuilderComponentJson> objComponentList        = objWebbuilderController.GetComponentValue(userModuleID.ToString());
         componentList = JsonConvert.SerializeObject(objComponentList);
         string components = "var storedComponent=" + componentList.ToString() + ";";
         File.WriteAllText(componentPath, String.Empty);
         using (StreamWriter writeToFile = new StreamWriter(File.Open(componentPath, FileMode.OpenOrCreate)))
         {
             writeToFile.WriteLine(components);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }