public HttpResponseMessage GetCarsInventory(string blockCode) { string sql = @"select ROW_NUMBER() OVER(ORDER BY timestart DESC) AS stt,(select top 1 identify from SmartCard s where s.id = c.id) as STTThe, id,digit,part,(select top 1 name from part p where p.id = c.idpart) as LOAIXE,timestart,timeend,cost,idticketmonth,idin,idout,matthe,images,images2,images3,images4, account,dateupdate, (select top (1) tenkh from ticketmonth t where t.id = c.id and processdate <=timestart order by rowid desc ) as Name, (select top 1 company from ticketmonth t where t.id = c.id and processdate <=timestart order by rowid desc ) as Company, computer from car c where TimeEnd IS NULL"; if (!CheckCode.checkcode(blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { List <CarContract> kq; using (DB db = new DB(blockCode)) { kq = db.Database.SqlQuery <CarContract>(sql).ToList(); } return(ResponseSuccess(kq)); } catch { return(ResponseFail(Constants.FAILD)); } }
public HttpResponseMessage GetListUser(string blockCode) { if (IsBodyNull(blockCode)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { using (DB db = new DB(blockCode)) { var listUser = db.UserCars.Where(x => x.IDFunct.Equals("Nh")).Select(x => new UserCar { ID = x.ID, NameUser = x.NameUser, Account = x.Account, Sex = x.Sex, Working = x.Working, IDFunct = x.IDFunct }).ToList(); return(ResponseSuccess(listUser)); } } catch { return(ResponseFail(Constants.FAILD)); } }
public HttpResponseMessage DeleteCard([FromBody] RequestDeleteCard request) { if (IsBodyNull(request)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(request.blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { SmartCard card; using (DB db = new DB(request.blockCode)) { card = db.SmartCards.Find(request.ID); db.SmartCards.Remove(card); db.SaveChanges(); } var model = new CardViewModel(); string info = "Xóa thẻ : " + request.ID + "\n -STT : " + card.Identify + "\n -Mã thẻ : " + request.ID + "\n -Loại thẻ : " + model.GetPartName(card.ID, request.blockCode) + "\n -Sử dụng : " + card.Using; var logModel = new LogViewModel(); logModel.AddLog(ActionType.DELETE_CARD_INFO, DateTime.Now, info, request.blockCode); return(ResponseSuccess(Constants.SUCCESS, model.Statistical(request.blockCode))); } catch { return(ResponseSuccess(Constants.FAILD)); } }
public static bool Check(LineObject lineObject, bool printFlag, CheckSt catSt, LexRecord lexObj, bool debugFlag) { bool flag = true; int curSt = catSt.GetCurState(); if (curSt == 40) { curSt = 161; catSt.SetCurState(curSt); } switch (curSt) { case 161: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkVariant_, new UpdateModalVariant(), 4, true); PrintStep(161, debugFlag, lineObject.GetLine()); break; } return(flag); }
public bool Check(CheckCode code) { if (code.Key == null || code.Code == null) { Errors = new ErrorInfo(ErrorDescription.CHECK_CODE_ERROR, ErrorDescription.CHECK_CODE_ERROR_MSG); return(false); } try { ISessionDaoStub stub = new SessionDaoStubFac().Get(); byte[] content = stub.getSession(3000, code.Key); string codeStr = System.Text.UTF8Encoding.UTF8.GetString(content); if (codeStr.Trim().ToLower() .Equals(code.Code.Trim().ToLower())) { return(true); } } catch (Exception e) { //SowayLog.Log.Error("set session fail", e); Errors = new ErrorInfo(ErrorDescription.CODE_SYSTEM_ERROR, ErrorDescription.MESSAGE_SYSTEM_ERROR); } return(false); }
//主方法,在任何页面调用该方法即可得到验证码,该码存储在Session["CheckCode"]中 public static void DrawImage() { CheckCode img = new CheckCode(); HttpContext.Current.Session["CheckCode"] = img.RndNum(4); img.checkCodes(HttpContext.Current.Session["CheckCode"].ToString()); }
public async Task <ActionResult <CheckCode> > CreateCode(string PhoneNumber, string userMAC) { if (_context.CheckCodes.Any(x => x.PhoneNumber == PhoneNumber && x.SendDate.AddMinutes(15) >= DateTime.Now)) { return(Problem("الرجاء الانتظار 15 دقيقة قبل اعادة طلب الرمز")); } Student student = _context.Students.FirstOrDefault(x => x.PhoneNumber == PhoneNumber); if (student != null && student.Mac != userMAC && student.LoginData.AddDays(3) > DateTime.Now) { return(Problem("لايمكنك تسجيل الدخول في هذا الوقت")); } CheckCode checkCode = new CheckCode { PhoneNumber = PhoneNumber, Code = RandomeCS.IntRandom(), SendDate = DateTime.Now }; _context.CheckCodes.Add(checkCode); await _context.SaveChangesAsync(); //todo Send MTN Code return(checkCode); }
public string SendEnterRequest(string JSon, string from) { CheckCode bll = new CheckCode(); CheckCode.ResultCompEnter result = bll.SendEnterRequest(AESHelper.Decrypt_android(JSon), from); JavaScriptSerializer js = new JavaScriptSerializer(); return(AESHelper.Encrypt_android(js.Serialize(result))); }
public string GetCaptchaPhoto() { CheckCode bll = new CheckCode(); CheckCode.ResultCaptchaPhoto result = bll.GetCaptchaPhoto(); JavaScriptSerializer js = new JavaScriptSerializer(); return(AESHelper.Encrypt_android(js.Serialize(result))); }
public ActionResult CheckCode() { CheckCode checkCode = new CheckCode(); CheckCodeStatus.SetCheckCode(checkCode.CodeText); Byte[] data = checkCode.GetBitmapData(); return(File(data, "image/jpeg")); }
protected void Page_Load(object sender, EventArgs e) { CheckCode vCode = new CheckCode(); string code = vCode.CreateValidateCode(5); Session["ValidateCode"] = code; byte[] imageBytes = vCode.CreateValidateGraphic(code); Response.BinaryWrite(imageBytes); }
public static bool Check(LineObject lineObject, bool printFlag, CheckSt catSt, LexRecord lexObj, bool debugFlag) { bool flag = true; int curSt = catSt.GetCurState(); if (curSt == 40) { curSt = 191; catSt.SetCurState(curSt); } switch (curSt) { case 191: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkVariants_, new UpdatePronVariants(), 4, true); PrintStep(191, debugFlag, lineObject.GetLine()); break; case 192: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkGender_, new UpdatePronGender(), 2, true); PrintStep(192, debugFlag, lineObject.GetLine()); break; case 193: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkInterrogative_, new UpdatePronInterrogative(), 6, false); PrintStep(193, debugFlag, lineObject.GetLine()); break; case 194: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkType_, new UpdatePronType(), 3, false); PrintStep(194, debugFlag, lineObject.GetLine()); break; } return(flag); }
protected void Page_Load(object sender, EventArgs e) { CheckCode.CodeDot = ShopConfig.ReadConfigInfo().CodeDot; CheckCode.CodeLength = ShopConfig.ReadConfigInfo().CodeLength; CheckCode.CodeType = (CodeType)ShopConfig.ReadConfigInfo().CodeType; CheckCode.Key = ShopConfig.ReadConfigInfo().SecureKey; CheckCode m = new CheckCode(); m.ProcessRequest(HttpContext.Current); this.mm.Text = CheckCode.Key; }
protected void Page_Load(object sender, EventArgs e) { string code = CheckCode.GenerateCheckCode(); byte[] bytes = CheckCode.CreateImage(code); //byte[] bytes = CheckCode.CreateVane("2.7"); Session["CheckCode"] = code; Response.ClearContent(); Response.ContentType = "image/Gif"; Response.BinaryWrite(bytes); }
public ActionResult Detial(string id) { string nonceStr = new CheckCode().CreateVerifyCode(); string timestamp = GetUnixTimeStamp(DateTime.Now); ReturnStr objec = SignatureHelper.GetSignature(timestamp, nonceStr); ViewBag.AppId = System.Configuration.ConfigurationManager.AppSettings["appid"]; ViewBag.NonceStr = objec.nonceStr; ViewBag.TimeStamp = objec.timestamp; ViewBag.Signature = objec.signature; return(View(WebService.Find_Image(id))); }
protected void Page_Load(object sender, EventArgs e) { string code = CheckCode.GenerateCheckCode(); byte[] bytes = CheckCode.CreateImage(code); //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); Response.ClearContent(); Response.ContentType = "image/Gif"; Response.BinaryWrite(bytes); }
private async void btnVerify_Clicked(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtCode.Text)) { await DisplayAlert("Error", "Error Code", "Cancel"); return; } CheckCode checkCode = new CheckCode { PhoneNumber = txtPhoneNumber.Text, Code = Convert.ToInt32(txtCode.Text) }; RegisterState State = CallAPI.PostObjectAndGetObject <CheckCode, RegisterState>(checkCode, "CheckCodeExists", "7"); if (State == RegisterState.Blocked) { await DisplayAlert("Error", "Your account has been banned", "Cancel"); return; } if (State == RegisterState.NoteFound) { await DisplayAlert("Error", "Incorrect code", "Cancel"); return; } if (State == RegisterState.unregistered) { await Navigation.PushModalAsync(new RegisterStudent(txtPhoneNumber.Text)); return; } if (State == RegisterState.AlreadyRegistered) { Student student = CallAPI.GetObjectContent <Student, Student>("GetStudentByNumber", txtPhoneNumber.Text); Settings.StudentId = student.Id.ToString(); Settings.StudentPhone = student.PhoneNumber; Settings.FirstName = student.FirstName; Settings.LastName = student.LastName; Settings.Location = student.Address; App.Current.MainPage = new AppShell(); } } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "Cancel"); } }
protected void BtnLogin_Click(object sender, DirectEventArgs e) { string loginID = this.txtUserName.Text.Trim(); string password = this.txtPassWord.Text.Trim(); string checkCode = this.txtCheckCode.Text.Trim(); if (checkCode != CheckCode.GetCheckCode()) { ResourceManager.AjaxSuccess = false; ResourceManager.AjaxErrorMessage = "验证码错误!"; return; } SystemUserWrapper userWrapper = SystemUserWrapper.FindByLoginID(loginID); if (userWrapper == null) { ResourceManager.AjaxSuccess = false; ResourceManager.AjaxErrorMessage = GetLocalResourceObject("msgLoginFailedUserPasswordError").ToString(); SystemLogWrapper.LogUserLoginFailed(loginID, HttpUtil.GetIP(this.Request), GetLocalResourceObject("msgLoginFailedUserPasswordError").ToString(), System.DateTime.Now); return; } if (userWrapper.IsLockedOut) { if (SystemUserWrapper.CheckUserIfDeveloperAdminOrSystemAdmin(loginID)) { SystemUserWrapper.UnlockUser(loginID); } else { ResourceManager.AjaxSuccess = false; ResourceManager.AjaxErrorMessage = GetLocalResourceObject("msgLoginFailedUserLockError").ToString(); SystemLogWrapper.LogUserLoginFailed(loginID, HttpUtil.GetIP(this.Request), GetLocalResourceObject("msgLoginFailedUserPasswordError").ToString(), System.DateTime.Now); return; } } if (SystemUserWrapper.FindByLoginID(loginID) == null) { ResourceManager.AjaxSuccess = false; ResourceManager.AjaxErrorMessage = GetLocalResourceObject("msgLoginFailedUserPasswordError").ToString(); SystemLogWrapper.LogUserLoginFailed(loginID, HttpUtil.GetIP(this.Request), GetLocalResourceObject("msgLoginFailedUserPasswordError").ToString(), System.DateTime.Now); return; } LoginUser(loginID); }
private void btnCheckCode_Click(object sender, EventArgs e) { string filePath = Path.Combine(Application.StartupPath, "passCodeAction.jpg"); Image image = Bitmap.FromFile(filePath); Bitmap bitmap = (Bitmap)image; try { string result = CheckCode.Read(bitmap); MessageUtil.ShowTips(result); //好像变化了,不可以了。 } catch (Exception ex) { MessageUtil.ShowError(ex.Message); } }
/// <summary> /// 提取信息初始化,从数组中得到数据,并相应的进行提取, /// </summary> /// <param name="eventManager">类型事件 同步管理</param> /// <param name="eventTransmissionManager">传输功能事件, 同步管理</param> public CheckGetMessage(EventTypeID eventManager, EventTCF eventTransmissionManager) { this.eventManager = eventManager; this.eventTransmissionManager = eventTransmissionManager; ReciveQuene = new Queue <byte>(); ReciveQueneBuffer = new Queue <byte>(); FrameQueneBuffer = new Queue <byte>(); //初始化为最小长度 chekNow = CheckCode.MinLength; readThread = new Thread(TcpReadThread); readThread.Priority = ThreadPriority.AboveNormal; readThread.Name = "数据解码"; readThread.Start(); }
private void btnCheckCode_Click(object sender, EventArgs e) { string filePath = Path.Combine(Application.StartupPath, "DB\\GenerateCheckCode.png"); Image image = Bitmap.FromFile(filePath); Bitmap bitmap = (Bitmap)image; try { string result = CheckCode.Read(bitmap); MessageDxUtil.ShowTips(result); //好像变化了,不可以了。 } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(Form1)); MessageDxUtil.ShowError(ex.Message); } }
public static bool Check(LineObject lineObject, bool printFlag, CheckSt catSt, LexRecord lexObj, bool debugFlag) { bool flag = true; int curSt = catSt.GetCurState(); if (curSt == 40) { curSt = 151; catSt.SetCurState(curSt); } switch (curSt) { case 151: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkVariants_, new UpdateDetVariants(), 1, true); PrintStep(151, debugFlag, lineObject.GetLine()); break; case 152: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkInterrogative_, new UpdateDetInterrogative(), 6, false); PrintStep(152, debugFlag, lineObject.GetLine()); break; case 153: flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkDemonstrative_, new UpdateDetDemonstrative(), 6, false); PrintStep(152, debugFlag, lineObject.GetLine()); break; } return(flag); }
public HttpResponseMessage GetListLogTicketMonth([FromBody] LogTicketMonthRequest request) { if (IsBodyNull(request)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (request.fromDate > request.toDate) { return(ResponseFail(Constants.MSG_ERROR_DATE)); } if (!CheckCode.checkcode(request.blockCode)) { return(ResponseFail(Constants.CODEERROR)); } string str1 = ""; string str2 = ""; string str3 = ""; if (request.tim != "" && request.tim != null) { str3 = " and (id = '" + request.tim + "' or digit like N'%" + request.tim + "%' or dateStart ='" + request.tim + "' or dateEnd ='" + request.tim + "' or tenkh like N'%" + request.tim + "%' or company like N'%" + request.tim + "%' or address like N'%" + request.tim + "%' or carkind like N'%" + request.tim + "%' or chargesAmount = '" + request.tim + "' or amount ='" + request.tim + "' or stt = '" + request.tim + "' or note like N'%" + request.tim + "%')"; } if (request.loaixe != "" && request.loaixe != null) { str2 = " and idpart =N'" + request.loaixe + "'"; } if (request.ActionType != "" && request.ActionType != null) { str1 = " and processtype= N'" + request.ActionType + "'"; } try { using (DB db = new DB(request.blockCode)) { string sql = "select * from ticketlog where dateprocess between '" + request.fromDate.ToString("yyyy-MM-dd 00:00:00") + "' and '" + request.toDate.ToString("yyyy-MM-dd 23:59:59") + "' " + str3 + str2 + str1; var kq = db.Database.SqlQuery <TicketLog>(sql).ToList(); return(ResponseSuccess(kq)); } } catch { return(ResponseFail(Constants.FAILD)); } }
public static bool Check(string cc, string ccid, HttpContext context) { if (string.IsNullOrEmpty(cc) || string.IsNullOrEmpty(ccid) || !HasInSession(ccid, context)) { return(false); } CheckCode tcc = Cache.GetCache(ccid) as CheckCode; if (tcc == null) { return(false); } else if (tcc.code != cc.ToLower()) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { CheckCode v = new CheckCode(); v.Length = this.length; v.FontSize = this.fontSize; v.Chaos = this.chaos; v.BackgroundColor = this.backgroundColor; v.ChaosColor = this.chaosColor; v.CodeSerial = this.codeSerial; v.Colors = this.colors; v.Fonts = this.fonts; v.Padding = this.padding; string code = v.CreateVerifyCode(); //取随机码 v.CreateImageOnPage(code, this.Context); // 输出图片 //Response.Cookies.Add(new HttpCookie("CheckCode", code.ToLower())); }
static void Main() { try { Stream resStream = null; string fullpath = SaveImage(ref resStream); CheckCode cc = new CheckCode(); fullpath = @"f:\_queryCph.jpg"; Bitmap bmp = new Bitmap(fullpath); string s = cc.Read(bmp); } catch (Exception ex) { } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmCode()); }
public HttpResponseMessage GetListCardCreateTicketMonth(string blockCode) { if (IsBodyNull(blockCode)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { var model = new CardViewModel(); return(ResponseSuccess(model.GetResponseCardCreateTicketMonth(blockCode))); } catch { return(ResponseFail(Constants.FAILD)); } }
public HttpResponseMessage GetListLog([FromBody] LogRequest request) { if (IsBodyNull(request)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(request.blockCode)) { return(ResponseFail(Constants.CODEERROR)); } if (request.fromDate > request.toDate) { return(ResponseFail(Constants.MSG_ERROR_DATE)); } else { try { var listLog = new List <Log>(); using (DB db = new DB(request.blockCode)) { if (string.IsNullOrEmpty(request.ActionType)) { listLog = db.Logs.AsEnumerable().Where(x => x.NgayXuly >= request.fromDate && x.NgayXuly <= request.toDate).OrderByDescending(x => x.NgayXuly).ToList(); return(ResponseSuccess(listLog)); } else if (request.ActionType == ActionType.ALL) { listLog = db.Logs.AsEnumerable().Where(x => x.NgayXuly >= request.fromDate && x.NgayXuly <= request.toDate).OrderByDescending(x => x.NgayXuly).ToList(); return(ResponseSuccess(listLog)); } listLog = db.Logs.AsEnumerable().Where(x => x.NgayXuly >= request.fromDate && x.NgayXuly <= request.toDate && x.LoaiThaoTac.Trim().Equals(request.ActionType)).OrderByDescending(x => x.NgayXuly).ToList(); return(ResponseSuccess(listLog)); } } catch { return(ResponseFail(Constants.FAILD)); } } }
public async Task <ActionResult <RegisterState> > CheckCodeExists(CheckCode checkCode, int z) { bool state = _context.CheckCodes.Any(x => x.PhoneNumber == checkCode.PhoneNumber && x.Code == checkCode.Code); if (!state) { return(RegisterState.NoteFound); } else { Student student = await _context.Students.FirstOrDefaultAsync(x => x.PhoneNumber == checkCode.PhoneNumber); if (student == null) { return(RegisterState.unregistered); } else if (!student.IsActive) { return(RegisterState.Blocked); } return(RegisterState.AlreadyRegistered); } }
public HttpResponseMessage GeIDPart(string blockCode, string Name) { if (IsBodyNull(blockCode)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { using (DB db = new DB(blockCode)) { var kq = db.Parts.Where(x => x.Name == Name).Select(x => new { Id = x.ID }).Single(); return(ResponseSuccess(kq)); } } catch { return(ResponseFail(Constants.FAILD)); } }
public static void Add(string ccid, CheckCode cc, HttpContext context) { Cache.SaveCache(ccid, cc); SetInSession(ccid, context); }