public static async Task <ReturnResult> IsLogOn(AsyncCalls async, string username) { if (UserList.Find(p => p.UserName == username) == null) { UserInfo user = new UserInfo() { UserName = username, token = async.AsyncUser }; async.UserToken = user; async.IsValidate = true; user.Nick = await async.GetNick(); async.SetUserList(UserList); foreach (var item in UserList) { item.token.AddUser(user); } async.AsyncUser.UserDisconnect += AsyncUser_UserDisconnect; UserList.Add(user); return(async.RET(true)); } else { return(async.RET(false, "username not use")); } }
public Statusbar(StatusController.Controller.StatusController controller) { this.RightToLeft = View.LayoutDirection; this.RenderMode = ToolStripRenderMode.ManagerRenderMode; this.AutoSize = false; this.Dock = System.Windows.Forms.DockStyle.Bottom; this.asyncHelper = new AsyncCalls(); this.currentState = StatusTypes.Info; if (Presentation.View.Theme != null) { this.BackColor = Presentation.View.Theme.ToolBarBackColor; this.ForeColor = Presentation.View.Theme.ToolBarForeColor; this.Font = Presentation.View.Theme.FormLabelFont; } else { this.ForeColor = Color.Black; this.Font = new Font("Tahoma", 9, FontStyle.Bold); } SetupLabel(); LoadImages(); LoadColors(); SetupTimer(); controller.RegisterForEvents(this); this.asyncHelper = new AsyncCalls(); }
public async Task <ReturnResult> DownHtml(AsyncCalls async, string url) { HttpClient client = new HttpClient(); byte[] html = await client.GetByteArrayAsync(url); return(async.RET(html)); }
public async Task <ReturnResult> DownHtml(AsyncCalls async, string url) { WebClient client = new WebClient(); byte[] html = await client.DownloadDataTaskAsync(url); return(async.RET(html)); }
public JobProgress(Entities.JobProgress Progress) { InitializeComponent(); this.appUpdAsyncHelper = new AsyncCalls(); job = Progress; if (job != null) { job.PropertyChanged += new PropertyChangedEventHandler(job_PropertyChanged); } }
public static async Task <ReturnResult> StartDown(AsyncCalls async, string url) { var htmldata = (await async.CR(2001, url))?[0]?.Value <byte[]>(); if (htmldata != null) { string html = Encoding.UTF8.GetString(htmldata); return(async.RET(html)); } return(async.RET());// or async.RET(null); }
public async Task <int> TestRec(AsyncCalls async, int count) { count--; if (count > 1) { var x = (await async.Func(2500, count)); if (x != null && x.IsHaveValue) { count = x.As <int>();; } } return(count); }
public static async Task <ReturnResult> TestRec(AsyncCalls async, int count) { count--; if (count > 1) { var x = (await async.Get <IClientPacker>().TestRec(count))?[0]?.Value <int>(); if (x != null && x.HasValue) { count = x.Value; } } return(async.RET(count)); }
public FrmAbout() { InitializeComponent(); CreateControls(); SetupTexts(); this.tlpUpdates.Visible = false; this.asyncHelper = new AsyncCalls(); AppUpdateController.UpdateInfo.PropertyChanged += new PropertyChangedEventHandler(UpdateInfo_PropertyChanged); UpdateData(); }
public async Task <ReturnResult> TestRec(AsyncCalls async, int count) { count--; if (count > 1) { var x = (await async.CR(2500, count))?[0]?.Value <int>(); if (x != null && x.HasValue) { count = x.Value; } } return(async.RET(count)); }
public StatusLabelAppUpdate() { this.asyncHelper = new AsyncCalls(); this.Name = "status_app_update"; this.RightToLeft = View.LayoutDirection; this.Image = DomainModel.Application.ResourceManager.GetImage("flag_green"); this.ToolTipText = Resources.Texts.stat_upd_up_to_date; this.AutoToolTip = false; this.menu = new ContextMenuStrip(); this.menu.ItemClicked += new ToolStripItemClickedEventHandler(menu_ItemClicked); //this.menu. AppUpdateController.UpdateInfo.PropertyChanged += new PropertyChangedEventHandler(UpdateInfo_PropertyChanged); this.MouseUp += new MouseEventHandler(StatusLabelAppUpdate_MouseUp); }
public static async Task <ReturnResult> ToMessage(AsyncCalls async, string account, string msg) { var userinfo = async.Token <UserInfo>(); if (userinfo != null && async.IsValidate == true) { var touser = UserList.Find(p => p.UserName == account); if (touser != null) { var ret = await touser.token.MakeAsync(async).MsgToUser(userinfo.UserName, msg); if (ret != null) { return(async.RET(ret)); } } } return(async.RET()); }
public bool CopyDirectory(AsyncCalls async, DirectoryInfo dir, DirectoryInfo target) { if (target.FullName.IndexOf(dir.FullName) == 0) { return(false); } DirectoryInfo targetdir = null; string targetpath = Path.Combine(target.FullName, dir.Name).Replace("\\", "/"); if (!Directory.Exists(path: targetpath)) { targetdir = Directory.CreateDirectory(path: targetpath); } else { targetdir = new DirectoryInfo(targetpath); } foreach (var item in dir.GetFileSystemInfos()) { if (item is DirectoryInfo p) { CopyDirectory(async, p, new DirectoryInfo(targetdir.FullName)); } else if (item is FileInfo x) { var file = Path.Combine(targetdir.FullName, x.Name).Replace("\\", "/"); x.CopyTo(file, true); async.AsyncUser.Action(20000, file + " Copy OK!"); } } return(true); }
public async Task Wrile(AsyncCalls client, string msg) { await Task.Run(() => Console.WriteLine(msg)); }
public static async Task <string> GetNick(this AsyncCalls async) { return((await async.CR((int)Cmdtype.GetNick))?.First?.Value <string>()); }
public static void SetUserList(this AsyncCalls async, List <UserInfo> userlist) { async.CV((int)Cmdtype.SetAllUser, userlist); }
public static Task <ReturnResult> GetTime(AsyncCalls async) { return(Task.FromResult <ReturnResult>(async.RET(DateTime.Now))); }
public static async Task <string> MsgToUser(this AsyncCalls async, string username, string msg) { return((await async.CR((int)Cmdtype.MsgToUser, username, msg))?.First?.Value <string>()); }
public async Task Message(AsyncCalls async, string msg) { msg += (await async.Get <IPacker>().GetTimeAsync())?.First?.Value <DateTime>(); Console.WriteLine(msg); }