Ejemplo n.º 1
0
        private static string Create_Par(string Name, string pid)
        {
            Department us = new Department();

            us.name     = Name;
            us.parentid = pid;
            string           data  = MyUtility.GetJsonFromObj(us);
            string           accss = MyUtility.GetGroupAccess();
            RequestContainer req   = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token=" + accss);

            req.RequestObj.Method      = "POST";
            req.RequestObj.ContentType = "application/Json";
            req.SetRequestContent(data);
            HttpWebResponse rep = req.GetResponse();
            string          x   = req.GetResponseContent(rep);
            dynamic         dy  = MyUtility.GetObjFromJson <dynamic>(x);

            if (dy.errcode == 0)
            {
                return(dy.id);
            }
            else
            {
                return("false");
            }
        }
Ejemplo n.º 2
0
        public string Mylogin(string UserName, string PassWord)
        {
            MessageApi mm = new MessageApi();

            try
            {
                if (s == null)
                {
                    s = new Service(Tm);
                }
                DataTable dll = s.sqlhelper.GetDataTable("select * from " + "APISERVER" + ".users where \"USERNAME\"='" + UserName + "' and \"PASSWORD\"='" + PassWord + "'");
                if (dll.Rows.Count == 0)
                {
                    mm.code = "201";
                    mm.txt  = "账号或密码错误!!";
                    return(MyUtility.GetJsonFromObj(mm));
                }
                else
                {
                    HttpContext.Session["UserName"] = dll.Select("1=1 ")[0]["USERNAME"].ToString();
                    string a = HttpContext.Session["UserName"].ToString();
                    mm.code = "0";
                    mm.txt  = "登陆成功!!";
                    return(MyUtility.GetJsonFromObj(mm));
                }
            }
            catch (Exception ex)
            {
                mm.code = "400";
                mm.txt  = ex.Message;
                return(MyUtility.GetJsonFromObj(mm));
            }
        }
