Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }