/// <summary> /// 删除分类任务 /// </summary> /// <returns></returns> public int DeleteTypeTasks(int typeid) { int flag = 0; string strSql = ""; if (typeid == 1) //定时任务 { strSql = strSql_delete_timedtasks; } else if (typeid == 2) { strSql = strSql_delete_globaltasks; } if (strSql != "") { try { flag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text, strSql, null); } catch (Exception ex) { LogUtils.Error(string.Format("删除任务出错:{0}", ex.ToString())); } } return(flag); }
/// <summary> /// 变更任务状态 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> public int UpdateTaskStatus(int id, int status) { int nflag = 0; string statusval = ""; switch (status) { case 1: statusval = "submit "; break; case -1: statusval = "fail"; break; case 0: statusval = "waiting"; break; default: statusval = "fail"; break; } MySqlParameter[] par = new MySqlParameter[2]; par[0] = new MySqlParameter("@id", MySqlDbType.Int32); par[0].Value = id; par[1] = new MySqlParameter("@status", MySqlDbType.Text); par[1].Value = statusval; nflag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text, strSql_update_updatetaskstatus, par); return(nflag); }
/// <summary> /// 保存账号 /// </summary> /// <param name="objadmins"></param> /// <returns></returns> public int AddAdmins(admins objadmins) { int flag = 0; string sql = " insert into admins (login_user,login_pwd,explain_detail,addtime)"; sql += " VALUES (@login_user,@login_pwd,@explain_detail,@addtime)"; MySqlParameter[] param = new MySqlParameter[] { new MySqlParameter("@login_user", objadmins.login_user), new MySqlParameter("@login_pwd", objadmins.login_pwd), new MySqlParameter("@explain_detail", objadmins.explain_detail), new MySqlParameter("@addtime", objadmins.addtime) }; try { flag = MySqlHelpers.Update(sql, param); } catch (Exception ex) { LogUtils.Error($"{ex}"); System.Diagnostics.EventLog.WriteEntry(" ", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return(flag); }
public IList <RecordStage> GetRecordstages(int mobileindex, int typeid) { List <RecordStage> list = new List <RecordStage>(); MySqlParameter[] par = new MySqlParameter[2]; par[0] = new MySqlParameter("@phonenum", MySqlDbType.Int32); par[0].Value = mobileindex; par[1] = new MySqlParameter("@typeid", MySqlDbType.Int32); par[1].Value = typeid; using (MySqlDataReader dr = MySqlHelpers.ExecuteReader(MySqlHelpers.ConnectionString, CommandType.Text, strSql_select_recordbymobile, par)) { while (dr.Read()) { RecordStage record = new RecordStage(); record.Id = Int32.Parse(dr["id"].ToString()); record.PhoneNum = Int32.Parse(dr["phonenum"].ToString()); record.TypeId = Int32.Parse(dr["typeid"].ToString()); record.LastNums = Int32.Parse(dr["lastnums"].ToString()); list.Add(record); } } return(list); }
/// <summary> /// 保存配置参数 /// </summary> /// <param name="lang"></param> /// <param name="groupnums"></param> /// <param name="rownums"></param> /// <returns></returns> public int InsertConfigs(int lang, int groupnums, int rownums) { int nflag = 0; MySqlParameter[] par = new MySqlParameter[4]; par[0] = new MySqlParameter("@lang", MySqlDbType.Int32); par[0].Value = lang; par[1] = new MySqlParameter("@rownums", MySqlDbType.Int32); par[1].Value = rownums; par[2] = new MySqlParameter("@groupnums", MySqlDbType.Int32); par[2].Value = groupnums; par[3] = new MySqlParameter("@id", MySqlDbType.Int32); par[3].Value = 1; try { nflag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text , strSql_update_createconfigs, par); } catch (Exception ex) { System.Diagnostics.EventLog.WriteEntry("WhatsApp", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return(nflag); }
public int InsertRecord(RecordStage record) { int flag = 0; MySqlParameter[] par = new MySqlParameter[3]; par[0] = new MySqlParameter("@phonenum", MySqlDbType.Int32); par[0].Value = record.PhoneNum; par[1] = new MySqlParameter("@typeid", MySqlDbType.Int32); par[1].Value = record.TypeId; par[2] = new MySqlParameter("@lastnums", MySqlDbType.Int32); par[2].Value = record.LastNums; try { flag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text , strSql_insert_record, par); } catch (Exception ex) { LogUtils.Error($"{ex}"); System.Diagnostics.EventLog.WriteEntry("Facebook", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return(flag); }
/// <summary> /// 执行存储过程方法 /// </summary> /// <param name="storedProcName"></param> /// <param name="lists"></param> /// <returns></returns> public string[] GetOutRunProcedure(string storedProcName, string rid, string SDIId, string limit) { DataSet ds = new DataSet(); IDataParameter[] iData = null; string[] nums = new string[3]; try { iData = new MySqlParameter[6]; iData[0] = new MySqlParameter("p_rid", rid); iData[1] = new MySqlParameter("p_SDIId", SDIId); iData[2] = new MySqlParameter("p_limit", limit); iData[3] = new MySqlParameter("p_better", MySqlDbType.Int32, 4, ParameterDirection.Output, false, 0, 0, string.Empty, DataRowVersion.Default, null); iData[4] = new MySqlParameter("p_Worse", MySqlDbType.Int32, 4, ParameterDirection.Output, false, 0, 0, string.Empty, DataRowVersion.Default, null); iData[5] = new MySqlParameter("p_equal", MySqlDbType.Int32, 4, ParameterDirection.Output, false, 0, 0, string.Empty, DataRowVersion.Default, null); iData = MySqlHelpers.RunProcedureInOut(storedProcName, iData); nums[0] = iData[3].Value.ToString(); nums[1] = iData[4].Value.ToString(); nums[2] = iData[5].Value.ToString(); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } return(nums); }
public IList <TaskSch> GetTimedTasks() { List <TaskSch> list = new List <TaskSch>(); using (MySqlDataReader dr = MySqlHelpers.ExecuteReader(MySqlHelpers.ConnectionString, CommandType.Text, strSql_select_timedtasks)) { while (dr.Read()) { TaskSch task = new TaskSch(); task.Id = Int32.Parse(dr["id"].ToString()); task.TypeId = Int32.Parse(dr["typeid"].ToString()); task.Remotes = dr["remotes"].ToString(); task.MobileIndex = Int32.Parse(dr["mobileindex"].ToString()); task.Bodys = dr["bodys"].ToString(); task.Status = dr["status"].ToString(); task.ResultVal = dr["resultval"].ToString(); task.SlideNums = Int32.Parse(dr["slidenums"].ToString()); task.FriendNums = Int32.Parse(dr["friendnums"].ToString()); task.RepeatNums = Int32.Parse(dr["repeatnums"].ToString()); task.RandomMins = Int32.Parse(dr["randommins"].ToString()); task.RandomMaxs = Int32.Parse(dr["randommaxs"].ToString()); task.IsStep = Int32.Parse(dr["isstep"].ToString()); task.IsWhole = Int32.Parse(dr["iswhole"].ToString()); task.InputName = dr["inputname"].ToString(); task.StartTime = DateTime.Parse(dr["starttime"].ToString()); list.Add(task); } } return(list); }
/// <summary> /// INSERT/UPDATE/DELETE公共方法 /// </summary> /// <param name="param">参数</param> /// <returns>影响记录数</returns> public int InsUpdDelDataTableToParam(Dictionary <string, List <Object> > param) { Dictionary <string, Dimention> report = GetReport(); string sql = string.Empty; int count = 0; List <string> repSql = new List <string>(); try { if (param != null) { foreach (var d in param) { Dimention dimention = report[d.Key]; sql = dimention.SqlAll; int i = 0; foreach (Object value in d.Value) { ////替换后的sql语句 sql = sql.Replace("{" + i + "}", value.ToString()); i = i + 1; } } } count = MySqlHelpers.ExecuteNonQuery(sql); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } return(count); }
/// <summary> /// 检测端口 /// </summary> /// /// <returns></returns> public bool CheckPortisAvailable() { lblAuthTips.Text = resourceManager.GetString("Check_Database_Service", cultureInfo); bool connFlag = false; connFlag = MySqlHelpers.ConnectionTest(MySqlHelpers.ConnectionString); if (connFlag) { ConfigsBLL bll = new ConfigsBLL(); Configs configs = bll.GetAllData(); if (configs != null) { if (configs.Lang == 1) { cultureInfo = CultureInfo.CreateSpecificCulture("zh-cn"); } else if (configs.Lang == 2) { cultureInfo = CultureInfo.CreateSpecificCulture("en-us"); } } } Title = resourceManager.GetString("Authentication", cultureInfo); lblAuthTips.Text = resourceManager.GetString("Authenticating", cultureInfo); btnRetry.Content = resourceManager.GetString("Retry", cultureInfo); return(connFlag); }
/// <summary> /// 初始化指标ID--指标名称的映射表 /// </summary> /// <param name="table"></param> private static Dictionary <string, string> IndexIdToName() { Dictionary <string, string> indexIdToName = new Dictionary <string, string>(); string in_sql = "select Indicatorid,Indicatorname from Angel_Indicator"; DataTable ind = MySqlHelpers.GetDataTable(in_sql); for (int i = 0; i < ind.Rows.Count; i++) { indexIdToName.Add(ind.Rows[i][0].ToString(), ind.Rows[i][1].ToString()); } //string fileName = "IndexIdToName.xml"; //string filePath = AppDomain.CurrentDomain.BaseDirectory + "Config\\";//获取基目录 //string file = filePath + fileName; //XmlDocument document = new XmlDocument(); //document.Load(file); //XmlNode root = document.SelectSingleNode("/config"); //if (root != null) //{ // XmlNodeList itemList = root.SelectNodes("item"); // string id = "", name = ""; // foreach (XmlNode item in itemList) // { // id = item.Attributes["id"].Value; // name = item.Attributes["name"].Value; // indexIdToName.Add(id, name); // } //} return(indexIdToName); }
/// <summary> /// 查询固定数据语句 /// </summary> /// <param name="tabID">tableid</param> /// <returns></returns> public DataTable GetDataSourceSqlId(string tabID, string where) { try { Dictionary <string, Dimention> report = GetReport(); Dimention dimention = report[tabID]; ArrayList al = new ArrayList(); string sql = ""; string citydatawherecondition = string.Empty; DataTable dt = new DataTable(); sql = dimention.SqlAll.Replace("%Where%", where); if (tabID.Equals("")) { dt = null; } else { al.Add(sql); dt = MySqlHelpers.Query(al).Tables[0]; } return(dt); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); return(null); } }
public static int UpdateTaskTrace(TaskTrace taskTrace) { int updateResult = 0; MySqlParameter[] parameters = new MySqlParameter[3]; parameters[0] = new MySqlParameter("@mobileindex", MySqlDbType.Int32); parameters[0].Value = taskTrace.MobileIndex; parameters[1] = new MySqlParameter("@typeid", MySqlDbType.Int32); parameters[1].Value = taskTrace.TypeId; parameters[2] = new MySqlParameter("@position", MySqlDbType.Int32); parameters[2].Value = taskTrace.Position; try { updateResult = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text, update_trace_sql, parameters); } catch (Exception ex) { Console.WriteLine("UpdateTaskTrace EXCEPTION"); LogUtils.Error($"{ex}"); } return(updateResult); }
public static int CountTaskTrace(TaskTrace taskTrace) { int countResult = 0; MySqlParameter[] parameters = new MySqlParameter[2]; parameters[0] = new MySqlParameter("@mobileindex", MySqlDbType.Int32); parameters[0].Value = taskTrace.MobileIndex; parameters[1] = new MySqlParameter("@typeid", MySqlDbType.Int32); parameters[1].Value = taskTrace.TypeId; try { countResult = int.Parse(MySqlHelpers.ExecuteScalar(MySqlHelpers.ConnectionString, CommandType.Text, count_trace_sql, parameters).ToString()); } catch (Exception ex) { Console.WriteLine("CountTaskTrace EXCEPTION"); LogUtils.Error($"{ex}"); } return(countResult); }
public static int GetTaskTracePosition(TaskTrace taskTrace) { int position = 0; MySqlParameter[] parameters = new MySqlParameter[2]; parameters[0] = new MySqlParameter("@mobileindex", MySqlDbType.Int32); parameters[0].Value = taskTrace.MobileIndex; parameters[1] = new MySqlParameter("@typeid", MySqlDbType.Int32); parameters[1].Value = taskTrace.TypeId; try { position = (int)MySqlHelpers.ExecuteScalar(MySqlHelpers.ConnectionString, CommandType.Text, get_trace_position_sql, parameters); } catch (Exception ex) { Console.WriteLine("GetTaskTracePosition EXCEPTION"); LogUtils.Error($"{ex}"); } return(position); }
/// <summary> /// 写入登录日志的方法 /// </summary> /// <param name="userid">用户ID</param> /// <param name="username">用户名称</param> /// <param name="roleid">权限ID</param> /// <param name="rolename">权限名称</param> /// <param name="logintdate">登录时间</param> public void SaveLog(int userid, string username, int roleid, string rolename, string clientip, string createuser, string type) { var values = XmlHelper.ReadXml("SqlQuery", "insertloginlog"); string sql = string.Format(values.First().Value, userid, username, roleid, rolename, createuser, clientip, DateTime.Now, DateTime.Now, type); MySqlHelpers.ExecuteNonQuery(sql); }
/// <summary> /// 执行存储过程方法(采集进度部分) /// </summary> /// <param name="storedProcName"></param> /// <param name="lists"></param> /// <param name="tableName"></param> /// <returns></returns> public DataSet GetDataSetRunAcquisitionApi(string storedProcName, List <string> lists, string tableName) { DataSet ds = new DataSet(); try { IDataParameter[] iData = new MySqlParameter[lists.Count]; for (int i = 0; i < lists.Count; i++) { if (i == 0) { iData[i] = new MySqlParameter("@datatm", lists[i]); } else if (i == 1) { iData[i] = new MySqlParameter("@number3", lists[i]); } } ds = MySqlHelpers.RunProcedure(storedProcName, iData, tableName); } catch (Exception ex) { FileLog.WriteLog(ex.ToString()); } return(ds); }
public int InsertPhoneNum(Phonenum phonenum) { int nflag = 1; MySqlParameter[] par = new MySqlParameter[3]; par[0] = new MySqlParameter("@simulator_id", MySqlDbType.Int32); par[0].Value = phonenum.SimulatorId; par[1] = new MySqlParameter("@phonenum", MySqlDbType.Text); par[1].Value = phonenum.PhoneNum; par[2] = new MySqlParameter("@status", MySqlDbType.Int32); par[2].Value = phonenum.Status; try { nflag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text , strSql_insert_phonenum, par); } catch (Exception ex) { System.Diagnostics.EventLog.WriteEntry("WhatsApp", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return(nflag); }
/// <summary> /// 插入任务 /// </summary> /// <param name="tasks"></param> /// <returns></returns> public int InsertTask(TaskSch tasks) { int flag = 0; MySqlParameter[] par = new MySqlParameter[14]; par[0] = new MySqlParameter("@typeid", MySqlDbType.Int32); par[0].Value = tasks.TypeId; par[1] = new MySqlParameter("@remotes", MySqlDbType.Text); par[1].Value = tasks.Remotes; par[2] = new MySqlParameter("@mobileindex", MySqlDbType.Int32); par[2].Value = tasks.MobileIndex; par[3] = new MySqlParameter("@bodys", MySqlDbType.Text); par[3].Value = tasks.Bodys; par[4] = new MySqlParameter("@status", MySqlDbType.Text); par[4].Value = tasks.Status; par[5] = new MySqlParameter("@slidenums", MySqlDbType.Int32); par[5].Value = tasks.SlideNums; par[6] = new MySqlParameter("@repeatnums", MySqlDbType.Int32); par[6].Value = tasks.RepeatNums; par[7] = new MySqlParameter("@friendnums", MySqlDbType.Int32); par[7].Value = tasks.FriendNums; par[8] = new MySqlParameter("@randommins", MySqlDbType.Int32); par[8].Value = tasks.RandomMins; par[9] = new MySqlParameter("@randommaxs", MySqlDbType.Int32); par[9].Value = tasks.RandomMaxs; par[10] = new MySqlParameter("@resultval", MySqlDbType.Text); par[10].Value = tasks.ResultVal; par[11] = new MySqlParameter("@isstep", MySqlDbType.Int32); par[11].Value = tasks.IsStep; par[12] = new MySqlParameter("@iswhole", MySqlDbType.Int32); par[12].Value = tasks.IsWhole; par[13] = new MySqlParameter("@inputname", MySqlDbType.Text); par[13].Value = tasks.InputName; try { flag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text , strSql_insert_tasksign, par); } catch (Exception ex) { LogUtils.Error($"{ex}"); System.Diagnostics.EventLog.WriteEntry("WhatsApp", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return(flag); }
/// <summary> /// 检测端口 /// </summary> /// /// <returns></returns> public bool CheckPortisAvailable() { lab_authmsg.Text = "正在检测数据库服务……"; bool connFlag = false; connFlag = MySqlHelpers.ConnectionTest(MySqlHelpers.ConnectionString); return connFlag; }
public async void GetInfo_Unauthorized() { //ARRANGE: Get a valid and existing privateSongId string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Miguel"); //ACT: string responseContentString = await GetInfo_Act(privateSongId, HttpStatusCode.Unauthorized); //ASSERT: Correct response object Assert.Equal("", responseContentString); }
public async void Delete_ValidId_Unauthorized() { //ARRANGE: Get a valid and existing privateSongId string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Anabela"); //ACT: string responseContentString = await Delete_Act(privateSongId, HttpStatusCode.Unauthorized); //ASSERT: Correct Response Object Assert.Equal("", responseContentString); }
public string Select(string sql) { string a = ";lt"; string b = ";gt"; sql = sql.Replace(a, "<").Replace(b, ">"); DataTable dt = MySqlHelpers.ExecuteDataTable(MySqlHelpers.connectionString, CommandType.Text, sql); IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; return(JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.None, timeFormat).ToLower()); }
/// <summary> /// 添加配置 /// </summary> /// <param name="objSimulators"></param> /// <returns></returns> public int Add(SystemConfig objSystemConfig) { string sql = "insert into systemconfig (uid,state)"; sql += " VALUES (@uid,@state)"; MySqlParameter[] param = new MySqlParameter[] { new MySqlParameter("@uid", objSystemConfig.uid), new MySqlParameter("@state", objSystemConfig.state) }; return(MySqlHelpers.Update(sql.ToString(), param)); }
/// <summary> /// 检测端口 /// </summary> /// /// <returns></returns> public bool CheckPortisAvailable() { App.Current.Dispatcher.BeginInvoke(new Action(() => { lblAuthTips.Text = SystemLanguageManager.Instance.ResourceManager.GetString("Check_Database_Service", SystemLanguageManager.Instance.CultureInfo); })); bool connFlag = false; connFlag = MySqlHelpers.ConnectionTest(MySqlHelpers.ConnectionString); return(connFlag); }
public async void Edit_InvalidModel(PrivateSongBM model) { //ARRANGE: authenticate user MyUser user = fixture.Authenticate_User("Anabela"); //ARRANGE: Get a valid and existing privateSongId string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId(user.UserName); //ACT: string responseContentString = await Edit_Act(privateSongId, model, HttpStatusCode.BadRequest); //ASSERT: Correct response object Assert.Equal("", responseContentString); }
public async void Get_Authenticated() { //ARRANGE: authenticate user MyUser user = fixture.Authenticate_User("Miguel"); //ACT: string responseContentString = await Get_Act(HttpStatusCode.OK); //ASSERT: Response object matches database state PrivateSongBasicVM[] responseObject = JsonConvert.DeserializeObject <PrivateSongBasicVM[]>(responseContentString); Assert.True(MySqlHelpers.CheckIfPrivateSongListMatchesDb(responseObject, user)); }
public async void Edit_Valid_Unauthorized() { //ARRANGE: Get a valid and existing privateSongId string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Anabela"); //ARRANGE: Set a privateSong model with the new info for the song PrivateSongBM model = ValidModelForEdit; //ACT: string responseContentString = await Edit_Act(privateSongId, model, HttpStatusCode.Unauthorized); //ASSERT: Correct response object Assert.Equal("", responseContentString); }
/// <summary> /// 根据uif进行用户的注册 /// </summary> /// <param name="uif"></param> /// <returns>是否注册成功</returns> public int register(userinfo uif) { if (isHaveThisUserName(uif.username) == null) { MySqlParameter[] mySqlParameter = { new MySqlParameter("@username", uif.username), new MySqlParameter("@pwd", uif.pwd), new MySqlParameter("@nicheng", uif.nicheng), new MySqlParameter("@touxiangurl", uif.touxiangurl) }; string sql = @"insert into boke.userinfo values(@username,@pwd,null,@nicheng,now(),now(),@touxiangurl,0)"; int Count = MySqlHelpers.ExecuteNonQuery(sql, mySqlParameter); return(Count); } else { return(0); } }
/// <summary> /// 更新任务的执行结果 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> public int UpdateTaskResult(int id, string status) { int nflag = 0; MySqlParameter[] par = new MySqlParameter[2]; par[0] = new MySqlParameter("@id", MySqlDbType.Int32); par[0].Value = id; par[1] = new MySqlParameter("@resultval", MySqlDbType.Text); par[1].Value = status; nflag = MySqlHelpers.ExecuteNonQuery(MySqlHelpers.ConnectionString, CommandType.Text, strSql_update_updatetaskres, par); return(nflag); }