protected void Page_Load(object sender, EventArgs e) { this.ToolBar1.AddBtn(NamesOfBtn.Forward, "移交"); this.ToolBar1.AddBtn(NamesOfBtn.Cancel, "取消"); this.ToolBar1.GetBtnByID(NamesOfBtn.Forward).Attributes["onclick"] = " return confirm('您确定要执行吗?');"; Depts depts = new Depts(); depts.RetrieveAllFromDBSource(); this.ToolBar1.AddDDL("DDL_Dept"); DDL ddl = this.ToolBar1.GetDDLByID("DDL_Dept"); ddl.AutoPostBack = true; ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); foreach (Dept dept in depts) { ListItem li = new ListItem(); li.Text = BP.DA.DataType.GenerSpace(dept.Grade - 1) + dept.Name; li.Text = BP.DA.DataType.GenerSpace(dept.Grade - 1) + dept.Name; li.Text = li.Text.Replace(" ", "_"); li.Value = dept.No; ddl.Items.Add(li); if (this.FK_Dept == li.Value) { li.Selected = true; } } this.ToolBar1.AddLab("ds", " 请选择移交人,输入移交原因,点移交按钮执行工作移交。"); this.ToolBar1.GetBtnByID(NamesOfBtn.Forward).Click += new EventHandler(Forward_Click); this.ToolBar1.GetBtnByID(NamesOfBtn.Cancel).Click += new EventHandler(Forward_Click); this.BindLB(); }
void btn_Save_Click(object sender, EventArgs e) { Cond cond = new Cond(); cond.Delete(CondAttr.ToNodeID, this.ToNodeID, CondAttr.DataFrom, (int)ConnDataFrom.Depts); Button btn = sender as Button; if (btn.ID == "Btn_Del") { this.Response.Redirect(this.Request.RawUrl, true); return; } cond.MyPK = this.GenerMyPK; if (cond.RetrieveFromDBSources() == 0) { cond.HisDataFrom = ConnDataFrom.Depts; cond.NodeID = this.FK_MainNode; cond.FK_Flow = this.FK_Flow; cond.ToNodeID = this.ToNodeID; cond.Insert(); } string val = ""; Depts sts = new Depts(); sts.RetrieveAllFromDBSource(); foreach (Dept st in sts) { if (this.Pub1.IsExit("CB_" + st.No) == false) { continue; } if (this.Pub1.GetCBByID("CB_" + st.No).Checked) { val += "@" + st.No; } } if (val == "") { cond.Delete(); return; } val += "@"; cond.OperatorValue = val; cond.FK_Flow = this.FK_Flow; cond.HisCondType = this.HisCondType; cond.FK_Node = this.FK_Node; switch (this.HisCondType) { case CondType.Flow: case CondType.Node: cond.Update(); this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr, true); return; case CondType.Dir: cond.ToNodeID = this.ToNodeID; cond.Update(); this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr + "&ToNodeID=" + this.Request.QueryString["ToNodeID"], true); return; default: throw new Exception("未设计的情况。"); } }
public void BindCond() { Cond cond = new Cond(); cond.MyPK = this.GenerMyPK; cond.RetrieveFromDBSources(); BP.WF.Node nd = new BP.WF.Node(this.FK_MainNode); BP.WF.Node tond = new BP.WF.Node(this.ToNodeID); this.Pub1.AddTable(); this.Pub1.AddTR(); this.Pub1.AddTDTitle("colspan=4", "部门选择"); this.Pub1.AddTREnd(); Depts sts = new Depts(); sts.RetrieveAllFromDBSource(); int idx = -1; foreach (Dept st in sts) { idx++; if (idx == 0) { this.Pub1.AddTR(); } CheckBox cb = new CheckBox(); cb.ID = "CB_" + st.No; cb.Text = st.Name; if (cond.OperatorValue.ToString().Contains("@" + st.No + "@")) { cb.Checked = true; } this.Pub1.AddTD(cb); if (idx == 3) { idx = -1; this.Pub1.AddTREnd(); } } switch (idx) { case 0: this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; case 1: this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; case 2: this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; } this.Pub1.AddTRSum(); this.Pub1.Add("<TD class=TD colspan=4 align=center>"); Button btn = new Button(); btn.ID = "Btn_Save"; btn.CssClass = "Btn"; btn.Text = "Save"; btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); btn = new Button(); btn.ID = "Btn_Del"; btn.CssClass = "Btn"; btn.Text = "Delete"; btn.Attributes["onclick"] = " return confirm('您确定要删除吗?');"; btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); this.Pub1.Add("</TD>"); this.Pub1.AddTREnd(); this.Pub1.AddTableEnd(); }
public void BindCond() { Cond cond = new Cond(); cond.MyPK = this.GenerMyPK; cond.RetrieveFromDBSources(); BP.WF.Node nd = new BP.WF.Node(this.FK_MainNode); BP.WF.Node tond = new BP.WF.Node(this.ToNodeID); this.Pub1.AddTable("class='Table' cellSpacing='1' cellPadding='1' border='1' style='width:100%'"); this.Pub1.AddTR(); this.Pub1.AddTD("colspan=3 class='GroupTitle'", "部门选择"); this.Pub1.AddTREnd(); Depts sts = new Depts(); sts.RetrieveAllFromDBSource(); int i = 0; foreach (Dept st in sts) { i++; if (i == 4) { i = 1; } if (i == 1) { Pub1.AddTR(); } CheckBox cb = new CheckBox(); cb.ID = "CB_" + st.No; cb.Text = st.Name; if (cond.OperatorValue.ToString().Contains("@" + st.No + "@")) { cb.Checked = true; } this.Pub1.AddTD(cb); if (i == 3) { Pub1.AddTREnd(); } } switch (i) { case 1: Pub1.AddTD(); Pub1.AddTD(); Pub1.AddTREnd(); break; case 2: Pub1.AddTD(); Pub1.AddTREnd(); break; default: break; } this.Pub1.AddTableEnd(); Pub1.AddBR(); Pub1.AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Save, "保存"); btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); Pub1.AddSpace(1); btn = new LinkBtn(false, NamesOfBtn.Delete, "删除"); btn.Attributes["onclick"] = " return confirm('您确定要删除吗?');"; btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); }
/// <summary> /// 增量同步组织结构 /// </summary> /// <returns></returns> public string AnsyIncrementOrgToGPM() { string access_token = getAccessToken(); string url = "https://oapi.dingtalk.com/department/list?access_token=" + access_token; try { StringBuilder append = new StringBuilder(); string str = new HttpWebResponseUtility().HttpResponseGet(url); DepartMent_List departMentList = FormatToJson.ParseFromJson <DepartMent_List>(str); if (departMentList == null || departMentList.department == null || departMentList.department.Count == 0) { return("钉钉获取部门出错。"); } #region 获取钉钉组织结构,进行更新与新增 //增加跟部门 int deptIdx = 0; bool doSomeThing = false; //部门信息 foreach (DepartMentDetailInfo deptMentInfo in departMentList.department) { deptIdx++; doSomeThing = false; //增加部门,排除根目录 if (deptMentInfo.id != "1") { Dept dept = new Dept(); if (dept.IsExit(DeptAttr.No, deptMentInfo.id) == true) { if (dept.No == deptMentInfo.id && !dept.Name.Equals(deptMentInfo.name)) { doSomeThing = true; append.Append("\r\n部门名称发生变化:" + dept.Name + " --> " + deptMentInfo.name); } if (!dept.ParentNo.Equals(deptMentInfo.parentid)) { doSomeThing = true; append.Append("\r\n部门父级发生变化:" + dept.ParentNo + " --> " + deptMentInfo.parentid); } //有变化,更新 if (doSomeThing == true) { dept.No = deptMentInfo.id; dept.Name = deptMentInfo.name; dept.ParentNo = deptMentInfo.parentid; dept.DirectUpdate(); } } else { //不存在则新增 dept.No = deptMentInfo.id; dept.Name = deptMentInfo.name; dept.ParentNo = deptMentInfo.parentid; dept.DirectInsert(); append.Append("\r\n新增部门:" + deptMentInfo.id + " - " + deptMentInfo.name); } } //部门人员 DepartMentUser_List userList = GenerDeptUser_List(access_token, deptMentInfo.id); if (userList != null) { foreach (DepartMentUserInfo userInfo in userList.userlist) { Emp emp = new Emp(); emp.No = userInfo.userid; DeptEmp deptEmp = new DeptEmp(); //如果账户存在则人员信息不添加,添加关联表 if (emp.RetrieveFromDBSources() > 0) { if (!emp.Name.Equals(userInfo.name)) { emp.Name = userInfo.name; emp.DirectUpdate(); append.Append("\r\n人员名称发生变化:" + emp.Name + " --> " + userInfo.name); } deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; if (deptEmp.RetrieveFromDBSources() > 0) { continue; } //增加人员归属部门 deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); append.Append("\r\n增加人员归属部门:" + emp.Name + " - " + deptMentInfo.name); continue; } //增加人员 emp.No = userInfo.userid; emp.Name = userInfo.name; emp.FK_Dept = deptMentInfo.id; emp.Tel = userInfo.mobile; emp.Email = userInfo.email; //emp.Idx = DataType.IsNullOrEmpty(userInfo.order) == true ? 0 : Int32.Parse(userInfo.order); emp.DirectInsert(); append.Append("\r\n增加人员:" + emp.Name + " 所属部门:" + deptMentInfo.name); //增加人员与部门对应表 deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); } } } #endregion #region GPM组织结构,在钉钉不存在进行删除部门与人员关系表,人员表不进行删除,删除业务人员表WF_Emp Depts gpm_Depts = new Depts(); gpm_Depts.RetrieveAllFromDBSource(); foreach (Dept gpm_Dept in gpm_Depts) { bool isHave = false; foreach (DepartMentDetailInfo ding_Dept in departMentList.department) { if (gpm_Dept.No.Equals(ding_Dept.id)) { isHave = true; break; } } //部门在钉钉不存在则进行删除:部门表、部门人员、部门人员岗位、部门职位、部门岗位 if (isHave == false) { //部门岗位 DeptStation deptStation = new DeptStation(); int iDeptStation = deptStation.Delete(DeptStationAttr.FK_Dept, gpm_Dept.No); //部门人员岗位 DeptEmpStation deptEmpStation = new DeptEmpStation(); int iDeptEmpStation = deptEmpStation.Delete(DeptEmpStationAttr.FK_Dept, gpm_Dept.No); //部门人员 DeptEmp deptEmp = new DeptEmp(); int iDeptEmp = deptEmp.Delete(DeptEmpAttr.FK_Dept, gpm_Dept.No); //部门表 Dept dt = new Dept(gpm_Dept.No); dt.Delete(); append.Append("\r\n删除部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); append.Append("\r\n 部门岗位 " + iDeptStation + " 条记录"); append.Append("\r\n 部门人员岗位 " + iDeptEmpStation + " 条记录"); append.Append("\r\n 部门人员 " + iDeptEmp + " 条记录"); } else { //组织结构人员 DeptEmps deptEmps = new DeptEmps(); QueryObject obj = new QueryObject(deptEmps); obj.AddWhere(DeptEmpAttr.FK_Dept, gpm_Dept.No); obj.addAnd(); obj.AddWhereNotIn(DeptEmpAttr.FK_Emp, "'admin'"); obj.DoQuery(); //部门下没有人员不需要处理 if (deptEmps == null || deptEmps.Count == 0) { continue; } //钉钉部门人员 DepartMentUser_List userList = GenerDeptUser_List(access_token, gpm_Dept.No); //部门下没有人员,清除部门下的所有人员 if (userList == null || userList.userlist.Count == 0) { append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); foreach (DeptEmp dt in deptEmps) { dt.Delete(); Emp ep = new Emp(); ep.No = dt.FK_Emp; ep.RetrieveFromDBSources(); append.Append("\r\n 人员编号:" + dt.FK_Emp + " 姓名:" + ep.Name); } continue; } //判断部门下的人员是否存在 foreach (DeptEmp deptEmp in deptEmps) { isHave = false; foreach (DepartMentUserInfo userInfo in userList.userlist) { if (deptEmp.FK_Emp.Equals(userInfo.userid)) { isHave = true; break; } } //不存在,删除 if (isHave == false) { deptEmp.Delete(); Emp ep = new Emp(); ep.No = deptEmp.FK_Emp; ep.RetrieveFromDBSources(); append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); append.Append("\r\n 人员编号:" + deptEmp.FK_Emp + " 姓名:" + ep.Name); } } } } //删除没包含在部门的人员 #endregion #region 处理部门名称全程 //OrgInit_NameOfPath nameOfPath = new OrgInit_NameOfPath(); //if (nameOfPath.IsCanDo) // nameOfPath.Do(); #endregion return(append.ToString()); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError(ex.Message); } return(null); }
void btn_Save_Click(object sender, EventArgs e) { Cond cond = new Cond(); cond.Delete(CondAttr.NodeID, this.FK_MainNode, CondAttr.ToNodeID, this.ToNodeID, CondAttr.CondType, (int)this.HisCondType); var btn = sender as LinkBtn; if (btn.ID == NamesOfBtn.Delete) { this.Response.Redirect(this.Request.RawUrl, true); return; } cond.MyPK = this.GenerMyPK; if (cond.RetrieveFromDBSources() == 0) { cond.HisDataFrom = ConnDataFrom.Depts; cond.NodeID = this.FK_MainNode; cond.FK_Flow = this.FK_Flow; cond.ToNodeID = this.ToNodeID; cond.Insert(); } string val = ""; Depts sts = new Depts(); sts.RetrieveAllFromDBSource(); foreach (Dept st in sts) { if (this.Pub1.IsExit("CB_" + st.No) == false) { continue; } if (this.Pub1.GetCBByID("CB_" + st.No).Checked) { val += "@" + st.No; } } if (val == "") { cond.Delete(); return; } val += "@"; cond.OperatorValue = val; cond.FK_Flow = this.FK_Flow; cond.HisCondType = this.HisCondType; cond.FK_Node = this.FK_Node; cond.ToNodeID = this.ToNodeID; #region //获取“指定的操作员”设置,added by liuxc,2015-10-7 cond.SpecOperWay = (SpecOperWay)Pub1.GetDDLByID("DDL_" + CondAttr.SpecOperWay).SelectedItemIntVal; if (cond.SpecOperWay != SpecOperWay.CurrOper) { cond.SpecOperPara = Pub1.GetTBByID("TB_" + CondAttr.SpecOperPara).Text; } else { cond.SpecOperPara = string.Empty; } #endregion switch (this.HisCondType) { case CondType.Flow: case CondType.Node: cond.Update(); this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr + "&ToNodeID=" + this.Request.QueryString["ToNodeID"], true); break; case CondType.Dir: cond.ToNodeID = this.ToNodeID; cond.Update(); this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr + "&ToNodeID=" + this.Request.QueryString["ToNodeID"], true); break; case CondType.SubFlow: cond.ToNodeID = this.ToNodeID; cond.Update(); this.Response.Redirect("CondDept.aspx?MyPK=" + cond.MyPK + "&FK_Flow=" + cond.FK_Flow + "&FK_Node=" + cond.FK_Node + "&FK_MainNode=" + cond.NodeID + "&CondType=" + (int)cond.HisCondType + "&FK_Attr=" + cond.FK_Attr + "&ToNodeID=" + this.Request.QueryString["ToNodeID"], true); break; default: throw new Exception("未设计的情况。"); } EasyUiHelper.AddEasyUiMessager(this, "保存成功!"); }
public void BindCond() { Cond cond = new Cond(); cond.MyPK = this.GenerMyPK; cond.RetrieveFromDBSources(); BP.WF.Node nd = new BP.WF.Node(this.FK_MainNode); BP.WF.Node tond = new BP.WF.Node(this.ToNodeID); this.Pub1.AddTable("class='Table' cellSpacing='1' cellPadding='1' border='1' style='width:100%'"); this.Pub1.AddTR(); this.Pub1.AddTD("colspan=3 class='GroupTitle'", "部门选择"); this.Pub1.AddTREnd(); Depts sts = new Depts(); sts.RetrieveAllFromDBSource(); int i = 0; foreach (Dept st in sts) { i++; if (i == 4) { i = 1; } if (i == 1) { Pub1.AddTR(); } CheckBox cb = new CheckBox(); cb.ID = "CB_" + st.No; cb.Text = st.Name; if (cond.OperatorValue.ToString().Contains("@" + st.No + "@")) { cb.Checked = true; } this.Pub1.AddTD(cb); if (i == 3) { Pub1.AddTREnd(); } } switch (i) { case 1: Pub1.AddTD(); Pub1.AddTD(); Pub1.AddTREnd(); break; case 2: Pub1.AddTD(); Pub1.AddTREnd(); break; default: break; } this.Pub1.AddTableEnd(); Pub1.AddBR(); #region //增加“指定的操作员”选项,added by liuxc,2015-10-7 var ddl = new DDL(); ddl.ID = "DDL_" + CondAttr.SpecOperWay; ddl.Width = 200; ddl.Items.Add(new ListItem("当前操作员", "0")); ddl.Items.Add(new ListItem("指定节点的操作员", "1")); ddl.Items.Add(new ListItem("指定表单字段作为操作员", "2")); ddl.Items.Add(new ListItem("指定操作员编号", "3")); ddl.SetSelectItem((int)cond.SpecOperWay); ddl.AutoPostBack = true; ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); Pub1.Add("指定的操作员:"); Pub1.Add(ddl); Pub1.AddBR(); Pub1.AddBR(); var lbl = new Label(); lbl.ID = "LBL1"; switch (cond.SpecOperWay) { case SpecOperWay.SpecNodeOper: lbl.Text = "节点编号:"; break; case SpecOperWay.SpecSheetField: lbl.Text = "表单字段:"; break; case SpecOperWay.SpenEmpNo: lbl.Text = "操作员编号:"; break; case SpecOperWay.CurrOper: lbl.Text = "参数:"; break; } Pub1.Add(lbl); var tb = new TB(); tb.ID = "TB_" + CondAttr.SpecOperPara; tb.Width = 200; tb.Text = cond.SpecOperPara; tb.Enabled = cond.SpecOperWay != SpecOperWay.CurrOper; Pub1.Add(tb); Pub1.AddSpace(1); Pub1.Add("多个值请用英文“逗号”来分隔。"); Pub1.AddBR(); Pub1.AddBR(); #endregion Pub1.AddSpace(1); var btn = new LinkBtn(false, NamesOfBtn.Save, "保存"); btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); Pub1.AddSpace(1); btn = new LinkBtn(false, NamesOfBtn.Delete, "删除"); btn.Attributes["onclick"] = " return confirm('您确定要删除吗?');"; btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); }