/// <summary> /// 生成转发 /// </summary> /// <param name="tkid"></param> private void BuildText(int tkid) { string tempText = "[二合一淘口令]"; string appkey = string.Empty; string appsecret = string.Empty; if (hotForm.myConfig == null) { hotForm.myConfig = new ConfigModel(); } else { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config); if (cfgTime != null) { appkey = cfgTime.appkey; appsecret = cfgTime.appsecret; } } if (string.IsNullOrEmpty(appkey) && string.IsNullOrEmpty(appsecret)) { appkey = Resources.taobaoappkey; appsecret = Resources.taobaoappsecret; } LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTaskTpwd(MyUserInfo.LoginToken, MyUserInfo.currentUserId, tkid, tempText, appkey, appsecret, (share) => { }, false, isJoinImage); }
/// <summary> /// 加载appkey 和 secret /// </summary> private bool LoadAppkeyAndSecret() { if (string.IsNullOrEmpty(appkey) || string.IsNullOrEmpty(appsecret)) { if (hotForm.myConfig == null) { hotForm.myConfig = new ConfigModel(); } else { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config); if (cfgTime != null) { appkey = cfgTime.appkey; appsecret = cfgTime.appsecret; } } if (string.IsNullOrEmpty(appkey) && string.IsNullOrEmpty(appsecret)) { appkey = Resources.taobaoappkey; appsecret = Resources.taobaoappsecret; return(true); } } else { return(true); } return(false); }
/// <summary> /// 生成分享内容 /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnBuildShareText_Click(object sender, EventArgs e) { if (BuildStart) { return; } BuildStart = true; string tempText = txtTemplateText.Text; this.dgvShareText.Rows.Clear(); new Thread(() => { string appkey = string.Empty; string appsecret = string.Empty; if (hotForm.myConfig == null) { hotForm.myConfig = new ConfigModel(); } else { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config); if (cfgTime != null) { appkey = cfgTime.appkey; appsecret = cfgTime.appsecret; } } if (string.IsNullOrEmpty(appkey) && string.IsNullOrEmpty(appsecret)) { appkey = Resources.taobaoappkey; appsecret = Resources.taobaoappsecret; } LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTaskTpwd(MyUserInfo.LoginToken, MyUserInfo.currentUserId, taskid, tempText, appkey, appsecret, (share) => { SetView(share); }); if (taskControl != null) { taskControl.LoadTaskPlanGridView(); } if (historyControl != null) { historyControl.LoadTaskPlanGridView(); } BuildStart = false; ShowAlert("生成完成"); }) { IsBackground = true }.Start(); }
/// <summary> /// 加载配置数据 /// </summary> private void LoadConfig() { if (hotForm.myConfig == null) { hotForm.myConfig = new ConfigModel(); } else { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config); if (cfgTime != null) { txtgoodsinterval.Text = cfgTime.goodsinterval > 0 ? cfgTime.goodsinterval.ToString() : "35"; txthandleInterval.Text = cfgTime.hdInterval > 0 ? cfgTime.hdInterval.ToString() : "1"; rbTwSort.Checked = cfgTime.imagetextsort == 0; rbWtSort.Checked = cfgTime.imagetextsort == 1; txtTaskInterval.Text = cfgTime.taskinterval > 0 ? cfgTime.taskinterval.ToString() : "30"; rdSendWindows.Checked = cfgTime.sendmode == 0; rdSendRequest.Checked = cfgTime.sendmode == 1; txtTaoAppKey.Text = cfgTime.appkey; txtTaoAppSecret.Text = cfgTime.appsecret; ckbSendVideo.Checked = cfgTime.enable_sendvideo; //txtNotifyMobile.Text = cfgTime.notity_email; } ConfigWhereModel cfgWhere = string.IsNullOrEmpty(hotForm.myConfig.where_config) ? null : JsonConvert.DeserializeObject <ConfigWhereModel>(hotForm.myConfig.where_config); if (cfgWhere != null) { //优惠券过期天数 ckbminCouponDayCount.Checked = cfgWhere.minCouponDateDayCountEnable == 1; txtminCouponDateDayCount.Text = cfgWhere.minCouponDateDayCount.ToString(); //优惠券低于n张 ckbCoupon.Checked = cfgWhere.minCouponAmountEnable == 1; txtminCouponAmount.Text = cfgWhere.minCouponAmount.ToString(); //商品销量 ckbMonthSales.Checked = cfgWhere.minMonthSalesAmountEnable == 1; txtminMonthSalesAmount.Text = cfgWhere.minMonthSalesAmount.ToString(); //商品返佣率过滤 ckbCmsRate.Checked = cfgWhere.minCmsRateAmountEnable == 1; txtminCmsRateAmount.Text = cfgWhere.minCmsRateAmount.ToString(); //商品价格过滤 ckbGoodsPrice.Checked = cfgWhere.GoodsPriceEnable == 1; txtminGoodsPrice.Text = cfgWhere.minGoodsPrice.ToString(); txtmaxGoodsPrice.Text = cfgWhere.maxGoodsPrice.ToString(); // ckbfilterGoods.Checked = cfgWhere.filterGoodsEnable == 1; } } rdSendRequest.Checked = setForm.sendRequest; }
/// <summary> /// 加载用户配置信息 /// </summary> public void LoadMyConfig() { ((Action)(delegate() { myConfig = LogicUser.Instance.GetConfigModel(MyUserInfo.LoginToken); if (myConfig != null) { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(myConfig.send_time_config); if (cfgTime != null) { MyUserInfo.sendmode = cfgTime.sendmode; } } })).BeginInvoke(null, null); }
public void Save() { int result = 0; decimal result2 = 0; hotForm.myConfig.userid = MyUserInfo.currentUserId; ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? new ConfigSendTimeModel() : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config); cfgTime = cfgTime == null ? new ConfigSendTimeModel() : cfgTime; //淘宝API cfgTime.appkey = txtTaoAppKey.Text; cfgTime.appsecret = txtTaoAppSecret.Text; //商品间隔 int.TryParse(txtgoodsinterval.Text, out result); cfgTime.goodsinterval = result < 0 ? 35 : result; //操作间隔 decimal result3 = 0; decimal.TryParse(txthandleInterval.Text, out result3); cfgTime.hdInterval = result3 == 0 ? 1 : result3; //任务间隔 int.TryParse(txtTaskInterval.Text, out result); cfgTime.taskinterval = result == 0 ? 30 : result; //图文顺序 cfgTime.imagetextsort = rbTwSort.Checked ? 0 : 1; //发送模式 cfgTime.sendmode = rdSendWindows.Checked ? 0 : 1; MyUserInfo.sendmode = cfgTime.sendmode; //过滤条件 ConfigWhereModel cfgWhere = string.IsNullOrEmpty(hotForm.myConfig.where_config) ? new ConfigWhereModel() : JsonConvert.DeserializeObject <ConfigWhereModel>(hotForm.myConfig.where_config); cfgWhere = cfgWhere == null ? new ConfigWhereModel() : cfgWhere; //优惠券过期 cfgWhere.minCouponDateDayCountEnable = ckbminCouponDayCount.Checked ? 1 : 0; int.TryParse(txtminCouponDateDayCount.Text, out result); cfgWhere.minCouponDateDayCount = result; //优惠券数量 cfgWhere.minCouponAmountEnable = ckbCoupon.Checked ? 1 : 0; int.TryParse(txtminCouponAmount.Text, out result); cfgWhere.minCouponAmount = result; //月销量 cfgWhere.minMonthSalesAmountEnable = ckbMonthSales.Checked ? 1 : 0; int.TryParse(txtminMonthSalesAmount.Text, out result); cfgWhere.minMonthSalesAmount = result; //佣金比率 cfgWhere.minCmsRateAmountEnable = ckbCmsRate.Checked ? 1 : 0; decimal.TryParse(txtminCmsRateAmount.Text, out result2); cfgWhere.minCmsRateAmount = result2; //商品价格 cfgWhere.GoodsPriceEnable = ckbGoodsPrice.Checked ? 1 : 0; decimal.TryParse(txtminGoodsPrice.Text, out result2); cfgWhere.minGoodsPrice = result2; decimal.TryParse(txtmaxGoodsPrice.Text, out result2); cfgWhere.maxGoodsPrice = result2; //过滤今日重复商品 cfgWhere.filterGoodsEnable = ckbfilterGoods.Checked ? 1 : 0; ConfigModel myConfig = hotForm.myConfig; myConfig.send_time_config = JsonConvert.SerializeObject(cfgTime); myConfig.where_config = JsonConvert.SerializeObject(cfgWhere); MessageAlert alert = new MessageAlert(); Loading ld = new Loading(); ((Action)(delegate() { if (LogicUser.Instance.AddUserConfigModel(MyUserInfo.LoginToken, hotForm.myConfig) > 0) { alert.Message = "保存成功"; } else { alert.Message = "保存失败,请重试"; } ld.CloseForm(); this.BeginInvoke((Action)(delegate() { hotForm.myConfig = myConfig; alert.ShowDialog(this); })); })).BeginInvoke(null, null); ld.ShowDialog(this); }
/// <summary> /// 生成商品,并判断是否开启创建任务计划 /// </summary> /// <param name="msgCode">商品</param> /// <param name="urls">采集到的URL</param> /// <param name="isAutoSend"></param> /// <param name="callback">处理回调通知</param> private void QqForm_BuildGoodsHandler(long msgCode, List <string> urls, bool isAutoSend, Action <MessageCallBackType, int, int> callback) { if (weChatGroups == null) { weChatGroups = LogicHotTao.Instance(MyUserInfo.currentUserId).GetUserWeChatGroupListByUserId(MyUserInfo.currentUserId); } int groupCount = weChatGroups.Count(); if (urls != null) { callback?.Invoke(MessageCallBackType.正在准备, 0, 0); List <Dictionary <string, string> > list = new List <Dictionary <string, string> >(); Dictionary <string, string> data = new Dictionary <string, string>(); if (urls.Count() > 0) { data["url"] = urls[0]; } else { data["url"] = ""; } if (urls.Count() > 1) { data["url2"] = urls[1]; } else { data["url2"] = ""; } list.Add(data); string jsonUrls = JsonConvert.SerializeObject(list); //根据地址,获取商品优惠信息 List <GoodsSelectedModel> goodsData = LogicGoods.Instance.getGoodsByLink(MyUserInfo.LoginToken, jsonUrls); try { if (goodsData != null && goodsData.Count() > 0) { bool isUpdate = false; //保存商品到本地数据库 int gid = LogicGoods.Instance.SaveGoods(goodsData[0], MyUserInfo.currentUserId, out isUpdate); if (isUpdate) { return; } List <GoodsTaskModel> goodsidList = new List <GoodsTaskModel>(); goodsidList.Add(new GoodsTaskModel() { id = gid }); List <GoodsTaskModel> pidList = new List <GoodsTaskModel>(); foreach (var group in weChatGroups) { if (pidList.FindIndex(r => { return(r.id == group.id); }) < 0) { pidList.Add(new GoodsTaskModel() { id = group.id }); } } string goodsText = JsonConvert.SerializeObject(goodsidList); string pidsText = JsonConvert.SerializeObject(pidList); if (groupCount > 0 && isAutoSend) { // var taskplan = LogicHotTao.Instance(MyUserInfo.currentUserId).FindExecTaskPlanByUserId(MyUserInfo.currentUserId); int taskId = 0; callback?.Invoke(MessageCallBackType.开始创建计划, 0, groupCount); //添加任务计划 var result = LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserTaskPlan(new TaskPlanModel() { userid = MyUserInfo.currentUserId, title = goodsData[0].goodsName, startTime = DateTime.Now.AddHours(-1), endTime = DateTime.Now.AddHours(5), pidsText = pidsText, goodsText = goodsText, id = 0 }); taskId = Convert.ToInt32(result.id); #region 开始转链准备 string appkey = string.Empty; string appsecret = string.Empty; if (myConfig == null) { myConfig = new ConfigModel(); } else { ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(myConfig.send_time_config) ? null : JsonConvert.DeserializeObject <ConfigSendTimeModel>(myConfig.send_time_config); if (cfgTime != null) { appkey = cfgTime.appkey; appsecret = cfgTime.appsecret; } } if (string.IsNullOrEmpty(appkey) && string.IsNullOrEmpty(appsecret)) { appkey = Resources.taobaoappkey; appsecret = Resources.taobaoappsecret; } //开始转链 int i = 1; LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTaskTpwd(MyUserInfo.LoginToken, MyUserInfo.currentUserId, taskId, MyUserInfo.sendtemplate, appkey, appsecret, (share) => { callback?.Invoke(MessageCallBackType.开始转链, i, groupCount); i++; }); #endregion callback?.Invoke(MessageCallBackType.转链完成, 0, groupCount); } } callback?.Invoke(MessageCallBackType.完成, 0, 0); } catch (Exception ex) { log.Error(ex); } } }