Exemplo n.º 1
0
 public static DBSql getInstance()
 {
     if (instance == null)
     {
         instance = new DBSql();
     }
     return(instance);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 暂停活动
        /// </summary>
        /// <param name="promotion_id"></param>
        /// <param name="session"></param>
        /// <param name="actionId"></param>
        /// <param name="iid"></param>
        public void promotionStop(string promotion_id, string session, string actionId, string iid)
        {
            string appkey = "12287381";
            string secret = "d3486dac8198ef01000e7bd4504601a4";
            IDictionary <string, string> param = new Dictionary <string, string>();

            //删除活动
            param = new Dictionary <string, string>();
            param.Add("promotion_id", promotion_id);
            string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotion.delete", session, param);

            //更新结束活动
            string sql = "update  tete_activitylist set Status=3 ,isok=1  WHERE ActivityID = " + actionId + " and  ProductID=" + iid;

            DBSql.getInstance().ExecSql(sql);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 暂停的活动
        /// </summary>
        private void activityStop()
        {
            try
            {
                string session = string.Empty;

                DBSql db = DBSql.getInstance();

                string    sql1 = "select * from tete_activity where status=3 and isok=0  "; //暂停的活动
                DataTable dt1  = DBSql.getInstance().GetTable(sql1);
                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    for (int i = 0; i < dt1.Rows.Count; i++)
                    {
                        string    sql2  = " select * from tete_activitylist where ActivityID=" + dt1.Rows[i]["ID"].ToString();//更新该活动下的商品
                        DataTable dt1s2 = DBSql.getInstance().GetTable(sql2);
                        if (dt1s2 != null && dt1s2.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt1s2.Rows.Count; j++)
                            {
                                string sqlstr1 = "SELECT session FROM TopTaobaoShop WHERE nick = '" + dt1s2.Rows[j]["nick"].ToString() + "'";

                                DataTable dtnick = db.GetTable(sqlstr1);
                                if (dtnick.Rows.Count != 0)
                                {
                                    session = dtnick.Rows[0]["session"].ToString();
                                }

                                //暂停活动
                                promotionStop(dt1s2.Rows[j]["promotionID"].ToString(), session, dt1s2.Rows[j]["ActivityID"].ToString(), dt1s2.Rows[j]["ProductID"].ToString());
                            }
                        }

                        sql1 = "update tete_activity set Status=3 , isok=1 where id=" + dt1.Rows[i]["ID"].ToString(); //暂停活动
                        DBSql.getInstance().ExecSql(sql1);
                    }
                }

                #region   除的活动  需要把活动商品删除掉
                sql1 = "select * from tete_activity where status=4 and isok=0  "; //删除的活动
                dt1  = DBSql.getInstance().GetTable(sql1);
                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    for (int i = 0; i < dt1.Rows.Count; i++)
                    {
                        string    sql2  = " select * from tete_activitylist where ActivityID=" + dt1.Rows[i]["ID"].ToString();//更新该活动下的商品
                        DataTable dt1s2 = DBSql.getInstance().GetTable(sql2);
                        if (dt1s2 != null && dt1s2.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt1s2.Rows.Count; j++)
                            {
                                string sqlstr1 = "SELECT session FROM TopTaobaoShop WHERE nick = '" + dt1s2.Rows[j]["nick"].ToString() + "'";

                                DataTable dtnick = db.GetTable(sqlstr1);
                                if (dtnick.Rows.Count != 0)
                                {
                                    session = dtnick.Rows[0]["session"].ToString();
                                }

                                //删除活动
                                promotionStop(dt1s2.Rows[j]["promotionID"].ToString(), session, dt1s2.Rows[j]["ActivityID"].ToString(), dt1s2.Rows[j]["ProductID"].ToString());
                            }
                        }

                        sql1 = "update tete_activity set Status=4 , isok=1 where id=" + dt1.Rows[i]["ID"].ToString(); //删除的活动
                        DBSql.getInstance().ExecSql(sql1);
                    }
                }
                #endregion


                dt1.Dispose();
                //休息后继续循环-默认1分半钟一次
                Thread.Sleep(90000);
                Thread newThread5 = new Thread(activityStop);
                newThread5.Start();
            }
            catch (Exception e)
            {
                WriteLog4("自动取消活动运行错误*****************************************" + e.StackTrace + e.Message + "----error!!!", "1");
                //MessageBox.Show("\r\n" + e.StackTrace);
                Thread newThread5 = new Thread(activityStop);
                //休息后继续循环-默认1分半钟一次
                Thread.Sleep(90000);
                newThread5.Start();
            }
        }