Пример #1
0
        protected override void WriteAll()
        {
            var client = new RestSharp.RestClient();

            if (AggreateSubmissions)
            {
                var request = new RestSharp.RestRequest(this.EndPoint, this.Method);
                request.AddBody(this.Buffer);
                client.ExecuteAsync(request, (res, req) => {
                    //se non c'è stato alcun errore, svuota il buffer
                    if (res.ErrorException == null)
                    {
                        this.ClearBuffer();
                    }
                });
            }
            else
            {
                foreach (var item in this.Buffer)
                {
                    var request = new RestSharp.RestRequest(this.EndPoint, this.Method);
                    request.AddBody(item);
                    client.ExecuteAsync(request, (res, req) =>
                    {
                        //se non c'è stato alcun errore, toglie l'elemento dal buffer
                        if (res.ErrorException == null)
                        {
                            this.Buffer.Remove(item);
                        }
                    });
                }
            }
        }
Пример #2
0
        private async Task GetDocStatus()
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "DocumentSQLConnection";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string str     = $"GET?qry=SELECT DocStatus FROM tblTempDocHeader WHERE DocNum ='{txfPOCode.Text}'";
                    var    Request = new RestSharp.RestRequest(str, RestSharp.Method.GET);
                    var    cancellationTokenSource = new CancellationTokenSource();
                    await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.Content.ToString().Contains("DocStatus"))
                    {
                        DataSet myds = new DataSet();
                        myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                        if (myds.Tables[0].Rows[0]["DocStatus"] != null)
                        {
                            if (Convert.ToInt32(myds.Tables[0].Rows[0]["DocStatus"]) == 3)
                            {
                                InProccess = true;
                            }
                        }
                    }
                }
            }
            else
            {
                Vibration.Vibrate();
                message.DisplayMessage("No Internet Connection", false);
            }
        }
Пример #3
0
        public async Task <bool> AddUser(string userName, string UserNum, int Access)
        {
            try
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "AddUser";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string str     = $"POST?UserName={userName}&UserNum={UserNum}&Access={Access}";
                    var    Request = new RestSharp.RestRequest();
                    Request.Resource = str;
                    Request.Method   = RestSharp.Method.POST;
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.IsSuccessful && res.Content.Contains("User has been added"))
                    {
                        return(true);
                    }
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Пример #4
0
        public async Task <TrustedPublisher> GetTrustedPublisher(string url)
        {
            client = new RestSharp.RestClient(configuration.GetValue <string>("ApimBaseUrl"));
            RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/we-trustedpublisher-func/GetTrustedPublisher", RestSharp.Method.POST);

            restRequest.AddHeader("Ocp-Apim-Subscription-Key", configuration.GetValue <string>("ApimKey"));
            restRequest.AddHeader("Content-Type", "application/json");

            TrustedPublisherRequest publisherRequest = new TrustedPublisherRequest()
            {
                Url = url
            };

            restRequest.AddJsonBody(publisherRequest);

            try
            {
                var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

                return(JsonConvert.DeserializeObject <TrustedPublisher>(response.Content));
            }
            catch (Exception)
            {
                return(new TrustedPublisher()
                {
                    Reason = "Konnte leider nicht validiert werden"
                });
            }
        }
        private async Task <bool> FetchWH()
        {
            RestSharp.RestClient client = new RestSharp.RestClient();
            string path = "GetWarehouses";

            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
            {
                string str     = $"GET?";
                var    Request = new RestSharp.RestRequest();
                Request.Resource = str;
                Request.Method   = RestSharp.Method.GET;
                var cancellationTokenSource = new CancellationTokenSource();
                var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.Content.ToString().Contains("WHID"))
                {
                    DataSet myds = new DataSet();
                    myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                    foreach (DataRow row in myds.Tables[0].Rows)
                    {
                        WHIDs.Add(row["WHID"].ToString());
                    }
                    txfAccWH.ItemsSource = WHIDs;
                    txfRejWH.ItemsSource = WHIDs;
                    return(true);
                }
            }
            return(false);
        }
