Exemplo n.º 1
0
    /// <summary>
    /// This method saves all tours as a JSON file.
    /// It calls the appropriate methods and then writes the output string to a file.
    /// </summary>
    public void SaveJSONCategoriesAsFile()
    {
        //Instantiate and Fill a DataTable object with test data

        DA_POI_Category tourDataObject      = new DA_POI_Category();
        DataTable       tourDataTableObject = tourDataObject.GetAllCategories();

        /*Instantiate Method to retrieve the data from the filled DataTable object
         * and concatenates it into a JSON-formatted string*/

        JSON_Utils utils          = new JSON_Utils();
        string     tourJsonString = utils.CovertCategoryDataTableToJSON(tourDataTableObject);
        string     pathToJSONFile;

        //Set path and filename for saved JSON file(NOTE: This is used when using a Data_Categories file to hold Category_.js files...
        //Claws at this time will not allow admin to be run with this extra layer)
        //pathToJSONFile = currentContext.Server.MapPath("../Data_Categories/ListOfCategories.js");

        //Set path and filename for saved JSON file
        pathToJSONFile = currentContext.Server.MapPath("../ListOfCategories.js");

        //Create StreamWriter object
        StreamWriter StreamWriter = new StreamWriter(pathToJSONFile);

        //Writing JSON string to the file.
        StreamWriter.Write(tourJsonString);

        ////Close the file.
        StreamWriter.Close();
    }
 /// <summary>
 /// name:         butSaveJSONFile_Click
 /// description:  button click method that is used to save a new Places.js file   
 /// </summary>
 protected void butSaveJSONFile_Click(object sender, EventArgs e)
 {
     DA_POI PoiDataObject = new DA_POI();
     JSON_Utils jsonUtilityObject = new JSON_Utils();
     jsonUtilityObject.SaveJSONCategoriesAsFile();
     jsonUtilityObject.SaveJSONCategoriesAndLocationsAsFile();
 }
    /// <summary>
    /// name:         butSaveJSONFile_Click
    /// description:  button click method that is used to save a new Places.js file
    /// </summary>
    protected void butSaveJSONFile_Click(object sender, EventArgs e)
    {
        DA_POI PoiDataObject = new DA_POI();

        ////Fill a DataTable object with test data
        //DataTable PoiDataTableObject = PoiDataObject.GetPOIs();

        ////Retrieve the data from the filled DataTable object
        //// and concatenate it into a JSON-formatted string
        //JSON_Utils jsonUtilityObject = new JSON_Utils();

        //string jsonString = JSON_Utils.ConvertDataTableToJSON(PoiDataTableObject);

        //jsonUtilityObject.SaveJSONStringAsFile(jsonString);

        JSON_Utils jsonUtilityObject = new JSON_Utils();

        jsonUtilityObject.SaveJSONCategoriesAsFile();
        jsonUtilityObject.SaveJSONCategoriesAndLocationsAsFile();
    }
    /// <summary>
    /// name:         butSaveJSONFile_Click
    /// description:  button click method that is used to save a new Places.js file   
    /// </summary>
    protected void butSaveJSONFile_Click(object sender, EventArgs e)
    {
        DA_POI PoiDataObject = new DA_POI();

        ////Fill a DataTable object with test data
        //DataTable PoiDataTableObject = PoiDataObject.GetPOIs();

        ////Retrieve the data from the filled DataTable object 
        //// and concatenate it into a JSON-formatted string
        //JSON_Utils jsonUtilityObject = new JSON_Utils();

        //string jsonString = JSON_Utils.ConvertDataTableToJSON(PoiDataTableObject);

        //jsonUtilityObject.SaveJSONStringAsFile(jsonString);

        JSON_Utils jsonUtilityObject = new JSON_Utils();
        jsonUtilityObject.SaveJSONCategoriesAsFile();
        jsonUtilityObject.SaveJSONCategoriesAndLocationsAsFile();

    }
