示例#1
0
        public void ServerPullThreadWorker()
        {
            while (true)
            {
                if (!ignoreNextPullTick)
                {
                    if (selectedService != null)
                    {
                        lock (selectedService)
                        {
                            Application.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                ModuleInfo item = (ModuleInfo)selectedService.Tag;
                                AdminNetwork.SendServiceLogRequest(item.Id, lastLogReceived);
                            }));
                        }
                    }

                    AdminNetwork.SendModuleListRequest();
                }
                else
                {
                    // Could reset this value either in the receive event or here.
                    ignoreNextPullTick = false;
                }

                Thread.Sleep(2000);
            }
        }
        public static void Enqueue(PageEntry entry)
        {
            Server.Admin.AdminNetwork.Distribute(AdminNetwork.Compress(new Server.Admin.NewPage(entry)));

            m_List.Add(entry);
            m_KeyedBySender[entry.Sender] = entry;

            bool isStaffOnline = false;

            foreach (NetState ns in NetState.Instances)
            {
                Mobile m = ns.Mobile;

                if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m))
                {
                    m.SendMessage("A new page has been placed in the queue.");
                }

                if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && m.LastMoveTime >= (DateTime.Now - TimeSpan.FromMinutes(10.0)))
                {
                    isStaffOnline = true;
                }
            }

            if (!isStaffOnline)
            {
                entry.Sender.SendMessage("We are sorry, but no staff members are currently available to assist you.  Your page will remain in the queue until one becomes available, or until you cancel it manually.");
            }

            if (Email.SpeechLogPageAddresses != null && entry.SpeechLog != null)
            {
                SendEmail(entry);
            }
        }
示例#3
0
文件: FrmAppAdmin.cs 项目: j0nat/JCIW
        private void btnPublish_Click(object sender, EventArgs e)
        {
            try
            {
                if (((ListView)listView1).SelectedItems.Count > 0)
                {
                    ListViewItem viewItem = ((ListView)listView1).SelectedItems[0];

                    ModuleInfo moduleInfo = (ModuleInfo)viewItem.Tag;

                    if (moduleInfo != null)
                    {
                        if (moduleInfo.Enabled == 0)
                        {
                            AdminNetwork.SendEnableApp(moduleInfo.Id);
                        }
                        else
                        {
                            AdminNetwork.SendDisableApp(moduleInfo.Id);
                        }
                    }
                }
            }
            catch
            {
            }
        }
示例#4
0
文件: FrmGroups.cs 项目: j0nat/JCIW
        public FrmGroups()
        {
            InitializeComponent();

            NetworkingEvents.GroupListResultEvent        += NetworkingEvents_GroupListResultEvent;
            NetworkingEvents.AddRemoveGroupReceivedEvent += NetworkingEvents_AddRemoveGroupReceivedEvent;
            AdminNetwork.SendRequestGroupList();
        }
示例#5
0
 private void FrmAccount_Load(object sender, EventArgs e)
 {
     NetworkingEvents.GroupListResultEvent        += NetworkingEvents_GroupListResultEvent;
     NetworkingEvents.GroupAddedToUserResultEvent += NetworkingEvents_GroupAddedToUserResultEvent;
     NetworkingEvents.UserGroupDeletedResultEvent += NetworkingEvents_UserGroupDeletedResultEvent;
     NetworkingEvents.PasswordChangeResultEvent   += NetworkingEvents_PasswordChangeResultEvent;
     NetworkingEvents.AccountUpdatedResultEvent   += NetworkingEvents_AccountUpdatedResultEvent;
     AdminNetwork.SendRequestGroupUserList(account.id);
 }
示例#6
0
        private void btnSetPassword_Click(object sender, EventArgs e)
        {
            string newPassword = Interaction.InputBox("Type in a new password for " + account.firstname + " " + account.lastname, "Change password", "");

            if (newPassword.Length > 3)
            {
                AdminNetwork.SendUpdateAccountPassword(account.id, newPassword);
            }
        }
示例#7
0
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            FrmRegister frmRegister = new FrmRegister();

            if (frmRegister.ShowDialog() == DialogResult.OK)
            {
                NetworkingEvents.AccountListResultEvent += NetworkingEvents_AccountListResultEvent;
                AdminNetwork.SendRequestAccountList();
            }
        }
