DeleteSettings() public static method

public static DeleteSettings ( ) : void
return void
        public bool RestoreInformationFromFile(string aPath)
        {
            FUserSettings.DeleteSettings();
            BackUp lBackup       = new BackUp();
            string lPathSecret   = Path.Combine(FDataFolder.FullName, InstanceId + ".secret");
            string lPathSettings = Path.Combine(FDataFolder.FullName, InstanceId + ".settings");
            string lPathExchange = Path.Combine(FDataFolder.FullName, InstanceId + ".exchange");

            using (FileStream lFileStream = new FileStream(aPath, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader lBinaryReader = new BinaryReader(lFileStream))
                {
                    lBackup.Version        = lBinaryReader.ReadInt32();
                    lBackup.LengthSecret   = lBinaryReader.ReadInt32();
                    lBackup.Secret         = lBinaryReader.ReadBytes(lBackup.LengthSecret);
                    lBackup.LengthSetting  = lBinaryReader.ReadInt32();
                    lBackup.Setting        = lBinaryReader.ReadBytes(lBackup.LengthSetting);
                    lBackup.LengthExchange = lBinaryReader.ReadInt32();
                    lBackup.Exchange       = lBinaryReader.ReadBytes(lBackup.LengthExchange);
                }
            }
            if (File.Exists(lPathSecret))
            {
                File.Delete(lPathSecret);
            }

            using (FileStream lFileStream = new FileStream(lPathSecret, FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter lBinaryWriter = new BinaryWriter(lFileStream))
                {
                    lBinaryWriter.Write(lBackup.Secret);
                }
            }
            if (File.Exists(lPathSettings))
            {
                File.Delete(lPathSettings);
            }
            using (FileStream lFileStream = new FileStream(lPathSettings, FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter lBinaryWriter = new BinaryWriter(lFileStream))
                {
                    lBinaryWriter.Write(lBackup.Setting);
                }
            }

            if (File.Exists(lPathExchange))
            {
                File.Delete(lPathExchange);
            }
            using (FileStream lFileStream = new FileStream(lPathExchange, FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter lBinaryWriter = new BinaryWriter(lFileStream))
                {
                    lBinaryWriter.Write(lBackup.Exchange);
                }
            }

            FUserSettings.LoadSettings();
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the listview with tasks.
        /// </summary>
        private void UpdateListView()
        {
            listViewTasks.Clear();
            listViewTasks.Columns.Add("User");
            listViewTasks.Columns.Add("Building");
            listViewTasks.Columns.Add("Time");
            listViewTasks.Columns.Add("Day");
            List <Setting> settings = null;

            try
            {
                settings = SettingsManager.ReadSettings();
            }
            catch (IOException)
            {
                return;
            }
            foreach (Setting setting in settings)
            {
                string[] row  = ToStringArray(setting);
                var      item = new ListViewItem(row);
                listViewTasks.Items.Add(item);
            }

            if (listViewTasks.Items.Count < 1)
            {
                TaskScheduler.RemoveTask();
                SettingsManager.DeleteSettings();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Starts the bot. Loops through each settings and tries to book the room for each setting.
 /// </summary>
 public void Run()
 {
     Console.WriteLine("Kronox Bot started.");
     foreach (var setting in SettingsManager.ReadSettings())
     {
         Console.WriteLine("Tries to book a room...");
         ReadSetting(setting);
         TryToBookRoom();
     }
     SettingsManager.DeleteSettings();
 }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         CustomList <Settings> lstSettings = _SettingsList;
         foreach (Settings s in lstSettings)
         {
             s.Delete();
         }
         if (lstSettings.Count != 0)
         {
             ManagerSettings.DeleteSettings(ref lstSettings);
             ClearControls();
             InitializeSession();
             // Message.ShowMessage(StaticInfo.DeletedSuccessfullyMsg);
         }
     }
     catch (Exception ex)
     {
         // Message.ShowMessage(StaticInfo.DeletedErrorMsg);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 执行命令。
        /// </summary>
        /// <param name="context">命令执行上下文。</param>
        public override void Execute(CommandExecuteContext context)
        {
            var setting = SettingsManager.LoadSettings()
                          .FirstOrDefault(i => i.Name.Equals(TenantName, StringComparison.OrdinalIgnoreCase));

            if (setting == null)
            {
                context.WriteLine("找不到名称为 '{0}' 的租户。", TenantName);
                return;
            }
            if (!Quiet)
            {
                context.WriteLine("确定要删除租户 '{0}' 吗?\t输入'Y'继续执行,输入其他则终止执行。", setting.Name);
                var t = context.Read("y");
                if (!t.Equals("y", StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
            }

            SettingsManager.DeleteSettings(TenantName);
            context.WriteLine("成功删除租户 '{0}'。", TenantName);
        }