Пример #6
0
        public async Task <ScraperResponse> GetWebScraperResult(string url)
        {
            client = new RestSharp.RestClient(configuration.GetValue <string>("ApimBaseUrl"));
            RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/we-webscraper-func/WebScraperFunc", RestSharp.Method.POST);

            restRequest.AddHeader("Ocp-Apim-Subscription-Key", configuration.GetValue <string>("ApimKey"));
            restRequest.AddHeader("Content-Type", "application/json");

            ScraperRequest requestObject = new ScraperRequest()
            {
                url = url
            };

            restRequest.AddJsonBody(requestObject);

            try
            {
                var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

                return(JsonConvert.DeserializeObject <ScraperResponse>(response.Content));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #7
0
        public async Task <List <Models.SearchResponse> > GetFakeNewsDb(string message)
        {
            try
            {
                client = new RestSharp.RestClient(configuration.GetValue <string>("ApimBaseUrl"));

                RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/we-factsearch-fa/Search", RestSharp.Method.POST);

                restRequest.AddHeader("Ocp-Apim-Subscription-Key", configuration.GetValue <string>("ApimKey"));
                restRequest.AddHeader("Content-Type", "application/json");

                Models.Request requestObject = new Models.Request
                {
                    text = message
                };

                restRequest.AddJsonBody(requestObject);

                var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

                return(JsonConvert.DeserializeObject <List <Models.SearchResponse> >(response.Content));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #8
0
        async Task <bool> NewPallet(int pallet)
        {
            RestSharp.RestClient client = new RestSharp.RestClient();
            string path = "DocumentSQLConnection";

            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
            {
                string qry     = $"INSERT INTO PalletTransaction(SONum, PalletID) VALUES('{txfSOCode.Text.ToUpper()}',{pallet})";
                string str     = $"POST?qry={qry}";
                var    Request = new RestSharp.RestRequest();
                Request.Resource = str;
                Request.Method   = RestSharp.Method.POST;
                var cancellationTokenSource = new CancellationTokenSource();
                var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.IsSuccessful && res.Content.Contains("Complete"))
                {
                    currentPallet = pallet;
                    return(true);
                }
                else
                {
                    Vibration.Vibrate();
                    message.DisplayMessage("Error in the server!", true);
                    return(false);
                }
            }
        }
        public static async Task <string> GetTwitter([ActivityTrigger] string request,
                                                     ILogger log)
        {
            client = new RestSharp.RestClient("https://we-factsearch-fa.azurewebsites.net");

            RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/api/SearchTwitter", RestSharp.Method.POST);

            restRequest.AddHeader("Content-Type", "application/json");
            Model.RootObject requestData = JsonConvert.DeserializeObject <Model.RootObject>(request);

            string query = string.Empty;

            foreach (var item in requestData.documents[0].keyPhrases)
            {
                query += item + " ";
            }

            Model.SearchQuery searchQuery = new Model.SearchQuery()
            {
                query = query
            };

            restRequest.AddJsonBody(searchQuery);

            var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

            return(response.Content);
        }
        private async Task <bool> ResetItem()
        {
            DocLine doc = (await App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemCode == lastItem).FirstOrDefault();
            var     ds  = new DataSet();

            try
            {
                var     t1  = new DataTable();
                DataRow row = null;
                t1.Columns.Add("DocNum");
                t1.Columns.Add("ItemBarcode");
                t1.Columns.Add("ScanAccQty");
                t1.Columns.Add("Balance");
                t1.Columns.Add("ScanRejQty");
                t1.Columns.Add("PalletNumber");
                t1.Columns.Add("GRV");
                row                 = t1.NewRow();
                row["DocNum"]       = doc.DocNum;
                row["ItemBarcode"]  = doc.ItemBarcode;
                row["ScanAccQty"]   = 0;
                row["Balance"]      = 0;
                row["ScanRejQty"]   = 0;
                row["PalletNumber"] = 0;
                row["GRV"]          = false;
                t1.Rows.Add(row);
                ds.Tables.Add(t1);
                string myds = Newtonsoft.Json.JsonConvert.SerializeObject(ds);
                RestSharp.RestClient client = new RestSharp.RestClient();
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath);
                {
                    var Request = new RestSharp.RestRequest("SaveDocLine", RestSharp.Method.POST);
                    Request.RequestFormat = RestSharp.DataFormat.Json;
                    Request.AddJsonBody(myds);
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.IsSuccessful && res.Content.Contains("COMPLETE"))
                    {
                        await restetQty(doc);

                        lblBalance.Text     = "0";
                        lblScanQTY.Text     = "";
                        lblOrderQTY.Text    = "";
                        lblitemDescAcc.Text = "";
                        PicImage.IsVisible  = false;
                        txfAccCode.Focus();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(false);
        }
Пример #11
0
        /// <summary>
        /// Sends an alarm in a separate thread to the web. The web adds or updates the alarm.
        /// </summary>
        /// <param name="url">The url used for uploading alarm data.</param>
        /// <param name="alarm">The alarm to send to the web.</param>
        /// <param name="exceptionLog">A method for logging if an exception occurs.</param>
        public static void SendAsync(string url, Alarm alarm, Action <string, Exception> exceptionLog = null)
        {
            mExceptionLog = exceptionLog;
            var client  = new RestSharp.RestClient(url);
            var request = new RestSharp.RestRequest(RestSharp.Method.POST);

            request.AddParameter("alarm", alarm.Serialize());
            client.ExecuteAsync(request, Done);
        }
Пример #12
0
        private async Task <bool> SaveData()
        {
            var ds = new DataSet();

            try
            {
                var     t1  = new DataTable();
                DataRow row = null;
                t1.Columns.Add("DocNum");
                t1.Columns.Add("ItemBarcode");
                t1.Columns.Add("ScanAccQty");
                t1.Columns.Add("Balance");
                t1.Columns.Add("ScanRejQty");
                t1.Columns.Add("PalletNumber");
                t1.Columns.Add("GRV");
                string         s    = txfSOCode.Text.ToUpper();
                List <DocLine> docs = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(s)).ToList();
                foreach (string str in docs.Select(x => x.ItemDesc).Distinct())
                {
                    foreach (int ints in docs.Where(x => x.PalletNum != 0 && x.ItemDesc == str).Select(x => x.PalletNum).Distinct())
                    {
                        row                 = t1.NewRow();
                        row["DocNum"]       = docs.Select(x => x.DocNum).FirstOrDefault();
                        row["ScanAccQty"]   = docs.Where(x => x.PalletNum == ints && x.ItemDesc == str).Sum(x => x.ScanAccQty);
                        row["ScanRejQty"]   = 0;
                        row["ItemBarcode"]  = docs.Where(x => x.PalletNum == ints && x.ItemDesc == str).Select(x => x.ItemBarcode).FirstOrDefault();
                        row["Balance"]      = -1;
                        row["PalletNumber"] = ints;
                        row["GRV"]          = false;
                        t1.Rows.Add(row);
                    }
                }
                ds.Tables.Add(t1);
            }
            catch (Exception)
            {
                return(false);
            }
            string myds = Newtonsoft.Json.JsonConvert.SerializeObject(ds);

            RestSharp.RestClient client = new RestSharp.RestClient();
            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath);
            {
                var Request = new RestSharp.RestRequest("SaveDocLine", RestSharp.Method.POST);
                Request.RequestFormat = RestSharp.DataFormat.Json;
                Request.AddJsonBody(myds);
                var cancellationTokenSource = new CancellationTokenSource();
                var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.IsSuccessful && res.Content.Contains("COMPLETE"))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #13
0
        public static async Task ReportMessage(Models.ReportDetails details, IConfiguration configuration)
        {
            client = new RestSharp.RestClient("https://we-sendfact-fa.azurewebsites.net");
            RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/api/messagearchive", RestSharp.Method.POST);

            restRequest.AddHeader("Content-Type", "application/json");
            restRequest.AddJsonBody(details);

            await client.ExecuteAsync(restRequest).ConfigureAwait(false);
        }
Пример #14
0
        public async Task ReportMessage(Models.ReportDetails details)
        {
            client = new RestSharp.RestClient(configuration.GetValue <string>("ApimBaseUrl"));
            RestSharp.RestRequest restRequest = new RestSharp.RestRequest("we-fakenews-func/Insert", RestSharp.Method.POST);

            restRequest.AddHeader("Ocp-Apim-Subscription-Key", configuration.GetValue <string>("ApimKey"));
            restRequest.AddHeader("Content-Type", "application/json");
            restRequest.AddJsonBody(details);

            await client.ExecuteAsync(restRequest).ConfigureAwait(false);
        }
Пример #15
0
        async Task <bool> FetchSO(string code)
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "GetDocument";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string str     = $"GET?qrystr=ACCHISTL|6|{code}|102|" + GoodsRecieveingApp.MainPage.UserCode;
                    var    Request = new RestSharp.RestRequest();
                    Request.Resource = str;
                    Request.Method   = RestSharp.Method.GET;
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.Content.ToString().Contains("DocNum"))
                    {
                        DataSet myds = new DataSet();
                        myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                        // if (await GoodsRecieveingApp.App.Database.GetHeader(myds.Tables[0].Rows[0]["OrderNumber"].ToString())==null){
                        foreach (DataRow row in myds.Tables[0].Rows)
                        {
                            try
                            {
                                var Doc = new DocLine();
                                Doc.DocNum       = row["DocNum"].ToString();
                                Doc.SupplierCode = row["SupplierCode"].ToString();
                                Doc.SupplierName = row["SupplierName"].ToString();
                                Doc.ItemBarcode  = row["ItemBarcode"].ToString();
                                Doc.ItemCode     = row["ItemCode"].ToString();
                                Doc.ItemDesc     = row["ItemDesc"].ToString();
                                Doc.ScanAccQty   = 0;
                                Doc.ScanRejQty   = 0;
                                Doc.ItemQty      = Convert.ToInt32(row["ItemQty"].ToString().Trim());
                                await GoodsRecieveingApp.App.Database.Insert(Doc);

                                supplier = Doc.SupplierName;
                            }
                            catch
                            {
                                return(false);
                            }
                        }
                        if (!SOTextlbl.Contains(txfSOCodes.Text))
                        {
                            SOTextlbl += txfSOCodes.Text + " - " + supplier + "\n";
                        }
                        return(true);
                        //}
                    }
                }
            }
            return(false);
        }
