Exemplo n.º 1
0
        /// <summary>
        /// 从省一体化平台按uuid获取质监申报数据到无锡数据中心
        /// </summary>
        public string YourTask_PullZJSBDataFromSythptByUUID(string deptCode, string password, string uuid)
        {
            string apiMessage = string.Empty;

            DataTable dtapizb = dataService.Get_API_zb_apiFlowDetail("0");

            if (dtapizb.Rows[0][0].ToString() == "1")
            {
                try
                {
                    ReceiveDataServiceSpace.ReceiveDataServicePortTypeClient client = new ReceiveDataServiceSpace.ReceiveDataServicePortTypeClient();
                    //根据uuid获取安监申报详细数据
                    string getDetailDataXml = String.Empty;

                    Public.WriteLog("YourTask_PullZJSBDataFromSythptByUUID:" + uuid);
                    //根据uuid获取质监申报详细数据

                    getDetailDataXml = client.getZJSBBByUuid(deptCode, password, uuid);
                    //Public.WriteLog("getZJSBBByUuid结果:" + getDetailDataXml);
                    if (getDetailDataXml.Contains("<?xml version=\"1.0\" encoding=\"gb2312\"?>"))
                    {
                        apiMessage       = "success";
                        getDetailDataXml = getDetailDataXml.Replace("<?xml version=\"1.0\" encoding=\"gb2312\"?>", "").Replace("<body>", "").Replace("</body>", "");
                        saveZJSBXmlDataToDb(uuid, deptCode, getDetailDataXml, DateTime.Now);
                    }
                }
                catch (Exception ex)
                {
                    Public.WriteLog("执行YourTask_PullZJSBDataFromSythptByUUID方法出现异常:" + ex.Message);
                    apiMessage += ex.Message;
                }
            }
            return(apiMessage);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从省一体化平台获取数据质监申报数据到无锡数据中心
        /// </summary>
        public string YourTask_PullZJSBDataFromSythpt(DateTime pullDate)
        {
            string    apiMessage = string.Empty;
            DataTable dtapizb    = dataService.Get_API_zb_apiFlowDetail("0");

            if (dtapizb.Rows[0][0].ToString() == "1")
            {
                try
                {
                    DateTime beginTime = DateTime.Now;
                    Public.WriteLog("开始执行YourTask_PullZJSBDataFromSythpt任务:" + beginTime.ToString("yyyy-MM-dd HH:mm:ss"));

                    //往数据监控日志表添加一条记录
                    DataTable dt_DataJkLog  = dataService.GetSchema_DataJkLog();
                    DataRow   row_DataJkLog = dt_DataJkLog.NewRow();
                    dt_DataJkLog.Rows.Add(row_DataJkLog);
                    string dataJkLogID = dataService.Get_DataJkLogNewID();
                    row_DataJkLog["ID"]           = dataJkLogID;
                    row_DataJkLog["DataFlow"]     = dtapizb.Rows[0]["apiFlow"];
                    row_DataJkLog["DataFlowName"] = dtapizb.Rows[0]["apiName"];
                    row_DataJkLog["ServiceUrl"]   = dtapizb.Rows[0]["apiUrl"];
                    row_DataJkLog["csTime"]       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    dataService.Submit_DataJkLog(dt_DataJkLog);

                    ReceiveDataServiceSpace.ReceiveDataServicePortTypeClient client = new ReceiveDataServiceSpace.ReceiveDataServicePortTypeClient();
                    #region  从省一体化平台获取质监申报数据

                    DataTable dtApApiUsers = dataService.GetApApiUsers("ZJ");//AJ-获取安监帐号列表
                    //string pullDate = DateTime.Now.ToString("yyyy-MM-dd");
                    string pullDateStr = pullDate.ToString("yyyy-MM-dd");
                    //DateTime pullDate;
                    //DateTime.TryParse(pullDateStr, out pullDate);

                    string    getUUIDXml          = String.Empty;
                    string    getDetailDataXml    = String.Empty;
                    string    message_lxxm        = String.Empty;
                    DataTable dt_DataJkDataDetail = dataService.GetSchema_DataJkDataDetail();


                    foreach (DataRow rowUser in dtApApiUsers.Rows)
                    {
                        try
                        {
                            Public.WriteLog("获取质监申报数据,机构:" + rowUser["deptCode"].ToString2() + ",日期:" + pullDateStr);
                            getUUIDXml = client.getZJSBBByDate(rowUser["deptCode"].ToString2(), rowUser["password"].ToString2(), pullDateStr);

                            //Public.WriteLog("获取质监申报数据结果:" + getUUIDXml);

                            if (getUUIDXml.Contains("<?xml version=\"1.0\" encoding=\"GB2312\"?>"))
                            {
                                apiMessage = "success";
                                getUUIDXml = getUUIDXml.Replace("<?xml version=\"1.0\" encoding=\"GB2312\"?>", "").Replace("<body>", "").Replace("</body>", "");
                            }
                            else
                            {
                                //错误处理, 往数据监控详细日志表项添加一条记录
                                createMonitorLog(dataService, dt_DataJkDataDetail, dataJkLogID, "Ap_zjsbb", "getZJSBBByDate");

                                /**
                                 * DataRow row_DataJkDataDetail = dt_DataJkDataDetail.NewRow();
                                 * dt_DataJkDataDetail.Rows.Add(row_DataJkDataDetail);
                                 * Int64 id = dataService.Get_DataJkDataDetailNewID().ToInt64();
                                 * row_DataJkDataDetail["ID"] = id;
                                 * row_DataJkDataDetail["DataJkLogID"] = row_DataJkLog["ID"];
                                 * row_DataJkDataDetail["tableName"] = "Ap_ajsbb";
                                 * row_DataJkDataDetail["MethodName"] = "getAJSBBByDate";
                                 */
                            }

                            if (!string.IsNullOrEmpty(getUUIDXml.Trim()))
                            {
                                DataTable dt = xmlHelper.ConvertXMLToDataTableWithBase64Decoding(getUUIDXml, out message_lxxm);
                                //string parseBase64Xml = xmlHelper.ConvertDataTableToXML(dt, "dataTable", "row");
                                //Public.WriteLog("获取安监申报数据结果:" + parseBase64Xml);

                                foreach (DataRow row in dt.Rows)
                                {
                                    try
                                    {
                                        //根据uuid获取质监申报详细数据
                                        Public.WriteLog("根据uuid获取质监申报详细数据:" + row[0].ToString());
                                        getDetailDataXml = client.getZJSBBByUuid(rowUser["deptCode"].ToString2(), rowUser["password"].ToString2(), row[0].ToString());
                                        //Public.WriteLog("getZJSBBByUuid结果:" + getDetailDataXml);
                                        if (getDetailDataXml.Contains("<?xml version=\"1.0\" encoding=\"gb2312\"?>"))
                                        {
                                            getDetailDataXml = getDetailDataXml.Replace("<?xml version=\"1.0\" encoding=\"gb2312\"?>", "").Replace("<body>", "").Replace("</body>", "");

                                            saveZJSBXmlDataToDb(row[0].ToString(), rowUser["deptCode"].ToString2(), getDetailDataXml, pullDate);
                                        }
                                        else
                                        {
                                            //错误处理, 往数据监控详细日志表项添加一条记录
                                            createMonitorLog(dataService, dt_DataJkDataDetail, dataJkLogID, "Ap_zjsbb", "getZJSBBByUuid");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Public.WriteLog("根据uuid获取质监申报详细数据出现异常:" + ex.Message);
                                        apiMessage += ex.Message;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Public.WriteLog("执行YourTask_PullZJSBDataFromSythpt方法出现异常:" + ex.Message);
                            apiMessage += ex.Message;
                        }
                    }

                    dataService.Submit_DataJkDataDetail(dt_DataJkDataDetail);

                    #endregion
                }
                catch (Exception ex)
                {
                    Public.WriteLog("执行YourTask_PullZJSBDataFromSythpt方法出现异常:" + ex.Message);
                    apiMessage += ex.Message;
                }
                finally
                {
                    DataTable dtapicb   = dataService.GetSchema_API_cb();
                    DataRow   row_apicb = dtapicb.NewRow();
                    dtapicb.Rows.Add(row_apicb);
                    row_apicb["apiCbID"]      = dataService.Get_apiCbNewID();
                    row_apicb["apiFlow"]      = "0";
                    row_apicb["apiMethod"]    = "getZJSBBByDate";
                    row_apicb["apiDyResult"]  = string.IsNullOrEmpty(apiMessage) == true ? "成功" : "失败";
                    row_apicb["apiDyMessage"] = apiMessage;
                    row_apicb["apiDyTime"]    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    dataService.Submit_API_cb(dtapicb);

                    dataService.UpdateZbJkzt("0", string.IsNullOrEmpty(apiMessage) == true ? "1" : "0", apiMessage);
                }
            }
            return(apiMessage);
        }