예제 #1
0
        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"));
            }
        }
예제 #2
0
        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();
        }
예제 #3
0
        public async Task <ReturnResult> DownHtml(AsyncCalls async, string url)
        {
            HttpClient client = new HttpClient();

            byte[] html = await client.GetByteArrayAsync(url);

            return(async.RET(html));
        }
예제 #4
0
        public async Task <ReturnResult> DownHtml(AsyncCalls async, string url)
        {
            WebClient client = new WebClient();

            byte[] html = await client.DownloadDataTaskAsync(url);

            return(async.RET(html));
        }
예제 #5
0
        public JobProgress(Entities.JobProgress Progress)
        {
            InitializeComponent();

            this.appUpdAsyncHelper = new AsyncCalls();

            job = Progress;
            if (job != null)
            {
                job.PropertyChanged += new PropertyChangedEventHandler(job_PropertyChanged);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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));
        }
예제 #9
0
        public FrmAbout()
        {
            InitializeComponent();
            CreateControls();
            SetupTexts();

            this.tlpUpdates.Visible = false;

            this.asyncHelper = new AsyncCalls();

            AppUpdateController.UpdateInfo.PropertyChanged += new
                                                              PropertyChangedEventHandler(UpdateInfo_PropertyChanged);

            UpdateData();
        }
예제 #10
0
        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);
        }
예제 #12
0
        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());
        }
예제 #13
0
        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);
        }
예제 #14
0
 public async Task Wrile(AsyncCalls client, string msg)
 {
     await Task.Run(() => Console.WriteLine(msg));
 }
예제 #15
0
 public static async Task <string> GetNick(this AsyncCalls async)
 {
     return((await async.CR((int)Cmdtype.GetNick))?.First?.Value <string>());
 }
예제 #16
0
 public static void SetUserList(this AsyncCalls async, List <UserInfo> userlist)
 {
     async.CV((int)Cmdtype.SetAllUser, userlist);
 }
예제 #17
0
 public static Task <ReturnResult> GetTime(AsyncCalls async)
 {
     return(Task.FromResult <ReturnResult>(async.RET(DateTime.Now)));
 }
예제 #18
0
 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>());
 }
예제 #19
0
        public async Task Message(AsyncCalls async, string msg)
        {
            msg += (await async.Get <IPacker>().GetTimeAsync())?.First?.Value <DateTime>();

            Console.WriteLine(msg);
        }