Пример #16
0
        private async Task <bool> CheckItem()
        {
            Loading.IsVisible = true;
            try
            {
                BOMItem bi = await GoodsRecieveingApp.App.Database.GetBOMItem(txfScannedItem.Text);

                if (!await CheckQTY(bi.ItemCode, bi.Qty))
                {
                    return(false);
                }
                items.Add(new IBTItem {
                    ScanBarcode = txfScannedItem.Text, ItemBarcode = bi.PackBarcode, ItemDesc = bi.ItemDesc, ItemCode = bi.ItemCode, ItemQtyOut = bi.Qty, ItemQtyIn = 0, PickDateTime = DateTime.Now
                });
                return(true);
            }
            catch
            {
                try
                {
                    RestSharp.RestClient client = new RestSharp.RestClient();
                    string path = "FindDescAndCode";
                    client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                    {
                        string qry     = $"ACCPRD|4|{txfScannedItem.Text}";
                        string str     = $"GET?qrystr={qry}";
                        var    Request = new RestSharp.RestRequest(str, RestSharp.Method.GET);
                        var    cancellationTokenSource = new CancellationTokenSource();
                        var    res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                        if (res.IsSuccessful && res.Content != null)
                        {
                            if (!await CheckQTY(res.Content.Split('|')[2], 1))
                            {
                                return(false);
                            }
                            items.Add(new IBTItem {
                                ScanBarcode = txfScannedItem.Text, ItemBarcode = res.Content.Split('|')[4], ItemCode = res.Content.Split('|')[2], ItemDesc = res.Content.Split('|')[3], ItemQtyOut = 1, ItemQtyIn = 0, PickDateTime = DateTime.Now
                            });
                            return(true);
                        }
                    }
                }
                catch
                {
                    Loading.IsVisible = false;
                    message.DisplayMessage("There was a error in getting this item", true);
                    return(false);
                }
            }
            Loading.IsVisible = false;
            message.DisplayMessage("Invalid Item", false);
            return(false);
        }
        async Task <bool> GetPallets(string SOCode)
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "Pallet";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string str     = $"POST?SOCode={SOCode}";
                    var    Request = new RestSharp.RestRequest();
                    Request.Resource = str;
                    Request.Method   = RestSharp.Method.POST;
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.IsSuccessful && res.Content.Contains("Complete"))
                    {
                        string s = res.Content.Replace('"', ' ').Replace('\\', ' ').Trim();
                        foreach (string strin in s.Split('|'))
                        {
                            if (strin != "")
                            {
                                try
                                {
                                    if (!AllPallets.Contains(Convert.ToInt32(strin)))
                                    {
                                        AllPallets.Add(Convert.ToInt32(strin));
                                        AllPallets.Sort();
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                    else
                    {
                        Vibration.Vibrate();
                        message.DisplayMessage("Error in the server", true);
                        return(false);
                    }
                }
            }
            else
            {
                Vibration.Vibrate();
                message.DisplayMessage("Please recconect to the internet", true);
                return(false);
            }
            return(true);
        }
Пример #18
0
        private void buttonSendReq_Click(object sender, EventArgs e)
        {
            RestSharp.RestClient restClient = new RestSharp.RestClient(textBaseUrl.Text);
            var req = new RestSharp.RestRequest(textResource.Text, GetRequestMethod());

            req.AddHeader("Authorization", "BEARER " + textToken.Text);
            restClient.ExecuteAsync(req, (r, h) =>
            {
                textResponse.BeginInvoke(new Action(() =>
                {
                    textResponse.Text = r.Content;
                }));
            });
        }
Пример #19
0
        //Russell will make a Var to control thre check
        async Task <bool> PalletCheck()
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "DocumentSQLConnection";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string str     = $"GET?qry=SELECT * FROM PalletTransaction WHERE SONum='{txfSOCode.Text.ToUpper()}'";
                    var    Request = new RestSharp.RestRequest();
                    Request.Resource = str;
                    Request.Method   = RestSharp.Method.GET;
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.IsSuccessful && res.Content.Contains("PalletID"))
                    {
                        DataSet myds = new DataSet();
                        myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                        if (!(myds.Tables[0].Rows.Count > 1))
                        {
                            if (myds.Tables[0].Rows.Count == 1)
                            {
                                //if (!isMultiPallet)
                                //{
                                //   Vibration.Vibrate();
                                //  message.DisplayMessage("This order has been started as a single pallet", true);
                                //  return false;
                                // }
                            }
                        }
                    }
                    else
                    {
                        if (!await AddPallet(txfSOCode.Text.ToUpper()))
                        {
                            return(false);
                        }
                    }
                }
            }
            else
            {
                Vibration.Vibrate();
                message.DisplayMessage("Please recconect to the internet", true);
                return(false);
            }
            return(true);
        }