Exemplo n.º 5
0
    public void SaveJSONCategoriesAndLocationsAsFile()
    {
        //Instantiate and Fill a DataTable object with Category data

        DA_POI_Category tourDataObject      = new DA_POI_Category();
        DataTable       tourDataTableObject = tourDataObject.GetAllCategories();

        foreach (DataRow row in tourDataTableObject.Rows)
        {
            string tourID        = Convert.ToString(row["Category_Code"]);
            bool   checkIsActive = true;

            /*Instantiate Method to retrieve the data from the filled DataTable object
             * and concatenates it into a JSON-formatted string*/

            JSON_Utils utils          = new JSON_Utils();
            string     tourJsonString = JSON_Utils.CovertCategoryPOIDataTableToJSON(tourID, tourDataTableObject, checkIsActive);
            string     pathToJSONFile;

            //Set path and filename for saved JSON file (NOTE: This is used when using a Data_Categories file to hold Category_.js files...
            //Claws at this time will not allow admin to be run with this extra layer)
            // pathToJSONFile = currentContext.Server.MapPath("../Data_Categories/Category_" + tourID + ".js");

            //Set path and filename for saved JSON file
            pathToJSONFile = currentContext.Server.MapPath("../Category_" + tourID + ".js");

            //Create StreamWriter object
            StreamWriter StreamWriter = new StreamWriter(pathToJSONFile);

            //Writing JSON string to the file.
            StreamWriter.Write(tourJsonString);

            ////Close the file.
            StreamWriter.Close();
        }
    }
 public static string get_JSON_object_result(string json_object_string)
 {
     return(JSON_Utils.get_JSON_object_field_value(json_object_string, "result"));
 }
 public static JArray get_JSON_array_result(string json_array_string)
 {
     return(JSON_Utils.get_JSON_array_field_value(json_array_string, "result"));
 }
Exemplo n.º 8
0
    /// <summary>
    /// This method saves all tours as a JSON file. 
    /// It calls the appropriate methods and then writes the output string to a file.
    /// </summary>
    public void SaveJSONCategoriesAsFile()
    {
        //Instantiate and Fill a DataTable object with test data

        DA_POI_Category tourDataObject = new DA_POI_Category();
        DataTable tourDataTableObject = tourDataObject.GetAllCategories();

        /*Instantiate Method to retrieve the data from the filled DataTable object
        and concatenates it into a JSON-formatted string*/

        JSON_Utils utils = new JSON_Utils();
        string tourJsonString = utils.CovertCategoryDataTableToJSON(tourDataTableObject);
        string pathToJSONFile;

        //Set path and filename for saved JSON file(NOTE: This is used when using a Data_Categories file to hold Category_.js files...
        //Claws at this time will not allow admin to be run with this extra layer)
        //pathToJSONFile = currentContext.Server.MapPath("../Data_Categories/ListOfCategories.js");

        //Set path and filename for saved JSON file
        pathToJSONFile = currentContext.Server.MapPath("../ListOfCategories.js");

        //Create StreamWriter object
        StreamWriter StreamWriter = new StreamWriter(pathToJSONFile);

        //Writing JSON string to the file.
        StreamWriter.Write(tourJsonString);

        ////Close the file.
        StreamWriter.Close();
    }
Exemplo n.º 9
0
    public void SaveJSONCategoriesAndLocationsAsFile()
    {
        //Instantiate and Fill a DataTable object with Category data

        DA_POI_Category tourDataObject = new DA_POI_Category();
        DataTable tourDataTableObject = tourDataObject.GetAllCategories();

        foreach (DataRow row in tourDataTableObject.Rows)
        {
            string tourID = Convert.ToString(row["Category_Code"]);
            bool checkIsActive = true;

            /*Instantiate Method to retrieve the data from the filled DataTable object
            and concatenates it into a JSON-formatted string*/

            JSON_Utils utils = new JSON_Utils();
            string tourJsonString = JSON_Utils.CovertCategoryPOIDataTableToJSON(tourID, tourDataTableObject, checkIsActive);
            string pathToJSONFile;

            //Set path and filename for saved JSON file (NOTE: This is used when using a Data_Categories file to hold Category_.js files...
            //Claws at this time will not allow admin to be run with this extra layer)
           // pathToJSONFile = currentContext.Server.MapPath("../Data_Categories/Category_" + tourID + ".js");

            //Set path and filename for saved JSON file
            pathToJSONFile = currentContext.Server.MapPath("../Category_" + tourID + ".js");

            //Create StreamWriter object
            StreamWriter StreamWriter = new StreamWriter(pathToJSONFile);

            //Writing JSON string to the file.
            StreamWriter.Write(tourJsonString);

            ////Close the file.
            StreamWriter.Close();
        }
    }