示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int             User_ID = Convert.ToInt32(context.Request["User_ID"]);
            String          contact = context.Request["Contact"];
            Contact         cont    = JsonConvert.DeserializeObject <Contact>(contact);
            MySqlHelper     helper1 = new MySqlHelper();
            MySqlDataReader reader1 = helper1.getMySqlReader("select count(*) from contact where User_ID=" + User_ID + ";");

            reader1.Read();
            int    id  = User_ID * 10000 + reader1.GetInt32(0);
            String sql = "insert into contact (ID,User_ID,Name) Values (" + id + "," + User_ID + ",\"" + cont.Name + "\");";

            reader1.Close();
            reader1.Dispose();
            helper1.mysqlcom.Dispose();
            helper1.mysqlcon.Close();
            helper1.mysqlcon.Dispose();
            MySqlHelper helper = new MySqlHelper();

            if (helper.getMySqlCom(sql) > 0)
            {
                sql = "insert into contact_info (EmailOrNumber,Number,Type,Contact_ID) values ";
                if (cont.ContactInfos != null)
                {
                    for (int j = 0; j < cont.ContactInfos.Count; j++)
                    {
                        if (sql.Length < 75)
                        {
                            sql += "(" + cont.ContactInfos[j].EmailOrNumber + ",\"" + cont.ContactInfos[j].Number + "\",\"" + cont.ContactInfos[j].Type + "\"," + id + ")";
                        }
                        else
                        {
                            sql += ",(" + cont.ContactInfos[j].EmailOrNumber + ",\"" + cont.ContactInfos[j].Number + "\",\"" + cont.ContactInfos[j].Type + "\"," + id + ")";
                        }
                        if (j == cont.ContactInfos.Count - 1)
                        {
                            if (helper.getMySqlCom(sql) > 0)
                            {
                                context.Response.Write("OK");
                            }
                            else
                            {
                                context.Response.Write("Error");
                            }
                        }
                    }
                }
                else
                {
                    context.Response.Write("OK");
                }
            }
            else
            {
                context.Response.Write("Error");
            }
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            String          UserName = context.Request["UserName"];
            String          sql      = "select * from user where UserName='******'";
            MySqlHelper     helper   = new MySqlHelper();
            MySqlDataReader reader   = helper.getMySqlReader(sql);

            reader.Read();
            context.Response.Write("Sign:" + (reader.IsDBNull(6)?"":reader.GetString(6)) + ";SignCount:" + (reader.IsDBNull(6) ? "0":reader.GetInt32(7) + ""));
            reader.Dispose();
            helper.mysqlcom.Dispose();
            helper.mysqlcon.Close();
            helper.mysqlcon.Dispose();
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            String          UserName = context.Request["UserName"];
            String          sql      = "select Sign,SignCount from user where UserName='******'";
            MySqlHelper     helper   = new MySqlHelper();
            MySqlDataReader reader   = helper.getMySqlReader(sql);

            reader.Read();
            String today     = DateTime.Today.Year + "-" + (DateTime.Today.Month > 9 ? "" + DateTime.Today.Month : "0" + DateTime.Today.Month) + "-" + DateTime.Today.Day;
            String ss        = reader.IsDBNull(0) ? "" : reader.GetString(0);
            String Sign      = ((ss.Equals("")?"": (reader.GetString(0) + ",")) + today);
            int    SignCount = reader.IsDBNull(1)?1:reader.GetInt32(1) + 1;

            helper.mysqlcom.Dispose();
            helper.mysqlcon.Close();
            helper.mysqlcon.Dispose();
            if (SignCount != 1)
            {
                if (ss.Split(',')[SignCount - 2].Equals(today))
                {
                    reader.Dispose();
                    context.Response.Write("Sign:" + ss + ";SignCount:" + (SignCount - 1));
                    return;
                }
            }
            reader.Dispose();
            if (helper.getMySqlCom("Update User set Sign='" + Sign + "',SignCount=" + SignCount + " where UserName='******'") > 0)
            {
                context.Response.Write("Sign:" + Sign + ";SignCount:" + SignCount);
            }
            else
            {
                context.Response.Write("ERROR");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            String     UserName = context.Request["UserName"];
            String     contact  = context.Request["Contact"];
            String     record   = context.Request["Record"];
            RootObject rb       = JsonConvert.DeserializeObject <RootObject>("{\"Contact\":" + contact + ",\"Record\":" + record + "}");
            String     sql      = "select ID from user where UserName=@u;";

            MySqlParameter[] pms =
            {
                new MySqlParameter("@u", UserName)
            };
            MySqlHelper     helper = new MySqlHelper();
            MySqlDataReader reader = helper.getMySqlReader(sql, pms);

            if (reader.HasRows)
            {
                reader.Read();
                int id = reader.GetInt32(0);
                sql = "select * from contact where User_ID=@id;";
                MySqlHelper     helper1 = new MySqlHelper();
                MySqlDataReader reader1 = helper1.getMySqlReader(sql, new MySqlParameter("@id", id));
                MySqlHelper     helper2 = new MySqlHelper();
                if (reader1.HasRows)
                {
                    while (reader1.Read())
                    {
                        int a1 = helper2.getMySqlCom("delete from contact_info where Contact_ID=@id", new MySqlParameter("@id", reader1.GetInt32(0) + ""));
                    }
                }
                helper2 = new MySqlHelper();
                int    a  = helper2.getMySqlCom("delete from contact where User_ID=@id", new MySqlParameter("@id", id + ""));
                string ss = "insert into record (Number,Duration,Date,User_ID,Type) values ";

                if (rb.Record != null)
                {
                    for (int i = 0; i < rb.Record.Count; i++)
                    {
                        if (i == 0)
                        {
                            ss += "(\"" + rb.Record[i].Number + "\",\"" + rb.Record[i].Duration + "\",\"" + rb.Record[i].Date + "\"," + id + ",\"" + rb.Record[i].Type + "\")";
                        }
                        else
                        {
                            ss += ",(\"" + rb.Record[i].Number + "\",\"" + rb.Record[i].Duration + "\",\"" + rb.Record[i].Date + "\"," + id + ",\"" + rb.Record[i].Type + "\")";
                        }
                    }
                    if (rb.Record.Count != 0)
                    {
                        helper2.getMySqlCom(ss);
                    }
                }

                ss  = "insert into contact (ID,User_ID,Name) values ";
                sql = "insert into contact_info (EmailOrNumber,Number,Type,Contact_ID) values ";
                if (rb.Contact != null)
                {
                    for (int i = 0; i < rb.Contact.Count; i++)
                    {
                        if (i == 0)
                        {
                            ss += "(" + (int)(id * 10000 + i) + "," + id + ",\"" + rb.Contact[i].Name + "\")";
                        }
                        else
                        {
                            ss += ",(" + (int)(id * 10000 + i) + "," + id + ",\"" + rb.Contact[i].Name + "\")";
                        }
                        if (rb.Contact[i].ContactInfos != null)
                        {
                            for (int j = 0; j < rb.Contact[i].ContactInfos.Count; j++)
                            {
                                if (sql.Length == 71)
                                {
                                    sql += "(" + rb.Contact[i].ContactInfos[j].EmailOrNumber + ",\"" + rb.Contact[i].ContactInfos[j].Number + "\",\"" + rb.Contact[i].ContactInfos[j].Type + "\"," + (int)(id * 10000 + i) + ")";
                                }
                                else
                                {
                                    sql += ",(" + rb.Contact[i].ContactInfos[j].EmailOrNumber + ",\"" + rb.Contact[i].ContactInfos[j].Number + "\",\"" + rb.Contact[i].ContactInfos[j].Type + "\"," + (int)(id * 10000 + i) + ")";
                                }
                            }
                        }
                    }
                    if (rb.Contact.Count != 0 && helper2.getMySqlCom(ss) < 0)
                    {
                        context.Response.Write("Error");
                        return;
                    }
                    if (rb.Contact.Count != 0)
                    {
                        if (sql.Length > 71 && helper2.getMySqlCom(sql) < 0)
                        {
                            context.Response.Write("Error");
                            return;
                        }
                    }
                }
                context.Response.Write("OK");
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
                reader1.Close();
                helper1.mysqlcom.Dispose();
                helper1.mysqlcon.Close();
                helper1.mysqlcon.Dispose();
            }
            else
            {
                context.Response.Write("Error");
            }
            if (!reader.IsClosed)
            {
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            String     UserName = context.Request["UserName"];
            String     contact  = context.Request["Contact"];
            String     record   = context.Request["Record"];
            String     res      = "";
            RootObject rb_local = JsonConvert.DeserializeObject <RootObject>("{\"Contact\":" + contact + ",\"Record\":" + record + "}");

            rb_local = Check(rb_local);
            String sql = "select * from user where UserName=@u ORDER BY ID;";

            MySqlParameter[] pms =
            {
                new MySqlParameter("@u", UserName)
            };
            MySqlHelper     helper   = new MySqlHelper();
            MySqlDataReader reader   = helper.getMySqlReader(sql, pms);
            RootObject      rb_cloud = new RootObject();

            rb_cloud.Contact = new List <Contact>();
            rb_cloud.Record  = new List <Record>();
            if (reader.HasRows)
            {
                reader.Read();
                int    id = reader.GetInt32(0);
                String u = reader.GetString(1), p = reader.GetString(2), s = reader.GetString(3), l = reader.GetString(4), r = reader.GetString(5);
                reader.Dispose();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
                res = "{\"ID\":" + id + ",\"UserName\":\"" + u + "\",\"Password\":\"" + p + "\",\"Sex\":\"" + s + "\",\"Location\":\"" + l + "\",\"Remark\":\"" + r + "\",\"Contact\":[";
                sql = "select * from contact where User_ID=@id ORDER BY ID;";
                MySqlHelper     helper1 = new MySqlHelper();
                MySqlDataReader reader1 = helper1.getMySqlReader(sql, new MySqlParameter("@id", id));
                while (reader1.Read())
                {
                    Contact con = new Contact();
                    con.ContactInfos = new List <ContactInfos>();
                    con.ID           = reader1.GetInt32(0) + "";
                    con.Name         = reader1.GetString(2);
                    con.Birthday     = Convert.IsDBNull(reader1[3])?"":reader1.GetString(3);
                    MySqlHelper         helper12     = new MySqlHelper();
                    MySqlDataReader     reader12     = helper12.getMySqlReader("select * from contact_info where Contact_ID=" + reader1.GetInt32(0) + "  ORDER BY ID");
                    List <ContactInfos> contactInfos = new List <ContactInfos>();
                    while (reader12.Read())
                    {
                        ContactInfos ci = new ContactInfos();
                        ci.EmailOrNumber = reader12.GetInt32(0) + "";
                        ci.ID            = reader12.GetInt32(1) + "";
                        ci.Number        = reader12.GetString(2);
                        ci.Type          = reader12.GetString(3);
                        contactInfos.Add(ci);
                    }
                    con.ContactInfos = contactInfos;
                    rb_cloud.Contact.Add(con);
                    reader12.Dispose();
                    helper12.mysqlcom.Dispose();
                    helper12.mysqlcon.Close();
                    helper12.mysqlcon.Dispose();
                }
                reader1.Dispose();
                helper1.mysqlcom.Dispose();
                helper1.mysqlcon.Close();
                helper1.mysqlcon.Dispose();
                rb_cloud = Check(rb_cloud);
                sql      = "select * from record where User_ID=@id ORDER BY ID;";
                MySqlHelper     helper2 = new MySqlHelper();
                MySqlDataReader reader2 = helper2.getMySqlReader(sql, new MySqlParameter("@id", id));
                while (reader2.Read())
                {
                    Record rec = new Record();
                    rec.ID       = reader2.GetInt32(0) + "";
                    rec.Number   = reader2.GetString(1);
                    rec.Duration = reader2.GetString(2);
                    rec.Date     = reader2.GetString(3);
                    rec.Type     = reader2.GetString(5);
                    rb_cloud.Record.Add(rec);
                }
                reader2.Dispose();
                helper2.mysqlcom.Dispose();
                helper2.mysqlcon.Close();
                helper2.mysqlcon.Dispose();
                Contact      a, b;
                ContactInfos c, d;
                if (rb_cloud.Contact.Count > 0)
                {
                    for (int i = 0; i < rb_cloud.Contact.Count; i++)
                    {
                        bool flag = false;
                        for (int j = 0; j < rb_local.Contact.Count; j++)
                        {
                            a = rb_local.Contact[j];
                            b = rb_cloud.Contact[i];
                            if (a.ContactInfos == null)
                            {
                                a.ContactInfos = new List <ContactInfos>();
                            }
                            if (a.Name.Equals(b.Name) && a.ContactInfos.Count == b.ContactInfos.Count)
                            {
                                if (a.ContactInfos.Count == 0)
                                {
                                    rb_local.Contact.RemoveAt(j);
                                    flag = true;
                                    j--;
                                }
                                else
                                {
                                    for (int k = 0; k < a.ContactInfos.Count; k++)
                                    {
                                        c = a.ContactInfos[k];
                                        d = b.ContactInfos[k];
                                        if (!c.EmailOrNumber.Equals(d.EmailOrNumber) || !c.Number.Equals(d.Number
                                                                                                         ) || !c.Type.Equals(d.Type))
                                        {
                                            k = a.ContactInfos.Count;
                                        }
                                        else if (k == a.ContactInfos.Count - 1)
                                        {
                                            rb_local.Contact.RemoveAt(j);
                                            flag = true;
                                            j--;
                                        }
                                    }
                                }
                            }
                        }
                        if (flag == true)
                        {
                            if (rb_cloud.Contact.Count > i)
                            {
                                for (int k = i + 1; k < rb_cloud.Contact.Count; k++)
                                {
                                    a = rb_cloud.Contact[k];
                                    b = rb_cloud.Contact[i];
                                    if (a.ContactInfos == null)
                                    {
                                        a.ContactInfos = new List <ContactInfos>();
                                    }
                                    if (a.Name.Equals(b.Name) && a.ContactInfos.Count == b.ContactInfos.Count)
                                    {
                                        if (a.ContactInfos.Count == 0)
                                        {
                                            rb_cloud.Contact.RemoveAt(k);
                                            flag = true;
                                            k--;
                                        }
                                        for (int m = 0; m < a.ContactInfos.Count; m++)
                                        {
                                            for (int n = 0; m < b.ContactInfos.Count; n++)
                                            {
                                                c = a.ContactInfos[m];
                                                d = b.ContactInfos[n];
                                                if (c.EmailOrNumber.Equals(d.EmailOrNumber) && c.Number.Equals(d.Number
                                                                                                               ) && c.Type.Equals(d.Type) && m == a.ContactInfos.Count - 1)
                                                {
                                                    rb_cloud.Contact.RemoveAt(k);
                                                    flag = true;
                                                    k--;
                                                }
                                                else if (c.EmailOrNumber.Equals(d.EmailOrNumber) && c.Number.Equals(d.Number) && c.Type.Equals(d.Type))
                                                {
                                                }
                                                else
                                                {
                                                    k = a.ContactInfos.Count;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            rb_cloud.Contact.RemoveAt(i);
                            i--;
                        }
                    }
                }
                Record r1, r2;
                if (rb_cloud.Record.Count > 0)
                {
                    for (int i = 0; i < rb_cloud.Record.Count; i++)
                    {
                        bool flag = false;
                        for (int j = 0; j < rb_local.Record.Count; j++)
                        {
                            r1 = rb_local.Record[j];
                            r2 = rb_cloud.Record[i];
                            if (r1.Type.Equals(r2.Type) && r1.Number.Equals(r2.Number) && r1.ID.Equals(r2.ID) && r1.Duration.Equals(r2.Duration) && r1.Date.Equals(r2.Date))
                            {
                                rb_local.Record.RemoveAt(j);
                                j--;
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            rb_cloud.Record.RemoveAt(i);
                            i--;
                        }
                    }
                }

                MySqlHelper helper3 = new MySqlHelper();
                string      ss      = "insert into contact (ID,User_ID,Name) values ";
                sql = "insert into contact_info (EmailOrNumber,Number,Type,Contact_ID) values ";
                if (rb_local.Contact != null)
                {
                    for (int i = 0; i < rb_local.Contact.Count; i++)
                    {
                        if (i == 0)
                        {
                            ss += "(" + (int)(id * 10000 + i) + "," + id + ",\"" + rb_local.Contact[i].Name + "\")";
                        }
                        else
                        {
                            ss += ",(" + (int)(id * 10000 + i) + "," + id + ",\"" + rb_local.Contact[i].Name + "\")";
                        }
                        if (rb_local.Contact[i].ContactInfos != null)
                        {
                            for (int j = 0; j < rb_local.Contact[i].ContactInfos.Count; j++)
                            {
                                if (sql.Length < 75)
                                {
                                    sql += "(" + rb_local.Contact[i].ContactInfos[j].EmailOrNumber + ",\"" + rb_local.Contact[i].ContactInfos[j].Number + "\",\"" + rb_local.Contact[i].ContactInfos[j].Type + "\"," + (int)(id * 10000 + i) + ")";
                                }
                                else
                                {
                                    sql += ",(" + rb_local.Contact[i].ContactInfos[j].EmailOrNumber + ",\"" + rb_local.Contact[i].ContactInfos[j].Number + "\",\"" + rb_local.Contact[i].ContactInfos[j].Type + "\"," + (int)(id * 10000 + i) + ")";
                                }
                            }
                        }
                    }
                    if (rb_local.Contact.Count != 0)
                    {
                        helper3.getMySqlCom(ss);
                    }
                    if (rb_local.Contact.Count != 0)
                    {
                        helper3.getMySqlCom(sql);
                    }
                }
                ss = "insert into record (Number,Duration,Date,User_ID,Type) values ";
                if (rb_local.Record != null)
                {
                    for (int i = 0; i < rb_local.Record.Count; i++)
                    {
                        if (i == 0)
                        {
                            ss += "(\"" + rb_local.Record[i].Number + "\",\"" + rb_local.Record[i].Duration + "\",\"" + rb_local.Record[i].Date + "\"," + id + ",\"" + rb_local.Record[i].Type + "\")";
                        }
                        else
                        {
                            ss += ",(\"" + rb_local.Record[i].Number + "\",\"" + rb_local.Record[i].Duration + "\",\"" + rb_local.Record[i].Date + "\"," + id + ",\"" + rb_local.Record[i].Type + "\")";
                        }
                    }
                    if (rb_local.Record.Count != 0)
                    {
                        helper3.getMySqlCom(ss);
                    }
                }
                rb_local.Record.AddRange(rb_cloud.Record);
                rb_local.Contact.AddRange(rb_cloud.Contact);
                if (rb_local.Contact != null)
                {
                    for (int i = 0; i < rb_local.Contact.Count; i++)
                    {
                        if (i == 0)
                        {
                            res += "{\"ID\":" + (int)(id * 10000 + i) + ",\"Name\":\"" + rb_local.Contact[i].Name + "\",\"Birthday\":\"" + rb_local.Contact[i].Birthday + "\",\"ContactInfos\":[";
                        }
                        else
                        {
                            res += ",{\"ID\":" + (int)(id * 10000 + i) + ",\"Name\":\"" + rb_local.Contact[i].Name + "\",\"Birthday\":\"" + rb_local.Contact[i].Birthday + "\",\"ContactInfos\":[";
                        }
                        if (rb_local.Contact[i].ContactInfos != null)
                        {
                            for (int j = 0; j < rb_local.Contact[i].ContactInfos.Count; j++)
                            {
                                if (j == 0)
                                {
                                    res += "{\"ID\":" + 0 + ",\"EmailOrNumber\":" + rb_local.Contact[i].ContactInfos[j].EmailOrNumber + ",\"Number\":\"" + rb_local.Contact[i].ContactInfos[j].Number + "\",\"Type\":\"" + rb_local.Contact[i].ContactInfos[j].Type + "\"}";
                                }
                                else
                                {
                                    res += ",{\"ID\":" + 0 + ",\"EmailOrNumber\":" + rb_local.Contact[i].ContactInfos[j].EmailOrNumber + ",\"Number\":\"" + rb_local.Contact[i].ContactInfos[j].Number + "\",\"Type\":\"" + rb_local.Contact[i].ContactInfos[j].Type + "\"}";
                                }
                            }
                        }
                        res += "]}";
                    }
                }
                res += "],\"Record\":[";
                if (rb_local.Record != null)
                {
                    for (int i = 0; i < rb_local.Record.Count; i++)
                    {
                        if (i == 0)
                        {
                            res += "{\"ID\":0,\"Number\":\"" + rb_local.Record[i].Number + "\",\"Duration\":\"" + rb_local.Record[i].Duration + "\",\"Date\":\"" + rb_local.Record[i].Date + "\",\"Type\":\"" + rb_local.Record[i].Type + "\"}";
                        }
                        else
                        {
                            res += ",{\"ID\":0,\"Number\":\"" + rb_local.Record[i].Number + "\",\"Duration\":\"" + rb_local.Record[i].Duration + "\",\"Date\":\"" + rb_local.Record[i].Date + "\",\"Type\":\"" + rb_local.Record[i].Type + "\"}";
                        }
                    }
                }
                res += "]}";
                context.Response.Write(res);
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
                reader1.Close();
                helper1.mysqlcom.Dispose();
                helper1.mysqlcon.Close();
                helper1.mysqlcon.Dispose();
            }
            else
            {
                context.Response.Write("Error");
            }
            if (!reader.IsClosed)
            {
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
            }
        }
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            String UserName = context.Request["UserName"];
            String sql      = "select * from user where UserName=@u;";

            MySqlParameter[] pms =
            {
                new MySqlParameter("@u", UserName)
            };
            MySqlHelper     helper = new MySqlHelper();
            MySqlDataReader reader = helper.getMySqlReader(sql, pms);

            if (reader.HasRows)
            {
                reader.Read();
                int    id = reader.GetInt32(0);
                string u = reader.GetString(1), p = reader.GetString(2), s = reader.GetString(3), l = reader.GetString(4), r = reader.GetString(5);
                string res = "{\"ID\":" + id + ",\"UserName\":\"" + u + "\",\"Password\":\"" + p + "\",\"Sex\":\"" + s + "\",\"Location\":\"" + l + "\",\"Remark\":\"" + r + "\",\"Contact\":[";
                sql = "select * from contact where User_ID=@id;";
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
                MySqlHelper     helper1 = new MySqlHelper();
                MySqlDataReader reader1 = helper1.getMySqlReader(sql, new MySqlParameter("@id", id));
                if (reader1.HasRows)
                {
                    reader1.Read();
                    res += "{\"ID\":" + reader1.GetInt32(0) + ",\"Name\":\"" + reader1.GetString(2) + "\",\"Birthday\":\"" + (reader1.IsDBNull(3)?"":reader1.GetString(3)) + "\",\"Contact_Info\":[";
                    MySqlHelper     helper2 = new MySqlHelper();
                    MySqlDataReader reader2 = helper2.getMySqlReader("select * from contact_info where Contact_ID=@id", new MySqlParameter("@id", reader1.GetInt32(0) + ""));
                    if (reader2.HasRows)
                    {
                        reader2.Read();
                        res += "{\"ID\":" + reader2.GetInt32(1) + ",\"EmailOrNumber\":" + reader2.GetInt32(0) + ",\"Number\":\"" + reader2.GetString(2) + "\",\"Type\":\"" + reader2.GetString(3) + "\"}";
                    }
                    while (reader2.Read())
                    {
                        res += ",{\"ID\":" + reader2.GetInt32(1) + ",\"EmailOrNumber\":" + reader2.GetInt32(0) + ",\"Number\":\"" + reader2.GetString(2) + "\",\"Type\":\"" + reader2.GetString(3) + "\"}";
                    }
                    res += "]}";
                    reader2.Close();
                    helper2.mysqlcom.Dispose();
                    helper2.mysqlcon.Close();
                    helper2.mysqlcon.Dispose();
                }
                while (reader1.Read())
                {
                    res += ",{\"ID\":" + reader1.GetInt32(0) + ",\"Name\":\"" + reader1.GetString(2) + "\",\"Birthday\":\"" + (reader1.IsDBNull(3) ? "" : reader1.GetString(3)) + "\",\"Contact_Info\":[";
                    MySqlHelper     helper2 = new MySqlHelper();
                    MySqlDataReader reader2 = helper2.getMySqlReader("select * from contact_info where Contact_ID=@id", new MySqlParameter("@id", reader1.GetInt32(0) + ""));
                    if (reader2.HasRows)
                    {
                        reader2.Read();
                        res += "{\"ID\":" + reader2.GetInt32(1) + ",\"EmailOrNumber\":" + reader2.GetInt32(0) + ",\"Number\":\"" + reader2.GetString(2) + "\",\"Type\":\"" + reader2.GetString(3) + "\"}";
                    }
                    while (reader2.Read())
                    {
                        res += ",{\"ID\":" + reader2.GetInt32(1) + ",\"EmailOrNumber\":" + reader2.GetInt32(0) + ",\"Number\":\"" + reader2.GetString(2) + "\",\"Type\":\"" + reader2.GetString(3) + "\"}";
                    }
                    res += "]}";
                    reader2.Close();
                    helper2.mysqlcom.Dispose();
                    helper2.mysqlcon.Close();
                    helper2.mysqlcon.Dispose();
                }
                res += "],\"Record\":[";
                sql  = "select * from record where User_ID=@id;";
                reader1.Close();
                helper1.mysqlcom.Dispose();
                helper1.mysqlcon.Close();
                helper1.mysqlcon.Dispose();
                MySqlHelper     helper3 = new MySqlHelper();
                MySqlDataReader reader3 = helper3.getMySqlReader(sql, new MySqlParameter("@id", id));
                if (reader3.HasRows)
                {
                    reader3.Read();
                    res += "{\"ID\":" + reader3.GetInt32(0) + ",\"Number\":\"" + reader3.GetString(1) + "\",\"Duration\":\"" + reader3.GetString(2) + "\",\"Date\":\"" + reader3.GetString(3).ToString() + "\",\"Type\":\"" + reader3.GetString(5) + "\"}";
                }
                while (reader3.Read())
                {
                    res += ",{\"ID\":" + reader3.GetInt32(0) + ",\"Number\":\"" + reader3.GetString(1) + "\",\"Duration\":\"" + reader3.GetString(2) + "\",\"Date\":\"" + reader3.GetString(3).ToString() + "\",\"Type\":\"" + reader3.GetString(5) + "\"}";
                }
                res += "]}";
                context.Response.Write(res);
                reader3.Close();
                helper3.mysqlcom.Dispose();
                helper3.mysqlcon.Close();
                helper3.mysqlcon.Dispose();
            }
            else
            {
                context.Response.Write("Error");
            }
            if (!reader.IsClosed)
            {
                reader.Close();
                helper.mysqlcom.Dispose();
                helper.mysqlcon.Close();
                helper.mysqlcon.Dispose();
            }
        }