コード例 #1
0
ファイル: IBMWCSKUInterface.cs プロジェクト: huaminglee/Code
        /// <summary>
        /// VEX框架的主入口
        /// </summary>
        /// <returns></returns>
        public Boolean Execute()
        {
            try
            {

                string strResult = "";
                HttpTools http = new HttpTools();

                int nExecuteRowCount = 200;
                string strurl = "http://172.16.71.137:8080/wcsportal/rest/goods/putGoodsDataList";

                if (m_request != null && m_request.Tables.Count > 0 && m_request.Tables[0].Rows.Count == 1)
                {
                    if (m_request.Tables[0].Columns.Contains("executeRowCount"))
                    {
                        try
                        {
                            nExecuteRowCount = Convert.ToInt32(m_request.Tables[0].Rows[0]["executeRowCount"]);
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    if (m_request.Tables[0].Columns.Contains("posturl"))
                    {
                        try
                        {
                            strurl = m_request.Tables[0].Rows[0]["posturl"].ToString();

                        }
                        catch (Exception ex)
                        {
                            throw new Exception("目标服务器URL不正确,请查看配置。");
                            return false;
                        }
                    }
                }

                m_conn.TimeOut = 60;
                //事务开始

                m_conn.Excute("update [dbo].[Put_SKU] set WCSFlag=2 where isnull(WCSFlag,0)=0 and SKU_GROUP4 NOT IN ('P','X','LX','RS','E','G','F','J','K','N','S','T','Z','D','B','Q')");

                m_conn.BeginTransaction();

                string strSQL = @"
                        SELECT top " + nExecuteRowCount.ToString() + @" [NewID]
                              ,[CreateTime]
                              ,[Timestamps]
                              ,[WMSFlag]
                              ,[WCSFlag]
                              ,[SKU]
                              ,[Descr_C]
                              ,[SKU_GROUP4]
                              ,[SKU_GROUP1]
                              ,[Price]
                              ,[Alternate_SKU1]
                              ,[ReservedField01]
                              ,[ReservedField02]
                              ,[ReservedField03]
                              ,[ReservedField04]
                              ,[ReservedField05]
                              ,[ReservedField06]
                              ,[ReservedField07]
                              ,[NOTES]
                              ,styleid
                          INTO #tmp
                          FROM [dbo].[Put_SKU] 
                          WHERE isnull(WCSFlag,0)=0
                          And SKU_GROUP4 IN ('P','X','LX','RS','E','G','F','J','K','N','S','T','Z','D','B','Q')


                          ORDER BY CreateTime ASC,Timestamps ASC 

                          UPDATE [dbo].[Put_SKU]
                          SET WCSFlag=1
                          WHERE EXISTS(SELECT 1 FROM #tmp WHERE #tmp.NewID = Put_SKU.newid)
                          SELECT * FROM #tmp
                          DROP TABLE #tmp
                                                        ";

                DataTable dtData = m_conn.GetDataTable(strSQL);


                string strInputValue = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><goodsDatas>";

                if (dtData.Rows.Count > 0)
                {

                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        strInputValue += "<goodsData>";
                        strInputValue += "<sku>" + dtData.Rows[i]["SKU"].ToString() + "</sku>";
                        strInputValue += "<price>" + dtData.Rows[i]["PRICE"].ToString() + "</price>";
                        strInputValue += "<sizeId>" + dtData.Rows[i]["ReservedField04"].ToString() + "</sizeId>";
                        strInputValue += "<colorId>" + dtData.Rows[i]["ReservedField05"].ToString() + "</colorId>";
                        strInputValue += "<goodsName>" + dtData.Rows[i]["Descr_C"].ToString() + "</goodsName>";
                        strInputValue += "<channelId>1</channelId>";
                        strInputValue += "<merchantId>1</merchantId>";
                        strInputValue += "<fid>" + dtData.Rows[i]["styleid"].ToString() + "</fid>";
                        //strInputValue += "<fid>001test</fid>";
                        strInputValue += "<barcode>" + dtData.Rows[i]["Alternate_SKU1"].ToString() + "</barcode>";
                        strInputValue += "<isUpdate>0</isUpdate>";
                        strInputValue += "<goodsCategory>" + dtData.Rows[i]["ReservedField03"].ToString() + "</goodsCategory>";
                        strInputValue += "<bigCategory>" + dtData.Rows[i]["SKU_GROUP1"].ToString() + "</bigCategory>";
                        strInputValue += "<smallCategory>" + dtData.Rows[i]["ReservedField01"].ToString() + "</smallCategory>";
                        strInputValue += "<goodsbrand>" + dtData.Rows[i]["SKU_GROUP4"].ToString() + "</goodsbrand>";
                        strInputValue += "<brandName>" + dtData.Rows[i]["ReservedField02"].ToString() + "</brandName>";
                        strInputValue += "<year>" + dtData.Rows[i]["ReservedField06"].ToString() + "</year>";
                        strInputValue += "<season>" + dtData.Rows[i]["ReservedField07"].ToString() + "</season>";

                        strInputValue += "</goodsData>";

                    }
                    //ws.Timeout = 3600 * 1000; 

                    strInputValue += "</goodsDatas>";
                    strInputValue = strInputValue.Replace("&", "&amp;");
                    strResult = http.CreateHttpPost(strurl, strInputValue, false, "UTF-8", "application/xml");


                    HZY.COM.Common.Log.WirteLogWS("IBMWCSKUInterface:" + strResult + " 传入参数:" + strInputValue, null);


                    //执行失败
                    if (!strResult.Contains("成功"))
                    {
                        m_conn.RollbackTransaction();
                        return false;
                    }
                }


                //事务提交 --注意:不能移动到每个方法里面,这里面的方法会有互相调用的情况
                m_conn.CommitTransaction();

            }
            catch
            {
                m_conn.RollbackTransaction();
                throw;
            }

            return true;
        }
コード例 #2
0
ファイル: WSRR.cs プロジェクト: huaminglee/Code
    private string ExecuteRestful(DataSet pdsWSID, DataSet pdsRequest)
    {
        string strParam = "";
        string strType = pdsWSID.Tables[0].Rows[0]["WSMethod"].ToString().ToLower();
        string strUnicode = pdsWSID.Tables[0].Rows[0]["WSUnicode"].ToString().ToUpper();

        for (int j = 0; j < pdsWSID.Tables[0].Rows.Count; j++)
        {
            if (pdsWSID.Tables[0].Rows[j]["ParamName"] == DBNull.Value)
            {
                continue;
            }
            string strParamName = pdsWSID.Tables[0].Rows[j]["ParamName"].ToString();
            DataRow[] drList = pdsRequest.Tables[0].Select("ParamName='" + strParamName + "'");

            if (drList.Length > 0)
            {
                if (strType == "get")
                {
                    strParam += drList[0]["ParamName"].ToString() + "=";
                    strParam += drList[0]["ParamValue"].ToString() + "&";

                    //Microsoft.JScript.GlobalObject.escape(
                }
                else if (strType == "post")
                {
                    strParam = drList[0]["ParamValue"].ToString();
                }
            }
            else
            {

                if (pdsWSID.Tables[0].Rows[j]["DefaultValue"] != DBNull.Value)
                {
                    if (strType == "get")
                    {
                        strParam += strParamName + "=";
                        strParam += pdsWSID.Tables[0].Rows[j]["DefaultValue"].ToString() + "&";
                    }
                    else if (strType == "post")
                    {
                        strParam = drList[0]["ParamValue"].ToString();
                    }
                }
                else
                {
                    if (pdsWSID.Tables[0].Rows[j]["ParamMustFlag"].ToString() == "1")
                    {
                        throw new Exception(strParamName + "参数没有被赋值!");
                    }
                }
            }

        }


        string strResult = "";
        HttpTools http = new HttpTools();
        string strurl = GetURL(pdsWSID);

        if (strType == "get")
        {
            strResult = http.CreateHttpGet(strurl + strParam, false, strUnicode);

        }
        else if (strType == "post")
        {
            strResult = http.CreateHttpPost(strurl, strParam, false, strUnicode);
        }

        return strResult;

    }
コード例 #3
0
        /// <summary>
        /// VEX框架的主入口
        /// </summary>
        /// <returns></returns>
        public Boolean Execute()
        {
            Log log = new Log();

            try
            {

                string strResult = "";
                HttpTools http = new HttpTools();

                int nExecuteRowCount = 200;
                string strurl = "http://172.16.71.186:8080/wcsportal/rest/goodsStork/putGoodsDataList";


                if (m_request != null && m_request.Tables.Count > 0 && m_request.Tables[0].Rows.Count == 1)
                {
                    if (m_request.Tables[0].Columns.Contains("executeRowCount"))
                    {
                        try
                        {
                            nExecuteRowCount = Convert.ToInt32(m_request.Tables[0].Rows[0]["executeRowCount"]);
                        }
                        catch (Exception ex)
                        {

                        }
                    }


                    if (m_request.Tables[0].Columns.Contains("posturl"))
                    {
                        try
                        {
                            strurl = m_request.Tables[0].Rows[0]["posturl"].ToString();

                        }
                        catch (Exception ex)
                        {
                            throw new Exception("目标服务器URL不正确,请查看配置。");
                        }
                    }
                }



                m_conn.TimeOut = 60;
                //事务开始
                m_conn.BeginTransaction();

                string strSQL = @"
                        SELECT top " + nExecuteRowCount.ToString() + @" [NewID]
                          ,[CreateTime]
                          ,[WCSFlag]
                          ,[SKU]
                          ,[totalInventory]
                          ,[UpdateTime] 
                          INTO #tmp
                          FROM [dbo].[Put_SkuStock]
                          WHERE isnull(WCSFlag,0)=0

                          ORDER BY CreateTime ASC,Timestamps DESC 

                          UPDATE [dbo].[Put_SkuStock]
                          SET WCSFlag=1
                          WHERE EXISTS(SELECT 1 FROM #tmp WHERE #tmp.NewID = Put_SkuStock.newid)
                          SELECT * FROM #tmp
                          DROP TABLE #tmp
                                                        ";

                DataTable dtData = m_conn.GetDataTable(strSQL);


                string strInputValue = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><goodsDatas>";

                if (dtData.Rows.Count > 0)
                {

                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        strInputValue += "<goodsData>";
                        strInputValue += "<sku>" + dtData.Rows[i]["SKU"].ToString() + "</sku>";
                        strInputValue += "<totalStork>" + dtData.Rows[i]["totalInventory"].ToString() + "</totalStork>";
                        strInputValue += "<updateFlag>0</updateFlag>";
                        strInputValue += "</goodsData>";

                    }

                    strInputValue += "</goodsDatas>";


                    log.WritePostLog("IBMWCStockInterface", strurl, strInputValue);

                    strResult = http.CreateHttpPost(strurl, strInputValue, false, "UTF-8", "application/xml");
                    log.WritePostLogUpdateResult(strResult);

                    //执行失败
                    if (!strResult.Contains("成功"))
                    {
                        m_conn.RollbackTransaction();
                        throw new Exception("调用接口失败,返回信息为:" + "调用地址:" + strurl+" 返回信息:" + strResult);
                        return false;
                    }
                }


                //事务提交 --注意:不能移动到每个方法里面,这里面的方法会有互相调用的情况
                m_conn.CommitTransaction();

            }
            catch(Exception ex)
            {
                log.WritePostLogUpdateResult(ex.ToString());

                m_conn.RollbackTransaction();
                throw ex;
            }

            return true;
        }