示例#8
0
        public FrmAccountAdmin()
        {
            InitializeComponent();

            AdminNetwork.SendRequestAccountList();
            NetworkingEvents.AccountListResultEvent   += NetworkingEvents_AccountListResultEvent;
            NetworkingEvents.DeleteAccountResultEvent += NetworkingEvents_DeleteAccountResultEvent;

            listView1.MouseDoubleClick += ListView1_MouseDoubleClick;
        }
示例#9
0
        public FrmSelectGroup()
        {
            InitializeComponent();

            NetworkingEvents.GroupListResultEvent += NetworkingEvents_GroupListResultEvent;
            AdminNetwork.SendRequestGroupList();

            GROUP = null;

            listView1.MouseDoubleClick += ListView1_MouseDoubleClick;
        }
示例#10
0
        private void btnUpdateAccount_Click(object sender, EventArgs e)
        {
            string username  = txtUsername.Text;
            string firstname = txtFirstname.Text;
            string lastname  = txtLastname.Text;

            if (username != account.username || lastname != account.lastname || firstname != account.firstname)
            {
                AdminNetwork.SendUpdateAccountInformation(account.id, username, firstname, lastname);
            }
        }
示例#11
0
文件: FrmAppAdmin.cs 项目: j0nat/JCIW
        private void FrmAppAdmin_Load(object sender, EventArgs e)
        {
            NetworkingEvents.AccountUpdatedResultEvent += NetworkingEvents_AccountUpdatedResultEvent;
            NetworkingEvents.AppListReceivedEvent      += NetworkingEvents_AppListReceivedEvent;
            AdminNetwork.SendRequestAllAppList();

            listView1.ItemSelectionChanged += ListView1_ItemSelectionChanged;
            listView1.DoubleClick          += ListView1_DoubleClick;

            btnPublish.Enabled = false;
        }
示例#12
0
文件: FrmGroups.cs 项目: j0nat/JCIW
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            FrmAddGroup frmAddGroup = new FrmAddGroup();

            if (frmAddGroup.ShowDialog() == DialogResult.OK)
            {
                string name        = FrmAddGroup.name;
                string description = FrmAddGroup.description;
                frmAddGroup.Dispose();

                AdminNetwork.SendAddGroup(name, description);
            }
        }
示例#13
0
        private void ServiceItem_EnableClickEvent(ServiceItem serviceItem)
        {
            ModuleInfo item = (ModuleInfo)serviceItem.Tag;

            if (item.Enabled == 0)
            {
                // ENABLE
                AdminNetwork.SendEnableService(item.Id);
            }
            else
            {
                AdminNetwork.SendDisableService(item.Id);
            }
        }
示例#14
0
        private void btnGroupAdd_Click(object sender, EventArgs e)
        {
            FrmSelectGroup frmSelectGroup = new FrmSelectGroup();

            if (frmSelectGroup.ShowDialog() == DialogResult.OK)
            {
                if (FrmSelectGroup.GROUP != null)
                {
                    long groupId = FrmSelectGroup.GROUP.id;
                    frmSelectGroup.Dispose();

                    AdminNetwork.SendAddGroupToUser(account.id, groupId);
                }
            }
        }
示例#15
0
文件: FrmGroups.cs 项目: j0nat/JCIW
        private void btnRemoveGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if ((listView1).SelectedItems.Count > 0)
                {
                    ListViewItem viewItem = (listView1).SelectedItems[0];

                    Group group = (Group)viewItem.Tag;

                    AdminNetwork.SendDeleteGroup(group.id);
                }
            }
            catch
            {
            }
        }
示例#16
0
        public void LoginClicked(string password)
        {
            IPAddress ipAddress = ParseHost(txtHost);

            if (ipAddress != null)
            {
                AdminNetwork.IpAddress = ipAddress.ToString();

                AdminNetwork.Initialize();

                AdminNetwork.SendLoginRequest(txtUsername, password);
            }
            else
            {
                MessageBox.Show("Invalid host.");
            }
        }
示例#17
0
        public void ManualUpdate()
        {
            ignoreNextPullTick = true;

            if (selectedService != null)
            {
                lock (selectedService)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        ModuleInfo item = (ModuleInfo)selectedService.Tag;
                        AdminNetwork.SendServiceLogRequest(item.Id, lastLogReceived);
                    }));
                }
            }

            AdminNetwork.SendModuleListRequest();
        }
