private void _ShowId() { string url = this._GetCode(InformerCode.BaseUrl); if (string.IsNullOrWhiteSpace(url)) { return; } try { this.PBConrolInformer.Image.Dispose(); this.PBConrolInformer.Image = (Image)WebGet.GetImage(url, this._clform._iLog); } catch (Exception) { this.PBConrolInformer.Image = (Image)Properties.Resources.InformerLoadingError; return; } this._Show(); }
private void bgNotifyWorker_DoWork(object sender, DoWorkEventArgs e) { try { if (this.bgNotifyWorker.CancellationPending) { e.Cancel = true; this.bgNotifyWorker.ReportProgress(0); return; } if ( (Properties.Settings.Default.USRUrl.Count < 3) || (string.IsNullOrWhiteSpace(Properties.Settings.Default.USRUrl[1])) ) { throw new ArgumentException( string.Format( Properties.Resources.fmtError, "URL " + Properties.Resources.txtSetupData, Properties.Resources.txtIncomplete ) ); } string jout, url = string.Format( Properties.Settings.Default.URLNotifySetup, Properties.Settings.Default.USRCoCServer, Properties.Settings.Default.USRUrl[1], new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); DateTime dtnow; CoCEnum.EventNotify type; bool isChangeMembers = false; int crw, cnp, cnt = 10; this._oldNotifyItems = crw = this.FLVNotify.Items.Count; this.bgNotifyWorker.ReportProgress(5); jout = WebGet.GetJsonString(url, this._iLog); if (string.IsNullOrWhiteSpace(jout)) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "Json " + Properties.Resources.txtRequest, Properties.Resources.txtIsEmpty ) ); } this.bgNotifyWorker.ReportProgress(cnt); DataTable dt = jout.JsonToDataTable <stClient.ClanNotifyClient>(); if (dt.Rows.Count < 1) { this.bgNotifyWorker.ReportProgress(0); throw new ArgumentException( string.Format( Properties.Resources.fmtError, "DataTable", Properties.Resources.txtIsEmpty ) ); } cnp = (int)(90 / dt.Rows.Count); cnp = ((cnp == 0) ? 1 : cnp); dtnow = DateTime.Now; string grpDate = dtnow.ToString("HH:mm dd-MM", CultureInfo.InvariantCulture); flatThreadSafe.Run(this, (Action)(() => this.TSCBGroup.Items.Add(grpDate))); ListViewGroup grp = new FlatListViewGroup( this.FLVNotify, new string[] { grpDate, string.Format( Properties.Resources.fmtListViewGroup, grpDate, dt.Rows.Count ) }, HorizontalAlignment.Left ).ListViewGroup(); foreach (DataRow dr in dt.Rows) { string ids, fmt1, fmt2; DataRow drn = this._dtnotify.NewRow(); drn.ItemArray = dr.ItemArray.Clone() as object[]; drn["dtin"] = dtnow; this._dtnotify.Rows.Add(drn); this.bgNotifyWorker.ReportProgress(cnt += cnp); try { ids = Convert.ToString(drn["id"], CultureInfo.InvariantCulture); if ( (string.IsNullOrWhiteSpace(ids)) || (!Enum.TryParse <CoCEnum.EventNotify>(ids, out type)) || // Check a valid event id (!(bool)Properties.Settings.Default[ids]) ) { throw new ArgumentException(); } fmt1 = stClient.Properties.ResourceNotify.ResourceManager.GetString("fmt1" + ids); fmt2 = stClient.Properties.ResourceNotify.ResourceManager.GetString("fmt2" + ids); if ( (string.IsNullOrWhiteSpace(fmt1)) || (string.IsNullOrWhiteSpace(fmt2)) ) { throw new ArgumentException(); } } catch (Exception) { continue; } switch (type) { case CoCEnum.EventNotify.MemberNew: case CoCEnum.EventNotify.MemberExit: case CoCEnum.EventNotify.ClanChangeMembers: { isChangeMembers = true; break; } } new FlatListViewItem( this.FLVNotify, grp, new string[] { "", grpDate, string.Format( fmt1, (string)drn["name"] as string, (string)drn["vold"] as string, (string)drn["vnew"] as string, (string)drn["vres"] as string, (string)drn["vs"] as string, (string)drn["vcalc"] as string, (string)drn["tag"] as string ), string.Format( fmt2, (string)drn["name"] as string, (string)drn["vold"] as string, (string)drn["vnew"] as string, (string)drn["vres"] as string, (string)drn["vs"] as string, (string)drn["vcalc"] as string, (string)drn["tag"] as string ), (string)drn["tag"] as string }, (string)drn["id"] as string, crw++ ); } if ( (this.TSTBNotifyFind.AutoCompleteCustomSource.Count == 0) || (isChangeMembers) ) { this.AutoCompleteNotifySelect(this.TSTBNotifyFind); } this.bgNotifyWorker.ReportProgress(90); if (crw > this._oldNotifyItems) { flatThreadSafe.Run(this, (Action)(() => this.FLVNotify.Items[this._oldNotifyItems].Selected = true)); } // Image Informer if (this._CheckSetupInformer()) { url = string.Format( Properties.Settings.Default.URLServerInformer, Properties.Settings.Default.USRCoCServer, Properties.Settings.Default.USRUrl[2], Properties.Settings.Default.USRInformerId, Properties.Settings.Default.USRCoCTag, new Random(DateTime.Now.Millisecond).Next(0, Int32.MaxValue) ); if (this.ImageInformer != null) { this.ImageInformer.Dispose(); this.ImageInformer = null; } try { this.ImageInformer = (Image)WebGet.GetImage(url, this._iLog); } catch (Exception ex) { this.ImageInformer = (Image)Properties.Resources.InformerLoadingError; throw ex; } finally { this.bgNotifyWorker.ReportProgress(100); } } } catch (Exception ex) { this._winMessageError(ex.Message); } finally { this.bgNotifyWorker.ReportProgress(0); } }