Exemple #1
0
        public async Task AddNewKeyAsync(byte[] publicKey, byte[] signPublicKey, long keyId, long expirationTime, long generationTime, bool withAuth)
        {
            if (withAuth)
            {
                if (!await TryConnectAsync(withAuth).ConfigureAwait(false))
                {
                    throw new LicensorException("Unable to establish connection with licensor.");
                }
            }
            if (webSocket.State != WebSocketState.Open)
            {
                await ConnectAndListenAsync().ConfigureAwait(false);
            }
            AddNewKeyRequest request = new AddNewKeyRequest(publicKey, signPublicKey, keyId, expirationTime, generationTime, NodeSettings.Configs.Node.Id);

            await SendRequestAsync(request).ConfigureAwait(false);

            var response = await GetResponseAsync(request).ConfigureAwait(false);

            if (response is ResultResponse resultResponse)
            {
                if (!string.IsNullOrWhiteSpace(resultResponse.ErrorMessage))
                {
                    throw new ResponseException($"Failed to add new key. Response error message: {resultResponse.ErrorMessage}");
                }
            }
        }
        protected void btnSearchKeyAdd_Click(object sender, EventArgs e)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("File");
            try
            {
                String           ZipRegex            = "^[0-9]+$";
                AddNewKeyRequest objAddNewKeyRequest = new AddNewKeyRequest();
                AdminAddNewKey   objaddkey           = new AdminAddNewKey();
                getLocationIDByName(ddllocation.SelectedValue.ToString());
                String  q  = txtbunchNo.Text;
                DataSet ds = dal.getdataset("select BunchNo from addnewkey where Location_ID='" + SearchLocID.Text + "' and BunchNo='" + txtbunchNo.Text + "'");

                int count = ds.Tables[0].Rows.Count;
                if (count > 0)
                {
                    for (i = 0; i < count; i++)
                    {
                        String z = ds.Tables[0].Rows[i].ItemArray[0].ToString();
                        if (string.Equals(q, z, StringComparison.CurrentCultureIgnoreCase))
                        {
                            lblerror.Visible = true;
                            lblerror.Text    = "Bunch No. already exist ..!";
                            lblerr1.Visible  = true;
                            throw new Exception();
                        }
                    }
                }
                else
                {
                    String  q1  = txtStaffiD.Text;
                    DataSet ds1 = dal.getdataset("select NRICno from UserInformation");
                    for (i = 0; i < ds1.Tables[0].Rows.Count; i++)
                    {
                        String z = ds1.Tables[0].Rows[i].ItemArray[0].ToString();
                        if (string.Equals(q1, z, StringComparison.CurrentCultureIgnoreCase))
                        {
                            getLocationIDByName(ddllocation.Text.Trim());
                            objaddkey.BunchNo     = txtbunchNo.Text;
                            objaddkey.Description = txtKeyDesc.Text;
                            objaddkey.status      = txtKeyStatus.Text;
                            objaddkey.name        = txtKeyName.Text;
                            objaddkey.position    = txtKeyPosition.Text;
                            objaddkey.NoOfKey     = txtKeyNo.Text;
                            objaddkey.Staff_ID    = txtStaffiD.Text;
                            // objaddkey.Location_ID = Convert.ToInt32(SearchLocID.Text);
                            objaddkey.Location_ID = SearchLocID.Text;
                            objaddkey.Date_From   = Convert.ToDateTime(DateTime.Now);

                            AdminBLL ws = new AdminBLL();
                            ws.Add_NewKey(objaddkey);

                            lblerror.Visible = true;
                            lblerror.Text    = "Insert Succesfully ..!";

                            HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                            Server.Transfer("AlertUpdateComplete.aspx");
                        }
                    }

                    lblerror.Visible = true;
                    lblerror.Text    = "Invalid NRICno ID ....!";
                    lblerr2.Visible  = true;
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
        }