/// <summary> /// /// </summary> /// <param name="device"></param> /// <returns></returns> internal RequestResult ExecuteRequestDeviceID(Device d) { if (this.IsRequestReady()) { object state = new object[] { d.Station.Group.Name , d.Station.Name , d.Name }; RequestResult r = this.ExecuteRequestDeviceID(state); if (r.ResultEnum == RequestResultEnum.OK) { int remoteDeviceID = (int)r.Result; d.RemoteID = remoteDeviceID; } return r; } else { RequestResult r2 = new RequestResult(); r2.ResultEnum = RequestResultEnum.Error; return r2; } }
/// <summary> /// /// </summary> /// <param name="clientID"></param> /// <param name="state"></param> /// <returns></returns> private RequestResult ProcessGetDeviceLastDataDateTime(string clientID, object state) { int deviceID = Convert.ToInt32(state); DateTime dt = this.DB.GetDeviceDataLastDateTime(deviceID); RequestResult r = new RequestResult(); r.ResultEnum = RequestResultEnum.OK; r.Result = dt; LogGetDeviceLastDataDateTime(deviceID, dt); return r; }
/// <summary> /// /// </summary> /// <param name="clientID"></param> /// <param name="state"></param> /// <returns></returns> private RequestResult ProcessSetWLData(string clientID, object state) { object[] objs = (object[])state; Debug.Assert(objs.Length == 2); int deviceID = Convert.ToInt32(objs[0]); DataTable tbl = (DataTable)objs[1]; DateTime first = DateTime.MinValue; DateTime last = DateTime.MinValue; int count = tbl.Rows.Count; if (tbl.Rows.Count > 0) { first = Convert.ToDateTime(tbl.Rows[0]["DT"]); last = Convert.ToDateTime(tbl.Rows[count - 1]["DT"]); } foreach (DataRow row in tbl.Rows) { DB.InsertWL2(deviceID, row); } LogSetWLData(deviceID, count, first, last); RequestResult r = new RequestResult(); r.ResultEnum = RequestResultEnum.OK; return r; }
/// <summary> /// /// </summary> /// <param name="clientID"></param> /// <param name="state"></param> /// <returns></returns> private RequestResult ProcessGetDeviceIDRequest(string clientID, object state) { object[] arr = (object[])state; Debug.Assert(arr.Length == 3); string g = arr[0].ToString(); string s = arr[1].ToString(); string d = arr[2].ToString(); RequestResult r = new RequestResult(); int deviceID = DB.GetDeviceID(g, s, d); if (deviceID > 0) { r.ResultEnum = RequestResultEnum.OK; r.Result = deviceID; } else { r.ResultEnum = RequestResultEnum.Error; } LogGetDeviceIDRequest(g, s, d, deviceID); return r; }