/// <summary> /// 删除计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolsTaskDelete_Click(object sender, EventArgs e) { DataGridViewRow row = this.dgvTaskPlan.Rows[MouseCurrentRowIndex]; if (row != null) { int taskid = Convert.ToInt32(row.Cells["taskid"].Value); int eCode = 0; int.TryParse(row.Cells["ExecStatus"].Value.ToString(), out eCode); if (eCode != 1) { MessageConfirm confirm = new MessageConfirm("您确认要删除计划【" + taskid + "】吗?"); confirm.CallBack += () => { LogicHotTao.Instance(MyUserInfo.currentUserId).DeleteUserTaskPlan(taskid); dgvTaskPlan.Rows.Remove(row); }; confirm.ShowDialog(this); } else { ShowAlert("不能删除正在执行的计划"); } } else { ShowAlert("请先选择要删除的数据行!"); } }
/// <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 btnSave_Click(object sender, EventArgs e) { if (WeChatId > 0) { string pidText = string.Empty; int result = 0; if (SelectedRow != null) { int.TryParse(SelectedRow["id"].Value.ToString(), out result); pidText = SelectedRow["pid"].Value.ToString(); } Loading ld = new Loading(); ((Action)(delegate() { if (LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserWeChatGroup(WeChatId, pidText)) { pidText = result > 0 ? pidText : ""; } ld.CloseForm(); this.BeginInvoke((Action)(delegate() //等待结束 { this.Close(); hotTask.SetWeChatRowData(CurrentRowIndex, "pid", pidText); })); })).BeginInvoke(null, null); ld.ShowDialog(hotForm); } }
private void Login_Load(object sender, EventArgs e) { //设置阴影 // WinApi.SetWinFormTaskbarSystemMenu(this); loginName.Focus(); var data = LogicHotTao.Instance(0).GetLoginNameList(); if (data != null && data.Count() > 0) { loginName.Text = data[0].login_name; this.ckbSavePwd.Checked = true; this.IsRememberPassword = true; lbLoginName.Visible = false; if (!string.IsNullOrEmpty(data[0].login_password) && data[0].is_save_pwd == 1) { loginPwd.Text = data[0].login_password; lbLoginPwd.Visible = false; } data.ForEach(item => { loginName.Items.Add(item.login_name); }); } }
/// <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); }
private void LoginPage_Load(object sender, EventArgs e) { loginName.Focus(); var data = LogicHotTao.Instance(MyUserInfo.currentUserId).GetLoginNameList(); if (data != null && data.Count() > 0) { loginName.Text = data[0].login_name; this.ckbSavePwd.Checked = true; this.ckbAutoLogin.Checked = false; this.IsRememberPassword = true; lbLoginName.Visible = false; if (!string.IsNullOrEmpty(data[0].login_password) && data[0].is_save_pwd == 1) { loginPwd.Text = data[0].login_password; lbLoginPwd.Visible = false; } data.ForEach(item => { loginName.Items.Add(item.login_name); }); } }
/// <summary> /// 发送任务商品 /// </summary> /// <param name="goodslist">The goodslist.</param> /// <param name="taskid">The taskid.</param> /// <param name="lst">The LST.</param> private bool SendGoods(List <GoodsModel> goodslist, TaskPlanModel taskModel, List <WindowInfo> wins) { bool result = false; var data = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserWechatShareTextList(MyUserInfo.currentUserId); if (data == null || data.Count() == 0) { return(true); } foreach (var goods in goodslist) { textResult.Clear(); imageResult.Clear(); if (!isStartTask || MyUserInfo.currentUserId == 0) { result = false; break; } if (taskModel.endTime.CompareTo(DateTime.Now) < 0) { result = false; break; } result = true; int goodsId = Convert.ToInt32(goods.id); var shareData = data.FindAll(share => { return(share.goodsid == goodsId && share.taskid == taskModel.id); }); if (shareData == null || shareData.Count() == 0) { continue; } //加载appkey,判断是否存在,如果不存在,则不发商品 if (LoadAppkeyAndSecret()) { //发送当前商品时,进行淘口令生产 shareData.ForEach(item => { if (item.status == -1) { bool flag = LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTpwd(MyUserInfo.currentUserId, MyUserInfo.LoginToken, goods, item, appkey, appsecret); if (flag) { item.status = 0; } } }); shareData = shareData.FindAll(share => { return(share.status == 0); }); SendWeChatGroupShareText(shareData, goods, wins); SleepGoods(); } } return(result); }
/// <summary> /// 更新分享状态 /// </summary> /// <param name="shareid"></param> private void UpdateShareTextStatus(long shareid) { new System.Threading.Thread(() => { LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserShareTextStatus(shareid); }) { IsBackground = true }.Start(); }
/// <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> public void loadUserPidGridView() { new Thread(() => { //是否自动添加属性字段 this.dgvShareText.AutoGenerateColumns = false; this.dgvShareText.Rows.Clear(); var data = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserWechatShareTextList(MyUserInfo.currentUserId, taskid); if (data != null) { SetView(data); } }) { IsBackground = true }.Start(); }
/// <summary> /// 切换账号时触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loginName_SelectedIndexChanged(object sender, EventArgs e) { lbLoginName.Visible = false; ComboBox cb = sender as ComboBox; var data = LogicHotTao.Instance(MyUserInfo.currentUserId).GetLoginName(cb.Text); if (data != null) { if (!string.IsNullOrEmpty(data.login_password) && data.is_save_pwd == 1) { loginPwd.Text = data.login_password; lbLoginPwd.Visible = false; } } }
private void Login_Load(object sender, EventArgs e) { txtLoginMobile.Focus(); var data = LogicHotTao.Instance(0).GetLoginNameList(); if (data != null && data.Count() > 0) { txtLoginMobile.Text = data[0].login_name; this.ckbSavePwd.Checked = true; this.IsRememberPassword = true; lbLoginMobile.Visible = false; if (!string.IsNullOrEmpty(data[0].login_password) && data[0].is_save_pwd == 1) { txtLoginPwd.Text = data[0].login_password; lbLoginPwd.Visible = false; } } }
/// <summary> /// 添加错误日志 /// </summary> /// <param name="item"></param> /// <param name="errorType">0 图片 1 文本</param> public void AddErrorLog(weChatShareTextModel item, int errorType) { new System.Threading.Thread(() => { //添加错误日志 LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserWeChatError(new weChatUserWechatErrorModel() { userid = item.userid, title = item.title, shareText = item.text, createtime = DateTime.Now, errorType = errorType }); }) { IsBackground = true }.Start(); }
private void SetAccountControl_Load(object sender, EventArgs e) { this.IsRememberPassword = false; var data = LogicHotTao.Instance(MyUserInfo.currentUserId).GetLoginName(MyUserInfo.userData.loginName); if (data != null) { loginName.Text = data.login_name; loginName.ReadOnly = true; loginPwd.ReadOnly = true; this.ckbSavePwd.Checked = data.is_save_pwd == 1; this.ckbAutoLogin.Checked = false; this.IsRememberPassword = true; if (!string.IsNullOrEmpty(data.login_password) && data.is_save_pwd == 1) { loginPwd.Text = data.login_password; } } }
/// <summary> /// 保存 /// </summary> public void Save() { try { LogicHotTao.Instance(MyUserInfo.currentUserId).AddLoginName(new HotTaoCore.Models.SQLiteEntitysModel.LoginNameModel() { userid = MyUserInfo.currentUserId, login_name = loginName.Text, login_password = loginPwd.Text, is_save_pwd = this.ckbSavePwd.Checked ? 1 : 0 }); ShowAlert("保存成功"); } catch (Exception ex) { log.Error(ex); ShowAlert("保存失败"); } }
/// <summary> /// 登录结果处理 /// </summary> /// <param name="data"></param> private void loginResult(UserModel data) { this.BeginInvoke((Action)(delegate() //等待结束 { //设置登陆状态,必须先设置登录状态 hotForm.SetLoginData(data); if (data != null) { LogicHotTao.Instance(data.userid).AddLoginName(new SQLiteEntitysModel.LoginNameModel() { userid = data.userid, login_name = data.loginName, login_password = lgpwd, is_save_pwd = SavePwd ? 1 : 0 }); } hotForm.SetHomeTabSelected(); hotForm.openControl(new GoodsControl(hotForm)); })); }
/// <summary> /// 加载计划数据 /// </summary> public void LoadTaskPlanGridView() { new Thread(() => { //是否自动添加属性字段 this.dgvTaskPlan.AutoGenerateColumns = false; var taskData = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserTaskPlanList(MyUserInfo.currentUserId); if (taskData != null) { SetTaskView(taskData); if (this.dgvTaskPlan.Rows.Count > 0) { dgvTaskPlan.Rows[0].Selected = false; dgvTaskPlan.ContextMenuStrip = cmsTask; } } }) { IsBackground = true }.Start(); }
private void ImportPidData(string filePath) { DataTable dt = is2007 ? ExcelHelper.ImportExcel2007toDt(filePath) : ExcelHelper.ImportExcel2003toDt(filePath); if (dt != null) { try { List <UserPidModel> data = new List <UserPidModel>(); foreach (DataRow row in dt.Rows) { var model = new SQLiteEntitysModel.weChatGroupModel() { title = row[0].ToString(), pid = row[1].ToString(), type = dt.Columns.Count > 2 ? Convert.ToInt32(row[2].ToString()) : 0, userid = MyUserInfo.currentUserId }; int flag = LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserWeChatGroup(model); if (flag > 0) { SetText(model.type == 1 ? "QQ" : "微信" + "群:" + model.title + "导入成功..."); } else { SetText(model.type == 1 ? "QQ" : "微信" + "群:" + model.title + "导入失败..."); } } } catch (Exception ex) { SetText(ex.Message); } ImportStart = false; SetText("数据导入完成"); taskControl.loadUserPidGridView(); } }
/// <summary> /// 删除计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolsTaskDelete_Click(object sender, EventArgs e) { DataGridViewRow row = this.dgvTaskPlan.Rows[MouseCurrentRowIndex]; if (row != null) { int taskid = Convert.ToInt32(row.Cells["taskid"].Value); int eCode = 0; int.TryParse(row.Cells["ExecStatus"].Value.ToString(), out eCode); if (eCode != 1) { MessageConfirm confirm = new MessageConfirm("您确认要删除计划【" + taskid + "】吗?"); confirm.CallBack += () => { LogicHotTao.Instance(MyUserInfo.currentUserId).DeleteUserTaskPlan(taskid); dgvTaskPlan.Rows.Remove(row); //var taskidList = new List<GoodsTaskModel>(); //taskidList.Add(new GoodsTaskModel() //{ // id = taskid //}); //string taskids = JsonConvert.SerializeObject(taskidList); //if (LogicTaskPlan.Instance.deleteTaskPlan(MyUserInfo.LoginToken, taskids)) //{ // dgvTaskPlan.Rows.Remove(row); //} }; confirm.ShowDialog(this); } else { ShowAlert("不能删除正在执行的计划"); } } else { ShowAlert("请先选择要删除的数据行!"); } }
/// <summary> /// 登录结果处理 /// </summary> /// <param name="data"></param> private void loginResult(UserModel data) { this.BeginInvoke((Action)(delegate() //等待结束 { //设置登陆状态,必须先设置登录状态 hotForm.SetLoginData(data); if (data != null) { LogicHotTao.Instance(data.userid).AddLoginName(new SQLiteEntitysModel.LoginNameModel() { userid = data.userid, login_name = data.loginName, login_password = lgpwd, is_save_pwd = SavePwd ? 1 : 0 }); } if (!data.softwarePermit) { AlertConfirm("当前账号还未激活,是否马上激活?", "激活提示", (result) => { if (result) { hotForm.ShowCDKeyForm(); } else { hotForm.CloseMain(); } }); } else { hotForm.SetHomeTabSelected(); hotForm.openControl(new GoodsControl(hotForm)); } })); }
/// <summary> /// 下载商品图片 /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="goodsImageUrl">The goods image URL.</param> private void downloadGoodsImage(string fileName, string goodsImageUrl, string goodsid) { new Thread(() => { try { string _goodsid = goodsid; byte[] data = BaseRequestService.GetNetWorkImageData(goodsImageUrl); if (data == null) { Thread.Sleep(1000); data = BaseRequestService.GetNetWorkImageData(goodsImageUrl); } if (data != null) { MemoryStream ms = new MemoryStream(data); Bitmap img = new Bitmap(ms); img.Save(fileName, ImageFormat.Jpeg); ms.Dispose(); ms = null; img.Dispose(); img = null; } else { LogicHotTao.Instance(MyUserInfo.currentUserId).DeleteGoodsByGoodsid(goodsid); taskControl.LoadGoodsGridView(); } } catch (Exception ex) { log.Error("downloadGoodsImage:" + ex.ToString()); } }) { IsBackground = true }.Start(); }
private void Main_FormClosed(object sender, FormClosedEventArgs e) { if (this.wxlogin != null) { wxlogin.isStartTask = false; wxlogin.isCloseWinForm = true; wxlogin.Close(); wxlogin = null; } if (this.winTask != null) { winTask.isStartTask = false; winTask.Close(); winTask = null; } //关闭数据库连接 if (MyUserInfo.currentUserId > 0) { LogicHotTao.Instance(MyUserInfo.currentUserId).CloseConnection(); } Application.ExitThread(); Process.GetCurrentProcess().Kill(); }
public void LoginHandle() { try { if (isLogining) { return; } if (string.IsNullOrEmpty(loginName.Text)) { lbTipMsg.Text = "请输入登录账户!"; return; } if (string.IsNullOrEmpty(loginPwd.Text)) { lbTipMsg.Text = "请输入登录密码!"; loginPwd.Focus(); return; } SavePwd = this.ckbSavePwd.Checked; AutoLogin = false; string pwd = string.Empty; pwd = EncryptHelper.MD5(loginPwd.Text); lgname = loginName.Text; lgpwd = loginPwd.Text; loginSuccess = false; isLogining = true; ((Action)(delegate() { var data = LogicUser.Instance.login(lgname, pwd, (err) => { if (err != null && err.resultCode != 200) { this.BeginInvoke((Action)(delegate() //等待结束 { lbTipMsg.Text = err.resultMsg; })); isLogining = false; loginSuccess = true; } }, true); if (data != null) { if (data.activate == 1) { loginSuccess = true; isLogining = false; this.BeginInvoke((Action)(delegate() //等待结束 { lbTipMsg.Text = "登录成功,请稍后..."; })); if (data != null) { MyUserInfo my = new MyUserInfo(); my.SetUserData(data); LogicHotTao.Instance(0).AddLoginName(new SQLiteEntitysModel.LoginNameModel() { userid = data.userid, login_name = data.loginName, login_password = lgpwd, is_save_pwd = SavePwd ? 1 : 0 }); } this.BeginInvoke((Action)(delegate() //等待结束 { this.Hide(); MainForm main = new MainForm(this); main.StartPosition = FormStartPosition.CenterScreen; main.Show(); })); } else { this.BeginInvoke((Action)(delegate() //等待结束 { lbTipMsg.Text = "该账号已禁用,请联系管理员!"; })); isLogining = false; loginSuccess = true; } } })).BeginInvoke(null, null); ((Action)(delegate() { int c = 1; while (!loginSuccess) { this.BeginInvoke((Action)(delegate() //等待结束 { string t = "登录中,请稍后"; if (c == 1) { t = "登录中,请稍后."; } else if (c == 2) { t = "登录中,请稍后.."; } else if (c == 3) { t = "登录中,请稍后..."; c = 0; } if (!loginSuccess) { lbTipMsg.Text = t; } })); c++; System.Threading.Thread.Sleep(1000); } })).BeginInvoke(null, null); } catch (Exception ex) { loginSuccess = true; log.Error(ex); this.BeginInvoke((Action)(delegate() //等待结束 { lbTipMsg.Text = "连接服务器失败!"; isLogining = false; })); } }
private void ImportGoodsData(string filePath) { DataTable dt = is2007 ? ExcelHelper.ImportExcel2007toDt(filePath) : ExcelHelper.ImportExcel2003toDt(filePath); if (dt != null) { foreach (DataRow row in dt.Rows) { try { GoodsModel goods = new GoodsModel() { userid = MyUserInfo.currentUserId, goodsId = row["商品id"].ToString(), goodsName = row["商品名称"].ToString(), goodsIntro = row["商品简介"].ToString(), goodsMainImgUrl = row["商品主图"].ToString(), goodsDetailUrl = row["商品详情页链接地址"].ToString(), goodsSupplier = row["平台类型"].ToString(), goodsComsRate = Convert.ToDecimal(row["收入比率(%)"].ToString()), goodsPrice = Convert.ToDecimal(row["商品价格"].ToString()), goodsSalesAmount = Convert.ToInt32(row["商品月销量"].ToString()), endTime = Convert.ToDateTime(row["优惠券结束时间"].ToString()), couponUrl = row["优惠券链接"].ToString(), couponId = row["优惠券id"].ToString(), couponPrice = Convert.ToDecimal(row["优惠券面额(单位元)"].ToString()) }; string fileName = Environment.CurrentDirectory + "\\temp\\img"; if (!Directory.Exists(fileName)) { Directory.CreateDirectory(fileName); } fileName += "\\" + EncryptHelper.MD5(goods.goodsId) + ".jpg"; //判断文件是否存在 if (!File.Exists(fileName)) { byte[] data = BaseRequestService.GetNetWorkImageData(goods.goodsMainImgUrl); if (data != null) { MemoryStream ms = new MemoryStream(data); Bitmap img = new Bitmap(ms); img.Save(fileName, ImageFormat.Jpeg); ms.Dispose(); ms = null; img.Dispose(); img = null; } else { continue; } } goods.goodslocatImgPath = fileName; if (LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserGoods(goods) > 0) { SetText("商品:" + goods.goodsId.ToString() + "导入成功..."); } else { SetText("商品:" + goods.goodsId.ToString() + "导入失败..."); } } catch (Exception ex) { SetText(ex.Message); } } ImportStart = false; SetText("数据导入完成"); taskControl.LoadGoodsGridView(); } }
/// <summary> /// 发送文本 /// </summary> /// <param name="shareData">The share data.</param> /// <param name="wins">The wins.</param> private void SendText(List <weChatShareTextModel> shareData, List <WindowInfo> wins, bool isImageText, GoodsModel goods) { bool isLogin = true; foreach (var item in shareData) { try { Tuple <string, string> resultTuple = TaobaoHelper.GetGaoYongToken(goods.goodsDetailUrl, goods.goodsId, item.tpwd, MyUserInfo.GetTbToken(), MyUserInfo.cookies, out isLogin); if (resultTuple != null) { if (!isLogin) { hotForm.isTaskRuning = true; isStartTask = false; hotForm.SendNotify(); System.Threading.Thread.Sleep(5000); break; } item.status = 0; if (item.text.Contains("[二合一淘口令]")) { item.text = item.text.Replace("[二合一淘口令]", resultTuple.Item1); } else { item.text += "复制这条信息,打开『手机淘宝』" + resultTuple.Item1 + "领券下单即可抢购宝贝"; } if (item.text.Contains("[短链接]")) { item.text = item.text.Replace("[短链接]", resultTuple.Item2); } LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserShareTextStatus(item.id, item.text, resultTuple.Item1); } else { bool flag = LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTpwd(MyUserInfo.currentUserId, MyUserInfo.LoginToken, goods, item, appkey, appsecret); if (!flag) { continue; } } if (!isStartTask || MyUserInfo.currentUserId == 0) { break; } ClipboardObjectData(item.text); //如果当前微信已经发送,则结束本循环 if (textResult.Contains(item.title)) { continue; } wins = WinApi.GetAllDesktopWindows(); if (wins == null || wins.Count() == 0) { continue; } bool b = wins.Exists(win => { return(win.szWindowName == item.title); }); if (b) { var win = wins.Find(w => { return(w.szWindowName == item.title); }); //设置微信为输入焦点 //复制粘贴发送 WinApi.SendData(win.hWnd, win.winType == 1); SleepImage(0.5m); if (!textResult.Contains(item.title)) { textResult.Add(item.title); } if (isImageText) { UpdateShareTextStatus(item.id);//更新修改状态 } } else { SendNotify(item.title);//通知 } } catch (Exception ex) { //通知 SendNotify(item.title); if (!textResult.Contains(item.title)) { textResult.Add(item.title); } //添加错误日志 AddErrorLog(item, 1); if (isImageText) { UpdateShareTextStatus(item.id);//更新修改状态 } log.Error(ex); } } }
/// <summary> /// 开始执行发送 /// </summary> /// <param name="str">The string.</param> /// <param name="image">The image.</param> private void StartSend() { List <WindowInfo> wins = WinApi.GetAllDesktopWindows(); if (wins == null || wins.Count() == 0) { return; } //获取任务数据 var taskdata = LogicHotTao.Instance(MyUserInfo.currentUserId).FindUserTaskPlanListByUserId(MyUserInfo.currentUserId); if (taskdata == null || taskdata.Count() == 0) { return; } //获取待执行的任务数据 taskdata = taskdata.FindAll(item => { return(item.status == 0 && item.isTpwd == 1 && item.startTime.CompareTo(DateTime.Now) < 0); }).OrderBy(x => x.startTime).ToList(); if (taskdata == null || taskdata.Count() == 0) { return; } //排序 taskdata = taskdata.OrderBy(x => x.startTime).ToList(); foreach (var item in taskdata) { if (!isStartTask || MyUserInfo.currentUserId == 0) { break; } if (item.endTime.CompareTo(DateTime.Now) < 0) { break; } textResult.Clear(); imageResult.Clear(); int taskid = Convert.ToInt32(item.id); List <UserPidTaskModel> lst = JsonConvert.DeserializeObject <List <UserPidTaskModel> >(item.goodsText); List <int> ids = new List <int>(); //如果群数据和商品数据都为空时 if (lst == null || lst.Count() == 0) { if (!isStartTask || MyUserInfo.currentUserId == 0) { break; } LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserTaskPlanExecStatus(taskid, 2); continue; } lst.ForEach(it => { if (!ids.Contains(it.id)) { ids.Add(it.id); } }); //获取商品数据 var goodslist = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserGoodsList(MyUserInfo.currentUserId, ids); if (goodslist == null || goodslist.Count() == 0) { if (!isStartTask || MyUserInfo.currentUserId == 0) { break; } LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserTaskPlanExecStatus(taskid, 2); continue; } //发送商品数据 var result = SendGoods(goodslist, item, wins); if (result) { if (!isStartTask || MyUserInfo.currentUserId == 0) { break; } LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserTaskPlanExecStatus(taskid, 2); //每个任务之间,休息一下 SleepTask(); } else { break; } } }
/// <summary> /// 发送任务商品 /// </summary> /// <param name="goodslist">The goodslist.</param> /// <param name="taskid">The taskid.</param> /// <param name="lst">The LST.</param> private bool SendGoods(List <GoodsModel> goodslist, TaskPlanModel taskModel, List <WindowInfo> wins) { bool result = false; var data = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserWechatShareTextList(MyUserInfo.currentUserId); if (data == null || data.Count() == 0) { return(true); } foreach (var goods in goodslist) { textResult.Clear(); imageResult.Clear(); if (!isStartTask || MyUserInfo.currentUserId == 0) { result = false; break; } if (taskModel.endTime.CompareTo(DateTime.Now) < 0) { result = false; break; } result = true; int goodsId = Convert.ToInt32(goods.id); var shareData = data.FindAll(share => { return(share.goodsid == goodsId && share.taskid == taskModel.id); }); if (shareData == null || shareData.Count() == 0) { continue; } //申请高佣金 hotForm.ApplyPlan(goods.goodsId, goods.goodsName); //加载appkey,判断是否存在,如果不存在,则不发商品 if (LoadAppkeyAndSecret()) { //发送当前商品时,进行淘口令生产 shareData.ForEach(item => { if (item.status == -1) { bool flag = LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTpwd(MyUserInfo.currentUserId, MyUserInfo.LoginToken, goods, item, appkey, appsecret); if (flag) { item.status = 0; } } }); hotForm.logRuningList.Add(new LogRuningModel() { goodsName = goods.goodsName, goodsid = goods.goodsId, title = goods.goodsId, content = goods.goodsName, logTime = DateTime.Now, logType = LogTypeOpts.商品发送, isError = false, remark = string.Format("[{0}]开始发送商品[{1}]", goods.goodsId, goods.goodsName) }); shareData = shareData.FindAll(share => { return(share.status == 0); }); SendWeChatGroupShareText(shareData, goods, wins); SleepGoods(); } } return(result); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtWeChatTitle.Text)) { txtWeChatTitle.Focus(); return; } MessageAlert alert = new MessageAlert(); //Loading ld = new Loading(); SetAutoReplyControl replyControl = hotAutoForm as SetAutoReplyControl; SetAutoRemoveChatroom autoRemoveControl = hotAutoForm as SetAutoRemoveChatroom; SendMessage sendControl = hotAutoForm as SendMessage; string groupTitle = txtWeChatTitle.Text; string groupPid = txtPid.Text; ((Action)(delegate() { int flag = 0; UserWechatListModel data = new UserWechatListModel(); if (hotTask != null) { //data = LogicUser.Instance.UpdateUserWeChatTitle(MyUserInfo.LoginToken, editId, txtWeChatTitle.Text); if (LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserWeChatTitle(MyUserInfo.currentUserId, editId, groupTitle, groupPid)) { data.pid = groupPid; data.wechattitle = groupTitle; flag = 1; } } else if (replyControl != null || sendControl != null) { flag = LogicUser.Instance.UpdateUserWeChatTitle(MyUserInfo.LoginToken, txtWeChatTitle.Text, 0); } else if (autoRemoveControl != null) { flag = LogicUser.Instance.UpdateUserWeChatTitle(MyUserInfo.LoginToken, txtWeChatTitle.Text, 1); } if (flag > 0) { alert.Message = "保存成功"; } else { alert.Message = "保存失败,请检查是否重复"; } //ld.CloseForm(); this.BeginInvoke((Action)(delegate() { alert.ShowDialog(this); if (flag > 0) { if (hotTask != null) { //hotTask.SetPidView(data, editId > 0 ? CurrentRowIndex : -1); hotTask.loadUserPidGridView(); } else { if (replyControl != null) { replyControl.LoadDgvChatRoom(); if (hotForm.wxlogin != null) { hotForm.wxlogin.LoadAutoHandleData(); } } else if (autoRemoveControl != null) { autoRemoveControl.LoadDgvChatRoom(); } else if (sendControl != null) { sendControl.LoadDgvChatRoom(); if (hotForm.wxlogin != null) { hotForm.wxlogin.LoadAutoHandleData(); } } } this.Close(); } })); })).BeginInvoke(null, null); //ld.ShowDialog(hotForm); }
private void btnSave_Click(object sender, EventArgs e) { MessageAlert alert = new MessageAlert(); if (string.IsNullOrEmpty(txtTaskTitle.Text)) { alert.Message = "请输入任务标题"; alert.ShowDialog(this); txtTaskTitle.Focus(); return; } if (string.IsNullOrEmpty(txtStartTime.Text)) { txtStartTime.Focus(); return; } if (string.IsNullOrEmpty(txtEndTime.Text)) { txtEndTime.Focus(); return; } string goodsText = JsonConvert.SerializeObject(hotGoodsText); string pidsText = JsonConvert.SerializeObject(hotPidsText); TaskPlanModel model = new TaskPlanModel() { userid = MyUserInfo.currentUserId, title = txtTaskTitle.Text, startTime = Convert.ToDateTime(txtStartTime.Text), endTime = Convert.ToDateTime(txtEndTime.Text), pidsText = pidsText, goodsText = goodsText, id = taskid }; Loading ld = new Loading(); ((Action)(delegate() { //TaskPlanModel data = LogicTaskPlan.Instance.addTaskPlan(MyUserInfo.LoginToken, model); TaskPlanModel data = LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserTaskPlan(model); ld.CloseForm(); if (data != null) { this.BeginInvoke((Action)(delegate() //等待结束 { if (hotTask != null) { hotTask.SetTaskView(data, taskid > 0 ? CurrentRowIndex : -1); } if (hotHistoryTask != null) { hotHistoryTask.LoadTaskPlanGridView(); } txtTaskTitle.Clear(); alert.Message = "保存成功"; alert.CallBack += () => { this.Close(); }; alert.ShowDialog(this); })); } else { this.BeginInvoke((Action)(delegate() //等待结束 { alert.Message = "保存失败"; alert.ShowDialog(this); })); } })).BeginInvoke(null, null); ld.ShowDialog(hotForm); }
private void ImportGoodsData(string filePath) { DataTable dt = is2007 ? ExcelHelper.ImportExcel2007toDt(filePath) : ExcelHelper.ImportExcel2003toDt(filePath); if (dt != null) { foreach (DataRow row in dt.Rows) { try { GoodsModel goods = new GoodsModel() { userid = MyUserInfo.currentUserId, goodsId = row["商品id"].ToString(), goodsName = row["商品名称"].ToString(), goodsIntro = row["商品简介"].ToString(), goodsMainImgUrl = row["商品主图"].ToString(), goodsDetailUrl = row["商品详情页链接地址"].ToString(), goodsSupplier = row["平台类型"].ToString(), goodsComsRate = Convert.ToDecimal(row["收入比率(%)"].ToString()), goodsPrice = Convert.ToDecimal(row["商品价格"].ToString()), goodsSalesAmount = Convert.ToInt32(row["商品月销量"].ToString()), endTime = Convert.ToDateTime(row["优惠券结束时间"].ToString()), couponUrl = row["优惠券链接"].ToString(), couponId = row["优惠券id"].ToString(), couponPrice = Convert.ToDecimal(row["优惠券面额(单位元)"].ToString()) }; string fileName = Environment.CurrentDirectory + "\\temp\\img\\" + MyUserInfo.currentUserId; if (!Directory.Exists(fileName)) { Directory.CreateDirectory(fileName); } fileName += "\\" + EncryptHelper.MD5(goods.goodsId) + ".jpg"; //判断文件是否存在 if (!File.Exists(fileName)) { downloadGoodsImage(fileName, goods.goodsMainImgUrl, goods.goodsId); } goods.goodslocatImgPath = fileName; bool isUpdate = false; if (LogicHotTao.Instance(MyUserInfo.currentUserId).AddUserGoods(goods, out isUpdate) > 0) { SetText("商品:" + goods.goodsId.ToString() + "导入成功..."); } else { SetText("商品:" + goods.goodsId.ToString() + "导入失败..."); } } catch (Exception ex) { SetText(ex.Message); } } ImportStart = false; SetText("数据导入完成"); taskControl.LoadGoodsGridView(); } }
/// <summary> /// 发送任务商品 /// </summary> /// <param name="goodslist">The goodslist.</param> /// <param name="taskid">The taskid.</param> /// <param name="lst">The LST.</param> private bool SendGoods(List <GoodsModel> goodslist, TaskPlanModel taskModel, List <WindowInfo> wins) { bool result = false; var data = LogicHotTao.Instance(MyUserInfo.currentUserId).FindByUserWechatShareTextList(Convert.ToInt32(taskModel.id)); if (data == null || data.Count() == 0) { return(true); } if (taskModel.title.Contains("【合成图片转发】")) { List <weChatShareTextModel> newdata = new List <weChatShareTextModel>(); foreach (var item in data) { if (item.taskid == taskModel.id) { if (!newdata.Exists(r => { return(r.field3.Equals(item.field3)); })) { newdata.Add(item); } } } SendImage(null, newdata, wins, true, false, true); result = true; foreach (var goods in goodslist) { //申请高佣金 ApplyCamp(goods); System.Threading.Thread.Sleep(1000); } } else { foreach (var goods in goodslist) { textResult.Clear(); imageResult.Clear(); if (!isStartTask || MyUserInfo.currentUserId == 0) { result = false; break; } if (taskModel.endTime.CompareTo(DateTime.Now) < 0) { result = false; break; } result = true; int goodsId = Convert.ToInt32(goods.id); var shareData = data.FindAll(share => { return(share.goodsid == goodsId && share.taskid == taskModel.id && share.status != 1); }); if (shareData == null || shareData.Count() == 0) { continue; } //申请高佣金 ApplyCamp(goods); //加载appkey,判断是否存在,如果不存在,则不发商品 if (LoadAppkeyAndSecret()) { shareData.ForEach(item => { if (item.status == -1) { item.status = 0; } }); hotForm.logRuningList.Add(new LogRuningModel() { goodsName = goods.goodsName, goodsid = goods.goodsId, title = goods.goodsId, content = goods.goodsName, logTime = DateTime.Now, logType = LogTypeOpts.商品发送, isError = false, remark = string.Format("[{0}]开始发送商品[{1}]", goods.goodsId, goods.goodsName) }); shareData = shareData.FindAll(share => { return(share.status == 0); }); SendWeChatGroupShareText(shareData, goods, wins, taskModel); SleepGoods(); } } } return(result); }