Пример #20
0
        private async Task <bool> CheckQTY(string iCode, int qty)
        {
            RestSharp.RestClient client = new RestSharp.RestClient();
            string path = "ItemQOH";

            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
            {
                string str     = $"GET?WH={OutPage.FromWH}&ItemCode={iCode}";
                var    Request = new RestSharp.RestRequest(str, RestSharp.Method.GET);
                var    cancellationTokenSource = new CancellationTokenSource();
                var    res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.IsSuccessful && res.Content != null)
                {
                    if (res.Content == "0")
                    {
                        Loading.IsVisible = false;
                        message.DisplayMessage("There isnt enough stock in this warehouse", true);
                        return(false);
                    }
                    else
                    {
                        int q = 0;

                        try
                        {
                            q = Convert.ToInt32(Double.Parse(res.Content, CultureInfo.InvariantCulture.NumberFormat), CultureInfo.InvariantCulture.NumberFormat);
                        }
                        catch (Exception ex)
                        {
                        }
                        if (q >= (qty + items.Where(x => x.ItemCode == iCode).Sum(X => X.ItemQtyOut)))
                        {
                            return(true);
                        }
                        else
                        {
                            Loading.IsVisible = false;
                            message.DisplayMessage("There arent enough of this item in this warehouse", true);
                            return(false);
                        }
                    }
                }
            }
            Loading.IsVisible = false;
            message.DisplayMessage("Please check your internet connection!", true);
            return(false);
        }
