Esempio n. 1
0
 public void OnLogin(User user)
 {
     _user = user;
     BinaryConnector.StaticSave(_user, GlobalConfig.UserDataFile);
     WindowVisibility = Visibility.Visible;
     ActivateItem(new MainControlViewModel(_eventAggregator, _user));
 }
Esempio n. 2
0
        public void CreateLocalFile(List <AppSession> data)
        {
            BinaryConnector.StaticSave(data, GlobalConfig.DataFilePath);
            BinaryFile file = EncodeIntoBinaryFile(GlobalConfig.DataFilePath);

            AddFile(file);
        }
Esempio n. 3
0
        public async Task SyncLogs(User user)
        {
            var api = ApiHelper.GetApiHelper();

            while (logs.Count > 0)
            {
                bool isPosted;
                try
                {
                    // !!!!!!!!!!!!!! NOT SENDING DATA TO SERVER !!!!!!!!!!!!!!!
                    isPosted = await api.PostLog(logs.Peek(), user);

                    if (isPosted)
                    {
                        logs.Dequeue();
                    }
                }
                catch (Exception)
                {
                    LogToTextFile(new ErrorLog
                    {
                        Severity = LogSeverity.Medium,
                        Type     = ErrorType.ConnectionError,
                        Text     = "Failed to sync logs, no connection to the server."
                    });
                    BinaryConnector.StaticSave(logs, GlobalConfig.LogCacheFilePath);
                    break;
                }
            }
            if (logs.Count == 0)
            {
                if (File.Exists(GlobalConfig.LogCacheFilePath))
                {
                    File.Delete(GlobalConfig.LogCacheFilePath);
                    LogToTextFile(new Log
                    {
                        Severity = LogSeverity.Low,
                        Type     = LogType.FileDeleted,
                        Text     = "Log cache file deleted after syncing properly."
                    });
                }
            }
        }
Esempio n. 4
0
 private void SaveSessionsToDisk()
 {
     BinaryConnector.StaticSave(GetAllSessions(), filePath);
 }