Пример #1
0
 /// <remarks/>
 public void applyServiceAsync(ApplyServiceParam param0) {
     this.applyServiceAsync(param0, null);
 }
Пример #2
0
 /// <remarks/>
 public void applyServiceAsync(ApplyServiceParam param0, object userState) {
     if ((this.applyServiceOperationCompleted == null)) {
         this.applyServiceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnapplyServiceOperationCompleted);
     }
     this.InvokeAsync("applyService", new object[] {
                 param0}, this.applyServiceOperationCompleted, userState);
 }
        // 申请服务
        private void buttonOK_Click(object sender, EventArgs e)
        {
            ApplyServiceInfo[] applyService = null;
            if (userId != null)
            {
                applyService = new ApplyServiceInfo[userId.Length + this.dataGridView2.SelectedRows.Count];
            }
            else
            {
                applyService = new ApplyServiceInfo[this.dataGridView2.SelectedRows.Count];
            }
            if (userId != null)
            {
                for (int i = 0; i < userId.Length; i++)
                {
                    ApplyServiceInfo applyServiceInfo = new ApplyServiceInfo();
                    applyServiceInfo.serviceTemplateId = userId[i];
                    applyServiceInfo.serviceTemplateIdSpecified = true;
                    applyService[i] = applyServiceInfo;

                }
            }
            
            DataGridViewSelectedRowCollection rows = this.dataGridView2.SelectedRows;
            if (rows.Count == 0)
            {
                MessageBox.Show("请至少选择一个服务。");
                return;
            }
            IEnumerator iter = rows.GetEnumerator();
            int j = userId==null?0:userId.Length;
            while (iter.MoveNext())
            {
                DataGridViewRow currentRow = (DataGridViewRow)iter.Current;
                ApplyServiceInfo applyServiceInfo = new ApplyServiceInfo();
                applyServiceInfo.serviceTemplateId = long.Parse(currentRow.Cells[0].Value.ToString());
                applyServiceInfo.serviceTemplateIdSpecified = true;
                
                if(long.Parse(currentRow.Cells[4].Value.ToString()) == 1)
                {
                    applyServiceInfo.userIpAddress = currentRow.Cells[3].Value.ToString();
                }
                applyService[j] = applyServiceInfo;
                j++;
            }
            ApplyServiceParam param = new ApplyServiceParam();
            param.accountName = userName;
            param.serviceInfo = applyService;
            WSCommonResult result = accessUserService.applyService(param);
            if (result.errorCode == 0)
            {
                MessageBox.Show("用户申请服务成功。");
            }
            else
            {
                MessageBox.Show("用户申请服务失败,失败原因为:" + result.errorMsg);
                return;
            }
            this.Dispose(true);
        }