private void BtnRunTool_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { LvEdgeToolItem model = lvToolSet.SelectedItem as LvEdgeToolItem; ToolDataBase Data = null; switch (model.ToolType) { case EnumToolType.CircleTool: Data = CircleTool.Data; break; case EnumToolType.LineTool: Data = LineTool.Data; break; case EnumToolType.PairTool: Data = PairTool.Data; break; case EnumToolType.FlagTool: Data = TagTool.Data; break; default: break; } (ListBoxRoiModel.DataContext as CamDebugViewModel).DebugRunToolCommand.Execute(Data); }
/// <summary> /// 检查验证码 /// </summary> /// <param name="UserID">用户ID</param> /// <param name="VCode">验证码</param> /// <param name="isAndroid">是否为安卓库</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>1、验证码有效。2、查询不到该用户的验证码数据。3、验证码为空。4、验证码不匹配。5、验证码已过时</returns> public static int CheckVerificationCode(int UserID, string VCode, bool isAndroid, bool isFormalDataBase) { VCodeModel VCM = ToolDataBase.Query <VCodeModel>("SELECT * FROM dbo.t_emp_UserVCode WHERE FUserID = '" + UserID + "'", isAndroid, isFormalDataBase); //没有该用户的验证码信息 if (VCM == null) { return(CheckVCode_Success); } //验证码不匹配 if (!VCM.FVerificationCode.Equals(VCode)) { return(3); } //验证码已过时 if ((GetTimeStampNow() - VCM.FDate) > 10 * 60) { return(4); } //验证码有效 return(0); }
/// <summary> /// 检查并获取token的实体类 /// </summary> /// <returns>检查通过后生成一个完整的token实体类,失败则生成一个只带有检查结果码的实体类</returns> public static TokenModel CheckAndGetToken() { //获取header里的token string ResultToken = HttpContext.Current.Request.Headers.Get("Token"); //header的token为空则说明接口没有传输header if (ResultToken.IsEmpty()) { return(new TokenModel(CheckToken_NoToken)); } String[] data = null; try { data = ResultToken.Md5Decrypt().Split('/'); } catch { return(new TokenModel(CheckToken_TokenError)); } //将header进行MD5解密并根据/拆分 得到token里的数据 //如果拆分出来的数组不为4则说明token格式不正确 if (data.Length != 4) { return(new TokenModel(CheckToken_TokenError)); } //根据接口传输回来的token中的(ID、时间戳、是否为安卓数据库、是否为正式库)4个参数去查询用户登录时生成的token string UserToken = ToolDataBase.QueryByID("SELECT TOP 1 FToken FROM dbo.t_emp_UserToken WHERE FUserID = '" + data[0] + "'", "FToken", bool.Parse(data[2]), bool.Parse(data[3])); //数据库中的token和接口收到的token进行对比 不一致则说明被篡改 if (!ResultToken.Equals(UserToken)) { return(new TokenModel(CheckToken_TokenError)); } //如果查询结果为空则说明该用户没有登录过 if (UserToken.IsEmpty()) { return(new TokenModel(CheckToken_NoLogin)); } //解码用户的token data = UserToken.Md5Decrypt().Split('/'); //获取token中的时间戳(单位:秒) long date = long.Parse(data[1]); //检查时间戳与当前时间的差值,差值大于8小时则说明token时效超出 if ((GetTimeStampNow() - date) > 8 * 60 * 60) { return(new TokenModel(CheckToken_TimeOut)); } //检查通过后生成Token实体类 return(new TokenModel(int.Parse(data[0]), long.Parse(data[1]), bool.Parse(data[2]), bool.Parse(data[3]))); }
private void DebugShowFlagTia(ToolDataBase para) { try { int nCamID = 0; FlagToolDaga data = para as FlagToolDaga; var L1Data = File.ReadAllText($"{PATH_TOOLPATH}{data.L1Name}.para"); var L2Data = File.ReadAllText($"{PATH_TOOLPATH}{data.L2Name}.para"); List <string> LineListString = new List <string>() { L1Data, L2Data }; string ModelName = L1Data.Split('|')[1].Split('&')[4]; StepFindModel FindModelTool = new StepFindModel() { In_CamID = nCamID, In_ModelNameFullPath = $"{PATH_MODELPATH}Cam0_{ModelName}.shm" }; HalconVision.Instance.ProcessImage(FindModelTool); //FindLine StepFindeLineByModel FindLineTool = new StepFindeLineByModel() { In_CamID = nCamID, In_Hom_mat2D = FindModelTool.Out_Hom_mat2D, In_ModelRow = FindModelTool.Out_ModelRow, In_ModelCOl = FindModelTool.Out_ModelCol, In_ModelPhi = FindModelTool.Out_ModelPhi, In_LineRoiPara = LineListString }; HalconVision.Instance.ProcessImage(FindLineTool); //ShowFlag var LineListForDraw = new List <Tuple <double, double, double, double> >(); foreach (var it in FindLineTool.Out_Lines) { LineListForDraw.Add(new Tuple <double, double, double, double>(it.Item1.D, it.Item2.D, it.Item3.D, it.Item4.D)); } StepShowFlag ShowFlagTool = new StepShowFlag() { In_CamID = nCamID, In_CenterRow = data.Halcon_Row, In_CenterCol = data.Halcon_Col, In_Phi = data.Halcon_Phi, In_HLine = LineListForDraw[0], In_VLine = LineListForDraw[1], In_RegionFullPathFileName = $"{PATH_TOOLPATH}Flag.reg}}" }; HalconVision.Instance.ProcessImage(ShowFlagTool); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 保存验证码 /// </summary> /// <param name="phone">手机号码</param> /// <param name="code">验证码</param> /// <param name="isAndroid">是否为安卓库</param> /// <param name="isFormalDataBase">是否为正式库</param> public static void SaveVerificationCode(string phone, string code, bool isAndroid, bool isFormalDataBase) { string UserID = ToolDataBase.QueryByID("SELECT FUserID FROM s_user t INNER JOIN t_Emp t0 ON t.FEmpID = t0.FitemID WHERE t0.FPhone = '" + phone + "'", "FUserID", isAndroid, isFormalDataBase); long date = GetTimeStampNow(); //UpDate结果为0则说明数据库中没有课UpDate的数据 则直接创建一条数据 if (ToolDataBase.Exec("UPDATE dbo.t_emp_UserVCode SET FVerificationCode = '" + code + "' ,FDate='" + date + "' WHERE FUserID = '" + UserID + "'", isAndroid, isFormalDataBase) == 0) { ToolDataBase.Exec("INSERT INTO dbo.t_emp_UserVCode VALUES ( '" + UserID + "','" + code + "','" + date + "')", isAndroid, isFormalDataBase); } }
public const int CheckVCode_TimeOut = 4; //验证码已过时 /// <summary> /// 创建并保存token到指定用户数据中 /// </summary> /// <param name="UserID">用户ID</param> /// <param name="isAndroid">是否为安卓库</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>操作成功后返回token</returns> public static string CreatAndSaveToken(int UserID, bool isAndroid, bool isFormalDataBase) { //token规则 (UserID/时间戳/是否为安卓库/是否为正式库) string token = (UserID + "/" + GetTimeStampNow() + "/" + isAndroid + "/" + isFormalDataBase).Md5Encrypt(); //UpDate结果为0则说明数据库中没有课UpDate的数据 则直接创建一条数据 if (ToolDataBase.Exec("UPDATE dbo.t_emp_UserToken SET FToken = '" + token + "' WHERE FUserID = '" + UserID + "'", isAndroid, isFormalDataBase) == 0) { ToolDataBase.Exec("INSERT INTO dbo.t_emp_UserToken VALUES ( '" + UserID + "','" + token + "')", isAndroid, isFormalDataBase); } return(token); }
private bool DebugTool(ToolDataBase para) { try { switch (para.ToolType) { case EnumToolType.LineTool: { var ToolData = para as LineToolData; HalconVision.Instance.Debug_FindLine(0, ToolData.Polarity, ToolData.SelectType, ToolData.Contrast, ToolData.CaliperNum); return(true); } case EnumToolType.CircleTool: { } break; case EnumToolType.PairTool: { PairToolData data = para as PairToolData; HalconVision.Instance.Debug_FindPair(0, data.Polarity, data.SelectType, data.ExpectPairNum, data.Contrast, data.CaliperNum); return(true); } case EnumToolType.FlagTool: { FlagToolDaga data = para as FlagToolDaga; AddFlag(data); } break; default: break; } return(true); } catch (Exception ex) { UC_MessageBox.ShowMsgBox("Error", ex.Message, MsgType.Error); return(false); } }
/// <summary> /// 获取本地化的文本内容 /// </summary> /// <param name="Language">语言ID</param> /// <param name="key">文本key值</param> /// <returns></returns> public static string GetLocalText(string Language, string key) { return(ToolDataBase.GetLocalText(Language, key)); }
/// <summary> /// 写入数据库 /// </summary> /// <param name="sql">SQL语句</param> /// <param name="isAndroid">是否为安卓库</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>写入成功返回写入了多少行数据,失败则返回0</returns> public int Exec(string sql, bool isFormalDataBase) => ToolDataBase.Exec(sql, true, isFormalDataBase);
/// <summary> /// 重载查询数据库并返回一个实体类 /// </summary> /// <typeparam name="T">model</typeparam> /// <param name="sql">SQL语句</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回对应的泛型,失败则返回null</returns> public T Query <T>(string sql, bool isFormalDataBase) => ToolDataBase.Query <T>(sql, true, isFormalDataBase);
/// <summary> /// 重载查询数据库中指定Key的Value /// </summary> /// <param name="sql">SQL语句</param> /// <param name="FieldName">Key</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回string 失败返回""</returns> public string QueryByID(string sql, string FieldName, bool isFormalDataBase) => ToolDataBase.QueryByID(sql, FieldName, true, isFormalDataBase);
/// <summary> /// 写入数据库 /// </summary> /// <param name="sql">SQL语句</param> /// <param name="isAndroid">是否为安卓库</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>写入成功返回写入了多少行数据,失败则返回0</returns> public int Exec(string sql) => ToolDataBase.Exec(sql, true, tokenModel.isFormalDataBase);
/// <summary> /// 重载获取数据库地址 /// </summary> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>返回一个服务器地址string</returns> public string GetServer() => ToolDataBase.GetServer(true, tokenModel.isFormalDataBase);
/// <summary> /// 重载查询数据库并返回一个List<T>(防sql注入) /// </summary> /// <typeparam name="T">model</typeparam> /// <param name="sql">SQL语句</param> /// <param name="Parameter">参数</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>>查询成功返回对应的List<泛型>,失败则返回null</returns> public List <T> QueryList <T>(string sql, Dictionary <string, object> Parameter) => ToolDataBase.QueryList <T>(sql, Parameter, true, tokenModel.isFormalDataBase);
/// <summary> /// 重载查询数据库并返回一个List<T> /// </summary> /// <typeparam name="T">model</typeparam> /// <param name="sql">SQL语句</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回对应的List<泛型>,失败则返回null</returns> public List <T> QueryList <T>(string sql) => ToolDataBase.QueryList <T>(sql, true, tokenModel.isFormalDataBase);
/// <summary> /// 重载查询数据库中指定Key的Value /// </summary> /// <param name="sql">SQL语句</param> /// <param name="FieldName">Key</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回string 失败返回""</returns> public string QueryByID(string sql, string FieldName) => ToolDataBase.QueryByID(sql, FieldName, true, tokenModel.isFormalDataBase);
public static string SetPicture(string EmpID, string ImageBase64, string UserID) { try { byte[] ByteImage = Convert.FromBase64String(ImageBase64); //1.连接图片服务器,配置服务器信息及调用FTPHelper string FServerURL = "ftp://192.168.99.79:1688/"; string FServerUserName = "******"; string FServerUserPassWord = "******"; FTPHelper myFtpHelper = null; List <Ge.Public.FTP.AttachFileInfo> FileInfos = new List <Ge.Public.FTP.AttachFileInfo>(); Uri url = new Uri(FServerURL); myFtpHelper = new FTPHelper(url, FServerUserName, FServerUserPassWord); var sqlstr = string.Format(@" SELECT t3.Fname + '/员工/' + CAST(year(t1.FBeginHireDate) AS varchar(4)) + '/' + CAST(month(t1.FBeginHireDate) AS varchar(4)) + '/' + t1.Fname + '/' + t1.Fnumber + '.jpg' AS FFullName , Fpicture , T1.FitemID , t3.Fname + '/员工/' + CAST(year(t1.FBeginHireDate) AS varchar(4)) + '/' + CAST(month(t1.FBeginHireDate) AS varchar(4)) + '/' + t1.Fname AS FPreDir FROM t_emp t1 INNER JOIN dbo.t_Emp_picture t2 ON t1.FitemID = t2.FitemID INNER JOIN dbo.s_GR_FrameWork t3 ON t1.FOrganizeID = t3.FitemID WHERE t1.FleaveDate IS NULL And Fpicture is not null AND t1.FitemID='{0}'", EmpID);//(FIsUploadFile = 0 OR FIsUploadFile IS NULL) AND var dt = ToolDataBase.Query <string>(sqlstr, true, true); if (dt != null) { /* //byte[] datas = row["Fpicture"] as byte[]; * string FFullName = row["FFullName"].ToMString(); * string FitemID = row["FitemID"].ToMString(); * string FPreDir = row["FPreDir"].ToMString(); * //3.1服务器创建文件 * if (!myFtpHelper.DirectoryExist(FPreDir)) * { * myFtpHelper.MakeDirectory(FPreDir); * } * //3.2 上传文件 * myFtpHelper.UploadFileAsync(ByteImage, FFullName, true); * //3.3 插入hq_From_AttachFiles 先删除再添加 * string insertSql = string.Format(@" * delete from hq_From_AttachFiles where FInterID={0}; * INSERT INTO hq_From_AttachFiles * (FEntryID, FOrganizeID, FYear, FPeriod, FClassID * , FClassName, FInterID, FFullName, FFullPath, FFileName * , FFileLength, FFileID, FFieldName, FType, FUpLoaderID * , FUpLoadDate, FFileNote, FClassificationID) * SELECT 1 AS FEntryID, t1.FOrganizeID, year(t1.FBeginHireDate) AS FYear * , month(t1.FBeginHireDate) AS FPeriod, 130 AS FClassID, '员工' AS FClassName * , t1.FitemID AS FInterID * , t3.Fname + '/员工/' + CAST(year(t1.FBeginHireDate) AS varchar(4)) + '/' + CAST(month(t1.FBeginHireDate) AS varchar(4)) + '/' + t1.Fname + '/' + t1.Fnumber + '.jpg' AS FFullName * , t3.Fname + '/员工/' + CAST(year(t1.FBeginHireDate) AS varchar(4)) + '/' + CAST(month(t1.FBeginHireDate) AS varchar(4)) + '/' + t1.Fname AS FFullPath * , t1.Fnumber + '.jpg' AS FFileName * , 15524 AS FFileLength, 0 AS FFileID, '' AS FFieldName, 0 AS FType, {1} AS FUpLoaderID * , GETDATE() AS FUpLoadDate, '' AS FFileNote, '' AS FClassificationID * FROM t_emp t1 * INNER JOIN dbo.t_Emp_picture t2 ON t1.FitemID = t2.FitemID * INNER JOIN dbo.s_GR_FrameWork t3 ON t1.FOrganizeID = t3.FitemID * WHERE t1.FleaveDate IS NULL And Fpicture is not null AND t2.FitemID={0} ", FitemID, UserID);//(FIsUploadFile = 0 OR FIsUploadFile IS NULL) AND * Db.Main.Exec(insertSql); * //3.4 修改t_Emp_picture表 * string updateSql = string.Format(@"update t_Emp_picture set FisUploadFIle=1 where FitemID={0}", FitemID); * Db.Main.Exec(updateSql);*/ return("上传成功!"); } else { return("上传失败!"); } } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 重载查询数据库并返回一个实体类(防sql注入) /// </summary> /// <typeparam name="T">model</typeparam> /// <param name="sql">SQL语句</param> /// <param name="Parameter">参数</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回对应的泛型,失败则返回null</returns> public T Query <T>(string sql, Dictionary <string, object> Parameter, bool isFormalDataBase) => ToolDataBase.Query <T>(sql, Parameter, true, isFormalDataBase);
/// <summary> /// 重载查询数据库并返回一个List<T> /// </summary> /// <typeparam name="T">model</typeparam> /// <param name="sql">SQL语句</param> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>查询成功返回对应的List<泛型>,失败则返回null</returns> public List <T> QueryList <T>(string sql, bool isFormalDataBase) => ToolDataBase.QueryList <T>(sql, true, isFormalDataBase);
/// <summary> /// 重载获取数据库地址 /// </summary> /// <param name="isFormalDataBase">是否为正式库</param> /// <returns>返回一个服务器地址string</returns> public string GetServer(bool isFormalDataBase) => ToolDataBase.GetServer(true, isFormalDataBase);