Esempio n. 1
0
        public static string MakeRequest(RequestTo recipient, string requestBody)
        {
            var request = HttpWebRequest.Create(_addressBook[recipient]);

            request.Method = "POST";

            var data = Encoding.UTF8.GetBytes(requestBody);

            request.ContentType   = "text/plain";
            request.ContentLength = data.Length;
            var newStream = request.GetRequestStream();

            newStream.Write(data, 0, data.Length);
            newStream.Close();

            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new ApplicationException("error code: " + response.StatusCode.ToString());
                }
                using (var responseStream = response.GetResponseStream())
                {
                    if (responseStream != null)
                    {
                        using (var reader = new StreamReader(responseStream))
                        {
                            return(reader.ReadToEnd());
                        }
                    }
                }
            }
            return(string.Empty);
        }
        private void LoadData()
        {
            #region Getting Systems
            try
            {
                connection.Open();
                DataSet    ds      = new DataSet();
                SqlCommand command = new SqlCommand("sp_GetSystemsForStore", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_UserSys", Convert.ToInt32(Session["UserSys"].ToString()));
                SqlDataAdapter dA = new SqlDataAdapter(command);
                dA.Fill(ds);

                RequestTo.DataSource     = ds.Tables[0];
                RequestTo.DataTextField  = "SystemName";
                RequestTo.DataValueField = "SystemID";
                RequestTo.DataBind();
                if (RequestTo != null)
                {
                    RequestTo.Items.Insert(0, "Select System");
                    RequestTo.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Esempio n. 3
0
        public void ChangeStatus(RequestTo request, string participantName)
        {
            FrameworkBase.Log.LogMessage(string.Format("Changing the participant: {0} status to {1}", participantName, request.ToString()));
            int index = GetParticipantIndex(participantName);

            Operations.ClickElement(page.ParticipantsList[index - 1].FindElements(By.TagName("a"))[(int)request]);
        }
Esempio n. 4
0
        public void UpdateParticipantStatus(string participantName, RequestTo status = RequestTo.Approve)
        {
            int index = FindParticipantIndex(participantName);

            if (index != 0)
            {
                List <IWebElement> options = page.ParticipantsList[index].FindElements(By.TagName("a")).ToList <IWebElement>();
                Operations.ClickElement(options[(int)status]);
            }
        }
Esempio n. 5
0
        private IRestCallbackClient Request(string url, Method method = Method.GET,
                                            string content            = "", string typeMedia = RestConstants.MediaTypeJson,
                                            ParameterType typePar     = ParameterType.RequestBody,
                                            RequestTo requestTo       = RequestTo.NoKey,
                                            string additionalFilePath = null)

        {
            MediaType  = typeMedia;
            SegmentUrl = url;

            var client  = new RestClient(Uri.EscapeUriString(BaseUrl + SegmentUrl));
            var request = new RestRequest(method);

            request.AddHeader("cache-control", "no-cache");

            if (!string.IsNullOrEmpty(MediaType))
            {
                request.AddHeader("Content-Type", MediaType);
            }

            if (requestTo == RequestTo.Key)
            {
                request.AddHeader("Authorization",
                                  "Bearer " + (UserManager.Instance.CurrentUser() as UserModel)?.Token);
            }

            if (!string.IsNullOrEmpty(content))
            {
                request.AddParameter(MediaType, content, typePar);
            }

            if (string.IsNullOrWhiteSpace(additionalFilePath))
            {
                return(GetCallBack(client.Execute(request)));
            }
            const string fileName = "file";

            request.AddFile(fileName, additionalFilePath);

            return(GetCallBack(client.Execute(request)));
        }
Esempio n. 6
0
        public void PopulateDropDownVendor(String Text)
        {
            #region Populating Vendor Name Dropdown

            try
            {
                connection.Open();

                Text = Text + "%";
                SqlCommand     command = new SqlCommand("Select * From tblVendor Where tblVendor.SupName LIKE '" + Text + "'", connection);
                DataSet        ds      = new DataSet();
                SqlDataAdapter sA      = new SqlDataAdapter(command);
                sA.Fill(ds);
                if (RequestTo.DataSource != null)
                {
                    RequestTo.DataSource = null;
                }

                ProductSet               = null;
                ProductSet               = ds;
                RequestTo.DataSource     = ds.Tables[0];
                RequestTo.DataTextField  = "SupName";
                RequestTo.DataValueField = "SuppID";
                RequestTo.DataBind();
                if (RequestTo != null)
                {
                    RequestTo.Items.Insert(0, "Select Vendor");
                    RequestTo.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Esempio n. 7
0
        private void LoadData()
        {
            #region Getting Vendors
            try
            {
                connection.Open();
                DataSet    ds      = new DataSet();
                SqlCommand command = new SqlCommand("Sp_GetVendor", connection);
                command.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter dA = new SqlDataAdapter(command);
                dA.Fill(ds);

                RequestTo.DataSource     = ds.Tables[0];
                RequestTo.DataTextField  = "SupName";
                RequestTo.DataValueField = "SuppID";
                RequestTo.DataBind();
                if (RequestTo != null)
                {
                    RequestTo.Items.Insert(0, "Select Vendor");
                    RequestTo.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion

            #region Populating Product List

            //try
            //{
            //    connection.Open();
            //    SqlCommand command = new SqlCommand("Select  Top 200 Product_Name,ProductID From tbl_ProductMaster Where tbl_ProductMaster.Product_Id_Org LIKE '444%' AND Status = 1", connection);
            //    DataSet ds = new DataSet();
            //    SqlDataAdapter sA = new SqlDataAdapter(command);
            //    sA.Fill(ds);
            //    ProductSet = ds;
            //    SelectProduct.DataSource = ds.Tables[0];
            //    SelectProduct.DataTextField = "Product_Name";
            //    SelectProduct.DataValueField = "ProductID";
            //    SelectProduct.DataBind();
            //    if (SelectProduct != null)
            //    {
            //        SelectProduct.Items.Insert(0, "Select Product");
            //        SelectProduct.SelectedIndex = 0;
            //    }
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
            //    connection.Close();
            //}
            #endregion
        }