private void CmdOk_Click() { try { _SaveReg = false; sqlServer = dfServer_txt.Trim(); userName = dfUsername_txt.Trim(); // IntPtr passwordBSTR = default(IntPtr); // string insecurePassword = ""; // passwordBSTR = Marshal.SecureStringToBSTR(dfPassword_txt); // insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); password = dfPassword_txt;// insecurePassword; database = cbDatabase_Item.Trim(); mastSvr = dfMastSvr_txt.Trim(); mastUsr = dfMastUsr_txt.Trim(); // insecurePassword = ""; //passwordBSTR = Marshal.SecureStringToBSTR(dfMastPass_txt); // insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); mastPass = dfMastPass_txt;//insecurePassword; mastDB = cbMastDB_Item.Trim(); imageSvr = dfImageSvr_txt.Trim(); imageUsr = dfImageUsr_txt.Trim(); // insecurePassword = ""; // passwordBSTR = Marshal.SecureStringToBSTR(dfImagePass_txt); // insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); imagePass = dfImagePass_txt;//insecurePassword; imageDB = cbImageDB_Item.Trim(); RadicacionesSvr = RadicacionesSvr_txt.Trim(); RadicacionesUsr = RadicacionesUsr_txt.Trim(); RadicacionesPass = RadicacionesUPass_txt.Trim(); RadicacionesDB = cbRadicacionesDB_Item.Trim(); string PDFPath = dfPathtoPictures_txt.Trim(); if (PDFPath.Trim().Length == 0) { throw new Exception("Error con los Path"); } imgPath = PDFPath; if ((sqlServer.Trim().Length == 0) || (userName.Trim().Length == 0) || (database.Trim().Length == 0) || (password.Trim().Length == 0) || (mastSvr.Trim().Length == 0) || (mastUsr.Trim().Length == 0) || (mastDB.Trim().Length == 0) || (mastPass.Trim().Length == 0) || (imageSvr.Trim().Length == 0) || (imageUsr.Trim().Length == 0) || (imageDB.Trim().Length == 0) || (imagePass.Trim().Length == 0) || (RadicacionesSvr.Trim().Length == 0) || (RadicacionesUsr.Trim().Length == 0) || (RadicacionesDB.Trim().Length == 0) || (RadicacionesPass.Trim().Length == 0)) { throw new Exception("Error con los Parametros de la Base de datos"); } else { //jolcode.Registry.write(_REGPATH,) jolcode.Registry.write(_REGPATH, "DBServer", sqlServer); jolcode.Registry.write(_REGPATH, "DBUser", userName); jolcode.Registry.write(_REGPATH, "DBPass", PasswordHash.Encrypt1(password)); jolcode.Registry.write(_REGPATH, "DBName", database); jolcode.Registry.write(_REGPATH, "MastSvr", mastSvr); jolcode.Registry.write(_REGPATH, "MastUsr", mastUsr); jolcode.Registry.write(_REGPATH, "MastPass", PasswordHash.Encrypt1(mastPass)); jolcode.Registry.write(_REGPATH, "MastDB", mastDB); jolcode.Registry.write(_REGPATH, "ImageSvr", imageSvr); jolcode.Registry.write(_REGPATH, "ImageUsr", imageUsr); jolcode.Registry.write(_REGPATH, "ImagePass", PasswordHash.Encrypt1(imagePass)); jolcode.Registry.write(_REGPATH, "ImageDB", imageDB); jolcode.Registry.write(_REGPATH, "RadicacionesSvr", RadicacionesSvr); jolcode.Registry.write(_REGPATH, "RadicacionesUsr", RadicacionesUsr); jolcode.Registry.write(_REGPATH, "RadicacionesPass", PasswordHash.Encrypt1(RadicacionesPass)); jolcode.Registry.write(_REGPATH, "RadicacionesDB", RadicacionesDB); jolcode.Registry.write(_REGPATH, "ImagePathNew", PDFPath); _SaveReg = true; MessageBox.Show("Done...", "CmdOk_Click", MessageBoxButton.OK, MessageBoxImage.Information); this.View.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "CmdOk_Click", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyOnInitWindow() { String yy = System.DateTime.Now.ToString("yyyy"); Title = String.Format("CEE Sistema de Validación de Endosos " + yy + " Version {0}", AssemblyVersion); Dia = DateTime.Now.ToString("MMM/dd/yyyy"); Hora = DateTime.Now.ToString("hh:mm:ss tt"); //DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate // { // Hora = DateTime.Now.ToString("hh:mm:ss tt"); // },this.View.Dispatcher); // DispatcherTimer setup DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(MyDispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); Logclass myLogClass = new Logclass(); try { myLogClass.LogName = "Applica"; myLogClass.MessageFile = string.Empty; myLogClass.SourceName = "MainVM"; myLogClass.CategoryCount = 0; myLogClass.DisplayNameMsgId = 256; myLogClass.CreateEvent(); myLogClass.MYEventLog.WriteEntry("APP Start:" + Dia + " " + Hora, EventLogEntryType.Information); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error-MyOnInitWindow", MessageBoxButton.OK, MessageBoxImage.Error); throw new Exception("Error en el EventLog " + ex.ToString()); } try { {//Get values from register try { _SqlServer = jolcode.Registry.read(_REGPATH, "DBServer"); } catch { _SqlServer = string.Empty; jolcode.Registry.write(_REGPATH, "DBServer", string.Empty); } try { _Username = jolcode.Registry.read(_REGPATH, "DBUser"); } catch { _Username = string.Empty; jolcode.Registry.write(_REGPATH, "DBUser", string.Empty); } try { _Password = jolcode.Registry.read(_REGPATH, "DBPass"); } catch { _Password = string.Empty; jolcode.Registry.write(_REGPATH, "DBPass", string.Empty); } try { _Database = jolcode.Registry.read(_REGPATH, "DBName"); } catch { _Database = string.Empty; jolcode.Registry.write(_REGPATH, "DBName", string.Empty); } try { _MastSvr = jolcode.Registry.read(_REGPATH, "MastSvr"); } catch { _MastSvr = string.Empty; jolcode.Registry.write(_REGPATH, "MastSvr", string.Empty); } try { _MastUsr = jolcode.Registry.read(_REGPATH, "MastUsr"); } catch { _MastUsr = string.Empty; jolcode.Registry.write(_REGPATH, "MastUsr", string.Empty); } try { _MastPass = jolcode.Registry.read(_REGPATH, "MastPass"); } catch { _MastPass = string.Empty; jolcode.Registry.write(_REGPATH, "MastPass", string.Empty); } try { _MastDB = jolcode.Registry.read(_REGPATH, "MastDB"); } catch { _MastDB = string.Empty; jolcode.Registry.write(_REGPATH, "MastDB", string.Empty); } try { _ImageSvr = jolcode.Registry.read(_REGPATH, "ImageSvr"); } catch { _ImageSvr = string.Empty; jolcode.Registry.write(_REGPATH, "ImageSvr", string.Empty); } try { _ImageUsr = jolcode.Registry.read(_REGPATH, "ImageUsr"); } catch { _ImageUsr = string.Empty; jolcode.Registry.write(_REGPATH, "ImageUsr", string.Empty); } try { _ImagePass = jolcode.Registry.read(_REGPATH, "ImagePass"); } catch { _ImagePass = string.Empty; jolcode.Registry.write(_REGPATH, "ImagePass", string.Empty); } try { _ImageDB = jolcode.Registry.read(_REGPATH, "ImageDB"); } catch { _ImageDB = string.Empty; jolcode.Registry.write(_REGPATH, "ImageDB", string.Empty); } try { _RadicacionesSvr = jolcode.Registry.read(_REGPATH, "RadicacionesSvr"); } catch { _RadicacionesSvr = string.Empty; jolcode.Registry.write(_REGPATH, "RadicacionesSvr", string.Empty); } try { _RadicacionesUsr = jolcode.Registry.read(_REGPATH, "RadicacionesUsr"); } catch { _RadicacionesUsr = string.Empty; jolcode.Registry.write(_REGPATH, "RadicacionesUsr", string.Empty); } try { _RadicacionesPass = jolcode.Registry.read(_REGPATH, "RadicacionesPass"); } catch { _RadicacionesPass = string.Empty; jolcode.Registry.write(_REGPATH, "RadicacionesPass", string.Empty); } try { _RadicacionesDB = jolcode.Registry.read(_REGPATH, "RadicacionesDB"); } catch { _RadicacionesDB = string.Empty; jolcode.Registry.write(_REGPATH, "RadicacionesDB", string.Empty); } try { _PDFPath = jolcode.Registry.read(_REGPATH, "ImagePathNew"); } catch { _PDFPath = string.Empty; jolcode.Registry.write(_REGPATH, "ImagePathNew", string.Empty); } } //if ((_SqlServer == "") || (_Username == "") || (_Database == "") || (_Password == "") || (_MastSvr == "") || (_MastUsr == "") || (_MastDB == "") || (_MastPass == "") || // (_ImageSvr == "") || (_ImageUsr == "") || (_ImageDB == "") || (_ImagePass == "") || (_ImgPath == "") || (_ValiSvr == "") || (_ValiUsr == "") || (_ValiDB == "") || // (_ValiPass == "")) if ((_SqlServer.Trim().Length == 0) || (_Username.Trim().Length == 0) || (_Database.Trim().Length == 0) || (_Password.Trim().Length == 0) || (_MastSvr.Trim().Length == 0) || (_MastUsr.Trim().Length == 0) || (_MastDB.Trim().Length == 0) || (_MastPass.Trim().Length == 0) || (_ImageSvr.Trim().Length == 0) || (_ImageUsr.Trim().Length == 0) || (_ImageDB.Trim().Length == 0) || (_ImagePass.Trim().Length == 0) || (_PDFPath.Trim().Length == 0) || (_RadicacionesSvr.Trim().Length == 0) || (_RadicacionesUsr.Trim().Length == 0) || (_RadicacionesDB.Trim().Length == 0) || (_RadicacionesPass.Trim().Length == 0)) { using (vmMantDB frmMantDB = new vmMantDB(_REGPATH)) { frmMantDB.sqlServer = _SqlServer; frmMantDB.userName = _Username; frmMantDB.password = _Password; frmMantDB.database = _Database; frmMantDB.mastSvr = _MastSvr; frmMantDB.mastUsr = _MastUsr; frmMantDB.mastPass = _MastPass; frmMantDB.mastDB = _MastDB; frmMantDB.imageSvr = _ImageSvr; frmMantDB.imageUsr = _ImageUsr; frmMantDB.imagePass = _ImagePass; frmMantDB.imageDB = _ImageDB; frmMantDB.RadicacionesSvr = _RadicacionesSvr; frmMantDB.RadicacionesUsr = _RadicacionesUsr; frmMantDB.RadicacionesPass = _RadicacionesPass; frmMantDB.RadicacionesDB = _RadicacionesDB; frmMantDB.imgPath = _PDFPath; frmMantDB.View.Owner = this.View as Window; frmMantDB.OnShow(); _SqlServer = frmMantDB.sqlServer; _Username = frmMantDB.userName; _Password = PasswordHash.Encrypt1(frmMantDB.password); _Database = frmMantDB.database; _MastSvr = frmMantDB.mastSvr; _MastUsr = frmMantDB.mastUsr; _MastPass = PasswordHash.Encrypt1(frmMantDB.mastPass); _MastDB = frmMantDB.mastDB; _ImageSvr = frmMantDB.imageSvr; _ImageUsr = frmMantDB.imageUsr; _ImagePass = PasswordHash.Encrypt1(frmMantDB.imagePass); _ImageDB = frmMantDB.imageDB; _RadicacionesSvr = frmMantDB.RadicacionesSvr; _RadicacionesUsr = frmMantDB.RadicacionesUsr; _RadicacionesPass = PasswordHash.Encrypt1(frmMantDB.RadicacionesPass); _RadicacionesDB = frmMantDB.RadicacionesDB; _PDFPath = frmMantDB.imgPath; } // end using } //End IF mnuChangePassword_IsEnabled = false; mnuLogout_IsEnabled = false; mnuLogin_IsEnabled = true; mnuVerElector_IsEnabled = false; mnuInformeEndosos_IsEnabled = false; mnuRecibirLotes_IsEnabled = false; mnuAutoRizarLotes_IsEnabled = false; mnuProcesarLotes_IsEnabled = false; mnuCorregirEndosos_IsEnabled = false; mnuRevLote_IsEnabled = false; mnuAreas_IsEnabled = false; mnuPartidos_IsEnabled = false; mnuNotarios_IsEnabled = false; mnuValidaciones_IsEnabled = false; mnuUsuarios_IsEnabled = false; mnuBaseDeDatos_IsEnabled = false; mnuInicializarLotes_IsEnabled = false; mnuVerEndosos_IsEnabled = false; mnuInformeEndosos_IsEnabled = false; mnuReydi_IsEnabled = false; mnuInformeDuplicados_IsEnable = false; mnuduplicadopornumelectoral_IsEnable = false; _DBEndososCnnStr = string.Concat("Persist Security Info=False;Data Source=", _SqlServer, ";Initial Catalog=", _Database, ";User ID=", _Username, ";Password="******"Persist Security Info=False;Data Source=", _MastSvr, ";Initial Catalog=", _MastDB, ";User ID=", _MastUsr, ";Password="******"Persist Security Info=False;Data Source=", _ImageSvr, ";Initial Catalog=", _ImageDB, ";User ID=", _ImageUsr, ";Password="******"Persist Security Info=False;Data Source=", _RadicacionesSvr, ";Initial Catalog=", _RadicacionesDB, ";User ID=", _RadicacionesUsr, ";Password="******"MyOnInitWindow", MessageBoxButton.OK, MessageBoxImage.Error); this.View.Close(); } else { MessageBox.Show(ex.ToString(), "MyOnInitWindow", MessageBoxButton.OK, MessageBoxImage.Error); } try { myLogClass.MYEventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error, 9000); } catch { } } }