Click here to Skip to main content
16,018,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
//using Oracle.DataAccess.Client;
using Timex.EmployeeLifeCycle;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using Timex.Shared;
using Timex.Project;

public partial class PM_Roots_RootChild : System.Web.UI.Page
{
    clsFunction fun = new clsFunction();
    App_Common objMessage = new App_Common();
    Common objBl = new Common();
    RootChild rs = new RootChild();
    string emp_mid;

     
    protected void Page_Load(object sender, EventArgs e)
    
    {
        emp_mid= txtEmpmid.Text;
        
        GenerateFlowChart();

        //UCpeople.txtSearchChange += new EventHandler(UCpeople_txtSearchChange);

        if (!Page.IsPostBack)
        {
            
        }
        //txtEmpmid.Attributes.Add("onblur", "javascript:init('" + txtEmpmid.ClientID + "', '" + txtEmpname.ClientID + "')");
        //txtEmpmid.Attributes.Add("onblur", "javascript:initTest('" + txtEmpmid.ClientID + "','" + txtEmpname.ClientID + "')");
        txtEmpmid.Attributes.Add("onblur", "javascript:initTest('" + txtEmpmid.ClientID + "','" + hdnJsonData.ClientID + "')");
        btnShowGraph.Attributes.Add("onClick", "javascript:ReloadFrame('" + frmCtrl.ClientID + "','" + hdnJsonData.ClientID + "')");

        //frmCtrl.s
       
    }

    //void UCpeople_txtSearchChange(object sender, EventArgs e)
    //{
    //    if (!UCpeople.Text.Equals(""))
    //    {
    //        DataSet ds = new DataSet();
    //        ds = rs.Select_emp(emp_mid);
    //        UCpeople.Text = UCpeople.Value;
    //        if (ds.Tables.Count != 0)
    //        {
    //            txtEmpmid.Text = ds.Tables[0].Rows[0]["EMP_NAME"].ToString().Replace(" ", "");
    //        }
    //    }
    //}


    
    private void GenerateFlowChart()
    {
        try
        {
            Timex.Project.RootChild rc = new Timex.Project.RootChild();
            rc.GenarateFlow(UCpeople.Value, ddpLevel.SelectedValue);
            DataTable dt = new DataTable();
            dt = fun.GetDataTable("SELECT * FROM TEMP_FLOW_REPORT ORDER BY FLOW_LEVEL, emp_mid");
            StringBuilder sb = new StringBuilder();
            sb.Append (Write_Header()).AppendLine();
            sb.Append("function init(){").AppendLine();
            sb.Append("    //init data").AppendLine();
            sb.Append("    var json = {").AppendLine();
            //sb.Append("        id: " + (char)34 + UCpeople.Code + (char)34 + ",").AppendLine();
            sb.Append("        id: " + (char)34 + "EM000751" + (char)34 + ",").AppendLine();
            sb.Append("        name: " + (char)34 + UCpeople.Text + (char)34 + ",").AppendLine();
            sb.Append("        data: {},").AppendLine();
            sb.Append(Write_Parent(dt, UCpeople.Value)).AppendLine();
            sb.Append("};").AppendLine();
            sb.Append(Write_Footer()).AppendLine();
            sb.Append("}").AppendLine();
            //System.IO.File.WriteAllText(@"D:\OSOURCE-ONEX\Application Source Code\trunk\Code\PM\Roots\js\example_new.js", sb.ToString());

        }
        catch (Exception ex)
        {
            throw ex; 
        }
    }
}


-Edit-
Added code blocks
Posted
Updated 27-Feb-14 21:41pm
v2

Popular high-performance JSON framework for .NET : NewtonSoft.JSON.dll

http://james.newtonking.com/json[^]
 
Share this answer
 
One way to go would be to use the (available as of .NET 3.5) DataContractJsonSerializer in the System.Runtime.Serialization.Json Namespace: [^].

I am not familiar with the System.Web.Helpers facilities, but, I suspect that the Json Class in that library might be useful: [^].

Mehdi Gholam, here on CodeProject, has excellent code for very fast JSON and BinaryJSON serialize/deserialize: [^], [^]. These projects were started in 2011, and Mehdi has been supporting them very generously all along, and updating them, adding new features, and improving performance, frequently.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900