加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

WebService

发布时间:2020-12-17 00:31:08 所属栏目:安全 来源:网络整理
导读:? connectionStrings ??? add name="mysqlwxs" connectionString="server=192.168.0.200;user id=root;password=admin;database=wxs;CharSet=gb2312;" providerName="MySql.Data.MySqlClient"/ ? /connectionStrings ? ? ?private string mysqlYunfeng = Con

? <connectionStrings>
??? <add name="mysqlwxs" connectionString="server=192.168.0.200;user id=root;password=admin;database=wxs;CharSet=gb2312;" providerName="MySql.Data.MySqlClient"/>
? </connectionStrings>

?

?

?private string mysqlYunfeng = ConfigurationManager.ConnectionStrings["mysqlwxs"].ConnectionString;

?

?public FriendGPSList ReturnFriendGPSList(string groupId)
??????? {
??????????? FriendGPSList gpsList = new FriendGPSList();
??????????? gpsList.gpsList = new List<GPSNode>();
??????????? gpsList.resNode = new ResErrorNode();
??????????? try
??????????? {
???????????????? MySqlConnection conn = new MySqlConnection(mysqlYunfeng);
??????????????? conn.Open();
??????????????? string selectStr = String.Format("select FID,FName,FTel,FSex,FGLatitude,FGLongitude,FGHight from friends where FGroupID = '{0}'",groupId);
??????????????? MySqlDataAdapter adapter = new MySqlDataAdapter(selectStr,conn);
??????????????? DataSet ds = new DataSet();
??????????????? adapter.Fill(ds);
??????????????? DataTable dt = ds.Tables[0];
??????????????? for (int i = 0; i < dt.Rows.Count; i++)
??????????????? {
??????????????????? GPSNode node = new GPSNode();
??????????????????? node.FId = dt.Rows[i][0].ToString();
??????????????????? node.FName = dt.Rows[i][1].ToString();
??????????????????? node.FTel = dt.Rows[i][2].ToString();
??????????????????? node.FSex = dt.Rows[i][3].ToString();
??????????????????? node.Latitude = double.Parse(dt.Rows[i][4].ToString());
??????????????????? node.Longitude = double.Parse(dt.Rows[i][5].ToString());
??????????????????? node.Hight =Int32.Parse(dt.Rows[i][6].ToString());
??????????????????? gpsList.gpsList.Add(node);
??????????????? }
??????????? }
??????????? catch(Exception e)
??????????? {
??????????????? gpsList.resNode.Code = -1;
??????????????? gpsList.resNode.Message = e.Message;
??????????????? gpsList.gpsList = null;
??????????????? return gpsList;
??????????? }
??????????? gpsList.resNode.Code = gpsList.gpsList.Count;
??????????? gpsList.resNode.Message = "OK";
??????????? return gpsList;
??????? }

?

?

?

?

?

?

?

?

?

?

?

?

?

?

? public ResErrorNode AddGroup(string name,string pass,string adminId)
??????? {
??????????? MySqlConnection conn = new MySqlConnection(mysqlYunfeng);
??????????? conn.Open();
??????????? DateTime dt = DateTime.Now;
??????????? string id = dt.ToString("MMddhhmmss");
??????????? string insertStr = String.Format("insert into Groups(GroupID,GroupName,GroupPass,GroupAdminId) values('{0}','{1}','{2}',{3})",id,name,pass,adminId);

??????????? MySqlCommand cmd = new MySqlCommand(insertStr,conn);??????????? ResErrorNode resNode = new ResErrorNode();??????????? try??????????? {??????????????? cmd.ExecuteNonQuery();??????????? }??????????? catch (Exception ex)??????????? {??????????????? String message = ex.Message;??????????????? Console.WriteLine("插入失败:" + message);??????????????? resNode.Code = -1;??????????????? resNode.Message = message;??????????????? return resNode;??????????? }??????????? resNode.Code = 0;??????????? resNode.Message = id;??????????? return resNode;??????? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读