/// <summary>
        /// 成功返回登陆用户名,失败返回null
        /// </summary>
        private string loginYongYou()
        {
            Configuration cfa     = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            String        userKey = cfa.AppSettings.Settings["userKey"].Value;
            String        pswKey  = cfa.AppSettings.Settings["pswKey"].Value;
            string        result  = YongYouHandler.userLogin(userKey, pswKey);

            return(result);
        }
        /// <summary>
        /// 主方法
        /// </summary>
        private void mainFunction(object arg)
        {
            init();
            while (threadFlag)
            {
                updateStatusStripLeftDelegate("正在获取最新任务……");
                //获取消息
                string html = YongYouHandler.getToDoTaskHtmlUl();
                if (html == HTTPRequests.CONN_ERR)
                {
                    lock (padlock)
                    {
                        updateStatusStripLeftDelegate("连接内网失败,正在重连……");
                        updateStatusStripCenterDelegate("网络状态:无法连接办公网");
                        threadFlag  = false;
                        checkThread = null;
                        startThread();
                        return;
                    }
                }
                else
                {
                    updateStatusStripLeftDelegate("已获取最新任务");
                    //显示到主页面中
                    updateWebBrowserDelegate(html);
                    //获取任务列表
                    List <ToDoTask> toDoTasks = YongYouHandler.getToDoTasks(html);
                    if (oldToDoTasks != null)
                    {
                        //找出有其中新增的任务列表
                        List <ToDoTask> newToDoTasks = YongYouHandler.getNewToDoTaskList(toDoTasks, oldToDoTasks);
                        //提示新增的任务
                        bool wechatSuccess = alertToDoTaskList(newToDoTasks);
                        if (!wechatSuccess)
                        {
                            netContectionStastion.isConnectInternet = false;
                            updateStatusStripCenterDelegate("网络状态:办公网");
                        }
                        else
                        {
                            netContectionStastion.isConnectInternet = true;
                            updateStatusStripCenterDelegate("网络状态:双网");
                        }
                    }
                    oldToDoTasks = toDoTasks;
                    updateStatusStripLeftDelegate("获取最新任务成功!");

                    Thread.Sleep(threadInterval);
                }
            }
            checkThread = null;
        }
Exemplo n.º 3
0
        private void  login()
        {
            updateStatusStripLeft("正在登陆……");
            Configuration cfa     = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            String        userKey = cfa.AppSettings.Settings["userKey"].Value;
            String        pswKey  = cfa.AppSettings.Settings["pswKey"].Value;
            string        result  = YongYouHandler.userLogin(userKey, pswKey);

            if (result != null)
            {
                updateStatusStripRight("欢迎您," + result);
            }
            else
            {
                MessageBox.Show("登录失败,请检查");
                this.Close();
            }
        }