Ejemplo n.º 3
0
        private static string createTag(string tagName)
        {
            Tag us = new Tag();

            us.tagname = tagName;
            string           data  = MyUtility.GetJsonFromObj(us);
            string           accss = MyUtility.GetGroupAccess();
            RequestContainer req   = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=" + accss);

            req.RequestObj.Method      = "POST";
            req.RequestObj.ContentType = "application/Json";
            req.SetRequestContent(data);
            HttpWebResponse rep = req.GetResponse();
            string          x   = req.GetResponseContent(rep);
            dynamic         dy  = MyUtility.GetObjFromJson <dynamic>(x);

            if (dy.errcode == 0)
            {
                return(dy.tagid);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 4
0
        private static MessageApi Create_Usr(string depId, string Name, string userId, string mobile)
        {
            MessageApi mm = new MessageApi();
            User       us = new User();

            us.department = depId;
            us.name       = Name;
            us.userid     = userId;
            us.mobile     = mobile;
            string           data  = MyUtility.GetJsonFromObj(us);
            string           accss = MyUtility.GetGroupAccess();
            RequestContainer req   = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token=" + accss);

            req.RequestObj.Method      = "POST";
            req.RequestObj.ContentType = "application/Json";
            req.SetRequestContent(data);
            HttpWebResponse rep = req.GetResponse();
            string          x   = req.GetResponseContent(rep);
            dynamic         dy  = MyUtility.GetObjFromJson <dynamic>(x);

            if (dy.errcode == 0)
            {
                mm.code = "0";
                mm.txt  = "";
                return(mm);
            }
            else
            {
                mm.code = "404";
                mm.txt  = dy.errmsg;
                return(mm);
            }
        }
Ejemplo n.º 5
0
        private static string getSapUser(string id, string Size, string From, string Search)
        {
            if (s == null)
            {
                s = new Service(Tm);
            }
            Content   cn  = new Models.Content();
            DataTable dll = s.sqlhelper.GetDataTable("call " + s.companyDb + ".\"U_PD_ZpGetUser\"('" + id + "'," + Size + "," + From + ",'" + Search + "')");

            if (dll.Rows.Count > 0)
            {
                for (int i = 0; i < dll.Rows.Count; i++)
                {
                    SapUser sa = new SapUser();
                    sa.CardCode    = dll.Select("1=1 ")[i]["CardCode"].ToString();
                    sa.CardName    = dll.Select("1=1 ")[i]["CardName"].ToString();
                    sa.Note        = dll.Select("1=1 ")[i]["Notes"].ToString();
                    sa.Phone       = dll.Select("1=1 ")[i]["Cellolar"].ToString();
                    sa.IsAttention = GetOnlyUser(dll.Select("1=1 ")[i]["Cellolar"].ToString());
                    cn.rows.Add(sa);
                }
                cn.total = Convert.ToInt32(dll.Select("1=1 ")[0]["sum"]);
            }
            else
            {
            }
            return(MyUtility.GetJsonFromObj(cn));
        }
Ejemplo n.º 6
0
        private static MessageApi createUser(string depId, string Name, string userId, string mobile)
        {
            MessageApi mm  = new MessageApi();
            User       us  = new User();
            Regex      reg = new Regex(@"^[1]+\d{10}");

            if (depId == "" || Name == "" || userId == "")
            {
                mm.code = "404";
                mm.txt  = "用户信息不完善";
                return(mm);
            }
            else if (!reg.IsMatch(userId))
            {
                mm.code = "404";
                mm.txt  = "Id要11位电话号码";
                return(mm);
            }
            else
            {
                if (Exist_Usr(userId))
                {
                    us.department = depId;
                    us.name       = Name;
                    us.userid     = userId;
                    us.mobile     = mobile;
                    string           data  = MyUtility.GetJsonFromObj(us);
                    string           accss = MyUtility.GetGroupAccess();
                    RequestContainer req   = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token=" + accss);
                    req.RequestObj.Method      = "POST";
                    req.RequestObj.ContentType = "application/Json";
                    req.SetRequestContent(data);
                    HttpWebResponse rep = req.GetResponse();
                    string          x   = req.GetResponseContent(rep);
                    dynamic         dy  = MyUtility.GetObjFromJson <dynamic>(x);
                    if (dy.errcode == 0)
                    {
                        mm.code = "0";
                        mm.txt  = "";
                        return(mm);
                    }
                    else
                    {
                        mm.code = "404";
                        mm.txt  = dy.errmsg;
                        return(mm);
                    }
                }
                else
                {
                    mm = Create_Usr(depId, Name, userId, mobile);
                    return(mm);
                }
            }
        }
Ejemplo n.º 7
0
        private static void createUser_tag(string tagId, string UserId)
        {
            UserTag us = new UserTag();

            us.tagid = tagId;
            us.userlist.Add(UserId);
            string           data  = MyUtility.GetJsonFromObj(us);
            string           accss = MyUtility.GetGroupAccess();
            RequestContainer req   = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers?access_token=" + accss);

            req.RequestObj.Method      = "POST";
            req.RequestObj.ContentType = "application/Json";
            req.SetRequestContent(data);
            HttpWebResponse rep = req.GetResponse();
            string          x   = req.GetResponseContent(rep);
        }
Ejemplo n.º 8
0
        private static string getUser(string id)
        {
            string           accss    = MyUtility.GetGroupAccess();
            RequestContainer req      = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + accss + "&department_id=" + id + "&fetch_child=1");
            HttpWebResponse  rep      = req.GetResponse();
            string           a        = req.GetResponseContent(rep);
            dynamic          dy       = MyUtility.GetObjFromJson <dynamic>(a);
            List <Customer>  userlist = new List <Customer>();

            for (int i = 0; i < dy.userlist.Count; i++)
            {
                Customer mm = new Customer();
                mm.userid = dy.userlist[i].userid;
                mm.status = dy.userlist[i].status;
                mm.name   = dy.userlist[i].name;
                mm.mobile = dy.userlist[i].mobile;
                userlist.Add(mm);
            }
            return(MyUtility.GetJsonFromObj(userlist));
        }
Ejemplo n.º 9
0
        public string GetTree()
        {
            string a = MyUtility.GetJsonFromObj(GetSapTree());

            return(a);
        }