Exemplo n.º 1
0
        public static async Task <ProfileStatsEntity> QueryStats(string uid)
        {
            var json   = (await HttpTools.GetAsync(uid)).Content;
            var origin = JsonTools.SerializeProfileEntity(json);

            return(origin.data.stats.ToObject <ProfileStatsEntity>());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载所有分类
        /// </summary>
        /// <param name="categoryService"></param>
        private static void LoadCategory(ICategoryService categoryService)
        {
            //2:初始化爬虫
            GM_Crawler crawler = new GM_Crawler();

            string allCateURL  = ConfigurationManager.AppSettings["GM_AllCategory"];
            string strCategory = HttpTools.Get(allCateURL);
            //2.1 加载当前页面所有的分类
            List <Category> tempCateList = crawler.GetAllCategoryURl(strCategory);
            //2.2 加载所有分类明细详情
            List <Category> allCagoryList = new List <Category>();
            //2.3 记录统一类别的情况不在发起请求
            List <string> typeList = new List <string>();

            tempCateList.ForEach(u =>
            {
                if (!typeList.Contains(u.ParentCode))
                {
                    Console.WriteLine($"类别:{u.Name},Url={u.Url}");

                    string strHtml = HttpTools.Get(u.Url);
                    allCagoryList.AddRange(crawler.GetAllCategoryList(strHtml));
                    typeList.Add(u.ParentCode);
                }
            });
            Console.WriteLine($"所有的类别数据都已经下载完成");
            //2.3 将类别数据插入到数据库中
            categoryService.AddCategory(allCagoryList);
            Console.WriteLine($"Category数据插入完成");
        }
Exemplo n.º 3
0
        public static async Task <IEnumerable <ProfileAvatarEntity> > QueryAvatars(string uid)
        {
            var json   = (await HttpTools.GetAsync(uid)).Content;
            var origin = JsonTools.SerializeProfileEntity(json);

            return(origin.data.avatars.ToObject <List <ProfileAvatarEntity> >());
        }
Exemplo n.º 4
0
        public List <ServerType> GetAllServerTypes(int userid)
        {
            string    url   = KNDBsysUrl.BaseInfoUrl.ServerTypeUrl.GetAllServerType;
            HttpTools tools = new HttpTools();

            tools.AddParam("userid", userid).Build();;
            return(GetList(url, tools));
        }
Exemplo n.º 5
0
        public SysVer GetNewSysVer()
        {
            string    url   = KNDBsysUrl.BaseInfoUrl.SysVerUrl.GetNewSysVer;
            HttpTools tools = new HttpTools();

            tools.AddParam("programtype", "winform").Build();
            return(GetEntity(url, tools));
        }
Exemplo n.º 6
0
        public List <Authority> GetOperAuthbyTag(int formtag, string authtypeName)
        {
            string    url   = KNDBsysUrl.BaseInfoUrl.AuthorityUrl.GetOperAuthByTag;
            HttpTools tools = new HttpTools();

            tools.AddParam("authtypeName", authtypeName).AddParam("tag", formtag).Build();
            return(GetList(url, tools));
        }
Exemplo n.º 7
0
        public List <Authority> GetAuthorities(int userid)
        {
            string    url   = KNDBsysUrl.BaseInfoUrl.AuthorityUrl.GetAllAuthority;
            HttpTools tools = new HttpTools();

            tools.AddParam("userid", userid).Build();
            return(GetList(url, tools));
        }
Exemplo n.º 8
0
        public List <Authority> GetUserAuth(string userid, string port)
        {
            string    url   = KNDBsysUrl.BaseInfoUrl.UserAuthUrl.GetUserAuth;
            HttpTools tools = new HttpTools();

            tools.AddParam("userid", userid)
            .AddParam("portType", port).Build();
            return(GetList(url, tools));
        }
Exemplo n.º 9
0
    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;

    }
Exemplo n.º 10
0
        /// <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;
        }
Exemplo n.º 11
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;
        }