protected void Page_Load(object sender, EventArgs e)
        {
            VerifyPage("", false);
            if (!IsPostBack) {

                #region

                string callback = Request.QueryString["jsoncallback"];
                var term = HttpUtility.UrlDecode(Request.QueryString["term"]);
                if (!string.IsNullOrEmpty(term)) {
                    MySQlHelper h = new MySQlHelper();
                    string sql = "SELECT UserName,UID,CONVERT(IsEnterprise,SIGNED) as IsEnterprise FROM dr_user WHERE UserName IS NOT NULL AND UserName!='' and username like '%" + term + "%' and IsEnterprise='" + CurrentEmp.OrgId + "'";
                    DataTable dt = h.ExecuteQuery(sql, CommandType.Text);
                    string data = "";
                    if (dt.Rows.Count > 0) {
                        string names = "";
                        for (int i = 0; i < dt.Rows.Count; i++) {

                            string s = "{\"label\":\"" + dt.Rows[i]["UserName"] + "\",\"value\":\"" + dt.Rows[i]["UID"] + "\",\"entId\":\"" + dt.Rows[i]["IsEnterprise"].ToString() + "\"},";
                            names += s;

                        }
                        names = names.Substring(0, names.Length - 1);
                        data = "[" + names + "]";
                    }
                    //data = "[\"title\", \"Recent Uploads tagged cat\",\"link\", \"http://www.sina.com.cn\",\"ch\",\"chtest\"]";
                    string result = string.Format("{0}({1})", callback, data);
                    Response.Expires = -1;
                    Response.Clear();
                    Response.ContentEncoding = Encoding.UTF8;
                    Response.ContentType = "application/json";
                    Response.Write(data);

                    Response.Flush();
                    Response.End();
                }

                #endregion
            }
        }
Example #2
0
        private StringBuilder GetMsg()
        {
            var sb = new StringBuilder();
            #region
            MySQlHelper mySQlHelper = new MySQlHelper();
            var sql = "SELECT * FROM dr_user_notice WHERE (UserName='******' AND FromUser='******') OR (UserName='******' AND FromUser='******') ORDER BY InfoId ";
            var dt = mySQlHelper.ExecuteDataset(sql).Tables[0];
            if (dt.Rows.Count > 0) {
                //sb.Append("<ul class=\"clearfix\">");
                for (int i = dt.Rows.Count - 1; i >= 0; i--) {
                    if (CurrentEmp.EmplName == dt.Rows[i]["FromUser"].ToString()) {
                        Literal1.Text = GetName(dt.Rows[i]["UserName"]);
                        sb.Append("<div class=\"message-right clearfix\">");
                        sb.Append("<span class=\"name\">" + CurrentEmp.EmplName + "</span>");
                        sb.Append("<p class=\"message\"><i></i>" + dt.Rows[i]["Message"] + "</p>");
                        sb.Append("<span class=\"time\">" +
                                      Convert.ToDateTime(dt.Rows[i]["CreateTime"])
                                          .ToString("yyyy-MM-dd HH:mm:ss") + "</span>");
                        sb.Append("</div>");

                        //sb.Append("<li class=\"out\">");
                        //sb.Append("<div class=\"message\">");
                        //sb.Append("<span class=\"arrow\"></span>");
                        //sb.Append("<a class=\"name\" href=\"javascript:void(0);\">" + CurrentEmp.EmplName + "</a>");
                        //sb.Append("<span class=\"datetime\"> " +
                        //          Convert.ToDateTime(dt.Rows[i]["CreateTime"])
                        //              .ToString("yyyy-MM-dd HH:mm:ss") + "</span>");
                        //sb.Append("<span class=\"body\">" + dt.Rows[i]["Message"]);
                        //sb.Append("</span>");
                        //sb.Append("</div>");
                        //sb.Append("</li>");
                    }
                    else
                    {
                        Literal1.Text = GetName(dt.Rows[i]["FromUser"]);
                        sb.Append("<div class=\"message-left clearfix\">");
                        sb.Append("<span class=\"name\">" + GetName(dt.Rows[i]["FromUser"]) + "</span>");
                        sb.Append("<p class=\"message\"><i></i>" + dt.Rows[i]["Message"] + "</p>");
                        sb.Append("<span class=\"time\">" +
                                      Convert.ToDateTime(dt.Rows[i]["CreateTime"])
                                          .ToString("yyyy-MM-dd HH:mm:ss") + "</span>");
                        sb.Append("</div>");

                        //sb.Append("<li class=\"in\">");
                        //sb.Append("<div class=\"message\">");
                        //sb.Append("<span class=\"arrow\"></span>");
                        //sb.Append("<a class=\"name\" href=\"javascript:void(0);\">" + GetName(dt.Rows[i]["FromUser"]) +
                        //          "</a>");
                        //sb.Append("<span class=\"datetime\"> " +
                        //          Convert.ToDateTime(dt.Rows[i]["CreateTime"])
                        //              .ToString("yyyy-MM-dd HH:mm:ss") + "</span>");
                        //sb.Append("<span class=\"body\">" + dt.Rows[i]["Message"]);
                        //sb.Append("</span>");
                        //sb.Append("</div>");
                        //sb.Append("</li>");
                    }
                }
                //sb.Append("</ul>");
            }
            #endregion
            return sb;
        }