コード例 #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
ファイル: PackHander.cs プロジェクト: 12345fish/ZYNet
        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
ファイル: PackHandler.cs プロジェクト: 12345fish/ZYNet
        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
ファイル: PackHandler.cs プロジェクト: 12345fish/ZYNet
        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
ファイル: FrmAbout.cs プロジェクト: HamedMousavi/BreweryTax
        public FrmAbout()
        {
            InitializeComponent();
            CreateControls();
            SetupTexts();

            this.tlpUpdates.Visible = false;

            this.asyncHelper = new AsyncCalls();

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

            UpdateData();
        }
コード例 #10
0
ファイル: PackHander.cs プロジェクト: 12345fish/ZYNet
        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));
        }
コード例 #11
0
        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
ファイル: ExtendMethods.cs プロジェクト: 12345fish/ZYNet
 public static async Task <string> GetNick(this AsyncCalls async)
 {
     return((await async.CR((int)Cmdtype.GetNick))?.First?.Value <string>());
 }
コード例 #16
0
ファイル: ExtendMethods.cs プロジェクト: 12345fish/ZYNet
 public static void SetUserList(this AsyncCalls async, List <UserInfo> userlist)
 {
     async.CV((int)Cmdtype.SetAllUser, userlist);
 }
コード例 #17
0
ファイル: PackHandler.cs プロジェクト: 12345fish/ZYNet
 public static Task <ReturnResult> GetTime(AsyncCalls async)
 {
     return(Task.FromResult <ReturnResult>(async.RET(DateTime.Now)));
 }
コード例 #18
0
ファイル: ExtendMethods.cs プロジェクト: 12345fish/ZYNet
 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
ファイル: PackHander.cs プロジェクト: 12345fish/ZYNet
        public async Task Message(AsyncCalls async, string msg)
        {
            msg += (await async.Get <IPacker>().GetTimeAsync())?.First?.Value <DateTime>();

            Console.WriteLine(msg);
        }