private bool Parse(string source, bool updateClient, out WiredAccount wiredAccount) { WiredInternetUsage wiredInternetUsage; try { // Convertir la source en objet using (XmlReader r = XmlReader.Create(new StringReader(source))) { XmlSerializer s = new XmlSerializer(typeof(WiredInternetUsage)); wiredInternetUsage = (WiredInternetUsage)s.Deserialize(r); } } catch (Exception seria) { wiredAccount = null; ParseException parseException = new ParseException(null, seria); parseException.OriginException = seria; DoError(parseException); return(false); } Message error = wiredInternetUsage.Messages.Message.FirstOrDefault(x => x.Severity == "error"); if (error != null) { throw new ApiException(error.Text); } // Transformation des données wiredAccount = WiredAccountFactory.CreateWiredAccount(wiredInternetUsage, Username); return(true); }
protected void DoDownloadDataEnd(WiredAccount wiredAccount) { if (OnDownloadDataEnd != null) { OnDownloadDataEnd(wiredAccount); } }
private void OnDownloadDataEnd(WiredAccount wiredAccount) { if (wiredAccount != null) { Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new ThreadStart(delegate { Account.Account.PeriodStart = wiredAccount.PeriodStart; Account.Account.PeriodEnd = wiredAccount.PeriodEnd.AddDays(1).AddMinutes(-1); Account.Account.Download = wiredAccount.DownloadedBytes; Account.Account.Upload = wiredAccount.UploadedBytes; Account.Account.CombinedMaximum = wiredAccount.MaxCombinedBytes; //Account.Account.Combined = wiredAccount.c //Account.Account.CombinedPercent = wiredAccount.CombinedPercent; UpdateUI(); Account.Account.Refresh(); })); } }
/// <summary> /// Met à jours un objet dans le cache /// </summary> /// <param name="token"></param> /// <param name="wiredAccount"></param> public void SetCache(string token, int period, WiredAccount wiredAccount) { _cache[GetKey(token, period)].WiredAccount = wiredAccount; }