示例#18
0
        private void btnGroupDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if ((listView1).SelectedItems.Count > 0)
                {
                    ListViewItem viewItem = (listView1).SelectedItems[0];

                    Group group = (Group)viewItem.Tag;

                    AdminNetwork.SendRemoveGroupFromApp(moduleInfo.Id, group.id);

                    listView1.Items.Remove(viewItem);
                }
            }
            catch
            {
            }
        }
示例#19
0
文件: FrmAppAdmin.cs 项目: j0nat/JCIW
        private void btnDeleteApp_Click(object sender, EventArgs e)
        {
            try
            {
                if (((ListView)listView1).SelectedItems.Count > 0)
                {
                    ListViewItem viewItem = ((ListView)listView1).SelectedItems[0];

                    ModuleInfo moduleInfo = (ModuleInfo)viewItem.Tag;

                    if (moduleInfo != null)
                    {
                        AdminNetwork.SendDeleteService(moduleInfo.Id);
                        listView1.Items.Remove(viewItem);
                    }
                }
            }
            catch
            {
            }
        }
示例#20
0
文件: FrmRegister.cs 项目: j0nat/JCIW
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;
            string firstname = txtFirstname.Text;
            string lastname  = txtLastname.Text;

            if (username.Length > 1 && password.Length > 1 && firstname.Length > 1 && lastname.Length > 1)
            {
                btnRegister.Enabled = false;
                isBusy = true;

                AdminNetwork.SendRegisterRequest(username, password, firstname, lastname);

                NetworkingEvents.RegisterResultEvent += NetworkingEvents_RegisterResultEvent;
            }
            else
            {
                MessageBox.Show("Information entered was too short.");
            }
        }
示例#21
0
        private void btnDeleteAccount_Click(object sender, EventArgs e)
        {
            try
            {
                if (((ListView)listView1).SelectedItems.Count > 0)
                {
                    ListViewItem viewItem = ((ListView)listView1).SelectedItems[0];

                    Account account = (Account)viewItem.Tag;

                    if (account != null)
                    {
                        AdminNetwork.SendRequestDeleteAccount(account.id);
                    }
                }
                else
                {
                    MessageBox.Show("No account selected.");
                }
            }
            catch
            {
            }
        }
示例#22
0
        public bool CommandEntered(string command)
        {
            bool entered = false;

            if (command.Length > 0)
            {
                if (selectedService != null)
                {
                    if (selectedService.Tag != null)
                    {
                        ModuleInfo item = (ModuleInfo)selectedService.Tag;

                        AdminNetwork.SendServiceCommand(item.Id, command);

                        //     OutputText += "CLIENT: " + command + "\n";
                        AddOutputLine("CLIENT", command, Brushes.LightGreen);

                        entered = true;
                    }
                }
            }

            return(entered);
        }
示例#23
0
 private void FrmAppGroups_Load(object sender, EventArgs e)
 {
     NetworkingEvents.AppGroupListResultEvent   += NetworkingEvents_AppGroupListResultEvent;
     NetworkingEvents.AccountUpdatedResultEvent += NetworkingEvents_AccountUpdatedResultEvent;
     AdminNetwork.SendRequestAppGroupList(moduleInfo.Id);
 }
示例#24
0
文件: FrmGroups.cs 项目: j0nat/JCIW
 private void NetworkingEvents_AddRemoveGroupReceivedEvent(Networking.Data.ResponseCodes.GenericResponse response)
 {
     NetworkingEvents.GroupListResultEvent += NetworkingEvents_GroupListResultEvent;
     AdminNetwork.SendRequestGroupList();
 }
示例#25
0
 private void NetworkingEvents_UserGroupDeletedResultEvent(Networking.Data.ResponseCodes.GenericResponse response)
 {
     NetworkingEvents.GroupListResultEvent += NetworkingEvents_GroupListResultEvent;
     AdminNetwork.SendRequestGroupUserList(account.id);
 }
示例#26
0
 private void NetworkingEvents_DeleteAccountResultEvent(Networking.Data.ResponseCodes.GenericResponse response)
 {
     NetworkingEvents.AccountListResultEvent += NetworkingEvents_AccountListResultEvent;
     AdminNetwork.SendRequestAccountList();
 }
示例#27
0
 private void NetworkingEvents_AccountUpdatedResultEvent(Networking.Data.ResponseCodes.GenericResponse response)
 {
     NetworkingEvents.AppGroupListResultEvent += NetworkingEvents_AppGroupListResultEvent;
     AdminNetwork.SendRequestAppGroupList(moduleInfo.Id);
 }
