Ejemplo n.º 1
0
 // 添加商品
 public void addProduct(string title, string url, string price, string rate, string commfee, string sale30, string addtime)
 {
     try
     {
         string enURL = EncryptDES.Encrypt(url); // URL进行加密
         string sql   = "insert into product(title, url, price, rate, commfee, sale30, addtime) values ('" + title + "', '" + enURL + "', '"
                        + price + "', '" + rate + "', '" + commfee + "', '" + sale30 + "', '" + addtime + "')";
         _helper.Execute(sql);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
        private void QunfaThreadProc(object param)
        {
            QunfaParam qunfaParam    = param as QunfaParam;
            DateTime   lastQunfaTime = new DateTime();

            while (!qunfaParam.Qunfa.StopThread)
            {
                DateTime nowTime = DateTime.Now;
                TimeSpan delta   = nowTime - lastQunfaTime;
                if (delta.TotalSeconds > qunfaParam.Interval * 60 && nowTime.Hour >= qunfaParam.StartTime && nowTime.Hour < qunfaParam.EndTime)
                {
                    Debugger.Log(0, null, "开始群发 " + DateTime.Now.ToString());
                    while (!qunfaParam.Qunfa.StopThread) // 解析失败后重试
                    {
                        bool bTranslatedSuccess = false;
                        // 从数据库中加载商品
                        List <ProductInfo> productList = qunfaParam.Database.loadProductList(qunfaParam.Qunfa.QunfaStartRow, qunfaParam.Qunfa.QunfaCount, true);
                        foreach (ProductInfo product in productList)
                        {
                            string url        = product._auctionUrl;
                            string decryptURL = EncryptDES.Decrypt(url); // 解密

                            if (qunfaParam.Qunfa.StopThread)
                            {
                                break;
                            }
                            string imgPath, qqShowContent, wechatShowContent;                                                                                         // 图片路径,文案
                            bool   bSuccess = qunfaParam.Mama.TranslateURL(decryptURL, qunfaParam.AdzoneName, out imgPath, out qqShowContent, out wechatShowContent); // 转链
                            if (qunfaParam.Qunfa.StopThread)
                            {
                                break;
                            }
                            if (!bSuccess) // 转链失败
                            {
                                Debugger.Log(0, null, decryptURL + " translate failed");
                                qunfaParam.Database.updateProductSendTime(product._id); // 更新商品的最新发送时间戳
                                break;
                            }

                            string strQQShowContent     = ClipboardDataWrapper.WrapFroQQ(imgPath, qqShowContent);
                            string strWechatShowContent = wechatShowContent;
                            int    nMajor = System.Environment.Version.Major;
                            int    nMinor = System.Environment.Version.Minor;
                            if (nMajor >= 6 && nMinor >= 2)
                            {
                                // win8及以上
                                strWechatShowContent = ClipboardDataWrapper.WrapForWechat(imgPath, wechatShowContent);
                            }
                            TranslateUrlResult result = new TranslateUrlResult(product._title, strQQShowContent, strWechatShowContent, imgPath);
                            lock (_translateListLock)
                            {
                                _translateList.Add(result);
                                bTranslatedSuccess = true;
                                qunfaParam.Database.updateProductSendTime(product._id); // 更新商品的最新发送时间戳
                            }
                        }

                        if (bTranslatedSuccess) // 如果有结果,则不再取,否则继续取
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                    }

                    lastQunfaTime = nowTime;
                }
                Thread.Sleep(1000);
            }
        }