internal Member Recharge(double money, long qq) { Member member = null; MyJsonUtil <Member> myJsonUtil = new MyJsonUtil <Member>(); string memberPath = MySystemUtil.GetMemberPath(qq); if (File.Exists(memberPath)) { string content = MyFileUtil.readFileAll(memberPath); member = myJsonUtil.parseJsonStr(content); //判断用户是否过期 long currentTime = Convert.ToInt64(MyDateUtil.GetTimeStamp(DateTime.Now)); if (currentTime > member.Time)//说明已经过期 { long outOfDate = currentTime + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + outOfDate).ToString("yyyy-MM-dd HH:mm:ss"); member.Time = outOfDate; member.Type = 3; } else//还没有过期 { member.Time = member.Time + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + member.Time).ToString("yyyy-MM-dd HH:mm:ss"); member.Type = 3; } MyFileUtil.writeToFile(memberPath, myJsonUtil.parseJsonObj(member)); } else { member = new Member(); long currentTime = Convert.ToInt64(MyDateUtil.GetTimeStamp(DateTime.Now)); long outOfDate = currentTime + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + outOfDate).ToString("yyyy-MM-dd HH:mm:ss"); member.Time = outOfDate; member.Type = 3; MyFileUtil.writeToFile(memberPath, myJsonUtil.parseJsonObj(member)); } return(member); }
private void UpdateAndSaveMovieConfig() { MovieConfig movieConfig = new MovieConfig(); movieConfig.CheckedQQQun = new Dictionary <long, int>(); //设置选中的QQ群 for (int i = 0; i < skinDataGridView1.Rows.Count; i++) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)this.skinDataGridView1.Rows[i].Cells[0]; if ((bool)checkBox.Value == true) { movieConfig.CheckedQQQun.Add((long)this.skinDataGridView1.Rows[i].Cells[2].Value, 1); } } //监听到群消息后,是否需要 @机器人触发命令: movieConfig.IsNeed = (radioButton1.Checked == true) ? true : false; //搜索命令 movieConfig.SearchCommand = string.IsNullOrWhiteSpace(skinTextBox2.Text)?"": skinTextBox2.Text; //未找到电影时,机器人在“群中”给用户的回复: movieConfig.NoSearchedMovieInQun = string.IsNullOrWhiteSpace(skinTextBox3.Text) ? "" : skinTextBox3.Text; //找到电影时,机器人在“群中”给用户的回复: movieConfig.HaveSearchedMovieInQun = string.IsNullOrWhiteSpace(skinTextBox6.Text) ? "" : skinTextBox6.Text; //未找到电影时,机器人“私聊”给与的回复: movieConfig.NoSearchedMovie = string.IsNullOrWhiteSpace(skinTextBox4.Text) ? "" : skinTextBox4.Text; //找到电影时,机器人“私聊”给与的回复: movieConfig.HaveSearchedMovie = string.IsNullOrWhiteSpace(skinTextBox5.Text) ? "" : skinTextBox5.Text; //是否开启私聊接受信息 movieConfig.IsCanPrivateMessage = radioButton7.Checked ? true:false; //选中的解析资源的方式 movieConfig.ConvertLinkIndex = skinComboBox1.SelectedIndex; //选择的解析器 movieConfig.SelectedParserIndex = skinComboBox2.SelectedIndex; //更新缓存数据 CacheData.MovieConfig = movieConfig; //持久化 MyJsonUtil <MovieConfig> myJsonUtil = new MyJsonUtil <MovieConfig>(); MyFileUtil.writeToFile(MySystemUtil.GetMovieJsonPath(), myJsonUtil.parseJsonObj(movieConfig)); }
private BaseJson UpdateAndSaveBaseJson() { BaseJson baseJson = new BaseJson(); baseJson.Keys = new Dictionary <string, string>(); baseJson.CheckedQQQun = new Dictionary <long, int>(); //设置关键词1 if (!string.IsNullOrWhiteSpace(this.textBox1.Text) && !string.IsNullOrWhiteSpace(this.textBox2.Text) && (checkBox1.Checked || checkBox2.Checked)) { baseJson.Keys.Add(this.textBox1.Text + "-##-" + (checkBox1.Checked ? 1 : 0) + "-##-" + (checkBox2.Checked ? 1 : 0), this.textBox2.Text); } //设置关键词2 if (!string.IsNullOrWhiteSpace(this.textBox4.Text) && !string.IsNullOrWhiteSpace(this.textBox3.Text) && (checkBox4.Checked || checkBox3.Checked)) { baseJson.Keys.Add(this.textBox4.Text + "-##-" + (checkBox4.Checked ? 1 : 0) + "-##-" + (checkBox3.Checked ? 1 : 0), this.textBox3.Text); } //设置关键词3 if (!string.IsNullOrWhiteSpace(this.textBox6.Text) && !string.IsNullOrWhiteSpace(this.textBox5.Text) && (checkBox6.Checked || checkBox5.Checked)) { baseJson.Keys.Add(this.textBox6.Text + "-##-" + (checkBox6.Checked ? 1 : 0) + "-##-" + (checkBox5.Checked ? 1 : 0), this.textBox5.Text); } //设置关键词4 if (!string.IsNullOrWhiteSpace(this.textBox8.Text) && !string.IsNullOrWhiteSpace(this.textBox7.Text) && (checkBox8.Checked || checkBox7.Checked)) { baseJson.Keys.Add(this.textBox8.Text + "-##-" + (checkBox8.Checked ? 1 : 0) + "-##-" + (checkBox7.Checked ? 1 : 0), this.textBox7.Text); } //设置关键词5 if (!string.IsNullOrWhiteSpace(this.textBox10.Text) && !string.IsNullOrWhiteSpace(this.textBox9.Text) && (checkBox10.Checked || checkBox9.Checked)) { baseJson.Keys.Add(this.textBox10.Text + "-##-" + (checkBox10.Checked ? 1 : 0) + "-##-" + (checkBox9.Checked ? 1 : 0), this.textBox9.Text); } //设置选中的QQ群 for (int i = 0; i < skinDataGridView2.Rows.Count; i++) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)this.skinDataGridView2.Rows[i].Cells[0]; if ((bool)checkBox.Value == true) { baseJson.CheckedQQQun.Add((long)this.skinDataGridView2.Rows[i].Cells[2].Value, 1); } } //是否自动加用户入群 baseJson.IsAutoAddQun = radioButton6.Checked ? true:false; //是否自动添加好友 baseJson.IsAutoAddFriend = radioButton3.Checked ? true:false; //入群后欢迎词 baseJson.NewerEnterQun = string.IsNullOrWhiteSpace(skinTextBox1.Text)?"": skinTextBox1.Text; //更新缓存数据 CacheData.BaseJson = baseJson; //持久化 MyJsonUtil <BaseJson> myJsonUtil = new MyJsonUtil <BaseJson>(); MyFileUtil.writeToFile(MySystemUtil.GetBaseJsonPath(), myJsonUtil.parseJsonObj(baseJson)); return(baseJson); }