Exemplo n.º 1
0
        private void MainThread()
        {
            TxtLog.WriteLine("数据库 chl", dbsp.ConnectionString);
            ThreadStart threadStart = delegate
            {
                do
                {
                    DataTable mqsDt  = null;
                    string    mqsSql = "select * from crm_attributesprodetect where   tools=" + textBox1.Text.Trim();
                    mqsDt = dbtool.ExecuteDataTable(mqsSql);
                    if (mqsDt != null && mqsDt.Rows.Count > 0)
                    {
                        Mypic mp = new Mypic();
                        this.SendMain(mqsDt);
                    }
                    Thread.Sleep(1000 * 10);//休息10s
                } while (true);
            };
            Thread thread = new Thread(threadStart);

            thread.IsBackground = true;
            thread.Start();
        }
Exemplo n.º 2
0
        public void TaskDetection(Dictionary <string, Item> dicItem, SellerInfoEntity sellerinfo, string activityId, string activityType)
        {
            try
            {
                if (dicItem == null)
                {
                    TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:获取宝贝为空" + sellerinfo.top_session);
                    return;
                }
                string      tableindex    = sellerinfo.strUserId.Substring(sellerinfo.strUserId.Length - 1, 1);
                MySqlHelper dbtool        = new MySqlHelper(DataType.ToolsProducts);
                string      sql           = "select proword from crm_prohibitedword where is_del='0'";
                string      sqluser       = "******" + tableindex + " where is_del='0' and seller_id =" + sellerinfo.strUserId;
                DataTable   dt            = dbtool.ExecuteDataTable(sql);
                DataTable   dtuser        = dbtool.ExecuteDataTable(sqluser);
                string      ItemImgsError = string.Empty;
                string      titleword     = string.Empty; //标题异常
                string      desc          = string.Empty; //详情异常
                string      pictext       = string.Empty;
                Mypic       myp           = new Mypic();
                int         itemcount     = 0;
                foreach (var item in dicItem.Values)
                {//'任务类型 0,文字检测 1图片检测 3 全部检测'
                    titleword = ""; desc = ""; ItemImgsError = "";
                    switch (activityType)
                    {
                    case "0":    //文字检测
                        myp.DetectionTitelDesc(dtuser, dt, item, ref titleword, ref desc);
                        break;

                    case "1":    //图片检测
                        myp.DetectionPIC(dtuser, dt, item, ref ItemImgsError, ref pictext);
                        break;

                    case "3":    //  全部检测'
                        myp.DetectionTitelDesc(dtuser, dt, item, ref titleword, ref desc);
                        myp.DetectionPIC(dtuser, dt, item, ref ItemImgsError, ref pictext);
                        break;

                    default:
                        break;
                    }
                    if (pictext != null && pictext.Contains("Open api daily request limit reached"))
                    {
                        LogApi.MonitorLog.Write(LogApi.LogType.Error, LogApi.Products.CRM, LogApi.VersionM.Standard, "图片检测欠费", sellerinfo.strUserId, sellerinfo.strUserNick, "", " 检测api欠费:活动id:" + activityId);
                        return;
                    }
                    else if (pictext != null && pictext.Contains("Open api qps request limit reached"))
                    {
                        LogApi.MonitorLog.Write(LogApi.LogType.Error, LogApi.Products.CRM, LogApi.VersionM.Standard, "图片检测欠费", sellerinfo.strUserId, sellerinfo.strUserNick, "", " 检测api限流 活动id:" + activityId);
                        return;
                    }
                    itemcount++;
                    ShowSend("开始检测" + DateTime.Now.ToString() + "宝贝id" + item.NumIid + itemcount + "/" + dicItem.Count + "用户id" + sellerinfo.strUserId);
                    //任务进度写进缓存
                    Sethc(activityId, itemcount + "/" + dicItem.Count);
                    string errors    = titleword + desc + ItemImgsError;
                    string tabelName = sellerinfo.strUserId.Substring(sellerinfo.strUserId.Length - 1);
                    if (!string.IsNullOrWhiteSpace(errors))
                    {
                        if (!string.IsNullOrWhiteSpace(ItemImgsError))
                        {
                            ItemImgsError = "[" + ItemImgsError.Substring(0, ItemImgsError.Length - 1) + "]";
                        }
                        string psql = string.Format("INSERT INTO  `crm_prohibiteword_detail{0}` (`id`, `mainid1`, `seller_id`, `num_id`, `title` , `pic_url`, `create_time`, `title_fail_reason`, `sellpoint_fail_reason`, `desc_fail_reason`, picture_fail_reason1,is_error) VALUES ('{1}', '{2}', '{3}', '{4}', '{5}' , '{6}', now(), '{7}', '', '{8}','{9}',{10} );", tabelName, Guid.NewGuid(), activityId, sellerinfo.strUserId, item.NumIid, item.Title.Replace("'", ""), item.PicUrl, titleword, desc, ItemImgsError, "1");
                        dbtool.ExecuteNonQuery(psql);
                    }
                    else
                    {
                        string psql = string.Format("INSERT INTO  `crm_prohibiteword_detail{0}` (`id`, `mainid1`, `seller_id`, `num_id`, `title` , `pic_url`, `create_time`, `title_fail_reason`, `sellpoint_fail_reason`, `desc_fail_reason`, picture_fail_reason1,is_error) VALUES ('{1}', '{2}', '{3}', '{4}', '{5}' , '{6}', now(), '{7}', '', '{8}','{9}' ,{10});", tabelName, Guid.NewGuid(), activityId, sellerinfo.strUserId, item.NumIid, item.Title.Replace("'", ""), item.PicUrl, titleword, desc, ItemImgsError, "0");
                        dbtool.ExecuteNonQuery(psql);
                    }
                }
            }
            catch (Exception ex)
            {
                TxtLog.WriteLine("图片违禁词检测", ex.ToString());
            }
        }