Пример #21
0
        async Task <bool> AddPallet(string SOCode)
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                RestSharp.RestClient client = new RestSharp.RestClient();
                string path = "DocumentSQLConnection";
                client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                {
                    string qry     = $"SELECT MAX(PalletID)AS[MAXPall] FROM PalletTransaction";
                    string str     = $"GET?qry={qry}";
                    var    Request = new RestSharp.RestRequest();
                    Request.Resource = str;
                    Request.Method   = RestSharp.Method.GET;
                    var cancellationTokenSource = new CancellationTokenSource();
                    var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                    if (res.IsSuccessful && res.Content.Contains("MAXPall"))
                    {
                        DataSet myds = new DataSet();
                        myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                        int maxpal = 0;
                        try
                        {
                            maxpal = Convert.ToInt32(myds.Tables[0].Rows[0]["MAXPall"]);
                        }
                        catch
                        {
                            maxpal = 0;
                        }
                        await NewPallet(maxpal + 1);
                    }
                    else
                    {
                        Vibration.Vibrate();
                        message.DisplayMessage("Error in the server!", true);
                        return(false);
                    }
                }
            }
            else
            {
                Vibration.Vibrate();
                message.DisplayMessage("Please recconect to the internet", true);
                return(false);
            }
            return(true);
        }
