Ejemplo n.º 1
0
 public async Task DrawModel(aModel m, CommonClass.databaseModel.detailmodel dm, WebSocket webSocket)
 {
     //this.ID = "n" + Guid.NewGuid().ToString("N");
     var sn = new
     {
         c           = "DrawModel",
         WebSocketID = 0,
         aModel      = m,
         id          = dm.modelID,
         x           = dm.x,
         y           = dm.y,
         z           = dm.z,
         r           = dm.rotatey
     };
     var sendMsg  = Newtonsoft.Json.JsonConvert.SerializeObject(sn);
     var sendData = Encoding.ASCII.GetBytes(sendMsg);
     await webSocket.SendAsync(new ArraySegment <byte>(sendData, 0, sendData.Length), WebSocketMessageType.Text, true, CancellationToken.None);
 }
Ejemplo n.º 2
0
        public static void Update(CommonClass.databaseModel.detailmodel item)
        {
            using (MySqlConnection con = new MySqlConnection(Connection.ConnectionStr))
            {
                con.Open();
                using (MySqlTransaction tran = con.BeginTransaction())
                {
                    try
                    {
                        {
                            string sQL = @"UPDATE detailmodel SET 
x=@x,
y=@y,
z=@z,
rotatey=@rotatey 
WHERE modelID=@modelID";
                            // long moneycount;
                            using (MySqlCommand command = new MySqlCommand(sQL, con, tran))
                            {
                                command.Parameters.AddWithValue("@x", item.x);
                                command.Parameters.AddWithValue("@y", item.y);
                                command.Parameters.AddWithValue("@z", item.z);
                                command.Parameters.AddWithValue("@rotatey", item.rotatey);
                                command.Parameters.AddWithValue("@modelID", item.modelID);
                                command.ExecuteNonQuery();
                            }
                        }
                        tran.Commit();
                    }
                    catch (Exception e)
                    {
                        throw e;
                        throw new Exception("新增错误");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Add(CommonClass.databaseModel.detailmodel item)
        {
            using (MySqlConnection con = new MySqlConnection(Connection.ConnectionStr))
            {
                con.Open();
                using (MySqlTransaction tran = con.BeginTransaction())
                {
                    try
                    {
                        bool hasValue;
                        // long moneycount;
                        {
                            string sQL = @"SELECT
                                modelID 
                            FROM
                                detailmodel WHERE modelID=@modelID";
                            // long moneycount;
                            using (MySqlCommand command = new MySqlCommand(sQL, con, tran))
                            {
                                command.Parameters.AddWithValue("@modelID", item.modelID);

                                using (var reader = command.ExecuteReader())
                                {
                                    if (reader.Read())
                                    {
                                        hasValue = true;
                                    }
                                    else
                                    {
                                        hasValue = false;
                                    }
                                }
                            }
                        }
                        if (hasValue)
                        {
                            string sQL = @"UPDATE detailmodel SET 
x=@x,
y=@y,
z=@z,
rotatey=@rotatey 
WHERE modelID=@modelID";
                            // long moneycount;
                            using (MySqlCommand command = new MySqlCommand(sQL, con, tran))
                            {
                                command.Parameters.AddWithValue("@x", item.x);
                                command.Parameters.AddWithValue("@y", item.y);
                                command.Parameters.AddWithValue("@z", item.z);
                                command.Parameters.AddWithValue("@rotatey", item.rotatey);
                                command.Parameters.AddWithValue("@modelID", item.rotatey);
                                command.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            string sQL = @"INSERT INTO detailmodel(modelID,x,y,z,amodel,rotatey)VALUES(@modelID,@x,@y,@z,@amodel,@rotatey)";
                            // long moneycount;
                            using (MySqlCommand command = new MySqlCommand(sQL, con, tran))
                            {
                                command.Parameters.AddWithValue("@modelID", item.modelID);
                                command.Parameters.AddWithValue("@x", item.x);
                                command.Parameters.AddWithValue("@y", item.y);
                                command.Parameters.AddWithValue("@z", item.z);
                                command.Parameters.AddWithValue("@amodel", item.amodel);
                                command.Parameters.AddWithValue("@rotatey", item.rotatey);
                                command.ExecuteNonQuery();
                            }
                        }
                        tran.Commit();
                    }
                    catch (Exception e)
                    {
                        throw e;
                        throw new Exception("新增错误");
                    }
                }
            }
        }