公有云数据同步到本地数据库(仅需要的数据字段)

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

公有云数据同步到本地数据库(仅需要的数据字段)

需求:有独立的数据BI平台,需要的数据存储在公有云中没法做交互,还存在部分其他原因,所以需要将公有云中的销售合同及销售订单数据表同步到本地的数据库中。

界面:

image.webp

部分代码:

 private void button1_Click(object sender, EventArgs e)

 {


     int a = ClearTable("crm_contract");

     LogTextBox.AppendText("销售合同表crm_contract清除:"+a.ToString() + "行;" + "\r\n");

     progressBar1.Value = 0;

     var clienter = new K3CloudApi();

     string formId = "CRM_Contract";

     string josnDat = "{" +

         "\"FormId\": \"CRM_Contract\"," +

         "\"FieldKeys\": \"FSalerId.FNAME,FBillNo,FDate,FName,F_ora_BasePropertyJFS,F_ora_TextZZYH,F_ora_Assistant.FDataValue,F_QETW_ASSISTANT_BU.Fdatavalue,FMaterialName,FMaterialModel,FUnitID.Fname,FQty,FAllAmount,FRecConditionId.FNAME,FSettleCurrId.FName,FDocumentStatus,FCancelStatus,FBDCUSTID.Fnumber,F_ora_Base1.Fname,FAllAmount_LC,FBILLALLAMOUNT_LC,F_ora_Remarks\"," +

         "\"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FDate\",\"Compare\":\"39\",\"Value\":\"2023-01-01 00:00:00\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FDate\",\"Compare\":\"16\",\"Value\":\"2024-12-31 00:00:00\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FDocumentStatus\",\"Compare\":\"105\",\"Value\":\"C\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FCancelStatus\",\"Compare\":\"105\",\"Value\":\"A\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FSalerId.FName\",\"Compare\":\"83\",\"Value\":\"***\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FSalerId.FName\",\"Compare\":\"83\",\"Value\":\"****\",\"Right\":\"\",\"Logic\":0}]," +

         "\"OrderString\": \"\"," +

         "\"TopRowCount\": 0," +

         "\"StartRow\": 0," +

         "\"Limit\": 5000," +

         "\"SubSystemId\": \"\"}";

     clienter.InitClient("*******", "******","*****","*****", 2052, "G", "https://********.ik3cloud.com/k3cloud/");

     var s =  clienter.BillQuery(josnDat);

     JArray ja = (JArray)JsonConvert.DeserializeObject(s);

     Console.WriteLine(ja[0].ToString());

     Console.WriteLine(ja.Count);

     // string connectionString = "server=192.168.100.******;database=erp;uid=root;password=*******;";

     MySQLHelper mySQLHelper = new MySQLHelper(connectionString);

    //DataTable dataTable = mySQLHelper.ExecuteQuery("SELECT * FROM crm_contract");

     Dictionary<string, object> data = new Dictionary<string, object>();

     LogTextBox.AppendText("数据开始写入数据库,数据总行数为:" + ja.Count.ToString() +";"+ "\r\n");

     progressBar1.Maximum = ja.Count;

     for (int i=0;i<ja.Count; i++)

     {

         data.Add("FBillNo", ja[i]["FBillNo"].ToString());

         data.Add("FBDCUSTNumber", ja[i]["FBDCUSTID.Fnumber"].ToString());

         data.Add("FSaler",ja[i]["FSalerId.FNAME"].ToString());

         data.Add("FName", ja[i]["FName"].ToString());

         data.Add("FDate", ja[i]["FDate"]);

         data.Add("F_ora_BasePropertyJFS", ja[i]["F.ora.BasePropertyJFS"].ToString());

         data.Add("F_ora_TextZZYH", ja[i]["F.ora.TextZZYH"].ToString());

         data.Add("F_ora_Assistant", ja[i]["F.ora.Assistant.FDataValue"].ToString());

         data.Add("F_ASSISTANT_BU", ja[i]["F.QETW.ASSISTANT.BU.Fdatavalue"].ToString());

         data.Add("FMaterialName", ja[i]["FMaterialName"].ToString());

         data.Add("FMaterialModel", ja[i]["FMaterialModel"].ToString());

         data.Add("FUnit", ja[i]["FUnitID.Fname"].ToString());

         data.Add("FQty", ja[i]["FQty"]);

         data.Add("FAllAmount", ja[i]["FAllAmount"]);

         data.Add("FRecCondition", ja[i]["FRecConditionId.FNAME"].ToString());

         data.Add("FSettleCurr", ja[i]["FSettleCurrId.FName"].ToString());

         data.Add("FBaseRec", ja[i]["F.ora.Base1.Fname"].ToString());

         data.Add("FRemarks", ja[i]["F.ora.Remarks"].ToString());

         data.Add("FDocStatus", ja[i]["FDocumentStatus"].ToString());

         data.Add("FCancelStatus", ja[i]["FCancelStatus"].ToString());

         data.Add("FAllAmount_LC", ja[i]["FAllAmount.LC"]);

         data.Add("FBILLALLAMOUNT_LC", ja[i]["FBILLALLAMOUNT.LC"]); 

         int result = mySQLHelper.Insert("crm_contract", data);

         progressBar1.Value++;

         data.Clear();

     }

     LogTextBox.AppendText("销售合同数据写入完成!" + "\r\n");

     progressBar1.Value = 0;     

 }


公有云数据同步到本地数据库(仅需要的数据字段)

需求:有独立的数据BI平台,需要的数据存储在公有云中没法做交互,还存在部分其他原因,所以需要将公有云中的销售合同及销售订单数据表同步...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息