Ejemplo n.º 1
0
        public async Task <ActionResult> HandleSignIn(User user)
        {
            try
            {
                user.UserId = user.UserId.Trim();
                user.UserId = user.UserId.ToLower();
                if (await galSvc.SignIn(user))
                {
                    if (ModelState.IsValid)
                    {
                        var token = await galSvc.GetUserToken(user.UserId);

                        MyCookie cook = new MyCookie()
                        {
                            Token  = token,
                            UserId = user.UserId
                        };
                        var        json       = JsonConvert.SerializeObject(cook);
                        HttpCookie userCookie = new HttpCookie("DreamGalCook");
                        userCookie.Value = json;
                        userCookie.Expires.AddYears(1);
                        HttpContext.Response.Cookies.Add(userCookie);
                        RedirectToAction("Index");
                    }
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Login"));
            }
            return(RedirectToAction("Login"));
        }
Ejemplo n.º 2
0
 public Login_Gdxj(GdxjUser gdxjUser, MyCookie cookie, GDXJEvens e)
 {
     this.myCookie = cookie;
     this.gdxjUser = gdxjUser;
     LoginEvens    = e;
     flag          = -1;
 }
Ejemplo n.º 3
0
        private void button5_Click(object sender, EventArgs e)//测试创建pid
        {
            //解析cookie中用于参数的字段
            CookieContainer cookieCollectionByString = MyCookie.GetCookieCollectionByString(DT.Cookie, "pub.alimama.com");

            StringBuilder header = new StringBuilder();

            header.Append("User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36\r\n");
            header.Append("Content-Type:application/x-www-form-urlencoded; charset=UTF-8\r\n");
            header.Append("Accept:application/json, text/javascript, */*; q=0.01\r\n");
            header.Append("Accept-Encoding:gzip, deflate\r\n");
            header.Append("Accept-Language:zh-CN,zh;q=0.8\r\n");
            header.Append("Host: pub.alimama.com\r\n");
            header.Append("Origin:http://pub.alimama.com\r\n");
            header.Append("X-Requested-With:XMLHttpRequest\r\n");
            header.Append("Cookie:" + DT.Cookie);
            Wininet       wininet  = new Wininet();
            StringBuilder postData = new StringBuilder("tag=29&gcid=0&siteid=40968507&selectact=add&newadzonename=test&t=" + DateTool.GetCurrentTimeStamp() + "&_tb_token_=" + MyCookie.GetCookie("_tb_token_", cookieCollectionByString));

            Console.WriteLine("当前post数据:" + postData.ToString());

            String responseBody = wininet.PostData("http://pub.alimama.com/common/adzone/selfAdzoneCreate.json", postData.ToString(), header);

            Console.WriteLine("响应内容:" + responseBody);
        }
Ejemplo n.º 4
0
        public IActionResult Index()
        {
            string keystr = _cookie.Get("Key");

            _cookie.Set("Key", "value here", new CookieOptions()
            {
                HttpOnly = true, Expires = DateTime.Now.AddDays(1)
            });

            // get <T> object from cookie
            //MyCookie myCookie = _cookieManager.Get<MyCookie>("Key");
            MyCookie objFromCookie = _cookieManager.Get <MyCookie>("Key1");
            MyCookie cooObj        = new MyCookie()
            {
                Id          = Guid.NewGuid().ToString(),
                Indentifier = "valueasgrsdgdf66514sdfgsd51d65s31g5dsg1rs5dg",
                Date        = DateTime.Now
            };

            _cookieManager.Set("Key1", cooObj, 100000);


            //Get or set <T>
            //Cookieoption example
            MyCookie myCook = _cookieManager.GetOrSet <MyCookie>("Key2", () =>
            {
                //write fucntion to store  output in cookie
                return(new MyCookie()
                {
                    Id = Guid.NewGuid().ToString(),
                    Indentifier = "valueasgrsdgdf66514sdfgsd51d65s31g5dsg1rs5dg",
                    Date = DateTime.Now
                });
            }, new CookieOptions()
            {
                HttpOnly = true, Expires = DateTime.Now.AddDays(1)
            });

            // expire time example
            //MyCookie myCookWithExpireTime = _cookieManager.GetOrSet<MyCookie>("Key", () =>
            //{
            //	//write fucntion to store  output in cookie
            //	return new MyCookie()
            //	{
            //		Id = Guid.NewGuid().ToString(),
            //		Indentifier = "value here",
            //		Date = DateTime.Now
            //	};

            //}, 60);



            return(View());
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // retain ClientId and clear other values
            string clientId = MyCookie.ClientId;

            MyCookie.ClearCookie();
            MyCookie.ClientId = clientId;

            //if (Request.QueryString.Count == 0) {
            //    Server.Transfer("ComingSoon.aspx");
            //}
        }
Ejemplo n.º 6
0
        public void Post(MyCookie myCookie)
        {
            //var response = new HttpResponseMessage();

            var cookie = new HttpCookie(myCookie.key, myCookie.value);

            cookie.Domain = myCookie.domain;
            //cookie.Path = "/";
            HttpContext.Current.Response.SetCookie(cookie);

            //return response;
        }
Ejemplo n.º 7
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
            if (String.IsNullOrEmpty((string)Session["User"]))
            {
                if (Request.Cookies["DreamGalCook"] != null)
                {
                    MyCookie cookie = JsonConvert.DeserializeObject <MyCookie>(Request.Cookies["DreamGalCook"].Value);
                    var      rs     = galSvc.ConfirmToken(cookie.UserId, cookie.Token);

                    //Session["User"] = cookie.UserId;
                    if (rs)
                    {
                        Session["User"] = cookie.UserId;
                    }
                    else
                    {
                        Request.Cookies["DreamGalCook"].Expires = DateTime.Now.AddDays(-1);
                        Request.Cookies.Add(Request.Cookies["DreamGalCook"]);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void Tongbu(int day1)
        {
            dbTable = txtTable.Text.Trim();
            string filepath = Application.StartupPath + "\\Orders";

            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }
            filepath = filepath + "\\" + xj.EncryptMD5String(DateTime.Now.ToString()) + ".xls";
            start    = true;
            string starttime = DateTime.Now.AddDays(-day1).ToShortDateString().Replace("/", "-");

            if (donging == false)
            {
                Addlogs("停止");
                return;
            }
            Addlogs("正在获取从 " + starttime + "至今 已同步数据库订单");



            DataTable data = DbHelperMySQL.Query(
                "SELECT  `orderId`,`goodId`,`orderStatus`,`goodCount`,`goodUnitPrice`,`incomeRatio`,`dividedIntoRatio`,`effect`  FROM `" + txtDbName.Text.Trim() + "`.`" + dbTable + "`WHERE `createTime`>'" + starttime + " 00:00:00'").Tables[0];
            StringBuilder sb = new StringBuilder(1000);

            if (data.Rows.Count > 0)
            {
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    sb.Append(data.Rows[i]["orderId"] + "---" + data.Rows[i]["goodId"] + "---" + data.Rows[i]["goodCount"] + "---" + data.Rows[i]["goodUnitPrice"] + "---" + data.Rows[i]["incomeRatio"] + "---" + data.Rows[i]["dividedIntoRatio"] + "---" + data.Rows[i]["effect"] + "---" + data.Rows[i]["orderStatus"]);
                }
            }
            if (donging == false)
            {
                Addlogs("停止");
                return;
            }
            Addlogs("从tbk_tb_order获取到" + data.Rows.Count + "条已同步订单");

            data = DbHelperMySQL.Query(
                "SELECT  `orderId`,`goodId`,`orderStatus`,`goodCount`,`goodUnitPrice`,`incomeRatio`,`dividedIntoRatio`,`effect`  FROM `" + txtDbName.Text.Trim() + "`.`" + dbTable + "`WHERE `createTime`>'" + starttime + " 00:00:00'").Tables[0];
            if (data.Rows.Count > 0)
            {
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    sb.Append(data.Rows[i]["orderId"] + "---" + data.Rows[i]["goodId"] + "---" + data.Rows[i]["goodCount"] + "---" + data.Rows[i]["goodUnitPrice"] + "---" + data.Rows[i]["incomeRatio"] + "---" + data.Rows[i]["dividedIntoRatio"] + "---" + data.Rows[i]["effect"] + "---" + data.Rows[i]["orderStatus"]);
                }
            }
            if (donging == false)
            {
                return;
            }
            if (donging == false)
            {
                Addlogs("停止");
                return;
            }
            //Addlogs("从" + dbTable + "获取到" + data.Rows.Count + "条已同步订单");
            string endtime = DateTime.Now.ToShortDateString().Replace("/", "-");
            string url     = "http://pub.alimama.com/report/getTbkPaymentDetails.json?spm=a219t.7664554.1998457203.57.493a27d77xCKBm&queryType=1&payStatus=&DownloadID=DOWNLOAD_REPORT_INCOME_NEW&startTime=" +
                             starttime + "&endTime=" + endtime;
            string          Ua = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.108 Safari/537.36 2345Explorer/8.6.1.15524";
            CookieContainer cookieCollectionByString = MyCookie.GetCookieCollectionByString(DT.Cookie, "pub.alimama.com");

            if (donging == false)
            {
                Addlogs("停止");
                return;
            }



            Addlogs("正在下载 从" + starttime + "至今 淘宝客订单");
            DataTable dt3 = null;

            for (int i = 0; i < 10; i++)
            {
                string result = this.Downer(url, cookieCollectionByString, Ua, filepath);
                //  DataTable dt3 = ExcelHelper.InputFromExcel(filepath, "Page1");
                dt3 = ExcelHelper.InputFromExcel(filepath, "Page1");
                if (dt3 != null && dt3.Rows.Count > 0)
                {
                    break;
                }
                Addlogs("下载失败,正在重新下载...");
                Thread.Sleep(1000);
                if (i >= 5)
                {
                    loginnum = 30;
                    Thread.Sleep(100000);
                }
            }
            if (dt3 == null)
            {
                Addlogs("淘宝登陆状态失效或没有登录");
                start = false;
                return;
            }

            List <string> sqList = new List <string>();

            //string path = Application.StartupPath + @"\temp\orders.txt";
            //if (!Directory.Exists(Application.StartupPath + @"\temp"))
            //{
            //    Directory.CreateDirectory(Application.StartupPath + @"\temp");
            //}
            if (donging == false)
            {
                Addlogs("停止");
                return;
            }
            Addlogs("获取到" + dt3.Rows.Count + "条 淘宝客订单");
            int           needUpdateOrderCount = 0; //需要更新的订单数量
            int           needInsertOrderCount = 0; //需要插入的订单数量, dbTable
            String        dbNameTemp           = this.txtDbName.Text;
            string        dbTableTemp          = this.txtTable.Text;
            StringBuilder finalBatchInsertSql  = new StringBuilder("INSERT INTO `" + dbNameTemp + "`.`" + dbTableTemp + "`(`createTime`,`clickTime`,`goodInfo`,`goodId`,`wangWangName`,`shopName`,`goodCount`,`goodUnitPrice`,`orderStatus`,`orderType`,`incomeRatio`,`dividedIntoRatio`,`paymentAmount`,`effect`,`settlementAmount`,`estimatedIncome`,`settlingTime`,`commissionRate`,`commissionAmount`,`subsidyRatio`,`subsidies`,`subsidiesType`,`transactionPlatform`,`thirdPartyServiceSource`,`orderId`,`catName`,`mediaSourceId`,`mediaSourceName`,`advertisingId`,`advertisingName`,`tbUnionAccountId`,`pid`) VALUES");

            //StringBuilder finalBatchUpdateSql = new StringBuilder("REPLACE INTO `" + dbNameTemp + "`.`" + dbTableTemp + "`(`createTime`,`clickTime`,`goodInfo`,`goodId`,`wangWangName`,`shopName`,`goodCount`,`goodUnitPrice`,`orderStatus`,`orderType`,`incomeRatio`,`dividedIntoRatio`,`paymentAmount`,`effect`,`settlementAmount`,`estimatedIncome`,`settlingTime`,`commissionRate`,`commissionAmount`,`subsidyRatio`,`subsidies`,`subsidiesType`,`transactionPlatform`,`thirdPartyServiceSource`,`orderId`,`catName`,`mediaSourceId`,`mediaSourceName`,`advertisingId`,`advertisingName`,`tbUnionAccountId`,`pid`) VALUES");
            for (int i = 0; i < dt3.Rows.Count; i++)
            {
                DataRow row          = dt3.Rows[i];
                string  create_time  = row[0].ToString().Trim();                  //创建时间
                string  click_time   = row[1].ToString().Trim();                  //点击时间
                string  goods_name   = row[2].ToString().Replace("'", "").Trim(); //商品名称
                string  goods_id     = row[3].ToString().Trim();                  //商品ID
                string  wangwang     = row[4].ToString().Replace("'", "").Trim(); //旺旺
                string  shop         = row[5].ToString().Replace("'", "").Trim(); //所属店铺
                string  goods_number = row[6].ToString().Trim();                  //商品数量
                string  goods_price  = row[7].ToString().Trim();                  //商品价格
                string  order_status = row[8].ToString().Trim();                  //订单状态
                string  order_type   = row[9].ToString().Trim();                  //淘宝/天猫


                string income_ratio      = row[10].ToString().Replace("%", "").Trim(); //收入比率
                string divided_ratio     = row[11].ToString().Replace("%", "").Trim(); //分成比率
                string order_amount      = row[12].ToString().Trim();                  //付款金额
                string effect_prediction = row[13].ToString().Trim();                  //效果预估
                string balance_amount    = row[14].ToString().Trim();                  //结算金额
                string estimated_revenue = row[15].ToString().Trim();                  //预估收入
                string balance_time      = row[16].ToString().Trim();                  //结算时间
                string commission_ratio  = row[17].ToString().Replace("%", "").Trim(); //佣金比率
                string commission_amount = row[18].ToString().Trim();                  //佣金金额
                string subsidy_ratio     = row[19].ToString().Replace("%", "").Trim(); //补贴比率
                string subsidy_amount    = row[20].ToString().Trim();                  //补贴金额
                string subsidy_type      = row[21].ToString().Trim();                  //补贴类型
                string order_platform    = row[22].ToString().Trim();                  //成交平台
                string serve_from        = row[23].ToString().Trim();                  //第三方服务来源
                string order_sn          = row[24].ToString().Trim();                  //订单编号
                string category          = row[25].ToString().Trim();                  //类目名称
                string media_id          = row[26].ToString().Trim();                  //来源媒体
                string media_name        = row[27].ToString().Trim();                  //来源媒体名称
                string adv_id            = row[28].ToString().Trim();                  //广告位ID
                string adv_name          = row[29].ToString().Trim();                  //广告位名称
                string tbUnionAccountId  = (String)this.tbUnionAccountCombox.SelectedValue;
                string pid = "mm_" + tbUnionAccountId + "_" + media_id + "_" + adv_id;


                string table = string.Empty;
                if (textBox1.Text.Contains(media_id + "_" + adv_id))
                {
                    table = "" + dbTable + "";
                }
                else
                {
                    table = "tbk_tb_order";
                }

                if (order_status == "订单完成")
                {
                    order_status = "订单结算";
                    balance_time = DateTime.Now.ToShortDateString().Replace("/", "-") + " " + DateTime.Now.ToShortTimeString();
                }
                if (string.IsNullOrEmpty(balance_time))
                {
                    balance_time = "0001-01-01";
                }

                /**
                 * string UpdataSql = string.Format(@"UPDATE `{33}`.`{32}`
                 * SET `createTime` = '{0}'
                 * ,`clickTime` ='{1}'
                 * ,`goodInfo` = '{2}'
                 * ,`goodId` ='{3}'
                 * ,`wangWangName` = '{4}'
                 * ,`shopName` = '{5}'
                 * ,`goodCount` ={6}
                 * ,`goodUnitPrice` ={7}
                 * ,`orderStatus` ='{8}'
                 * ,`orderType` ='{9}'
                 * ,`incomeRatio` = {10}
                 * ,`dividedIntoRatio` ={11}
                 * ,`paymentAmount` ={12}
                 * ,`effect` = {13}
                 * ,`settlementAmount` = {14}
                 * ,`estimatedIncome` ={15}
                 * ,`settlingTime` = '{16}'
                 * ,`commissionRate` = {17}
                 * ,`commissionAmount` ={18}
                 * ,`subsidyRatio` = {19}
                 * ,`subsidies` = {20}
                 * ,`subsidiesType` = '{21}'
                 * ,`transactionPlatform` ='{22}'
                 * ,`thirdPartyServiceSource` ='{23}'
                 * ,`id` = '{24}'
                 * ,`catName` = '{25}'
                 * ,`mediaSourceId` = '{26}'
                 * ,`mediaSourceName` ='{27}'
                 * ,`advertisingId` = '{28}'
                 * ,`advertisingName` ='{29}'
                 * ,`tbUnionAccountId` ='{34}'
                 * ,`pid` ='{35}'
                 * WHERE createTime= '{30}' and id='{31}';", create_time, click_time, goods_name, goods_id, wangwang, shop, goods_number, goods_price, order_status, order_type, income_ratio, divided_ratio, order_amount, effect_prediction, balance_amount, estimated_revenue, balance_time, commission_ratio, commission_amount, subsidy_ratio, subsidy_amount, subsidy_type, order_platform, serve_from, order_sn, category, media_id, media_name, adv_id, adv_name, create_time, order_sn, table, dbTable, tbUnionAccountId,pid);
                 *
                 * string InserSql = string.Format(@"INSERT INTO `{31}`.`{30}`
                 * (`createTime`
                 * ,`clickTime`
                 * ,`goodInfo`
                 * ,`goodId`
                 * ,`wangWangName`
                 * ,`shopName`
                 * ,`goodCount`
                 * ,`goodUnitPrice`
                 * ,`orderStatus`
                 * ,`orderType`
                 * ,`incomeRatio`
                 * ,`dividedIntoRatio`
                 * ,`paymentAmount`
                 * ,`effect`
                 * ,`settlementAmount`
                 * ,`estimatedIncome`
                 * ,`settlingTime`
                 * ,`commissionRate`
                 * ,`commissionAmount`
                 * ,`subsidyRatio`
                 * ,`subsidies`
                 * ,`subsidiesType`
                 * ,`transactionPlatform`
                 * ,`thirdPartyServiceSource`
                 * ,`id`
                 * ,`catName`
                 * ,`mediaSourceId`
                 * ,`mediaSourceName`
                 * ,`advertisingId`
                 * ,`advertisingName`
                 * ,`tbUnionAccountId`
                 * ,`pid`)
                 * VALUES
                 * ('{0}'
                 * ,'{1}'
                 * ,'{2}'
                 * ,'{3}'
                 * ,'{4}'
                 * ,'{5}'
                 * ,{6}
                 * ,{7}
                 * ,'{8}'
                 * ,'{9}'
                 * ,{10}
                 * ,{11}
                 * ,{12}
                 * ,{13}
                 * ,{14}
                 * ,{15}
                 * ,'{16}'
                 * ,{17}
                 * ,{18}
                 * ,{19}
                 * ,{20}
                 * ,'{21}'
                 * ,'{22}'
                 * ,'{23}'
                 * ,'{24}'
                 * ,'{25}'
                 * ,'{26}'
                 * ,'{27}'
                 * ,'{28}'
                 * ,'{29}'
                 * ,'{32}'
                 * ,'{33}');", create_time, click_time, goods_name, goods_id, wangwang, shop, goods_number, goods_price, order_status, order_type, income_ratio, divided_ratio, order_amount, effect_prediction, balance_amount, estimated_revenue, balance_time, commission_ratio, commission_amount, subsidy_ratio, subsidy_amount, subsidy_type, order_platform, serve_from, order_sn, category, media_id, media_name, adv_id, adv_name, table, txtDbName.Text.Trim(), tbUnionAccountId, pid);
                 */
                //解决商品名称偶尔乱码
                //string UpdataSql = string.Format(@"UPDATE `{33}`.`{32}` SET `createTime` = '{0}',`clickTime` ='{1}',`goodInfo` = '"+goods_name+ "',`goodId` ='{3}',`wangWangName` = '{4}',`shopName` = '{5}',`goodCount` ={6},`goodUnitPrice` ={7},`orderStatus` ='{8}',`orderType` ='{9}',`incomeRatio` = {10},`dividedIntoRatio` ={11},`paymentAmount` ={12},`effect` = {13},`settlementAmount` = {14},`estimatedIncome` ={15},`settlingTime` = '{16}',`commissionRate` = {17},`commissionAmount` ={18},`subsidyRatio` = {19},`subsidies` = {20},`subsidiesType` = '{21}',`transactionPlatform` ='{22}',`thirdPartyServiceSource` ='{23}',`id` = '{24}',`catName` = '{25}',`mediaSourceId` = '{26}',`mediaSourceName` ='{27}',`advertisingId` = '{28}',`advertisingName` ='{29}',`tbUnionAccountId` ='{34}',`pid` ='{35}'  WHERE createTime= '{30}' and id='{31}';", create_time, click_time, goods_name, goods_id, wangwang, shop, goods_number, goods_price, order_status, order_type, income_ratio, divided_ratio, order_amount, effect_prediction, balance_amount, estimated_revenue, balance_time, commission_ratio, commission_amount, subsidy_ratio, subsidy_amount, subsidy_type, order_platform, serve_from, order_sn, category, media_id, media_name, adv_id, adv_name, create_time, order_sn, table, dbTable, tbUnionAccountId, pid);

                //string InserSql = string.Format(@"INSERT INTO `{31}`.`{30}`(`createTime`,`clickTime`,`goodInfo`,`goodId`,`wangWangName`,`shopName`,`goodCount`,`goodUnitPrice`,`orderStatus`,`orderType`,`incomeRatio`,`dividedIntoRatio`,`paymentAmount`,`effect`,`settlementAmount`,`estimatedIncome`,`settlingTime`,`commissionRate`,`commissionAmount`,`subsidyRatio`,`subsidies`,`subsidiesType`,`transactionPlatform`,`thirdPartyServiceSource`,`id`,`catName`,`mediaSourceId`,`mediaSourceName`,`advertisingId`,`advertisingName`,`tbUnionAccountId`,`pid`) VALUES('{0}','{1}','"+goods_name+"','{3}','{4}','{5}',{6},{7},'{8}','{9}',{10},{11},{12},{13},{14},{15},'{16}',{17},{18},{19},{20},'{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{32}' ,'{33}');", create_time, click_time, goods_name, goods_id, wangwang, shop, goods_number, goods_price, order_status, order_type, income_ratio, divided_ratio, order_amount, effect_prediction, balance_amount, estimated_revenue, balance_time, commission_ratio, commission_amount, subsidy_ratio, subsidy_amount, subsidy_type, order_platform, serve_from, order_sn, category, media_id, media_name, adv_id, adv_name, table, txtDbName.Text.Trim(), tbUnionAccountId, pid);
                string tempstr = order_sn + "---" + goods_id + "---" + DataUtil.DeleteFloatZero(goods_number) + "---" + DataUtil.DeleteFloatZero(goods_price) + "---" + DataUtil.DeleteFloatZero(income_ratio) + "---" + DataUtil.DeleteFloatZero(divided_ratio) + "---" + DataUtil.DeleteFloatZero(effect_prediction) + "---" + order_status;
                //string txtOrders = LogHelper.ReadTxtAllpath(path);
                string orderstr = sb.ToString();
                Console.WriteLine("总串:" + orderstr);

                if (orderstr.Contains(tempstr) == false && orderstr.Contains(order_sn + "---" + goods_id + "---" + goods_number + "---" + goods_price + "---" + income_ratio + "---" + divided_ratio + "---" + effect_prediction + "---"))//已经同步过  但是订单状态发生改变  需要更新
                {
                    string sql = "UPDATE `" + dbNameTemp + "`.`" + dbTableTemp + "SET paymentAmount=" + order_amount + ",effect=" + effect_prediction + ",settlementAmount=" + balance_amount + ",estimatedIncome=" + estimated_revenue + ",settlingTime='" + balance_time + "',commissionAmount=" + commission_amount + ",orderStatus='" + order_status + "' where orderId=" + order_sn + " and goodId=" + goods_id + " and goodCount=" + goods_number + " and goodUnitPrice=" + goods_price + " and incomeRatio=" + income_ratio + " and dividedIntoRatio=" + divided_ratio + " and effect=" + effect_prediction + ";";
                    sqList.Add(sql.Replace("%", ""));
                    //LogHelper.AppendTxtAllpath(tempstr + "\r\n", path);
                    needUpdateOrderCount++;

                    //finalBatchUpdateSql.Append(string.Format(@"('{0}', '{1}', '" + goods_name + "', '{3}', '{4}', '{5}',{ 6},{ 7},'{8}','{9}',{ 10},{ 11},{ 12},{ 13},{ 14},{ 15},'{16}',{ 17},{ 18},{ 19},{ 20},'{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}' ,'{31}'),", create_time, click_time, goods_name, goods_id, wangwang, shop, goods_number, goods_price, order_status, order_type, income_ratio, divided_ratio, order_amount, effect_prediction, balance_amount, estimated_revenue, balance_time, commission_ratio, commission_amount, subsidy_ratio, subsidy_amount, subsidy_type, order_platform, serve_from, order_sn, category, media_id, media_name, adv_id, adv_name, tbUnionAccountId, pid));
                    //finalBatchUpdateSql.Append(@"('"+create_time+"','"+click_time+"','" + goods_name + "','"+goods_id+"','"+wangwang+"','"+shop+"',"+goods_number+","+goods_price+",'"+order_status+"','"+order_type+"',"+income_ratio+","+divided_ratio+","+order_amount+","+effect_prediction+","+balance_amount+","+estimated_revenue+",'"+balance_time+"',"+commission_ratio+","+commission_amount+","+subsidy_ratio+","+subsidy_amount+",'"+subsidy_type+"','"+order_platform+"','"+serve_from+"','"+order_sn+"','"+category+"','"+media_id+"','"+media_name+"','"+adv_id+"','"+adv_name+"','"+tbUnionAccountId+"' ,'"+pid+"'),");
                }
                else if (orderstr.Contains(tempstr) == false)//没有同步过    需要添加
                {
                    //需要先获取数据库信息做一下判断
                    //bool exist = DbHelperMySQL.Exists("SELECT `id`FROM `taoke`.`ftxia_taoke_detail` WHERE order_sn='" + order_sn + "'");
                    //string sql = InserSql;
                    //if (exist)
                    //{
                    //    sql = UpdataSql;
                    //}

                    // sqList.Add(sql.Replace("%", ""));
                    //LogHelper.AppendTxtAllpath(tempstr + "\r\n", path);
                    //Console.WriteLine("商品名称:"+ goods_name);
                    //Console.WriteLine("打印的sql语句:"+ sql.Replace("%", ""));
                    Console.WriteLine("分串:" + tempstr);
                    needInsertOrderCount++;
                    finalBatchInsertSql.Append(@"('" + create_time + "','" + click_time + "','" + goods_name + "','" + goods_id + "','" + wangwang + "','" + shop + "'," + goods_number + "," + goods_price + ",'" + order_status + "','" + order_type + "'," + income_ratio + "," + divided_ratio + "," + order_amount + "," + effect_prediction + "," + balance_amount + "," + estimated_revenue + ",'" + balance_time + "'," + commission_ratio + "," + commission_amount + "," + subsidy_ratio + "," + subsidy_amount + ",'" + subsidy_type + "','" + order_platform + "','" + serve_from + "','" + order_sn + "','" + category + "','" + media_id + "','" + media_name + "','" + adv_id + "','" + adv_name + "','" + tbUnionAccountId + "' ,'" + pid + "'),");
                }


                if (donging == false)
                {
                    Addlogs("停止");
                    return;
                }

                /**
                 * if (sqList.Count == 10)
                 * {
                 *
                 *      int count = DbHelperMySQL.ExecuteSqlTran(sqList);
                 *      Addlogs("更新" + count + " 条新数据");
                 *      sqList.Clear();
                 *      sqList = new List<string>();
                 *
                 *
                 * }
                 */
            }
            //if (sqList.Count == 0)
            if (needUpdateOrderCount == 0 && needInsertOrderCount == 0)
            {
                Addlogs("订单状态没有变化无需更新");
            }
            else
            {
                /*
                 *  int count = DbHelperMySQL.ExecuteSqlTran(sqList);
                 *  Addlogs("更新" + count + " 条新数据");
                 *  sqList.Clear();
                 *  sqList = new List<string>();
                 *  Addlogs("本轮更新完成");
                 */
                if (needUpdateOrderCount > 0)
                {
                    DbHelperMySQL.ExecuteSqlTran(sqList);
                    Addlogs("此次更新了" + needUpdateOrderCount + "笔订单");
                    sqList.Clear();
                    sqList = new List <string>();
                }

                if (needInsertOrderCount > 0)
                {
                    string finalSql = finalBatchInsertSql.ToString();
                    finalSql  = finalSql.Substring(0, finalSql.Length - 1);
                    finalSql += ";";
                    Console.WriteLine("insert:" + finalSql);
                    DbHelperMySQL.ExecuteSql(finalSql.Replace("%", ""));

                    Addlogs("此次插入了" + needInsertOrderCount + "笔订单");
                }
            }
            start = false;
            //2018-01-18 会抛异常“System.Threading.ThreadAbortException”(位于 mscorlib.dll 中)
            System.Threading.Thread.CurrentThread.Abort();
            //System.Threading.Thread.CurrentThread.Join();
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Config.IsTestMode)
            {
                if (Config.SSLEnabled)
                {
                    if (!Request.IsSecureConnection)
                    {
                        Response.Redirect("https://www.yourlifenavigator.com/Login.aspx", true);
                    }
                }
            }

            // Google CDN supports SSL, but doesn't combine files
            string YUILib = String.Format("{0}://ajax.googleapis.com/ajax/libs/yui/2.7.0/build", (Request.IsSecureConnection ? "https" : "http"));

            StringBuilder sbJS = new StringBuilder(1024);

            sbJS.AppendFormat("<script type=\"text/javascript\" src=\"{0}/connection/connection-min.js\"></script>", YUILib);
            sbJS.AppendFormat("<script type=\"text/javascript\" src=\"{0}/json/json-min.js\"></script>", YUILib);
            litExternalJS.Text = sbJS.ToString();

            if (IsPostBack)
            {
                string clientId          = String.Empty;
                bool   isEmailMissing    = String.IsNullOrEmpty(txtEmail.Text);
                bool   isPasswordMissing = String.IsNullOrEmpty(txtPassword.Text);
                if (isEmailMissing && isPasswordMissing)
                {
                    lblError.Text = "please enter your email address and password";
                }
                else if (isEmailMissing)
                {
                    lblError.Text = "please enter your email address";
                }
                else if (isPasswordMissing)
                {
                    lblError.Text = "please enter your password";
                }
                else
                {
                    bool isEmailValid    = Regex.IsMatch(txtEmail.Text, @"^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$");
                    bool isPasswordValid = Regex.IsMatch(txtPassword.Text, "^.{4,10}$");
                    if (!isEmailValid && !isPasswordValid)
                    {
                        lblError.Text = "your email address and password are not valid";
                    }
                    else if (!isEmailValid)
                    {
                        lblError.Text = "your email address is not valid";
                    }
                    else if (!isPasswordValid)
                    {
                        lblError.Text = "your password is not valid";
                    }
                    else
                    {
                        bool isAuthenticated = false;
                        using (ClientDataContext db = new ClientDataContext(Config.LIFENAVConnectionString))
                        {
                            var data     = from client in db.LIFENAV_Clients where client.Email.Equals(txtEmail.Text) where client.Password.Equals(txtPassword.Text) select client;
                            var myClient = data.FirstOrDefault <LIFENAV_Client>();
                            if (myClient != null)
                            {
                                isAuthenticated = true;
                                clientId        = myClient.Id.ToString();
                            }
                        }
                        if (isAuthenticated)
                        {
                            MyCookie.ClientId     = clientId;
                            MyCookie.EmailAddress = txtEmail.Text;
                            Response.Redirect("/Account.aspx", true);
                        }
                        else
                        {
                            lblError.Text = "sorry, we could not find that account";
                        }
                    }
                }
            }
            else
            {
                if (MyCookie.HasClientId)
                {
                    Response.Redirect("/Account.aspx", true);
                }
                else
                {
                    MyCookie.ClearCookie();
                }
            }
        }