SecureDelete.Schedule.HistoryManager.LoadHistory C# (CSharp) Method

LoadHistory() public method

Load the report database from disk.
public LoadHistory ( string path ) : bool
path string
return bool
        public bool LoadHistory(string path)
        {
            // check if the file exists
            if(File.Exists(path) == false) {
                Debug.ReportWarning("History file not found. Path: {0}", path);
                return false;
            }

            try {
                // create the store
                FileStore.FileStore store = new FileStore.FileStore();
                store.Encrypt = true;
                store.UseDPAPI = true;

                // load store
                if(store.Load(path) == false) {
                    Debug.ReportError("Error while loading store from path {0}", path);
                    return false;
                }

                // deserialize
                _categories = DeserializeHistory(store.ReadFile("history.dat"));

                if(_categories == null) {
                    // load failed, allocate history categories
                    _categories = new Dictionary<Guid, HistoryCategory>();
                    return false;
                }

                return true;
            }
            catch(Exception e) {
                Debug.ReportError("Error while loading task history. Exception: {0}", e.Message);
                return false;
            }
        }

Usage Example

示例#1
0
        private void button5_Click(object sender, EventArgs e)
        {
            if(MessageBox.Show("Do you really want to remove all task history ?", "SecureDelete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
                HistoryManager man = new HistoryManager();

                man.LoadHistory(SecureDeleteLocations.GetScheduleHistoryFile());
                man.Clear();
                man.SaveHistory(SecureDeleteLocations.GetScheduleHistoryFile());
            }
        }