示例#1
0
        public static void readSettings()
        {
            if (File.Exists(settingFile_location) == true)
            {
                Settings4file st = new Settings4file();

                //Read the binary file
                //Create a BinaryFormatter object
                BinaryFormatter      bf2 = new BinaryFormatter();
                IgnoreAssemblyBinder iab = new IgnoreAssemblyBinder();
                bf2.Binder = iab;
                //Open the file
                FileStream fs2 = new FileStream(settingFile_location, FileMode.Open);

                bool settingFileError = false;
                //Deserialize the binary file
                try
                {
                    st = (Settings4file)bf2.Deserialize(fs2);
                    fs2.Close();
                }
                catch (InvalidOperationException)
                {
                    settingFileError = true;
                    fs2.Close();
                    deleteSettingFileOrShutdown();
                }
                catch (SerializationException)
                {
                    settingFileError = true;
                    fs2.Close();
                    deleteSettingFileOrShutdown();
                }

                if (settingFileError == false)
                {
                    Settings.DBSrvIP       = st.DBSrvIP;
                    Settings.DBSrvPort     = st.DBSrvPort;
                    Settings.DBconnectID   = st.DBconnectID;
                    Settings.DBconnectPw   = PasswordEncoder.Decrypt(st.DBconnectPw);
                    Settings.endoPrintFile = st.endoPrintFile;
                    Settings.figureFolder  = st.figureFolder;
                }
            }
        }
示例#2
0
        public static void saveSettings()
        {
            Settings4file st = new Settings4file();

            st.DBSrvIP      = DBSrvIP;
            st.DBSrvPort    = DBSrvPort;
            st.DBconnectID  = DBconnectID;
            st.DBconnectPw  = PasswordEncoder.Encrypt(DBconnectPw);
            st.figureFolder = figureFolder;

            //Write to a binary file
            //Create a BinaryFormatter object
            BinaryFormatter bf1 = new BinaryFormatter();
            //Open the file
            FileStream fs1 = new FileStream(settingFile_location, FileMode.Create);

            //Serialize it and save to the binery file
            bf1.Serialize(fs1, st);
            fs1.Close();
        }
示例#3
0
        public static void saveSettings()
        {
            Settings4file st = new Settings4file();
            st.DBSrvIP = Settings.DBSrvIP;
            st.DBSrvPort = Settings.DBSrvPort;
            st.DBconnectID = Settings.DBconnectID;
            st.DBconnectPw = PasswordEncoder.Encrypt(Settings.DBconnectPw);
            st.figureFolder = Settings.figureFolder;

            //Write to a binary file
            //Create a BinaryFormatter object
            BinaryFormatter bf1 = new BinaryFormatter();
            //Open the file
            System.IO.FileStream fs1 =
                new System.IO.FileStream(Settings.settingFile_location, System.IO.FileMode.Create);
            //Serialize it and save to the binery file
            bf1.Serialize(fs1, st);
            fs1.Close();
        }
示例#4
0
        public static void readSettings()
        {
            if (System.IO.File.Exists(Settings.settingFile_location) == true)
            {
                Settings4file st = new Settings4file();

                //Read the binary file
                //Create a BinaryFormatter object
                BinaryFormatter bf2 = new BinaryFormatter();
                IgnoreAssemblyBinder iab = new IgnoreAssemblyBinder();
                bf2.Binder = iab;
                //Open the file
                System.IO.FileStream fs2 = new System.IO.FileStream(Settings.settingFile_location, System.IO.FileMode.Open);
                //Deserialize the binary file
                try
                {
                    st = (Settings4file)bf2.Deserialize(fs2);
                    fs2.Close();
                }
                catch (InvalidOperationException)
                {
                    DialogResult ret;
                    ret = MessageBox.Show(Properties.Resources.SettingFileBroken, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    fs2.Close();
                    if (ret == DialogResult.Yes)
                    {
                        file_control.delFile(Settings.settingFile_location);
                    }
                }

                Settings.DBSrvIP = st.DBSrvIP;
                Settings.DBSrvPort = st.DBSrvPort;
                Settings.DBconnectID = st.DBconnectID;
                Settings.DBconnectPw = PasswordEncoder.Decrypt(st.DBconnectPw);
                Settings.endoPrintFile = st.endoPrintFile;
                Settings.figureFolder = st.figureFolder;
            }
        }