Exemplo n.º 1
0
        /// <summary>
        /// Handles the SelectedTabChanged event of the tabControl1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevComponents.DotNetBar.TabStripTabChangedEventArgs"/> instance containing the event data.</param>
        private void tabControl1_SelectedTabChanged(object sender, DevComponents.DotNetBar.TabStripTabChangedEventArgs e)
        {
            if (PanelSession.Tag == null)
            {
                return;
            }
            ConnectSetup Setup = PanelSession.Tag as ConnectSetup;

            if (string.IsNullOrEmpty(Setup.userName) || AsyncStackNet.Instance.ASyncSetup.AsynCollection == null || AsyncStackNet.Instance.ASyncSetup.AsynCollection.Count == 0)
            {
                return;
            }
            if (AsyncStackNet.Instance.ASyncSetup.AsynCollection[
                    AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup()
            {
                SID = Setup.SID, RID = Setup.RID
            })].Traffics == null)
            {
                return;
            }
            this.comboTree1.DataSource = AsyncStackNet.Instance.ASyncSetup.AsynCollection[
                AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup()
            {
                SID = Setup.SID, RID = Setup.RID
            })].Traffics;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the btnSingleSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnSingleSave_Click(object sender, EventArgs e)
        {
            PanelSession.Enabled = false;

            string groupCode = string.Empty;

            if (comboBoxEx1.SelectedItem != null)
            {
                groupCode = comboBoxEx1.SelectedItem.GetType().GetProperty("Value").GetValue(comboBoxEx1.SelectedItem, null).ToString();
            }
            int          Sid   = Int32.Parse(textBoxX1.Text, System.Globalization.NumberStyles.HexNumber);
            int          Rid   = Int32.Parse(textBoxX2.Text, System.Globalization.NumberStyles.HexNumber);
            ConnectSetup Setup = new ConnectSetup()
            {
                LocalIp      = ipLocalIp.Value,
                TSessionType = radPassword.Checked?CertificationType.Password:CertificationType.Address,
                Address      = txtAddress.Text,
                IsOpen       = chkIsOpen.Checked,
                userName     = string.IsNullOrEmpty(txtSessionName.Text) ? StringUtil.GenUniqueString() : txtSessionName.Text,
                IsSsl        = chkIsSsl.Checked,
                Port         = txtPort.Value,
                SiText       = txtSIText.Text,
                GroupCode    = groupCode, AutoSi = chkAutoSi.Checked,
                OfficeCode   = txtOfficeCode.Text,
                userPass     = txtPassword.Text,
                SID          = (byte)Sid,
                RID          = (byte)Rid,
                FlowRate     = integerInput2.Value
            };

            Setup.Traffics   = (PanelSession.Tag as ConnectSetup).Traffics;
            PanelSession.Tag = Setup;
            if (!AsyncStackNet.Instance.ASyncSetup.AsynCollection.Contains(Setup))
            {
                AsyncStackNet.Instance.ASyncSetup.AsynCollection.Add(Setup);
            }
            else
            {
                int indexOf = AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(this.PanelSession.Tag as ConnectSetup);
                AsyncStackNet.Instance.ASyncSetup.AsynCollection[indexOf] = Setup;
            }
            btnSave_Click(null, EventArgs.Empty);
            this.OnLoad(EventArgs.Empty);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Handles the Click event of the btnDispose control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void btnDispose_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in this.lstSession.Items)
     {
         if (!item.Selected)
         {
             continue;
         }
         ConnectSetup setup = item.Tag as ConnectSetup;
         AsyncStackNet.Instance.AppendAsync(
             new eTerm.AsyncSDK.Net.eTerm443Async(
                 setup.Address,
                 setup.Port,
                 setup.userName,
                 setup.userPass,
                 setup.SID,
                 setup.RID)
         {
             SiText = setup.SiText, IsSsl = setup.IsSsl, GroupCode = setup.GroupCode, OfficeCode = setup.OfficeCode
         });
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the lstSession control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        //private void lstSession_SelectedIndexChanged(object sender, EventArgs e) {
        //    if (lstSession.SelectedItems.Count != 1) {
        //        btnDispose.Enabled = false;
        //        btnInsert.Enabled = false;
        //        btnSessionEdit.Enabled = false;
        //        btnDelete.Enabled = false;
        //        return;
        //    }
        //    btnDelete.Enabled = true;
        //    btnDispose.Enabled = true;
        //    btnInsert.Enabled = true;
        //    btnSessionEdit.Enabled = true;
        //    ConnectSetup Setup = lstSession.SelectedItems[0].Tag as ConnectSetup;
        //    if (string.IsNullOrEmpty(Setup.userName) || AsyncStackNet.Instance.ASyncSetup.AsynCollection == null || AsyncStackNet.Instance.ASyncSetup.AsynCollection.Count == 0) return;
        //    if (AsyncStackNet.Instance.ASyncSetup.AsynCollection[
        //        AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup() { SID = Setup.SID, RID = Setup.RID })].Traffics == null)
        //        return;
        //    this.comboTree1.DataSource = AsyncStackNet.Instance.ASyncSetup.AsynCollection[
        //        AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup() { SID = Setup.SID, RID = Setup.RID })].Traffics;
        //}

        /// <summary>
        /// Handles the Click event of the btnClearTraffic control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnClearTraffic_Click(object sender, EventArgs e)
        {
            ConnectSetup Setup = lstSession.SelectedItems[0].Tag as ConnectSetup;

            if (this.comboTree1.SelectedValue.ToString() == DateTime.Now.ToString(@"yyyyMM"))
            {
                MessageBox.Show(@"当月流量统计不允许清除!", @"操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            List <SocketTraffic> Traffics = AsyncStackNet.Instance.ASyncSetup.AsynCollection[
                AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup()
            {
                SID = Setup.SID, RID = Setup.RID
            })].Traffics;

            Traffics.RemoveAt(Traffics.IndexOf(new SocketTraffic()
            {
                MonthString = this.comboTree1.SelectedValue.ToString()
            }));
            AsyncStackNet.Instance.BeginRateUpdate(new AsyncCallback(delegate(IAsyncResult iar)
            {
                AsyncStackNet.Instance.EndRateUpdate(iar);
                btnSessionEdit_Click(null, EventArgs.Empty);
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Click event of the btnSingleSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnSingleSave_Click(object sender, EventArgs e)
        {
            PanelSession.Enabled = false;

            string groupCode = string.Empty;
            if (comboBoxEx1.SelectedItem != null)
                groupCode = comboBoxEx1.SelectedItem.GetType().GetProperty("Value").GetValue(comboBoxEx1.SelectedItem, null).ToString();
            int Sid = Int32.Parse(textBoxX1.Text, System.Globalization.NumberStyles.HexNumber);
            int Rid = Int32.Parse(textBoxX2.Text, System.Globalization.NumberStyles.HexNumber);
            ConnectSetup Setup = new ConnectSetup()
            {
                 LocalIp=ipLocalIp.Value,
                  TSessionType=radPassword.Checked?CertificationType.Password:CertificationType.Address,
                 Address=txtAddress.Text,
                  IsOpen =chkIsOpen.Checked,
                 userName = string.IsNullOrEmpty(txtSessionName.Text) ? StringUtil.GenUniqueString() : txtSessionName.Text,
                    IsSsl=chkIsSsl.Checked,
                     Port=txtPort.Value,
                       SiText=txtSIText.Text,
                 GroupCode = groupCode, AutoSi=chkAutoSi.Checked,
                        OfficeCode=txtOfficeCode.Text,
                         userPass=txtPassword.Text,
                 SID = (byte)Sid,
                 RID = (byte)Rid,
                           FlowRate=integerInput2.Value
            };
            Setup.Traffics = (PanelSession.Tag as ConnectSetup).Traffics;
            PanelSession.Tag = Setup;
            if (!AsyncStackNet.Instance.ASyncSetup.AsynCollection.Contains(Setup))
                AsyncStackNet.Instance.ASyncSetup.AsynCollection.Add(Setup);
            else{
                int indexOf = AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(this.PanelSession.Tag as ConnectSetup);
                AsyncStackNet.Instance.ASyncSetup.AsynCollection[indexOf] = Setup;
            }
            btnSave_Click(null, EventArgs.Empty);
            this.OnLoad(EventArgs.Empty);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the Click event of the btnSessionEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnSessionEdit_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lstSession.Items)
            {
                if (!item.Selected)
                {
                    continue;
                }
                ConnectSetup Setup = item.Tag as ConnectSetup;
                this.PanelSession.Tag = Setup;
                this.txtAddress.Text  = Setup.Address;
                this.txtPassword.Text = Setup.userPass;
                this.txtPort.Value    = Setup.Port;

                this.radAddress.Checked = (Setup.TSessionType ?? CertificationType.Password) == CertificationType.Address;
                if (this.radAddress.Checked)
                {
                    this.radAddress_CheckedChanged(null, EventArgs.Empty);
                }

                this.radPassword.Checked = (Setup.TSessionType ?? CertificationType.Password) == CertificationType.Password;
                if (this.radPassword.Checked)
                {
                    this.radPassword_CheckedChanged(null, EventArgs.Empty);
                }
                this.ipLocalIp.Value     = Setup.LocalIp;
                this.txtOfficeCode.Text  = Setup.OfficeCode;
                chkIsOpen.Checked        = Setup.IsOpen;
                chkIsSsl.Checked         = Setup.IsSsl;
                integerInput2.Value      = int.Parse((Setup.FlowRate ?? 0.0).ToString());
                this.txtSessionName.Text = Setup.userName;
                this.txtSIText.Text      = Setup.SiText;
                this.textBoxX1.Text      = String.Format("{0:X}", Setup.SID);
                this.textBoxX2.Text      = String.Format("{0:X}", Setup.RID);
                //this.integerInput3.Value = (int)Setup.RID;
                chkAutoSi.Checked = Setup.AutoSi ?? false;
                comboBoxEx1.Items.Clear();
                if (AsyncStackNet.Instance.ASyncSetup.GroupCollection == null)
                {
                    return;
                }
                foreach (SDKGroup group in AsyncStackNet.Instance.ASyncSetup.GroupCollection)
                {
                    comboBoxEx1.Items.Add(new { Text = group.groupName, Value = group.groupCode });
                }


                if (!string.IsNullOrEmpty(Setup.GroupCode))
                {
                    foreach (object group in this.comboBoxEx1.Items)
                    {
                        string GValue = group.GetType().GetProperty("Value").GetValue(group, null).ToString();
                        //string GText = group.GetType().GetProperty("Text").GetValue(group, null).ToString();
                        if (GValue == Setup.GroupCode)
                        {
                            comboBoxEx1.SelectedItem = group;
                        }
                    }
                }

                PanelSession.Enabled = true;
                if (!AsyncStackNet.Instance.ASyncSetup.AsynCollection.Contains(new ConnectSetup()
                {
                    SID = Setup.SID, RID = Setup.RID
                }))
                {
                    return;
                }
                this.comboTree1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
                this.comboTree1.ValueMember    = @"MonthString";
                this.comboTree1.DisplayMembers = @"MonthString,Traffic,UpdateDate";
                this.comboTree1.DataSource     = AsyncStackNet.Instance.ASyncSetup.AsynCollection[
                    AsyncStackNet.Instance.ASyncSetup.AsynCollection.IndexOf(new ConnectSetup()
                {
                    SID = Setup.SID, RID = Setup.RID
                })].Traffics;
                tabControl1.SelectedTab = tabItem2;

                //PanelSession.Show();
                break;
            }
        }