Ejemplo n.º 1
0
        /// <summary>
        /// 更新部门
        /// </summary>
        /// <param name="dept"></param>
        /// <returns>更新结果</returns>
        public bool UpdateDepartment(CorpDepartment dept)
        {
            bool sign = false;

            try
            {
                string url    = string.Format("https://qyapi.weixin.qq.com/cgi-bin/department/update?access_token={0}", sAccessToken);
                string result = string.Empty;
                result = HTTPHelper.PostRequest(url, DataTypeEnum.json, dept.ToJson());
                JObject jo = (JObject)JsonConvert.DeserializeObject(result);
                if ("updated".Equals(jo["errmsg"].ToString()))
                {
                    sign = true;
                }
                else
                {
                    log.Info(string.Format("CorpCore UpdateDepartment Failed: {0} ", result));
                }
            }
            catch (Exception err)
            {
                log.Error("CorpCore UpdateDepartment error!", err);
            }
            return(sign);
        }
        private static CorpDepartment FindDept(string id, out CorpDepartmentCollection deptList)
        {
            deptList = WeDataUtil.GetCacheData <CorpDepartmentCollection>(WeCorpConst.CORP_DEPT_NAME);
            CorpDepartment result = deptList.Department[id];

            TkDebug.AssertNotNull(result, string.Format(ObjectUtil.SysCulture,
                                                        "数据有错误,无法找到Id为{0}的Department", id), null);
            return(result);
        }
        public object CreateNew(IInputData input)
        {
            int            parentId = input.QueryString["ParentId"].Value <int>(1);
            CorpDepartment dept     = new CorpDepartment()
            {
                ParentId = parentId
            };

            return(dept);
        }
        public OutputData Insert(IInputData input, object instance)
        {
            CorpDepartmentProxy dept = instance.Convert <CorpDepartmentProxy>();
            var deptList             = WeDataUtil.GetCacheData <CorpDepartmentCollection>(
                WeCorpConst.CORP_DEPT_NAME);

            var lastNode = deptList.Department[deptList.Department.Count - 1];
            var newDept  = CorpDepartment.Create(dept.ParentId, dept.Name, lastNode.Id + 1);

            deptList.Department.Add(newDept);
            WeDataUtil.SaveData(WeCorpConst.CORP_DEPT_NAME, deptList);

            return(OutputData.CreateToolkitObject(new KeyData(newDept)));
        }
Ejemplo n.º 5
0
        public object MoveUpDown(string nodeId, TreeNodeMoveDirection direction)
        {
            CorpDepartmentCollection depts = GetDepartments();
            var            node            = depts.Department[nodeId];
            var            list            = depts.GetChildren(node.ParentId).ToArray();
            int            index           = Array.IndexOf(list, node);
            CorpDepartment swapNode        = null;

            switch (direction)
            {
            case TreeNodeMoveDirection.Up:
                if (index == 0)
                {
                    break;
                }
                swapNode = list[index - 1];
                break;

            case TreeNodeMoveDirection.Down:
                if (index == list.Length - 1)
                {
                    break;
                }
                swapNode = list[index + 1];
                break;
            }
            if (swapNode != null)
            {
                node.VerifyOrder();
                swapNode.VerifyOrder();
                int swap = node.Order;
                node.Order     = swapNode.Order;
                swapNode.Order = swap;

                node.Update();
                swapNode.Update();
                WeDataUtil.SaveData(WeCorpConst.CORP_DEPT_NAME, depts);
            }

            return(new KeyData("Id", nodeId));
        }
Ejemplo n.º 6
0
 public WeixinResult RetrieveData()
 {
     return(CorpDepartment.GetDepartmentList());
 }