Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            app_notify = new NotifyIcon();
            app_notify.Icon = new Icon(SystemIcons.Application, 40, 40);
            app_notify.Icon = (Icon)Properties.Resources.ResourceManager.GetObject("myappicon");
            app_notify.Visible = true;
            app_notify.DoubleClick += new EventHandler(NotifyIcon_DoubleClicked);

            notify_menu = new System.Windows.Forms.ContextMenu();
            MenuItem exit_item = new MenuItem("�˳�");
            notify_menu.MenuItems.Add(exit_item);
            exit_item.Click += new EventHandler(NotifyMenuExitItem_Clicked);

            app_notify.ContextMenu = notify_menu;

            //����������
            RootObj = new RTXSAPILib.RTXSAPIRootObj();
            //���÷�����IP
            RootObj.ServerIP = _ServerIP;
            //���÷������˿�
            RootObj.ServerPort = _ServerPort;

            //ͨ�������󴴽��û���֤����
            UserAuthObj = RootObj.UserAuthObj;
            //�����û���֤��Ӧ�¼�
            UserAuthObj.OnRecvUserAuthRequest += new _IRTXSAPIUserAuthObjEvents_OnRecvUserAuthRequestEventHandler(UserAuthObj_OnRecvUserAuthRequest);
            //����Ӧ��GUID
            UserAuthObj.AppGUID = _AppGUID;
            //����Ӧ����
            UserAuthObj.AppName = _AppName;

            UserManagerObj = RootObj.UserManager;
            DeptManagerObj = RootObj.DeptManager;
            OrgsManagerObj = ((RTXSAPIRootObj2)RootObj).OrgstructManager;

            updateAuthResult = new UpdateDisplayControl(AuthCompleted);
            updateSychResult = new UpdateDisplayControl(SychCompleted);

            try
            {
                //ע��Ӧ��
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| ����ע��Ӧ��..." + Environment.NewLine;
                UserAuthObj.RegisterApp();
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| Ӧ��ע��ɹ�..." + Environment.NewLine;
                //���Ӧ��
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| �������Ӧ��..." + Environment.NewLine; ;
                UserAuthObj.StartApp("", 8);
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| Ӧ������ɹ�..." + Environment.NewLine;

                // ���ͬ���߳�
                sychronThread = new Thread(new ThreadStart(AccountSychronization));
                sychronThread.Start();

                _AppRunning = true;
            }
            catch (COMException ex)
            {
                _AppRunning = false;
                this.authExecuteResultTxtBox.Text += ex.Message;
            }
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            app_notify              = new NotifyIcon();
            app_notify.Icon         = new Icon(SystemIcons.Application, 40, 40);
            app_notify.Icon         = (Icon)Properties.Resources.ResourceManager.GetObject("myappicon");
            app_notify.Visible      = true;
            app_notify.DoubleClick += new EventHandler(NotifyIcon_DoubleClicked);

            notify_menu = new System.Windows.Forms.ContextMenu();
            MenuItem exit_item = new MenuItem("退出");

            notify_menu.MenuItems.Add(exit_item);
            exit_item.Click += new EventHandler(NotifyMenuExitItem_Clicked);

            app_notify.ContextMenu = notify_menu;

            //创建根对象
            RootObj = new RTXSAPILib.RTXSAPIRootObj();
            //设置服务器IP
            RootObj.ServerIP = _ServerIP;
            //设置服务器端口
            RootObj.ServerPort = _ServerPort;

            //通过根对象创建用户认证对象
            UserAuthObj = RootObj.UserAuthObj;
            //订阅用户认证响应事件
            UserAuthObj.OnRecvUserAuthRequest += new _IRTXSAPIUserAuthObjEvents_OnRecvUserAuthRequestEventHandler(UserAuthObj_OnRecvUserAuthRequest);
            //设置应用GUID
            UserAuthObj.AppGUID = _AppGUID;
            //设置应用名
            UserAuthObj.AppName = _AppName;

            UserManagerObj = RootObj.UserManager;
            DeptManagerObj = RootObj.DeptManager;
            OrgsManagerObj = ((RTXSAPIRootObj2)RootObj).OrgstructManager;

            updateAuthResult = new UpdateDisplayControl(AuthCompleted);
            updateSychResult = new UpdateDisplayControl(SychCompleted);

            try
            {
                //注册应用
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| 正在注册应用..." + Environment.NewLine;
                UserAuthObj.RegisterApp();
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| 应用注册成功..." + Environment.NewLine;
                //启动应用
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| 正在启动应用..." + Environment.NewLine;;
                UserAuthObj.StartApp("", 8);
                this.authExecuteResultTxtBox.Text += DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "| 应用启动成功..." + Environment.NewLine;

                // 启动同步线程
                sychronThread = new Thread(new ThreadStart(AccountSychronization));
                sychronThread.Start();

                _AppRunning = true;
            }
            catch (COMException ex)
            {
                _AppRunning = false;
                this.authExecuteResultTxtBox.Text += ex.Message;
            }
        }