Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //应用名称
            var appName = Request.Params["AppName"];
            //用户名筛选
            var filter = Request.Params["Filter"];

            Dictionary <string, Array> info = new Dictionary <string, Array>();

            try
            {
                if (appName == null)
                {
                    string[] arry0 = new string[1];
                    arry0[0] = "http://218.92.115.55/MobilePlatform/Contacts/GetPerContactList.aspx?AppName=WLKG&filter=";
                    info.Add("参数AppName,Filter不能为null", arry0);
                    Json = JsonConvert.SerializeObject(info);
                    return;
                }

                //获取App应用对应的公司,公司对应的内部网公司ID
                string nbwCompanyId = DictionaryTool.GetNbwCompanyId(appName.ToUpper());
                if (nbwCompanyId == string.Empty)
                {
                    return;
                }

                string sql;
                if (string.IsNullOrEmpty(filter) || string.IsNullOrWhiteSpace(filter))
                {
                    sql =
                        string.Format(
                            "select t.user_id,t.login_name,t.user_name,t.tel,t.email,t.company_id,t.company_name,t.dept_id,t.tel1,t.duty,t.tel2,t.pemail,t.phone1,t.head_pic from VW_SYS_USER t where t.company_id='{0}' order by t.user_name",
                            nbwCompanyId);
                }
                else
                {
                    sql =
                        string.Format(
                            "select t.user_id,t.login_name,t.user_name,t.tel,t.email,t.company_id,t.company_name,t.dept_id,t.tel1,t.duty,t.tel2,t.pemail,t.phone1,t.head_pic from VW_SYS_USER t where t.company_id='{0}' and t.user_name like '%{1}%' order by t.user_name",
                            nbwCompanyId, filter);
                }

                var dt = new Leo.Oracle.DataAccess(RegistryKey.KeyPathMa).ExecuteTable(sql);
                string[,] arrys = new string[dt.Rows.Count, 4];

                for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
                {
                    arrys[iRow, 0] = Convert.ToString(dt.Rows[iRow]["user_id"]);
                    arrys[iRow, 1] = Convert.ToString(dt.Rows[iRow]["user_name"]);
                    arrys[iRow, 2] = Convert.ToString(dt.Rows[iRow]["tel1"]);
                    arrys[iRow, 3] = Convert.ToString(dt.Rows[iRow]["email"]);
                }

                string[] arry2 = new string[1];
                arry2[0] = "Yes";
                info.Add("IsGet", arry2);
                info.Add("PerContactList", arrys);
                Json = JsonConvert.SerializeObject(info);
            }
            catch (Exception ex)
            {
                string[] arry0 = new string[1];
                arry0[0] = "NO";
                info.Add("IsGet", arry0);
                string[] arry1 = new string[1];
                arry1[0] = ex.Message;
                info.Add("Message", arry1);
                Json = JsonConvert.SerializeObject(info);
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //应用名称
            var appName = Request.Params["AppName"];

            try
            {
                if (appName == null)
                {
                    string warning = "参数AppName不能为null!举例:http://218.92.115.55/MobilePlatform/Contacts/GetPersonContactList.aspx?AppName=WLKG";
                    Json = JsonConvert.SerializeObject(warning);
                    return;
                }

                //获取App应用对应的公司,公司对应的内部网公司ID
                string nbwCompanyId = DictionaryTool.GetNbwCompanyId(appName.ToUpper());
                if (nbwCompanyId == string.Empty)
                {
                    string warning = "应用名称错误!";
                    Json = JsonConvert.SerializeObject(warning);
                    return;
                }

                string sql = string.Format("select code,Description from gpms2000_nbw..department_sr");
                var    dt0 = new Leo.SqlServer.DataAccess(RegistryKey.KeyPathNbwDept).ExecuteTable(sql);
                if (dt0.Rows.Count == 0)
                {
                    string error = "网络错误,请稍后再试!";
                    Json = JsonConvert.SerializeObject(error);
                    return;
                }

                sql =
                    string.Format(
                        "select a.id,a.username as login_name,a.truename as user_name,a.tel,a.email,a.companyid as company_id,b.shortname as company_name,a.bumenid as dept_id,a.tel1,a.duty,a.tel2,a.pemail,a.phone1,a.head_pic from user_info a, company_name b where a.companyid='{0}' and substr(a.bumenid,1,4)=b.companyid  order by user_name",
                        nbwCompanyId);
                var dt1 = new Leo.Oracle.DataAccess(RegistryKey.KeyPathNbw).ExecuteTable(sql);

                var infoArray = new List <Dictionary <string, string> >();
                for (int iRow = 0; iRow < dt1.Rows.Count; iRow++)
                {
                    string departmentName = "";
                    bool   markWeibo      = true;
                    var    rows           = dt0.Select(string.Format("CODE='{0}'", Convert.ToString(dt1.Rows[iRow]["dept_id"])));
                    if (rows.Length > 0)
                    {
                        departmentName = rows[0]["DESCRIPTION"] as string;
                    }
                    departmentName = departmentName == null ? string.Empty : departmentName;

                    markWeibo =
                        !(dt1.Rows[iRow]["EMAIL"] is DBNull) && !string.IsNullOrEmpty(dt1.Rows[iRow]["EMAIL"] as string) &&
                        !string.IsNullOrWhiteSpace(dt1.Rows[iRow]["EMAIL"] as string);

                    Dictionary <string, string> info = new Dictionary <string, string>();
                    info.Add("userID", Convert.ToString(dt1.Rows[iRow]["ID"]));
                    info.Add("name", Convert.ToString(dt1.Rows[iRow]["USER_NAME"]));
                    info.Add("company", Convert.ToString(dt1.Rows[iRow]["COMPANY_NAME"]));
                    info.Add("department", departmentName);
                    info.Add("duty", Convert.ToString(dt1.Rows[iRow]["DUTY"]));
                    info.Add("mobilephone", Convert.ToString(dt1.Rows[iRow]["TEL"]));
                    info.Add("backupmobilephone", Convert.ToString(dt1.Rows[iRow]["PHONE1"]));
                    info.Add("telephone", Convert.ToString(dt1.Rows[iRow]["TEL1"]));
                    info.Add("backuptelephone", Convert.ToString(dt1.Rows[iRow]["TEL2"]));
                    info.Add("workemail", Convert.ToString(dt1.Rows[iRow]["EMAIL"]));
                    info.Add("personalemail", Convert.ToString(dt1.Rows[iRow]["PEMAIL"]));
                    info.Add("weibo", markWeibo == true ? "已开通" : "未开通");
                    infoArray.Add(info);
                }

                Json = JsonConvert.SerializeObject(infoArray);
            }
            catch (Exception ex)
            {
                Json = JsonConvert.SerializeObject(ex.Message);
            }
        }