示例#28
0
        /*
         *  Transfer code partially retrieved from NetworkComms example https://www.networkcomms.net/creating-a-wpf-file-transfer-application/
         *  on 07.10.2020
         */
        private void btnUpload_Click(object sender, EventArgs e)
        {
            string filename = openFileDialog1.FileName;

            if (File.Exists(filename))
            {
                btnUpload.Enabled = false;
                btnBrowse.Enabled = false;
                this.isBusy       = true;

                progressBar1.Value = (int)0;

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        //Create a fileStream from the selected file
                        FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read);

                        //Wrap the fileStream in a threadSafeStream so that future operations are thread safe
                        StreamTools.ThreadSafeStream safeStream = new StreamTools.ThreadSafeStream(stream);

                        //Get the filename without the associated path information
                        string shortFileName = System.IO.Path.GetFileName(filename);

                        //Parse the remote connectionInfo
                        //We have this in a separate try catch so that we can write a clear message to the log window
                        //if there are problems

                        //Get a connection to the remote side
                        Connection connection = AdminNetwork.Connection();

                        //Break the send into 20 segments. The less segments the less overhead
                        //but we still want the progress bar to update in sensible steps
                        long sendChunkSizeBytes = (long)(stream.Length / 20.0) + 1;

                        //Limit send chunk size to 500MB
                        long maxChunkSizeBytes = 500L * 1024L * 1024L;
                        if (sendChunkSizeBytes > maxChunkSizeBytes)
                        {
                            sendChunkSizeBytes = maxChunkSizeBytes;
                        }

                        long totalBytesSent = 0;
                        do
                        {
                            //Check the number of bytes to send as the last one may be smaller
                            long bytesToSend = (totalBytesSent + sendChunkSizeBytes < stream.Length ? sendChunkSizeBytes : stream.Length - totalBytesSent);

                            //Wrap the threadSafeStream in a StreamSendWrapper so that we can get NetworkComms.Net
                            //to only send part of the stream.
                            StreamTools.StreamSendWrapper streamWrapper = new StreamTools.StreamSendWrapper(safeStream, totalBytesSent, bytesToSend);

                            //We want to record the packetSequenceNumber
                            long packetSequenceNumber;
                            //Send the select data
                            connection.SendObject("PartialFileData", streamWrapper, NetworkComms.DefaultSendReceiveOptions, out packetSequenceNumber);
                            //Send the associated SendInfo for this send so that the remote can correctly rebuild the data
                            connection.SendObject("PartialFileDataInfo", new SendInfo(shortFileName, stream.Length, totalBytesSent, packetSequenceNumber), NetworkComms.DefaultSendReceiveOptions);

                            totalBytesSent += bytesToSend;

                            //Update the GUI with our send progress
                            UpdateSendProgress(shortFileName, (double)totalBytesSent / stream.Length);
                        } while (totalBytesSent < stream.Length);

                        //Clean up any unused memory
                        GC.Collect();

                        UpdateSendProgress(shortFileName, 100);
                        //   AddLineToLog("Completed file send to '" + connection.ConnectionInfo.ToString() + "'.");
                    }
                    catch (CommunicationException)
                    {
                        //If there is a communication exception then we just write a connection
                        //closed message to the log window
                        //   AddLineToLog("Failed to complete send as connection was closed.");
                        MessageBox.Show("Failed to complete send as connection was closed.");
                    }
                    catch (Exception ex)
                    {
                        //If we get any other exception which is not an InvalidDataException
                        //we log the error

                        /* if (!windowClosing && ex.GetType() != typeof(InvalidDataException))
                         * {
                         *   AddLineToLog(ex.Message.ToString());
                         *   LogTools.LogException(ex, "SendFileError");
                         * }*/

                        MessageBox.Show(ex.ToString());
                    }
                });
            }
        }
示例#29
0
文件: FrmAppAdmin.cs 项目: j0nat/JCIW
 private void NetworkingEvents_AccountUpdatedResultEvent(Networking.Data.ResponseCodes.GenericResponse response)
 {
     NetworkingEvents.AppListReceivedEvent += NetworkingEvents_AppListReceivedEvent;
     AdminNetwork.SendRequestAllAppList();
 }
示例#30
0
        private void ServiceItem_DeleteClickEvent(ServiceItem serviceItem)
        {
            ModuleInfo item = (ModuleInfo)serviceItem.Tag;

            AdminNetwork.SendDeleteService(item.Id);
        }