private void OnInitWindow() { try { dfServer_txt = string.Empty; dfUsername_txt = string.Empty; dfMastSvr_txt = string.Empty; dfMastUsr_txt = string.Empty; // dfMastPass_txt = string.Empty; dfImageSvr_txt = string.Empty; dfImageUsr_txt = string.Empty; // dfImagePass_txt = new SecureString(); dfPathtoPictures_txt = string.Empty; cbDatabaseEndoso = new ObservableCollection <string>(); cbImageDB = new ObservableCollection <string>(); cbMastDB = new ObservableCollection <string>(); cbRadicacionesDB = new ObservableCollection <string>(); dfServer_txt = sqlServer; dfUsername_txt = userName; string decryptPassword; if (password.Trim().Length > 0) { decryptPassword = PasswordHash.Decrypt1(password); GetDataBaseName(sqlServer, userName, decryptPassword, cbDatabaseEndoso); cbDatabase_Item = database; //dfPassword_txt = ToSecureString(decryptPassword); dfPassword_txt = decryptPassword; password = decryptPassword; } if (mastPass.Trim().Length > 0) { decryptPassword = PasswordHash.Decrypt1(mastPass); GetDataBaseName(mastSvr, mastUsr, decryptPassword, cbMastDB); cbMastDB_Item = mastDB; dfMastSvr_txt = mastSvr; dfMastUsr_txt = mastUsr; //dfMastPass_txt = ToSecureString(decryptPassword); dfMastPass_txt = decryptPassword; mastPass = decryptPassword; } if (imagePass.Trim().Length > 0) { decryptPassword = PasswordHash.Decrypt1(imagePass); GetDataBaseName(imageSvr, imageUsr, decryptPassword, cbImageDB); cbImageDB_Item = imageDB; dfImageSvr_txt = imageSvr; dfImageUsr_txt = imageUsr; //dfImagePass_txt = ToSecureString(decryptPassword); dfImagePass_txt = decryptPassword; imagePass = decryptPassword; } if (RadicacionesPass.Trim().Length > 0) { decryptPassword = PasswordHash.Decrypt1(RadicacionesPass); GetDataBaseName(RadicacionesSvr, RadicacionesUsr, decryptPassword, cbRadicacionesDB); cbRadicacionesDB_Item = RadicacionesDB; RadicacionesSvr_txt = RadicacionesSvr; RadicacionesUsr_txt = RadicacionesUsr; RadicacionesUPass_txt = decryptPassword; RadicacionesPass = decryptPassword; } dfPathtoPictures_txt = imgPath; string myBorderBrush = ConfigurationManager.AppSettings["BorderBrush"]; if (myBorderBrush != null && myBorderBrush.Trim().Length > 0) { Type t = typeof(Brushes); Brush b = (Brush)t.GetProperty(myBorderBrush).GetValue(null, null); BorderBrush = b; } else { BorderBrush = Brushes.Black; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "OnInitWindow", 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 { } } }