|
@@ -0,0 +1,744 @@
|
|
|
+using ConsoleApp1.Controller.Sql_controller;
|
|
|
+using ConsoleApp1.Controller.Ykb_API;
|
|
|
+using ConsoleApp1.Model;
|
|
|
+using H3.BizBus;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace ConsoleApp1.Controller.CY_API
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// NC同步基础资料到氚云
|
|
|
+ /// </summary>
|
|
|
+ public class CY_NC_Api
|
|
|
+ {
|
|
|
+ //private Ding_YP_Public ding_YP_Public = new Ding_YP_Public();
|
|
|
+ private Ykb_APIServer ykb_API = new Ykb_APIServer();
|
|
|
+
|
|
|
+ public void NC_CY()
|
|
|
+ {
|
|
|
+ string ykbToken = ykb_API.dttoken();
|
|
|
+
|
|
|
+ string dates = (DateTime.Now.AddDays(-5)).ToString("yyyy-MM-dd"); //获取当前年月日
|
|
|
+ //string dates = "2021-02-22";
|
|
|
+
|
|
|
+ IBDdocQuer.BDdocQueyPortTypeClient cs = new IBDdocQuer.BDdocQueyPortTypeClient();
|
|
|
+ //string css1 = CY_API_Server.LoadBizObjects("LoadBizObjects", "D116604ab3e5ca3a3f944b2bb2db76b67780a2a", this.Filter("张涛"));
|
|
|
+ int i = 0, j = 0; string mun = "", codes = null;
|
|
|
+ #region NC 业务单元
|
|
|
+ do
|
|
|
+ {
|
|
|
+ i = i + 1;
|
|
|
+ var json = cs.bdDocQuey("{\"data\": {\"billfalg\": \"业务单元\",\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\":\"creationtime >= '" + dates + "'\"}}");//,\"code\":\"G00070\",\"ts\": \"ts>='"+ dates + "'\,\"ts\": \"ts\">='2021-02-22'\",\"currentPage\":" + i + ",\"linesize\":\"200\", ,\"ts\":\"ts >= '" + dates + "'\"
|
|
|
+ JObject ResultJson = JsonConvert.DeserializeObject<JObject>(json.ToString());
|
|
|
+ mun = ResultJson["msg"].ToString();
|
|
|
+ if (ResultJson["code"].ToString() == "Y")
|
|
|
+ {
|
|
|
+ foreach (var item in ResultJson["returndata"])
|
|
|
+ {
|
|
|
+ ///调用查询方法判断该表中是否存在该条Code的值
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D116604Szkzflihsy7yhpiqs3v99ysio4", this.Filter(item["code"].ToString()));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ //ykb_API.InsertDAN(ykbToken, item["code"].ToString(), "gCEbY44UmM4Q00:法人实体", item["name"].ToString());
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item["code"].ToString());
|
|
|
+ int man = Convert.ToInt32(setData);
|
|
|
+ if (man < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item["name"].ToString(), "gCEbY44UmM4Q00:法人实体", item["code"].ToString());
|
|
|
+ }
|
|
|
+ DataTable dt1 = BizObjectId(jObject);
|
|
|
+ dt1.PrimaryKey = new DataColumn[] { dt1.Columns["Code"] };
|
|
|
+ DataRow rows = dt1.Rows.Find(item["code"]);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ BusinessUnit businessUnit = new BusinessUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item["code"].ToString(),
|
|
|
+ F0000002 = item["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ //调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D116604Szkzflihsy7yhpiqs3v99ysio4", ObjectId, dic);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item["code"].ToString());
|
|
|
+ int man = Convert.ToInt32(setData);
|
|
|
+ if (man < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item["name"].ToString(), "gCEbY44UmM4Q00:法人实体", item["code"].ToString());
|
|
|
+ }
|
|
|
+ //氚云接口(1.需要实体类 2.数据集合 3.IsSubmit)
|
|
|
+ BusinessUnit businessUnit = new BusinessUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item["code"].ToString(),
|
|
|
+ F0000002 = item["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ dic.Add("SchemaCode", "D116604Szkzflihsy7yhpiqs3v99ysio4");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ ///新增方法
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ codes += "&" + item["code"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j > 0)
|
|
|
+ {
|
|
|
+ //ding_YP_Public.send_to_conversation(null, "text", "业务单元新增" + j + "条数据,数据为:" + codes, false, "1951251420023804");
|
|
|
+ }
|
|
|
+ Sql_Controller.Synchronous_Log("业务单元同步成功","0", "成功信息:" + ResultJson["msg"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sql_Controller.Synchronous_Log("业务单元同步失败","1", "错误原因:" + ResultJson["msg"].ToString());
|
|
|
+ }
|
|
|
+ } while (mun == "查询到200条数据");
|
|
|
+ i = 0; j = 0; codes = null;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region NC 项目档案
|
|
|
+ do
|
|
|
+ {
|
|
|
+ i = i + 1;
|
|
|
+ var json1 = cs.bdDocQuey("{\"data\": {\"billfalg\": \"项目档案\",\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\":\"creationtime >= '" + dates + "'\"}}");//,\"code\":\"XX00096\",\"currentPage\":" + i + ",\"linesize\":\"200\"
|
|
|
+ JObject ResultJson1 = JsonConvert.DeserializeObject<JObject>(json1.ToString());
|
|
|
+ mun = ResultJson1["msg"].ToString();
|
|
|
+ if (ResultJson1["code"].ToString() == "Y")
|
|
|
+ {
|
|
|
+
|
|
|
+ foreach (var item2 in ResultJson1["returndata"])
|
|
|
+ {
|
|
|
+ ///调用批量查询接口
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D11660428ef6c76643f493daaa976d0909157cd", this.Filter(item2["project_code"].ToString()));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ //ykb_API.InsertDAN(ykbToken, item2["project_code"].ToString(), "gCEbY44UmM4Q00:项目", item2["project_name"].ToString());
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item2["project_code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item2["project_name"].ToString(), "gCEbY44UmM4Q00:项目", item2["project_code"].ToString());
|
|
|
+ }
|
|
|
+ DataTable dt = BizObjectId(jObject);
|
|
|
+ dt.PrimaryKey = new DataColumn[] { dt.Columns["Code"] };
|
|
|
+ DataRow rows = dt.Rows.Find(item2["project_code"]);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ ProjectFiles businessUnit = new ProjectFiles()
|
|
|
+ {
|
|
|
+ F0000001 = item2["project_code"].ToString(),
|
|
|
+ F0000002 = item2["project_name"].ToString(),
|
|
|
+ F0000003 = item2["orgcode"].ToString(),
|
|
|
+ F0000004 = item2["orgname"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ //调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D11660428ef6c76643f493daaa976d0909157cd", ObjectId, dic);
|
|
|
+ }
|
|
|
+ else //无数据则新增进去
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken,item2["project_code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item2["project_name"].ToString(), "gCEbY44UmM4Q00:项目", item2["project_code"].ToString());
|
|
|
+ }
|
|
|
+ //氚云接口(1.需要实体类 2.数据集合 3.IsSubmit)
|
|
|
+ ProjectFiles project = new ProjectFiles()
|
|
|
+ {
|
|
|
+ F0000001 = item2["project_code"].ToString(),
|
|
|
+ F0000002 = item2["project_name"].ToString(),
|
|
|
+ F0000003 = item2["orgcode"].ToString(),
|
|
|
+ F0000004 = item2["orgname"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(project));
|
|
|
+ dic.Add("SchemaCode", "D11660428ef6c76643f493daaa976d0909157cd");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ codes += "&" + item2["project_code"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j > 0)
|
|
|
+ {
|
|
|
+ //ding_YP_Public.send_to_conversation(null, "text", "项目档案新增" + j + "条数据,数据为:" + codes, false, "1951251420023804");
|
|
|
+ }
|
|
|
+ Sql_Controller.Synchronous_Log("项目档案同步成功", "0","成功信息:" + ResultJson1["msg"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sql_Controller.Synchronous_Log("项目档案同步失败","1", "错误原因:" + ResultJson1["msg"].ToString());
|
|
|
+ }
|
|
|
+ } while (mun == "查询到200条数据");
|
|
|
+ i = 0; j = 0;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 客商档案
|
|
|
+ do
|
|
|
+ {
|
|
|
+ i = i + 1;
|
|
|
+ var json3 = cs.bdDocQuey("{\"data\": {\"billfalg\": \"客商\",\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\":\"creationtime >= '" + dates + "'\"}}");//,\"code\":\"W09999\"\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\": \"creationtime >= '" + dates + "'\"
|
|
|
+ JObject ResultJson3 = JsonConvert.DeserializeObject<JObject>(json3.ToString());
|
|
|
+ mun = ResultJson3["msg"].ToString();
|
|
|
+ if (ResultJson3["code"].ToString() == "Y")
|
|
|
+ {
|
|
|
+ foreach (var item4 in ResultJson3["returndata"])
|
|
|
+ {
|
|
|
+
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D1166047df1ad979abe4335b41ec9b070b6d20f", this.Filter(item4["head"]["code"].ToString()));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ //ykb_API.InsertDAN(ykbToken, item4["head"]["name"].ToString(), "gCEbY44UmM4Q00:客商档案", item4["head"]["code"].ToString());
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item4["head"]["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item4["head"]["name"].ToString(), "gCEbY44UmM4Q00:供应商档案", item4["head"]["code"].ToString());
|
|
|
+ }
|
|
|
+ DataTable dt4 = BizObjectId(jObject);
|
|
|
+ dt4.PrimaryKey = new DataColumn[] { dt4.Columns["Code"] };
|
|
|
+ DataRow rows = dt4.Rows.Find(item4["head"]["code"]);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ merchantsUnit businessUnit = new merchantsUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item4["head"]["code"].ToString(),
|
|
|
+ F0000002 = item4["head"]["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ //调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D1166047df1ad979abe4335b41ec9b070b6d20f", ObjectId, dic);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item4["head"]["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item4["head"]["name"].ToString(), "gCEbY44UmM4Q00:供应商档案", item4["head"]["code"].ToString());
|
|
|
+ }
|
|
|
+ merchantsUnit dapa = new merchantsUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item4["head"]["code"].ToString(),
|
|
|
+ F0000002 = item4["head"]["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(dapa));
|
|
|
+ dic.Add("SchemaCode", "D1166047df1ad979abe4335b41ec9b070b6d20f");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ codes += "&" + item4["head"]["code"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j > 0)
|
|
|
+ {
|
|
|
+ //ding_YP_Public.send_to_conversation(null, "text", "客商档案新增" + j + "条数据,数据为:" + codes, false, "1951251420023804");//
|
|
|
+ }
|
|
|
+ Sql_Controller.Synchronous_Log("客商档案同步成功","0" ,"成功信息:" + ResultJson3["msg"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sql_Controller.Synchronous_Log("客商档案同步失败","1", "错误原因:" + ResultJson3["msg"].ToString());
|
|
|
+ }
|
|
|
+ } while (mun == "查询到200条数据");
|
|
|
+ i = 0; j = 0;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 预算组织
|
|
|
+ do
|
|
|
+ {
|
|
|
+ i = i + 1;
|
|
|
+ var json4 = cs.bdDocQuey("{\"data\": {\"billfalg\": \"预算组织\",\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\":\"creationtime >= '" + dates + "'\"}}"); //\"currentPage\":" + i + ",\"linesize\":\"200\",
|
|
|
+ JObject ResultJson4 = JsonConvert.DeserializeObject<JObject>(json4.ToString());
|
|
|
+ mun = ResultJson4["msg"].ToString();
|
|
|
+ if (ResultJson4["code"].ToString() == "Y")
|
|
|
+ {
|
|
|
+ foreach (var item5 in ResultJson4["returndata"])
|
|
|
+ {
|
|
|
+
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D116604Sq74oibupd5yckiaxh8209f1q5", this.Filter1(item5["code"].ToString()));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item5["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item5["name"].ToString(), "gCEbY44UmM4Q00:预算组织", item5["code"].ToString());
|
|
|
+ }
|
|
|
+ DataTable dt5 = BizObjectId2(jObject);
|
|
|
+ dt5.PrimaryKey = new DataColumn[] { dt5.Columns["Code"] };
|
|
|
+ DataRow rows = dt5.Rows.Find(item5["code"]);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ merchantsUnit businessUnit = new merchantsUnit()
|
|
|
+ {
|
|
|
+ F0000002 = item5["code"].ToString(),
|
|
|
+ F0000001 = item5["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ //调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D116604Sq74oibupd5yckiaxh8209f1q5", ObjectId, dic);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item5["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item5["name"].ToString(), "gCEbY44UmM4Q00:预算组织", item5["code"].ToString());
|
|
|
+ }
|
|
|
+ TheBudget Yv = new TheBudget()
|
|
|
+ {
|
|
|
+ F0000002 = item5["code"].ToString(),
|
|
|
+ F0000001 = item5["name"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(Yv));
|
|
|
+ dic.Add("SchemaCode", "D116604Sq74oibupd5yckiaxh8209f1q5");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ codes += "&" + item5["code"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j > 0)
|
|
|
+ {
|
|
|
+ //ding_YP_Public.send_to_conversation(null, "text", "预算组织新增" + j + "条数据,数据为:" + codes, false, "1951251420023804");
|
|
|
+ }
|
|
|
+ Sql_Controller.Synchronous_Log("客商档案同步成功","0","成功信息:" + ResultJson4["msg"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sql_Controller.Synchronous_Log("客商档案同步失败","1", "错误原因:" + ResultJson4["msg"].ToString());
|
|
|
+ }
|
|
|
+ } while (mun == "查询到200条数据");
|
|
|
+ i = 0; j = 0;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region NC 部门档案
|
|
|
+ do
|
|
|
+ {
|
|
|
+ i = i + 1;
|
|
|
+ var json2 = cs.bdDocQuey("{\"data\": {\"billfalg\": \"部门\",\"currentPage\":" + i + ",\"linesize\":\"200\",\"creationtime\":\"creationtime >= '" + dates + "'\"}}"); //,\"code\":\"0046\"\"currentPage\":" + i + ",\"linesize\":\"200\",
|
|
|
+ JObject ResultJson2 = JsonConvert.DeserializeObject<JObject>(json2.ToString());
|
|
|
+ mun = ResultJson2["msg"].ToString();
|
|
|
+ if (ResultJson2["code"].ToString() == "Y")
|
|
|
+ {
|
|
|
+ foreach (var item3 in ResultJson2["returndata"])
|
|
|
+ {
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D11660434d73096fca14c20acffdfa2dfcfb5ac", this.Filter(item3["code"].ToString()));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item3["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item3["name"].ToString(), "gCEbY44UmM4Q00:部门档案", item3["code"].ToString());
|
|
|
+ }
|
|
|
+ DataTable dt3 = BizObjectId(jObject);
|
|
|
+ dt3.PrimaryKey = new DataColumn[] { dt3.Columns["Code"] };
|
|
|
+ DataRow rows = dt3.Rows.Find(item3["code"]);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ departmentUnit businessUnit = new departmentUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item3["code"].ToString(),
|
|
|
+ F0000002 = item3["name"].ToString(),
|
|
|
+ F0000003 = item3["projectcode"].ToString(),
|
|
|
+ F0000004 = item3["projectname"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ //调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D11660434d73096fca14c20acffdfa2dfcfb5ac", ObjectId, dic);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string setData = ykb_API.setDAN(ykbToken, item3["code"].ToString());
|
|
|
+ if (Convert.ToInt32(setData) < 1)
|
|
|
+ {
|
|
|
+ ykb_API.InsertDAN(ykbToken, item3["name"].ToString(), "gCEbY44UmM4Q00:部门档案", item3["code"].ToString());
|
|
|
+ }
|
|
|
+ //氚云接口(1.需要实体类 2.数据集合 3.IsSubmit)
|
|
|
+ departmentUnit depa = new departmentUnit()
|
|
|
+ {
|
|
|
+ F0000001 = item3["code"].ToString(),
|
|
|
+ F0000002 = item3["name"].ToString(),
|
|
|
+ F0000003 = item3["projectcode"].ToString(),
|
|
|
+ F0000004 = item3["projectname"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(depa));
|
|
|
+ dic.Add("SchemaCode", "D11660434d73096fca14c20acffdfa2dfcfb5ac");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ codes += "&" + item3["code"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (j > 0)
|
|
|
+ {
|
|
|
+ //ding_YP_Public.send_to_conversation(null, "text", "部门档案新增" + j + "条数据,数据为:" + codes, false, "1951251420023804");
|
|
|
+ }
|
|
|
+ Sql_Controller.Synchronous_Log("部门档案同步成功", "0","成功信息:" + ResultJson2["msg"].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sql_Controller.Synchronous_Log("部门档案同步失败","1", "错误原因:" + ResultJson2["msg"].ToString());
|
|
|
+ }
|
|
|
+ } while (mun == "查询到200条数据");
|
|
|
+ i = 0;
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 钉钉-氚云
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 钉钉写入氚云
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json2"></param>
|
|
|
+ public void Basic(JObject json2)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ string value = json2["userid"].ToString();
|
|
|
+ ///调用查询方法判断该表中是否存在该条Code的值
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D116604ab3e5ca3a3f944b2bb2db76b67780a2a", this.Filter(value, ""));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ DataTable dt1 = BizObjectId(jObject);
|
|
|
+ DataTable dt2 = BizObjectId2(json2, value, dt1.Rows[0]["ObjectId"].ToString());
|
|
|
+ dt2.PrimaryKey = new DataColumn[] { dt2.Columns["userid"] };
|
|
|
+ //DataRow rows = dt1.Rows.Find(item["code"]);
|
|
|
+ DataRow rows = dt2.Rows.Find(value);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ BasicData businessUnit = new BasicData()
|
|
|
+ {
|
|
|
+ F0000009 = value, //员工ID
|
|
|
+ F0000001 = dt2.Rows[0]["sys00-name"].ToString().Trim(), //姓名 sys00-name
|
|
|
+ F0000010 = dt2.Rows[0]["sys00-mainDeptId"].ToString().Trim(), //部门ID
|
|
|
+ F0000002 = dt2.Rows[0]["sys00-mainDept"].ToString().Trim(), //部门
|
|
|
+ F0000003 = dt2.Rows[0]["145d3425-9dea-42a6-88ae-1e4e3590046c"].ToString().Trim(), //所属公司 145d3425-9dea-42a6-88ae-1e4e3590046c
|
|
|
+ F0000006 = dt2.Rows[0]["sys00-position"].ToString().Trim(), //岗位 sys00-position
|
|
|
+ F0000007 = dt2.Rows[0]["sys00-confirmJoinTime"].ToString().Trim(), //入职时间
|
|
|
+ F0000008 = dt2.Rows[0]["sys01-positionLevel"].ToString().Trim(), //职级 sys01-positionLevel
|
|
|
+ F0000004 = dt2.Rows[0]["sys05-nowContractStartTime"].ToString().Trim(), //原合同开始时间
|
|
|
+ F0000005 = dt2.Rows[0]["sys05-nowContractEndTime"].ToString().Trim(), //原合同结束时间
|
|
|
+ F0000012 = dt2.Rows[0]["sys05-contractPeriodType"].ToString().Trim(), //续签期限 sys05-contractPeriodType
|
|
|
+ F0000013 = dt2.Rows[0]["sys05-contractRenewCount"].ToString().Trim() //续签次数 sys05-contractRenewCount
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ ////调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D116604ab3e5ca3a3f944b2bb2db76b67780a2a", ObjectId, dic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataTable dt2 = BizObjectId2(json2, value, "");
|
|
|
+ //dt2.PrimaryKey = new DataColumn[] { dt2.Columns["Code"]};
|
|
|
+ //DataRow rows = dt2.Rows.Find(dt2.Columns["field_list"]);
|
|
|
+ //string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ //氚云接口(1.需要实体类 2.数据集合 3.IsSubmit)
|
|
|
+ BasicData businessUnit = new BasicData()
|
|
|
+ {
|
|
|
+ F0000009 = value, //员工ID
|
|
|
+ F0000001 = dt2.Rows[0]["sys00-name"].ToString(), //姓名 sys00-name
|
|
|
+ F0000010 = dt2.Rows[0]["sys00-mainDeptId"].ToString(), //部门ID
|
|
|
+ F0000002 = dt2.Rows[0]["sys00-mainDept"].ToString(), //部门
|
|
|
+ F0000003 = dt2.Rows[0]["145d3425-9dea-42a6-88ae-1e4e3590046c"].ToString(), //所属公司 145d3425-9dea-42a6-88ae-1e4e3590046c
|
|
|
+ F0000006 = dt2.Rows[0]["sys00-position"].ToString(), //岗位 sys00-position
|
|
|
+ F0000007 = dt2.Rows[0]["sys00-confirmJoinTime"].ToString(), //入职时间
|
|
|
+ F0000008 = dt2.Rows[0]["sys01-positionLevel"].ToString(), //职级 sys01-positionLevel
|
|
|
+ F0000004 = dt2.Rows[0]["sys05-nowContractStartTime"].ToString(), //原合同开始时间
|
|
|
+ F0000005 = dt2.Rows[0]["sys05-nowContractEndTime"].ToString(), //原合同结束时间
|
|
|
+ F0000012 = dt2.Rows[0]["sys05-contractPeriodType"].ToString(), //续签期限 sys05-contractPeriodType
|
|
|
+ F0000013 = dt2.Rows[0]["sys05-contractRenewCount"].ToString() //续签次数 sys05-contractRenewCount
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ dic.Add("SchemaCode", "D116604ab3e5ca3a3f944b2bb2db76b67780a2a");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ ///新增方法
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 钉钉写入氚云-基础资料-人员基础信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json3"></param>
|
|
|
+ public void employee(JObject json3)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string value = json3["userid"].ToString();
|
|
|
+ ///调用查询方法判断该表中是否存在该条Code的值
|
|
|
+ string css = CY_API_Server.LoadBizObjects("LoadBizObjects", "D116604d621ec6c5f904694941a255b98aca91b", this.Filter(value, ""));
|
|
|
+ JObject jObject = JsonConvert.DeserializeObject<JObject>(css);
|
|
|
+ if (jObject["Successful"].ToString().ToLower() == "true" && !string.IsNullOrEmpty(jObject["ReturnData"].ToString())) //表示已经存在
|
|
|
+ {
|
|
|
+ DataTable dt3 = BizObjectId(jObject);
|
|
|
+ DataTable dt4 = BizObjectId2(json3, value, dt3.Rows[0]["ObjectId"].ToString());
|
|
|
+ dt4.PrimaryKey = new DataColumn[] { dt4.Columns["userid"] };
|
|
|
+ //DataRow rows = dt3.Rows.Find(item["code"]);
|
|
|
+ DataRow rows = dt4.Rows.Find(value);
|
|
|
+ string ObjectId = string.Format(rows["ObjectId"].ToString());
|
|
|
+ BasicData businessUnit = new BasicData()
|
|
|
+ {
|
|
|
+ F0000009 = value, //员工ID
|
|
|
+ F0000001 = dt4.Rows[0]["sys00-name"].ToString(), //姓名 sys00-name
|
|
|
+ F0000005 = dt4.Rows[0]["a66a51a7-dcaa-47da-b056-ccebe6fca72d"].ToString(),
|
|
|
+ F0000002 = dt4.Rows[0]["145d3425-9dea-42a6-88ae-1e4e3590046c"].ToString(),
|
|
|
+ F0000003 = dt4.Rows[0]["473f9667-d220-426f-8431-56be1e8a027d"].ToString(),
|
|
|
+ F0000004 = dt4.Rows[0]["395840c1-2cbe-4f36-b3fb-249d7ddf42f2"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ ////调用修改方法进行修改
|
|
|
+ CY_API_Server.UpdateBizObject("UpdateBizObject", "D116604d621ec6c5f904694941a255b98aca91b", ObjectId, dic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataTable dt4 = BizObjectId2(json3, value, "");
|
|
|
+ BasicPersonnelInformation businessUnit = new BasicPersonnelInformation()
|
|
|
+ {
|
|
|
+ F0000009 = value, //员工ID
|
|
|
+ F0000001 = dt4.Rows[0]["sys00-name"].ToString(), //姓名 sys00-name
|
|
|
+ F0000005 = dt4.Rows[0]["a66a51a7-dcaa-47da-b056-ccebe6fca72d"].ToString(),
|
|
|
+ F0000002 = dt4.Rows[0]["145d3425-9dea-42a6-88ae-1e4e3590046c"].ToString(),
|
|
|
+ F0000003 = dt4.Rows[0]["473f9667-d220-426f-8431-56be1e8a027d"].ToString(),
|
|
|
+ F0000004 = dt4.Rows[0]["395840c1-2cbe-4f36-b3fb-249d7ddf42f2"].ToString()
|
|
|
+ };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+ dic.Add("BizObject", JsonConvert.SerializeObject(businessUnit));
|
|
|
+ dic.Add("SchemaCode", "D116604d621ec6c5f904694941a255b98aca91b");
|
|
|
+ dic.Add("IsSubmit", "true");
|
|
|
+ bool success = false;
|
|
|
+ ///新增方法
|
|
|
+ CY_API_Server.H3YunApi("CreateBizObject", dic, out success);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //_Controller.Synchronous_Log("氚云同步失败", "错误原因:氚云错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 过滤器
|
|
|
+
|
|
|
+
|
|
|
+ public string Filter(string code)
|
|
|
+ {
|
|
|
+ // return "{\"FromRowNum\": -1,\"RequireCount\": 5000,\"ReturnItems\": [], \"SortByCollection\": [],\"ToRowNum\": 5000, \"Matcher\": { \"Type\": \"And\", \"Matchers\": [{\"Name\":\"F0000001\",\"Operator\":2,\"Value\":\""+code+ "\"}]}}";
|
|
|
+ Filter filter = new Filter(); //构建过滤器
|
|
|
+ And andMatcher = new And(); //构造And匹配器
|
|
|
+ andMatcher.Add(new ItemMatcher("F0000001", ComparisonOperatorType.Equal, code)); //添加查询条件
|
|
|
+ //andMatcher.Add(new ItemMatcher("ZT", ComparisonOperatorType.Equal, qJ.ZT)); //添加查询条件
|
|
|
+ filter.Matcher = andMatcher;
|
|
|
+ filter.ToRowNum = 500;
|
|
|
+ return H3.BizBus.BizStructureUtility.FilterToJson(filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public string Filter1(string code)
|
|
|
+ {
|
|
|
+ // return "{\"FromRowNum\": -1,\"RequireCount\": 5000,\"ReturnItems\": [], \"SortByCollection\": [],\"ToRowNum\": 5000, \"Matcher\": { \"Type\": \"And\", \"Matchers\": [{\"Name\":\"F0000001\",\"Operator\":2,\"Value\":\""+code+ "\"}]}}";
|
|
|
+ Filter filter = new Filter(); //构建过滤器
|
|
|
+ And andMatcher = new And(); //构造And匹配器
|
|
|
+ andMatcher.Add(new ItemMatcher("F0000002", ComparisonOperatorType.Equal, code)); //添加查询条件
|
|
|
+ //andMatcher.Add(new ItemMatcher("ZT", ComparisonOperatorType.Equal, qJ.ZT)); //添加查询条件
|
|
|
+ filter.Matcher = andMatcher;
|
|
|
+ filter.ToRowNum = 500;
|
|
|
+ return H3.BizBus.BizStructureUtility.FilterToJson(filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 过滤器
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="code"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public string Filter(string code, string organization)
|
|
|
+ {
|
|
|
+ // return "{\"FromRowNum\": -1,\"RequireCount\": 5000,\"ReturnItems\": [], \"SortByCollection\": [],\"ToRowNum\": 5000, \"Matcher\": { \"Type\": \"And\", \"Matchers\": [{\"Name\":\"F0000001\",\"Operator\":2,\"Value\":\""+code+ "\"}]}}";
|
|
|
+ Filter filter = new Filter(); //构建过滤器
|
|
|
+ And andMatcher = new And(); //构造And匹配器
|
|
|
+ andMatcher.Add(new ItemMatcher("F0000009", ComparisonOperatorType.Equal, code)); //添加查询条件
|
|
|
+ //andMatcher.Add(new ItemMatcher("F0000010", ComparisonOperatorType.Equal, organization)); //添加查询条件
|
|
|
+ filter.Matcher = andMatcher;
|
|
|
+ filter.ToRowNum = 500;
|
|
|
+ return H3.BizBus.BizStructureUtility.FilterToJson(filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public DataTable BizObjectId(JObject ResultJson)
|
|
|
+ {
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ dt.Columns.Add("ObjectId", typeof(string));
|
|
|
+ dt.Columns.Add("Code", typeof(string));
|
|
|
+
|
|
|
+ foreach (var item in ResultJson["ReturnData"]["BizObjectArray"])
|
|
|
+ {
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
+ dr["ObjectId"] = item["ObjectId"].ToString();
|
|
|
+ dr["Code"] = item["F0000001"].ToString();
|
|
|
+ dt.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public DataTable BizObjectId2(JObject ResultJson)
|
|
|
+ {
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ dt.Columns.Add("ObjectId", typeof(string));
|
|
|
+ dt.Columns.Add("Code", typeof(string));
|
|
|
+
|
|
|
+ foreach (var item in ResultJson["ReturnData"]["BizObjectArray"])
|
|
|
+ {
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
+ dr["ObjectId"] = item["ObjectId"].ToString();
|
|
|
+ dr["Code"] = item["F0000002"].ToString();
|
|
|
+ dt.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public DataTable BizObjectId1(JObject ResultJson)
|
|
|
+ {
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ dt.Columns.Add("ObjectId", typeof(string));
|
|
|
+ dt.Columns.Add("orgcode", typeof(string));
|
|
|
+
|
|
|
+ foreach (var item in ResultJson["ReturnData"]["BizObjectArray"])
|
|
|
+ {
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
+ dr["ObjectId"] = item["ObjectId"].ToString();
|
|
|
+ dr["orgcode"] = item["F0000001"].ToString();
|
|
|
+ dt.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public DataTable BizObjectId2(JObject ResultJson, string value, string ObjectId)
|
|
|
+ {
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ dt.Columns.Add("ObjectId", typeof(string));
|
|
|
+ foreach (var items in ResultJson["field_list"])
|
|
|
+ {
|
|
|
+ if (!dt.Columns.Contains(items["field_code"].ToString()))
|
|
|
+ dt.Columns.Add(items["field_code"].ToString(), typeof(string));
|
|
|
+ }
|
|
|
+ dt.Columns.Add("userid", typeof(string));
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
+ int i = 0;
|
|
|
+ dr["ObjectId"] = ObjectId;
|
|
|
+ foreach (var item in ResultJson["field_list"])
|
|
|
+ {
|
|
|
+ long mun = ResultJson["field_list"][i].LongCount();
|
|
|
+ if (mun < 4)
|
|
|
+ {
|
|
|
+ dr[item["field_code"].ToString()] = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dr[item["field_code"].ToString()] = item["label"].ToString();
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ dr["userid"] = value;
|
|
|
+ dt.Rows.Add(dr);
|
|
|
+
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+}
|