Пример #22
0
        public static async Task <Models.FakeAPIResponse> GetFakeNews(string message)
        {
            message = message.Replace("/check", "");
            try
            {
                client = new RestSharp.RestClient("https://prod-56.westeurope.logic.azure.com");

                RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/workflows/73896dc86d9149058d3bd5234fb4ae86/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=MmoB-9jJt1DbB25AfNJis889rx8b9LbJDX0zJSCsmoM", RestSharp.Method.POST);

                restRequest.AddHeader("Content-Type", "application/json");

                bool result = Uri.TryCreate(message, UriKind.Absolute, out Uri uriResult) &&
                              uriResult.Scheme == Uri.UriSchemeHttp;

                Models.Request requestObject;
                if (result)
                {
                    requestObject = new Models.Request
                    {
                        url  = message,
                        text = string.Empty
                    };
                }
                else
                {
                    requestObject = new Models.Request
                    {
                        text = message,
                        url  = string.Empty
                    };
                }

                restRequest.AddJsonBody(requestObject);

                var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

                return(JsonConvert.DeserializeObject <Models.FakeAPIResponse>(response.Content));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static async Task <string> Validate([ActivityTrigger] string request,
                                                   ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            try
            {
                client = new RestSharp.RestClient(Environment.GetEnvironmentVariable("CognitiveEndpoint"));

                RestSharp.RestRequest restRequest = new RestSharp.RestRequest("/text/analytics/v2.1/keyPhrases", RestSharp.Method.POST);


                restRequest.AddHeader("Ocp-Apim-Subscription-Key", Environment.GetEnvironmentVariable("CognitiveApiKey"));
                restRequest.AddHeader("Content-Type", "application/json");

                var doc = new Document
                {
                    id       = "1",
                    language = "de",
                    text     = request
                };

                var requestObject = new RootObject
                {
                    documents = new List <Document>()
                    {
                        doc
                    }
                };

                restRequest.AddJsonBody(requestObject);

                var response = await client.ExecuteAsync(restRequest).ConfigureAwait(false);

                return(response.Content);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #24
0
        private static async Task GetAccessTokenAsync()
        {
            var client = new RestSharp.RestClient("https://login.windows.net/common/oauth2/token");

            client.Timeout = -1;
            var internalRequest = new RestSharp.RestRequest(RestSharp.Method.POST);

            internalRequest.AddHeader("Cookie", "x-ms-gateway-slice=prod; stsservicecookie=ests; fpc=AgHuTQ6BuTdPsqX9wzbtm_AqP8ELAQAAADqYsdYOAAAA");
            internalRequest.AlwaysMultipartFormData = true;
            internalRequest.AddParameter("grant_type", "password");
            internalRequest.AddParameter("username", "*****@*****.**");
            internalRequest.AddParameter("password", "Micheal30");
            internalRequest.AddParameter("client_id", "b68f7dee-4098-4f3f-a9db-36a8b71305aa");
            internalRequest.AddParameter("resource", "https://graph.microsoft.com");
            RestSharp.IRestResponse response = await client.ExecuteAsync(internalRequest);


            var jsonresult = Newtonsoft.Json.Linq.JObject.Parse(response.Content);

            Token = (string)jsonresult["access_token"];
        }
Пример #25
0
        public async Task <Boolean> InitializateDb()
        {
            var isUp = false;

            while (!isUp)
            {
                _logger.LogInformation("Checking for DB");
                System.Threading.Thread.Sleep(10000);
                isUp = IsUp().Result;
            }
            await CreateDd().ConfigureAwait(true);

            var    rCouch   = new RestSharp.RestClient(ConnectionDB.ConnectionString);
            string user     = "";
            string password = "";

            if (_configuration.COUCHDB_URL != null)
            {
                user     = _configuration.COUCHDB_USER;
                password = _configuration.COUCHDB_PASSWORD;
            }
            else
            {
                user     = Startup.StaticConfig["DBconnection:user"];
                password = Startup.StaticConfig["DBconnection:password"];
            }
            var auth = new RestSharp.Authenticators.HttpBasicAuthenticator(user, password);

            rCouch.Authenticator = auth;
            try
            {
                rCouch.ExecuteAsync(new RestSharp.RestRequest("/_users"), (resp, opt) => { }, RestSharp.Method.PUT);
            }
            catch
            {
                _logger.LogInformation("Users table creation skip.");
            }
            ConnectionDB.Dispose();
            return(true);
        }
Пример #26
0
        async Task <bool> SendStatus(string status)
        {
            string Status = "DocControlUser";

            if (status == "2")
            {
                Status = "PickerUser";
            }
            else if (status == "3")
            {
                Status = "PackerUser";
            }
            else if (status == "4")
            {
                Status = "AuthUser";
            }
            else
            {
                Status = "DocControlUser";
            }
            RestSharp.RestClient client = new RestSharp.RestClient();
            string path = "DocumentSQLConnection";

            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
            {
                string str     = $"POST?qry=UPDATE tblTempDocHeader SET DocStatus={((Convert.ToInt32(status)) + 1)},{Status}=1 WHERE DocNum ='1'";
                var    Request = new RestSharp.RestRequest();
                Request.Resource = str;
                Request.Method   = RestSharp.Method.POST;
                var cancellationTokenSource = new CancellationTokenSource();
                var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.Content.ToString().Contains("Complete"))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #27
0
        private void buttonGetToken_Click(object sender, EventArgs e)
        {
            RestSharp.RestClient restClient = new RestSharp.RestClient(textBaseUrl.Text);
            var req = new RestSharp.RestRequest("/token", RestSharp.Method.POST);

            req.AddParameter("username", textUsername.Text);
            req.AddParameter("password", textPassword.Text);
            restClient.ExecuteAsync(req, (r, h) =>
            {
                textResponse.BeginInvoke(new Action(() =>
                {
                    if (r.Content.ToLower().Contains("token"))
                    {
                        var settings = new Jose.JwtSettings();

                        dynamic token = JsonConvert.DeserializeObject(r.Content);
                        string _token = token.token;
                    }

                    textGeneratedToken.Text = r.Content;
                }));
            });
        }
        private async Task <bool> SaveData()
        {
            List <DocLine> docs = new List <DocLine>();
            var            ds   = new DataSet();

            try
            {
                var     t1  = new DataTable();
                DataRow row = null;
                t1.Columns.Add("DocNum");
                t1.Columns.Add("ItemBarcode");
                t1.Columns.Add("ScanAccQty");
                t1.Columns.Add("Balance");
                t1.Columns.Add("ScanRejQty");
                t1.Columns.Add("PalletNumber");
                t1.Columns.Add("GRV");
                docs = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemQty == 0 || x.GRN).ToList();
                if (docs.Count == 0)
                {
                    return(true);
                }
                foreach (string str in docs.Select(x => x.ItemCode).Distinct())
                {
                    DocLine currentGRV = (await App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.GRN && x.ItemCode == str).FirstOrDefault();
                    if (currentGRV != null && await GRVmodule())
                    {
                        row                 = t1.NewRow();
                        row["DocNum"]       = UsingDoc.DocNum;
                        row["ItemBarcode"]  = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemCode == str && x.ItemQty != 0).FirstOrDefault().ItemBarcode;
                        row["ScanAccQty"]   = currentGRV.ScanAccQty;
                        row["Balance"]      = 0;
                        row["ScanRejQty"]   = currentGRV.ScanRejQty;
                        row["PalletNumber"] = 0;
                        row["GRV"]          = true;
                        t1.Rows.Add(row);
                    }
                    else if (currentGRV != null && !await GRVmodule())
                    {
                        await DisplayAlert("Please set up GRV in the settings", "Error", "OK");
                    }
                    List <DocLine> CurrItems = (await App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => !x.GRN && x.ItemCode == str && x.ItemQty == 0).ToList();
                    if (CurrItems.Count() > 0)
                    {
                        row                 = t1.NewRow();
                        row["DocNum"]       = UsingDoc.DocNum;
                        row["ItemBarcode"]  = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemCode == str && x.ItemQty != 0).FirstOrDefault().ItemBarcode;
                        row["ScanAccQty"]   = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemCode == str && !x.GRN).Sum(x => x.ScanAccQty);
                        row["Balance"]      = 0;
                        row["ScanRejQty"]   = (await GoodsRecieveingApp.App.Database.GetSpecificDocsAsync(UsingDoc.DocNum)).Where(x => x.ItemCode == str && !x.GRN).Sum(x => x.ScanRejQty);
                        row["PalletNumber"] = 0;
                        row["GRV"]          = false;
                        t1.Rows.Add(row);
                    }
                }
                ds.Tables.Add(t1);
            }
            catch (Exception)
            {
                return(false);
            }
            string myds = Newtonsoft.Json.JsonConvert.SerializeObject(ds);

            RestSharp.RestClient client = new RestSharp.RestClient();
            client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath);
            {
                var Request = new RestSharp.RestRequest("SaveDocLine", RestSharp.Method.POST);
                Request.RequestFormat = RestSharp.DataFormat.Json;
                Request.AddJsonBody(myds);
                var cancellationTokenSource = new CancellationTokenSource();
                var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                if (res.IsSuccessful && res.Content.Contains("COMPLETE"))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #29
0
        private async Task <bool> GetItems(string code)
        {
            if (await RemoveAllOld(code))
            {
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    RestSharp.RestClient client = new RestSharp.RestClient();
                    string path = "GetDocument";
                    client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                    {
                        //https://manifoldsa.co.za/FDBAPI/api/GetDocument/GET?qrystr=ACCHISTL|6|PO100352|106|1
                        string str     = $"GET?qrystr=ACCHISTL|6|{code}|106|" + MainPage.UserCode;
                        var    Request = new RestSharp.RestRequest();
                        Request.Resource = str;
                        Request.Method   = RestSharp.Method.GET;
                        var cancellationTokenSource = new CancellationTokenSource();
                        var res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                        // var res = client.ExecuteAsync(Request);
                        if (res.Content.ToString().Contains("DocNum"))
                        {
                            DataSet myds = new DataSet();
                            myds = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet>(res.Content);
                            foreach (DataRow row in myds.Tables[0].Rows)
                            {
                                try
                                {
                                    var Doc = new DocLine();
                                    Doc.DocNum       = row["DocNum"].ToString();
                                    Doc.SupplierCode = row["SupplierCode"].ToString();
                                    Doc.SupplierName = row["SupplierName"].ToString();
                                    Doc.ItemBarcode  = row["ItemBarcode"].ToString();
                                    Doc.ItemCode     = row["ItemCode"].ToString();
                                    Doc.ItemDesc     = row["ItemDesc"].ToString();
                                    Doc.Bin          = row["Bin"].ToString();
                                    Doc.ItemQty      = Convert.ToInt32(row["ItemQty"].ToString().Trim());
                                    Doc.PalletNum    = 0;
                                    try
                                    {
                                        Doc.ScanAccQty = Convert.ToInt32(row["ScanAccQty"].ToString());
                                    }
                                    catch
                                    {
                                        Doc.ScanAccQty = 0;
                                    }
                                    try
                                    {
                                        Doc.GRN = Convert.ToBoolean(row["GRV"].ToString());
                                    }
                                    catch
                                    {
                                        Doc.GRN = false;
                                    }
                                    try
                                    {
                                        Doc.ScanRejQty = Convert.ToInt32(row["ScanRejQty"].ToString());
                                    }
                                    catch
                                    {
                                        Doc.ScanRejQty = 0;
                                    }
                                    await App.Database.Insert(Doc);
                                }
                                catch (Exception ex)
                                {
                                    Vibration.Vibrate();
                                    message.DisplayMessage("Error in storing items" + ex.Message, true);
                                }
                            }
                            return(true);
                        }
                        else
                        {
                            message.DisplayMessage("Error - Unable to load PO - Please check in Pastel if PO exists and is valid.", true);
                            LodingIndiactor.IsVisible = false;
                            Vibration.Vibrate();
                        }
                    }
                }
                else
                {
                    LodingIndiactor.IsVisible = false;
                    Vibration.Vibrate();
                    message.DisplayMessage("Please connect to the internet", true);
                }
            }
            return(false);
        }
        private async void TxfPackbarcode_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (txfPackbarcode.Text.Length > 1)
            {
                docLines.Clear();
                isLoading.IsVisible = true;
                if (MustMakePack)
                {
                    try
                    {
                        RestSharp.RestClient client = new RestSharp.RestClient();
                        string path = "FindDescAndCode";
                        client.BaseUrl = new Uri(GoodsRecieveingApp.MainPage.APIPath + path);
                        {
                            string qry     = $"ACCPRD|4|{txfPackbarcode.Text}";
                            string str     = $"GET?qrystr={qry}";
                            var    Request = new RestSharp.RestRequest(str, RestSharp.Method.GET);
                            var    cancellationTokenSource = new CancellationTokenSource();
                            var    res = await client.ExecuteAsync(Request, cancellationTokenSource.Token);

                            if (res.IsSuccessful && res.Content != null)
                            {
                                docLines.Add(new DocLine {
                                    ItemBarcode = txfPackbarcode.Text, ItemCode = res.Content.Split('|')[2], ItemDesc = res.Content.Split('|')[3], ItemQty = 1
                                });
                                lblDesc.Text            = "Item: " + res.Content.Split('|')[3];
                                lblDesc.IsVisible       = true;
                                btnGoToRepack.IsVisible = true;
                                return;
                            }
                        }
                    }
                    catch
                    {
                        Vibration.Vibrate();
                        btnGoToRepack.IsVisible = false;
                        message.DisplayMessage("No item code found", true);
                        txfPackbarcode.Text = "";
                        txfPackbarcode.Focus();
                    }
                }
                else
                {
                    try
                    {
                        BOMItem bi = await GoodsRecieveingApp.App.Database.GetBOMItem(txfPackbarcode.Text);

                        lblDesc.IsVisible = true;
                        lblQTY.IsVisible  = false;
                        lblDesc.Text      = "Item: " + bi.ItemDesc;
                        lblQTY.Text       = "Qty: " + bi.Qty;
                        docLines.Add(new DocLine {
                            ItemBarcode = bi.PackBarcode, ItemCode = bi.ItemCode, ItemDesc = "1ItemFromMain", ItemQty = bi.Qty
                        });
                        btnGoToRepack.IsVisible = true;
                    }
                    catch
                    {
                        Vibration.Vibrate();
                        btnGoToRepack.IsVisible = false;
                        message.DisplayMessage("No pack code found", true);
                        txfPackbarcode.Text = "";
                        txfPackbarcode.Focus();
                    }
                }
                isLoading.IsVisible = false;
            }
        }