/// <summary> /// Serialize to XML /// </summary> /// <param name="serialiseData"></param> public void createxml(object pword) { var passwordBox = pword as PasswordBox; string password = passwordBox.Password; OptionData optionData = new OptionData(); optionData.TrueCare_Url = this.TrueURL; optionData.OAuth2_ClientID = this.Authorization; optionData.MSSQL_Server = this.SQL_Server; optionData.MSSQL_User = this.SQL_User; optionData.MSSQL_Password = EncAndDec.Encrypt(password); GenericXmlOps <OptionData> serializer = new GenericXmlOps <OptionData>(); string xml = serializer.Serialize(optionData); CaseInstallerBase caseInstallerBase = new CaseInstallerBase(); this.regionManager.RequestNavigate("ContentRegion", "TrueManagementLegal"); //string navigatePath = "TrueManagementLegal"; //if (navigatePath != null) //{ // this.regionManager.RequestNavigate("ContentRegion", navigatePath); //} //var ProcessListTemp = this.ProcessList; //ProcessListTemp.Where(count => count.Process == "Initial Configurations").Select(s => s.Progresses = 2).ToList(); //ProcessListTemp.Where(count => count.Process == "Configuration Settings").Select(s => s.Progresses = 2).ToList(); //ProcessListTemp.Where(count => count.Process == "Legal Agreement").Select(s => s.Progresses = 1).ToList(); //this.ProcessList = new ObservableCollection<InstallationSteps>(ProcessListTemp); }
private bool SaveCardToDB(string FingerNo, string CardNo) { bool ret = false; bool IsExists; DataTableReader dr = null; try { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "203", SystemInfo.MacTypeID.ToString(), FingerNo, ((int)FKBackup.BACKUP_CARD).ToString() })); IsExists = dr.Read(); SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000101, new string[] { "210", CardNo, FingerNo })); if (SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000300, new string[] { IsExists ? "205" : "204", SystemInfo.MacTypeID.ToString(), FingerNo, ((int)FKBackup.BACKUP_CARD).ToString(), "NULL" })) == 1) { SystemInfo.db.UpdateByteData(Pub.GetSQL(DBCode.DB_000300, new string[] { "202", SystemInfo.MacTypeID.ToString(), FingerNo, ((int)FKBackup.BACKUP_CARD).ToString() }), "FingerData", EncAndDec.getCard(CardNo)); ret = true; } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(ret); }
private void Form1_Load(object sender, EventArgs e) { string jxDB = ConfigurationManager.AppSettings["JXDataBase"]; string jxDBUserPwd = ConfigurationManager.AppSettings["JXDataBaseUserPwd"]; jxDBUserPwd = EncAndDec.Decode(jxDBUserPwd, "zwx", "xwz"); if (string.IsNullOrEmpty(jxDBUserPwd)) { MessageBox.Show("数据库连接信息错误"); return; } PubConstant.ConnectionString = jxDB + jxDBUserPwd; this.comboBoxPlcObjList.SelectedIndex = 0; // this.tabPage1.Enabled = false; devBll = new DeviceBll(); ctlTaskBll = new ControlTaskBll(); ctlTaskIFBll = new ControlInterfaceBll(); palletBll = new OCVPalletBll(); batteryBll = new OCVBatteryBll(); manTaskBll = new ManageTaskBll(); makeCardBll = new MakeCardRecordBll(); plcRwObj = new PLCRW(); plcRwObj.eventLinkLost += PlcLostConnectHandler; plcRwObj2 = new PLCRWNet(); plcRwObj2.eventLinkLost += PlcLostConnectHandler; if (this.comboBoxPlcObjList.Text == "PLC控件") { plcRwIF = plcRwObj; } else if (this.comboBoxPlcObjList.Text == "重新实现MC协议") { plcRwIF = plcRwObj2; } plcFx485 = new PlcRW485BD(); plcFx485.StationNumber = 1; HFReaderIF readerIF = new HFReaderIF(); rfidRW = new SgrfidRW(1); rfidRW.ReaderIF = readerIF; this.comboBoxComports.Items.Clear(); string[] ports = System.IO.Ports.SerialPort.GetPortNames(); foreach (string port in ports) { this.comboBoxComports.Items.Add(port); this.comboBoxFXComs.Items.Add(port); } if (ports != null && ports.Count() > 0) { this.comboBoxComports.Text = ports[0]; this.comboBoxFXComs.Text = ports[0]; } makeCardCount = makeCardBll.GetRecordCount(" "); this.labelMakeCardCount.Text = "计数:" + makeCardCount.ToString(); }
/// <summary> /// 得到连接字符串 /// </summary> /// <returns>连接字符串</returns> private static string getConnectionSql() { string ConfigFile = System.IO.Directory.GetCurrentDirectory() + "\\Config.ini"; string connectionSql = ""; string P_str_Server = INIOperationClass.INIGetStringValue(ConfigFile, "SqlServer", "IP", null); //服务器 string P_str_DataBase = INIOperationClass.INIGetStringValue(ConfigFile, "SqlServer", "DBNAME", null); //数据库名称 string P_str_uid = INIOperationClass.INIGetStringValue(ConfigFile, "SqlServer", "USER", null); //用户 string P_str_pwd_Encrypt = INIOperationClass.INIGetStringValue(ConfigFile, "SqlServer", "PWD", null); //密码 string P_str_pwd = EncAndDec.MD5Decrypt(P_str_pwd_Encrypt); //解密 connectionSql = "Server=" + P_str_Server + ";DataBase=" + P_str_DataBase + ";User ID=" + P_str_uid + ";Password="******";Persist Security Info=True; "; return(connectionSql); }
protected override void OnViewSet() { string jxDB = ConfigurationManager.AppSettings["JXDataBase"]; string jxDBUserPwd = ConfigurationManager.AppSettings["JXDataBaseUserPwd"]; jxDBUserPwd = EncAndDec.Decode(jxDBUserPwd, "zwx", "xwz"); if (string.IsNullOrEmpty(jxDBUserPwd)) { return; } PubConstant.ConnectionString = jxDB + jxDBUserPwd; //PubConstant.ConnectionString = jxDB + "Persist Security info = True;Initial Catalog=ECAMSDatabase;User ID=sa;Password=123456;"; this.View.eventBindRoleData += BindRoleDataEventHandler; this.View.eventLogin += LoginEventHandler; }
// ConfigurationManager.ConnectionStrings["ConnectionStrings"].ConnectionString; #endregion #region getConnectionSql 得到连接字符串 /// <summary> /// 得到连接字符串 /// </summary> /// <returns>连接字符串</returns> /// static private string getConnectionSql() { string ConfigFile = System.IO.Directory.GetCurrentDirectory() + "\\Config.ini"; string P_str_UserId = INIOperationClass.INIGetStringValue(ConfigFile, "Oracle", "USER", null); //用户 string P_str_Password_Encrypt = INIOperationClass.INIGetStringValue(ConfigFile, "Oracle", "PWD", null); //密码 string P_str_pwd = EncAndDec.MD5Decrypt(P_str_Password_Encrypt); //解密 string P_str_HOST = INIOperationClass.INIGetStringValue(ConfigFile, "Oracle", "IP", null); //服务器IP string P_str_PORT = INIOperationClass.INIGetStringValue(ConfigFile, "Oracle", "PORT", null); //端口 string P_str_SERVICE_NAME = INIOperationClass.INIGetStringValue(ConfigFile, "Oracle", "SID", null); string ConnectionStrings = "User Id=" + P_str_UserId.Trim() + ";Password="******";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + P_str_HOST.Trim() + ")(PORT=" + P_str_PORT.Trim() + ")))(CONNECT_DATA=(SERVICE_NAME=" + P_str_SERVICE_NAME.Trim() + ")))"; return(ConnectionStrings); }
/// <summary> /// Deserialize from XML /// </summary> /// <param name="DeserialiseData"></param> public void LoadData(object deserialiseData) { this.ProcessList = new ObservableCollection <InstallationSteps>(Process()); if (File.Exists(@"D:\\DotNET\\test\\CaseInstaller.xml")) { GenericXmlOps <OptionData> serializer = new GenericXmlOps <OptionData>(); var deserilizedObject = serializer.Deserialize(); this.TrueURL = deserilizedObject.TrueCare_Url; this.Authorization = deserilizedObject.OAuth2_ClientID; this.SQL_Server = deserilizedObject.MSSQL_Server; this.SQL_User = deserilizedObject.MSSQL_User; string password = EncAndDec.Decrypt(deserilizedObject.MSSQL_Password); this.SQL_Password = password; } else { this.TrueURL = String.Empty; this.Authorization = String.Empty; this.SQL_Server = String.Empty; this.SQL_User = String.Empty; this.SQL_Password = String.Empty; } }
private void btnOk_Click(object sender, EventArgs e) { if (cardGrid.RowCount == 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorSelectEmp", "")); return; } bool HasMac = false; for (int i = 0; i < macGrid.RowCount; i++) { if (Pub.ValueToBool(macGrid[0, i].Value)) { HasMac = true; break; } } if (!HasMac) { ShowErrorSelectCorrect(gbxMacInfo.Text); return; } string msg = ""; DataTable dtMac = (DataTable)macGrid.DataSource; DataTable dtEmp = (DataTable)cardGrid.DataSource; DataTable dtFinger = null; TConnInfoFinger conn; UInt32 EnrollNumber = 0; string CardID = ""; string CardPWD = ""; int BackupNumber = 0; int Privilege = 0; int EnableFlag = 0; int PasswordData = 0; int nPhotoSize = 0; byte[] fpData = new byte[(int)FKMax.FK_FaceDataSize]; string EnrollName = ""; bool IsError = false; string EmpSysID = ""; byte[] buff = new byte[0]; bool ReqName = false; int ErrCode = 0; for (int j = 0; j < dtEmp.Rows.Count; j++) { EnrollNumber = Convert.ToUInt32(dtEmp.Rows[j]["CardFingerNo"]); EnrollName = dtEmp.Rows[j]["EmpName"].ToString(); msg = EnrollNumber.ToString() + "[" + dtEmp.Rows[j]["EmpNo"].ToString() + "]" + EnrollName; EmpSysID = dtEmp.Rows[j]["EmpSysID"].ToString(); if (oprtFlag != 0) { try { dtFinger = db.GetDataTable(Pub.GetSQL(DBCode.DB_002001, new string[] { "2014", "3", EmpSysID })); } catch (Exception E) { Pub.ShowErrorMsg(E); return; } } IsError = false; int MacSN = 0; string MacSN_GRPS = ""; bool IsGPRS = false; for (int i = 0; i < dtMac.Rows.Count; i++) { DataRow row = dtMac.Rows[i]; if (!Pub.ValueToBool(dtMac.Rows[i]["SelectCheck"])) { continue; } MacSN = 0; MacSN_GRPS = ""; IsGPRS = Pub.ValueToBool(dtMac.Rows[i]["IsGPRS"].ToString()); if (IsGPRS) { MacSN_GRPS = row["MacSN"].ToString(); } else { MacSN = Convert.ToInt32(row["MacSN"].ToString()); MacSN_GRPS = MacSN.ToString(); } conn = Pub.ValueToConnInfoFinger(MacSN, MacSN_GRPS, row["MacConnType"].ToString(), row["MacIPAddress"].ToString(), row["MacPort"].ToString(), row["MacConnPWD"].ToString(), IsGPRS); DeviceObject.objFK623.InitConn(conn); if (!DeviceObject.objFK623.IsOpen) { DeviceObject.objFK623.Open(); } if (!DeviceObject.objFK623.IsOpen) { Pub.ShowErrorMsg(DeviceObject.objFK623.ErrMsg); return; } if (DeviceObject.objFK623.EnableDevice(0) != (int)FKRun.RUN_SUCCESS) { IsError = true; Pub.ShowErrorMsg(DeviceObject.objFK623.ErrMsg); goto ErrorExitFK623; } switch (oprtFlag) { case 0: foreach (FKBackup ii in Enum.GetValues(typeof(FKBackup))) { BackupNumber = (int)ii; DeviceObject.objFK623.RunCode = DeviceObject.objFK623.GetEnrollData(EnrollNumber, BackupNumber, ref Privilege, fpData, ref PasswordData); if (DeviceObject.objFK623.RunCode == (int)FKRun.RUN_SUCCESS) { EnrollName = ""; DeviceObject.objFK623.GetUserName(EnrollNumber, ref EnrollName); if (!db.SaveEnrollToDB(EnrollNumber, BackupNumber, EnableFlag, Privilege, PasswordData, fpData, EnrollName, ref ReqName)) { IsError = true; goto ErrorExitFK623; } } } buff = new byte[0]; if (DeviceObject.objFK623.GetEnrollPhoto(EnrollNumber, ref buff)) { db.UpdateByteData(Pub.GetSQL(DBCode.DB_001003, new string[] { "10", EmpSysID }), "EmpPhotoImage", buff); } break; case 1: for (int ii = 0; ii < dtFinger.Rows.Count; ii++) { BackupNumber = Convert.ToInt32(dtFinger.Rows[ii]["FaceBkNo"].ToString()); CardID = dtFinger.Rows[ii]["CardPhysicsNo10"].ToString(); CardPWD = dtFinger.Rows[ii]["CardPWD"].ToString(); Privilege = 0; int.TryParse(dtFinger.Rows[ii]["FacePrivilege"].ToString(), out Privilege); EnrollName = dtFinger.Rows[ii]["EmpName"].ToString(); PasswordData = 0; buff = new byte[0]; if (dtFinger.Rows[ii]["FaceTemplate"].ToString() != "") { buff = (byte[])dtFinger.Rows[ii]["FaceTemplate"]; } if (BackupNumber >= (int)FKBackup.BACKUP_FP_0 && BackupNumber <= (int)FKBackup.BACKUP_FP_9) { fpData = new byte[(int)FKMax.FK_FPDataSize]; } else if (BackupNumber == (int)FKBackup.BACKUP_PSW) { fpData = new byte[(int)FKMax.FK_PasswordDataSize]; string xxx = ""; EncAndDec.PWDAndCard(BackupNumber, buff, ref xxx); if (CardPWD != "" && CardPWD != "000000" && CardPWD != xxx) { buff = EncAndDec.getPWD(CardPWD); } if (buff.Length == 0 && (CardPWD == "" || CardPWD == "000000")) { continue; } if (buff.Length == 0) { buff = EncAndDec.getPWD(CardPWD); } } else if (BackupNumber == (int)FKBackup.BACKUP_CARD) { fpData = new byte[(int)FKMax.FK_PasswordDataSize]; string xxx = ""; EncAndDec.PWDAndCard(BackupNumber, buff, ref xxx); if (CardID != "" && CardID != xxx) { buff = EncAndDec.getCard(CardID); } if (buff.Length == 0 && CardID == "") { continue; } if (buff.Length == 0) { buff = EncAndDec.getCard(CardID); } } else if (BackupNumber == (int)FKBackup.BACKUP_FACE) { fpData = new byte[(int)FKMax.FK_FaceDataSize]; } else if (BackupNumber >= (int)FKBackup.BACKUP_PALMVEIN_0 && BackupNumber <= (int)FKBackup.BACKUP_PALMVEIN_3) { fpData = new byte[(int)FKMax.PALMVEINDataSize]; } else if (BackupNumber == (int)FKBackup.BACKUP_VEIN_0) { fpData = new byte[(int)FKMax.FK_VeinDataSize]; } Array.Copy(buff, fpData, fpData.Length); EEE: DeviceObject.objFK623.RunCode = DeviceObject.objFK623.PutEnrollData(EnrollNumber, BackupNumber, Privilege, fpData, PasswordData); if (DeviceObject.objFK623.RunCode == (int)FKRun.RUNERR_DATADOUBLE) { DeviceObject.objFK623.DeleteEnrollData(EnrollNumber, BackupNumber); goto EEE; } if (DeviceObject.objFK623.RunCode != (int)FKRun.RUN_SUCCESS) { IsError = true; Pub.ShowErrorMsg(DeviceObject.objFK623.ErrMsg); goto ErrorExitFK623; } } if (DeviceObject.objFK623.RunCode == (int)FKRun.RUN_SUCCESS) { DeviceObject.objFK623.SetUserName(EnrollNumber, EnrollName, ref ErrCode); DataTableReader drPhoto = null; try { drPhoto = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "104", EmpSysID })); if (drPhoto.Read()) { if (drPhoto["EmpPhotoImage"].ToString() != "") { byte[] buf = (byte[])(drPhoto["EmpPhotoImage"]); nPhotoSize = buf.Length; DeviceObject.objFK623.SetEnrollPhoto(EnrollNumber, buf, nPhotoSize); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (drPhoto != null) { drPhoto.Close(); } drPhoto = null; } } break; case 2: for (int ii = 0; ii < dtFinger.Rows.Count; ii++) { BackupNumber = Convert.ToInt32(dtFinger.Rows[ii]["FaceBkNo"].ToString()); DeviceObject.objFK623.RunCode = DeviceObject.objFK623.DeleteEnrollData(EnrollNumber, BackupNumber); if (DeviceObject.objFK623.RunCode != (int)FKRun.RUN_SUCCESS) { IsError = true; Pub.ShowErrorMsg(DeviceObject.objFK623.ErrMsg); goto ErrorExitFK623; } else { try { db.ExecSQL(Pub.GetSQL(DBCode.DB_001003, new string[] { "18", EmpSysID, BackupNumber.ToString() })); } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); goto ErrorExitFK623; } } } break; } ErrorExitFK623: DeviceObject.objFK623.EnableDevice(1); DeviceObject.objFK623.Close(); } if (IsError) { break; } if (!IsError) { db.WriteSYLog(title, oprt, msg); } } if (IsError) { return; } this.Close(); this.DialogResult = DialogResult.OK; }