コード例 #1
0
        public string Data_TongBuSAPCH_ByKH()              //更新今天某客户的发货数据
        {
            token = appClass.CRM_Gettoken();
            WebMSG msg = new WebMSG();
            //return Newtonsoft.Json.JsonConvert.SerializeObject(msg);
            int staffid = appClass.CRM_GetStaffid();

            CRM_KH_KHList[] KHdata = crmModels.KH_KH.ReadBySTAFFID(appClass.CRM_GetStaffid(), token);
            if (KHdata.Length == 0)
            {
                msg.KEY = 1;
                msg.MSG = "没有需要同步的客户";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }

            //CRM_KH_KHList[] KHdata = new CRM_KH_KHList[1];
            //KHdata[0] = new CRM_KH_KHList();
            //KHdata[0].SAPSN = "100016";


            MODEL_ZBCFUN_DLV_GET SAPdata = crmModels.BarCode.GET_ZBCFUN_DLV_GET2(Newtonsoft.Json.JsonConvert.SerializeObject(KHdata), token);        //获取SAP数据

            if (SAPdata.ET_TTXX.Length == 0)
            {
                msg.KEY = 1;
                msg.MSG = "没有需要同步的信息";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
            int delete = crmModels.BC_CHTT_FAKE.TTMXDelete(token);        //把FAKE表的数据清光

            if (delete != 0)
            {
                msg.KEY = 0;
                msg.MSG = "出货抬头同步发生异常,请重试";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
            for (int i = 0; i < SAPdata.ET_TTXX.Length; i++)       //抬头新增
            {
                CRM_BC_CHTT TTmodel = new CRM_BC_CHTT();
                TTmodel.VBELN     = SAPdata.ET_TTXX[i].VBELN;
                TTmodel.WERKS     = SAPdata.ET_TTXX[i].WERKS;
                TTmodel.POSNR     = SAPdata.ET_TTXX[i].POSNR;
                TTmodel.MATNR     = SAPdata.ET_TTXX[i].MATNR;
                TTmodel.KUNAG     = SAPdata.ET_TTXX[i].KUNAG;
                TTmodel.LGORT     = SAPdata.ET_TTXX[i].LGORT;
                TTmodel.WADAT_IST = SAPdata.ET_TTXX[i].WADAT_IST;
                TTmodel.XGR       = SAPdata.ET_TTXX[i].XGR;

                int id = crmModels.BC_CHTT_FAKE.TTCreate(TTmodel, token);
                if (id == 0)
                {
                    msg.KEY = 0;
                    msg.MSG = "出货抬头同步失败,请重试";
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }
            }
            for (int i = 0; i < SAPdata.ET_HXMXX.Length; i++)      //行项目新增
            {
                Sonluk.UI.Model.CRM.BC_CHTT_FAKEService.CRM_BC_CHMX MXmodel = new Sonluk.UI.Model.CRM.BC_CHTT_FAKEService.CRM_BC_CHMX();
                MXmodel.VBELN = SAPdata.ET_HXMXX[i].VBELN;
                MXmodel.POSNR = SAPdata.ET_HXMXX[i].POSNR;
                MXmodel.TPM   = SAPdata.ET_HXMXX[i].TPM;
                MXmodel.DXM   = SAPdata.ET_HXMXX[i].DXM;
                MXmodel.NHM   = SAPdata.ET_HXMXX[i].NHM;
                MXmodel.CHARG = SAPdata.ET_HXMXX[i].CHARG;
                MXmodel.LWEDT = SAPdata.ET_HXMXX[i].LWEDT;
                MXmodel.QXBS  = SAPdata.ET_HXMXX[i].QXBS;

                int id = crmModels.BC_CHTT_FAKE.MXCreate(MXmodel, token);
                if (id == 0)
                {
                    msg.KEY = 0;
                    msg.MSG = "出货行项目同步失败,请重试";
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                }
            }

            int error = crmModels.BC_CHTT.Modify(token);      //数据更新

            if (error == 0)
            {
                msg.KEY = 1;
                msg.MSG = "同步完成";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
            else
            {
                msg.KEY = 0;
                msg.MSG = "同步失败,请重试";
                return(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
            }
        }
コード例 #2
0
        public string Data_TongBuSAP_CH()         //更新昨天到今天的发货数据
        {
            token = appClass.CRM_Gettoken();

            try
            {
                string yesterday             = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                MODEL_ZBCFUN_DLV_GET SAPdata = crmModels.BarCode.GET_ZBCFUN_DLV_GET_CRM(yesterday, "C", token);        //获取SAP数据
                if (SAPdata.ET_TTXX.Length == 0)
                {
                    return("没有需要同步的信息");
                }
                int delete = crmModels.BC_CHTT_FAKE.TTMXDelete(token);        //把FAKE表的数据清光
                if (delete != 0)
                {
                    return("出货抬头同步发生异常,请重试");
                }
                for (int i = 0; i < SAPdata.ET_TTXX.Length; i++)       //抬头新增
                {
                    CRM_BC_CHTT TTmodel = new CRM_BC_CHTT();
                    TTmodel.VBELN     = SAPdata.ET_TTXX[i].VBELN;
                    TTmodel.WERKS     = SAPdata.ET_TTXX[i].WERKS;
                    TTmodel.POSNR     = SAPdata.ET_TTXX[i].POSNR;
                    TTmodel.MATNR     = SAPdata.ET_TTXX[i].MATNR;
                    TTmodel.KUNAG     = SAPdata.ET_TTXX[i].KUNAG;
                    TTmodel.LGORT     = SAPdata.ET_TTXX[i].LGORT;
                    TTmodel.WADAT_IST = SAPdata.ET_TTXX[i].WADAT_IST;
                    TTmodel.XGR       = SAPdata.ET_TTXX[i].XGR;

                    int id = crmModels.BC_CHTT_FAKE.TTCreate(TTmodel, token);
                    if (id == 0)
                    {
                        return("出货抬头同步失败,请重试");
                    }
                }
                for (int i = 0; i < SAPdata.ET_HXMXX.Length; i++)      //行项目新增
                {
                    Sonluk.UI.Model.CRM.BC_CHTT_FAKEService.CRM_BC_CHMX MXmodel = new Sonluk.UI.Model.CRM.BC_CHTT_FAKEService.CRM_BC_CHMX();
                    MXmodel.VBELN = SAPdata.ET_HXMXX[i].VBELN;
                    MXmodel.POSNR = SAPdata.ET_HXMXX[i].POSNR;
                    MXmodel.TPM   = SAPdata.ET_HXMXX[i].TPM;
                    MXmodel.DXM   = SAPdata.ET_HXMXX[i].DXM;
                    MXmodel.NHM   = SAPdata.ET_HXMXX[i].NHM;
                    MXmodel.CHARG = SAPdata.ET_HXMXX[i].CHARG;
                    MXmodel.LWEDT = SAPdata.ET_HXMXX[i].LWEDT;
                    MXmodel.QXBS  = SAPdata.ET_HXMXX[i].QXBS;

                    int id = crmModels.BC_CHTT_FAKE.MXCreate(MXmodel, token);
                    if (id == 0)
                    {
                        return("出货行项目同步失败,请重试");
                    }
                }

                int error = crmModels.BC_CHTT.Modify(token);      //数据更新

                if (error == 0)
                {
                    return("同步完成");
                }
                else
                {
                    return("同步失败,请重试");
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }