public async Task <LoginReport> Create(User user) { var loginreport = new LoginReport { UserId = user.Id, CounterLogsIn = 1, FirstLogin = DateTime.Now, LastLogin = DateTime.Now, AvgPerday = 1, PerMonth = 1, User = user }; var result = await _loginReport.Create(loginreport); return(result); }
/// <summary> /// Socket接收 /// </summary> public void ReceiveInfo() { while (true) { try { byte[] result = new byte[1024 * 1024 * 3]; int receiveLength = SOCKET_SEND.Receive(result); if (receiveLength == 0) { stopSocket(); break; } result = result.Skip(0).Take(receiveLength).ToArray(); //string dd = ByteWithString.byteToHexStr(result); //Log.LogWrite("REC:"+dd); //登录标识... if (ByteWithString.byteToHexStrAppend(result, "").Equals("1049FFFF4716".ToLower())) { Thread.Sleep(500); LoginReport theLoginReport = new LoginReport(); theLoginReport.USERNAME = Encoding.ASCII.GetBytes(USER_NAME); theLoginReport.USERNAME_LENGTH = (byte)theLoginReport.USERNAME.Length; theLoginReport.PASSWORD = Encoding.ASCII.GetBytes(PASSWORD); theLoginReport.PASSWORD_LENGTH = (byte)theLoginReport.PASSWORD.Length; theSocketSend(0x01, theLoginReport); } else { //处理报文... reportSel(result); } } catch (Exception msg) { Log.LogWrite(msg); break; } } }
public ActionResult ConfirmedLogin() { string id = Request["username"]; string pass = Request["password"]; Employee employee = employeeService.Get(id); if (employee != null) { if (pass == employee.Password && employee.CurrentStatus == "Active") { Session["message"] = null; LoginReport loginReport = new LoginReport(); loginReport.EmployeeId = id; Session["logTime"] = loginReport.LoginTime = DateTime.Now; Session["uname"] = employee.Name; Session["id"] = id; Session["From"] = employee.Email; Session["Position"] = employee.Position; loginReportService.Insert(loginReport); if (id[0] == 'A') { Session["Count"] = requestUpdateService.getRowCount(); return(RedirectToAction("Dashboard", "Employee")); } else if (id[0] == 'D') { return(RedirectToAction("Dashboard", "Driver")); } else if (id[0] == 'M') { return(RedirectToAction("Dashboard", "Manager")); } } } Session["message"] = "Invalid User or Password"; return(RedirectToAction("Login", "Home"));; }
/// <summary> /// 发送 /// </summary> /// <param name="data"></param> /// <returns></returns> public byte[] clientReportUnSerialize(ClientReport data) { List <byte> reportList = new List <byte>(); try { reportList.Add(0x03); reportList.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 }); reportList.Add(data.CONTROL_FIELD); switch (data.CONTROL_FIELD) { case 0x01: //Login LoginReport lr = (LoginReport)data.REPORT_BODY; reportList.Add(lr.USERNAME_LENGTH); reportList = reportList.Concat(lr.USERNAME).ToList(); reportList.Add(lr.PASSWORD_LENGTH); reportList = reportList.Concat(lr.PASSWORD).ToList(); break; case 0x04: //DataGridView TheCatalog theCatalog = (TheCatalog)data.REPORT_BODY; reportList = reportList.Concat(theCatalog.DEVICE_ADDRESS).ToList(); reportList = reportList.Concat(theCatalog.CATALOG_NAME).ToList(); break; case 0x06: //UpdataFileInfo CatalogFiles theCatalogFiles = (CatalogFiles)data.REPORT_BODY; reportList = reportList.Concat(theCatalogFiles.DeviceAddress).ToList(); reportList.Add(theCatalogFiles.FILE_LENGTH); reportList = reportList.Concat(theCatalogFiles.FILE_NAME).ToList(); break; case 0x09: //RequestRemoteData(请求遥信) reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x13: //设备状态 string[] str = (data.REPORT_BODY as string).Split('|'); reportList = reportList.Concat(ByteWithString.strToToHexByte(str[0])).ToList(); reportList = reportList.Concat(ByteWithString.strToToHexByte(str[1])).ToList(); break; case 0x15: // ResponseValueData theResponseValueData = (ResponseValueData)data.REPORT_BODY; reportList = reportList.Concat(theResponseValueData.DEVICE_ADDRESS).ToList(); reportList.Add(theResponseValueData.VALUE_TYPE); reportList.Add(theResponseValueData.VALUE_COUNT); for (int i = 0; i < theResponseValueData.theResponseValueArray.Count; i++) { string ss = ByteWithString.byteToHexStr(theResponseValueData.theResponseValueArray[i].VALUE_ADDRESS); reportList = reportList.Concat(theResponseValueData.theResponseValueArray[i].VALUE_ADDRESS).ToList(); reportList.Add(theResponseValueData.theResponseValueArray[i].VALUE_LENGTH); reportList = reportList.Concat(theResponseValueData.theResponseValueArray[i].VALUE).ToList(); } break; case 0x17: reportList = reportList.Concat((data.REPORT_BODY as TheCatalog).CATALOG_NAME).ToList(); break; case 0x18: reportList = reportList.Concat((data.REPORT_BODY as TheCatalog).CATALOG_NAME).ToList(); break; case 0x19: reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x20: reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x22: reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x27: //维护变电站 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x28: //维护变电站 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x29: //维护变电站 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x30: //维护变电站 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x31: //维护变电站 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x32: reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x34: //获取线路参数 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x36: //设定定时执行参数 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x37: //请求返回设定参数 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; case 0x39: //上传文件 reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList(); break; default: break; } reportList.Add(0x00); reportList.Add(0x16); reportList[reportList.Count - 2] = makeValidateField(reportList); reportList[1] = Convert.ToByte(reportList.Count >> 24 & 0xff); reportList[2] = Convert.ToByte(reportList.Count >> 16 & 0xff); reportList[3] = Convert.ToByte(reportList.Count >> 8 & 0xff); reportList[4] = Convert.ToByte(reportList.Count & 0xff); } catch (Exception msg) { Log.LogWrite(msg); } return(reportList.ToArray <byte>()); }
public override void OnLoginReport(ClientSession session, LoginRequestClientContext LoginRequestClientContext, LoginReport message) { var context = (LoginAsyncContext)LoginRequestClientContext; context.Tcs.SetResult(null); }
public async Task <LoginReport> Update(LoginReport loginReport) { var result = await _loginReport.Update(loginReport); return(result); }