示例#1
0
        public static SettingItems Load()
        {
            SettingItems settings = new SettingItems();

            if (!File.Exists(Application.StartupPath + "\\config.ini"))
            {
                return(null);
            }
            byte[]     arrByte = new byte[1024];
            FileStream fs      = new FileStream(Application.StartupPath + "\\config.ini", FileMode.Open, FileAccess.Read);

            fs.Read(arrByte, 0, 1024);
            fs.Close();
            int nLength = PubHelper.byteToInt(arrByte);

            //下面这个判断,是为了防止文件中记录的长度被改写导致溢出
            if (nLength >= 1020)
            {
                nLength = 1020;
            }

            byte[] arrEncryptByte = new byte[nLength];
            for (int i = 0; i < nLength; i++)
            {
                arrEncryptByte[i] = arrByte[i + 4];
            }

            settings = (SettingItems)(Serialize.DecryptToObject(arrEncryptByte));
            return(settings);
        }
示例#2
0
        public static void Save(SettingItems settings)
        {
            FileStream fs = new FileStream(Application.StartupPath + "\\config.ini", FileMode.OpenOrCreate);

            byte[] arrEncryptByte = Serialize.EncryptToBytes(settings);
            byte[] arrLength      = PubHelper.intToByte(arrEncryptByte.Length); //将长度(整数)保存在4个元素的字节数组中
            fs.Write(arrLength, 0, arrLength.Length);
            fs.Write(arrEncryptByte, 0, arrEncryptByte.Length);
            fs.Close();
        }
示例#3
0
        //构造函数
        public QueueBase()
        {
            SettingItems settings = AppSettings.Load();

            if (settings == null)
            {
                settings = AppSettings.LoadDefault();
            }
            iMaxLengthInMem = settings.MaxLengthInMem;
        }
示例#4
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="DatabaseConnectionString">数据库连接串</param>
        public OracleDatabase()
        {
            _database_type = "Oracle";
            SettingItems settings = AppSettings.Load();

            if (settings == null)
            {
                settings = AppSettings.LoadDefault();
            }
            _connection_string = "Data Source=" + settings.DBServer + ";User Id=" + settings.DBUserName + ";Password="******";database=" + settings.DBName;
        }
示例#5
0
        public static Database CreateDatabase()
        {
            Database     db;
            SettingItems settings = AppSettings.Load();

            if (settings == null)
            {
                settings = AppSettings.LoadDefault();
            }

            string strDBType = settings.DBType;

            if (strDBType == "SQL Server")
            {
                db = new SqlDatabase();
            }
            else
            {
                db = new OracleDatabase();
            }

            return(db);
        }
示例#6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            GlobalPool.UserInfoRobotEnabled = chkUserInfo.Checked;
            GlobalPool.TagRobotEnabled = chkTag.Checked;
            GlobalPool.StatusRobotEnabled = chkStatus.Checked;
            GlobalPool.CommentRobotEnabled = chkComment.Checked;

            SettingItems settings = new SettingItems();
            settings.MaxLengthInMem = tbQueueLength.Value;
            settings.DBType = drplstDBType.SelectedItem.ToString();
            settings.DBServer = txtDBServer.Text.Trim();
            settings.DBUserName = txtDBUserName.Text.Trim();
            settings.DBPwd = txtDBPwd.Text;
            settings.DBName = txtDBName.Text.Trim();

            settings.UserInfoRobot = chkUserInfo.Checked;
            settings.TagsRobot = chkTag.Checked;
            settings.StatusesRobot = chkStatus.Checked;
            settings.CommentsRobot = chkComment.Checked;
            settings.ConfirmRelationship = chkConfirmRelationship.Checked;

            AppSettings.Save(settings);

            MessageBox.Show("Settings have been saved and will be used when new crawling starts. ", "Sinawler");
        }
示例#7
0
        private void ShowSettings(SettingItems settings)
        {
            tbQueueLength.Value = settings.MaxLengthInMem;
            numQueueLength.Value = settings.MaxLengthInMem;

            if (settings.DBType == "SQL Server")
                drplstDBType.SelectedIndex = 0;
            else
                drplstDBType.SelectedIndex = 1;

            txtDBServer.Text = settings.DBServer;
            txtDBUserName.Text = settings.DBUserName;
            txtDBPwd.Text = settings.DBPwd;
            txtDBName.Text = settings.DBName;

            GlobalPool.UserInfoRobotEnabled = settings.UserInfoRobot;
            GlobalPool.TagRobotEnabled = settings.TagsRobot;
            GlobalPool.StatusRobotEnabled = settings.StatusesRobot;
            GlobalPool.CommentRobotEnabled = settings.CommentsRobot;

            chkUserInfo.Checked = settings.UserInfoRobot;
            chkTag.Checked = settings.TagsRobot;
            chkStatus.Checked = settings.StatusesRobot;
            chkComment.Checked = settings.CommentsRobot;
            chkConfirmRelationship.Checked = settings.ConfirmRelationship;
        }
示例#8
0
        public static SettingItems Load()
        {
            SettingItems settings = new SettingItems();
            if (!File.Exists(Application.StartupPath + "\\config.ini"))
                return null;
            byte[] arrByte = new byte[1024];
            FileStream fs = new FileStream(Application.StartupPath + "\\config.ini", FileMode.Open, FileAccess.Read);
            fs.Read(arrByte, 0, 1024);
            fs.Close();
            int nLength = PubHelper.byteToInt(arrByte);
            //下面这个判断,是为了防止文件中记录的长度被改写导致溢出
            if (nLength >= 1020) nLength = 1020;

            byte[] arrEncryptByte = new byte[nLength];
            for (int i = 0; i < nLength; i++)
                arrEncryptByte[i] = arrByte[i + 4];

            settings = (SettingItems)(Serialize.DecryptToObject(arrEncryptByte));
            return settings;
        }
示例#9
0
 public static void Save(SettingItems settings)
 {
     FileStream fs = new FileStream(Application.StartupPath + "\\config.ini", FileMode.OpenOrCreate);
     byte[] arrEncryptByte = Serialize.EncryptToBytes(settings);
     byte[] arrLength = PubHelper.intToByte(arrEncryptByte.Length);  //将长度(整数)保存在4个元素的字节数组中
     fs.Write(arrLength, 0, arrLength.Length);
     fs.Write(arrEncryptByte, 0, arrEncryptByte.Length);
     fs.Close();
 }