Exemple #1
0
        public static bool CheckHttpStatusCode()
        {
            //  StatusCodes statusCodes = new StatusCodes();

            bool       isSuccess = false;
            HttpClient client    = new HttpClient();

            client = BusinessAuthentication.SendAuthentication();
            string apiUrl = ConfigurationManager.AppSettings["api_url"];
            HttpResponseMessage response = null;

            try
            {
                response = client.GetAsync(apiUrl + "/connectivity/retrievestatus").Result;
                if (response.IsSuccessStatusCode)
                {
                    isSuccess   = response.IsSuccessStatusCode;
                    statusCodes = response.StatusCode.ToString();
                    // statusCodes.StatusCodeInteger =(int) response.StatusCode;
                }
                else
                {
                    isSuccess   = response.IsSuccessStatusCode;
                    statusCodes = response.StatusCode.ToString();
                    // statusCodes.StatusCodeInteger = (int)response.StatusCode;
                }
            }
            catch (Exception ex)
            {
                statusCodes = "ERROR: " + ex;
            }
            return(isSuccess);
        }
        public static void SendClientStatus()
        {
            string      connectionError = "";
            NetworkInfo netInfo         = new NetworkInfo();

            //netInfo.UserName = "******";
            //netInfo.Password = "******";
            netInfo.UserID = 1;
            //  InternetConnection ic = new InternetConnection();
            netInfo.BusinessIDLocal     = InternetConnection.GetBusinessID();
            netInfo.NetworkAvailability = IsConnectedToInternet().ToString();
            netInfo.BusinessCode        = InternetConnection.GetBusinessCode().ToString();

            HttpClient client = new HttpClient();

            client = BusinessAuthentication.SendAuthentication();

            string              apiUrl       = ConfigurationManager.AppSettings["api_url"] + "Connectivity";
            string              inputJson    = (new JavaScriptSerializer()).Serialize(netInfo);
            HttpContent         inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");
            HttpResponseMessage response     = null;

            try
            {
                response = client.PostAsync(apiUrl + "/insertstatus", inputContent).Result;
                if (response.IsSuccessStatusCode)
                {
                    var readTask = response.Content.ReadAsAsync <NetworkInfo>();
                    // lblNetworkInfo.Text = readTask.ToString();
                }
                else
                {
                    ///code for no status of 200 OK
                }
            }
            catch (AggregateException ex)
            {
                foreach (Exception inner in ex.InnerExceptions)
                {
                    Console.WriteLine("Exception type {0} from {1}", inner.GetType(), inner.Source);
                }
            }
        }
        public static string SendVendorOfflineInvoices()
        {
            string read            = "";
            string connectionError = "";

            try
            {
                HttpClient client = new HttpClient();
                client = BusinessAuthentication.SendAuthentication();
                string      apiUrl       = ConfigurationManager.AppSettings["api_url"] + "sales";
                string      inputJson    = (new JavaScriptSerializer()).Serialize(OfflineActivities.GetOfflineInvoices());
                HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");

                HttpResponseMessage response = client.PostAsync(apiUrl + "/salesofflineinvoice", inputContent).Result;
                if (response.IsSuccessStatusCode)
                {
                    Sales sales    = new Sales();
                    var   readTask = response.Content.ReadAsAsync <List <Sales> >().Status;
                    read = readTask.ToString();
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_ClientConnectionStatusInOfflineActivityToNullInSales_Master", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                else
                {
                }
            }
            catch (SystemException ex)
            {
                read = "Exception: " + ex.Message.ToString();
            }
            catch (Exception ex)
            {
                read = "Exception: " + ex.Message.ToString();
            }

            return(read);
        }
Exemple #4
0
        /// <summary>
        /// BY TRANSFERRING REALTIME VOUCHERS AND SALE INVOICES IS PREREQUISITE TO EVERY SERVER-SIDE RIMS APPLICATION.
        /// THIS DETAILED SALE INVOICE IS USED TO TRANSFER INVOICING DATA TO THE RELEVANT SERVER BY ONE BUTTON CLICK.
        /// </summary>
        /// <param name="totalAmount">THIS PARAM REPRESENTS THE TOTAL AMOUNT OF INVOICE CREATED</param>
        /// <param name="discount">THIS PARAM REPRESENTS DISCOUNT RATES OFFERED TO CUSTOMERS</param>
        /// <param name="salesTaxRate">THIS PARAM REPRESENTS SALES TAX RATE</param>
        /// <param name="salesTax">THIS PARAM REPRESENTS SALES TAX ON SERVICES AS PER TOTAL SUM OF INVOICE</param>
        /// <param name="netAmount">THIS PARAM REPRESENTS NET AMOUNT OF THE INVOICE CREATED</param>
        /// <param name="paid">THIS PARAM REPRESENTS MONEY PAID BY THE CUSTOMER</param>
        /// <param name="todayTime">THIS PARAM REPRESENTS CURRENT DATE AND TIME OF INVOICE CREATED ON</param>
        /// <param name="businessID">THIS PARAM REPRESENTS BUSINESS ID OF PER BUSINESS FIRM OR COMPANY</param>
        /// <param name="stationID">THIS PARAM REPRESENTS STATION IDENTIFIER OF EACH STATION LINKED WITH A PARTICULAR BUSINESS FIRM OR COMPANY </param>
        /// <param name="description">THIS PARAM REPRESENTS THE EXPLAINATION OF THE INVOICE</param>
        /// <param name="otherCharges">THIS PARAM REPRESENTS MISCELLANEOUS CHARGES RENDERD</param>
        public static void SendOnlineSalesDetail(long productID, string productName, int quantity,
                                                 decimal unitPrice, decimal totalPrice, long salesMasterIDLocal, long businessIDLocal, string businessCode)
        {
            string results;
            string connectionError = "";

            try
            {
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = productID;
                salesDetail.ProductName        = productName;
                salesDetail.Quantity           = quantity;
                salesDetail.UnitPrice          = unitPrice;
                salesDetail.TotalPrice         = totalPrice;
                salesDetail.SalesMasterIDLocal = salesMasterIDLocal;
                salesDetail.BusinessIDLocal    = businessIDLocal;
                salesDetail.BusinessCode       = businessCode;

                //using (var client = new HttpClient())
                //{
                HttpClient client = new HttpClient();
                client = BusinessAuthentication.SendAuthentication();
                string      apiUrl       = ConfigurationManager.AppSettings["api_url"] + "sales";
                string      inputJson    = (new JavaScriptSerializer()).Serialize(salesDetail);
                HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");
                try
                {
                    HttpResponseMessage response = client.PostAsync(apiUrl + "/SalesDetail", inputContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        results = response.Content.ReadAsStringAsync().Result.ToString();
                        SqlConnection conn = new SqlConnection(connStaticString);
                        SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStateFromOneToNullInSales_Details", conn);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                    else
                    {
                        //update isconnected value to 0 in sales_details table where isConnected is equal to 1 recently
                        SqlConnection conn = new SqlConnection(connStaticString);
                        SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
                catch (Exception ex)
                {
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }



                //}
            }
            catch {
                SqlConnection conn = new SqlConnection(connStaticString);
                SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
Exemple #5
0
        public static void SendOnlineInvoice(double totalAmount, decimal discount, double salesTaxRate, double salesTax, double netAmount,
                                             double paid, DateTime?todayTime, string description, double otherCharges, long salesMasterID, long businessIDLocal, string businessCode)
        {
            #region local vars
            string results;
            string connectionError = "";

            Sales sales = new Sales();

            sales.TotalAmount        = Convert.ToDecimal(totalAmount);
            sales.Discount           = discount;
            sales.SalesTaxRate       = Convert.ToDecimal(salesTaxRate);
            sales.SalesTax           = Convert.ToDecimal(salesTax);
            sales.NetAmount          = Convert.ToDecimal(netAmount);
            sales.Paid               = Convert.ToDecimal(paid);
            sales.TodayTime          = todayTime;
            sales.Description        = description;
            sales.OtherCharges       = Convert.ToDecimal(otherCharges);
            sales.SalesMasterIDLocal = Convert.ToInt64(salesMasterID);
            sales.BusinessIDLocal    = businessIDLocal;
            sales.BusinessCode       = businessCode;
            #endregion
            //using (var client = new HttpClient())
            //{
            HttpClient client = new HttpClient();
            client = BusinessAuthentication.SendAuthentication();
            string apiUrl = ConfigurationManager.AppSettings["api_url"] + "sales";

            string      inputJson    = (new JavaScriptSerializer()).Serialize(sales);
            HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");
            try
            {
                HttpResponseMessage response = null;

                response = client.PostAsync(apiUrl + "/salesinvoice", inputContent).Result;
                if (response.IsSuccessStatusCode)
                {
                    results = response.Content.ReadAsStringAsync().Result.ToString();
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStateFromOneToNullInSales_Master", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }

                else
                {
                    //update isConnected value to 0 in sales_master table where isConnected Value happened to be 1 recently
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Master", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                //update isConnected value to 0 in sales_master table where isConnected Value happened to be 1 recently
                SqlConnection conn = new SqlConnection(connStaticString);
                SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Master", conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
        /// <summary>
        /// THIS METHOD IS A STATIC ONE, IS USED TO SEND OFFLINE INVOICES ON WINDOWS FORM ACTIVATED METHOD WHENEVER THE CONNECTION GETS ONLINE
        /// THE EVENT IS INVOKED AND RESUMES THE PROCESS OF SENDING OFFLINE INVOICES FROM THE LOCAL MACHINE TO THE SERVER SITE
        ///
        /// </summary>
        public static string SendVendorOfflineSalesDetail()
        {
            string read            = "";
            string connectionError = "";

            try
            {
                HttpClient client = new HttpClient();
                client = BusinessAuthentication.SendAuthentication();
                string      apiUrl       = ConfigurationManager.AppSettings["api_url"] + "sales";
                string      inputJson    = (new JavaScriptSerializer()).Serialize(OfflineActivities.GetOfflineSalesDetail());
                HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");

                HttpResponseMessage response = client.PostAsync(apiUrl + "/SalesDetailOfflineInvoice", inputContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    SalesDetail sales    = new SalesDetail();
                    var         readTask = response.Content.ReadAsAsync <List <SalesDetail> >().Status;
                    read = readTask.ToString();
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_ClientConnectionStatusInOfflineActivityToNullInSales_Details", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                else
                {
                }
            }
            catch (SocketException ex)
            {
                string s = ex.ToString();
                //return false;
            }
            //catch (System.Net.Sockets.SocketException socketEx)
            //{
            //    read += socketEx.Message + "\r\n" + socketEx.StackTrace;
            //}
            catch (System.Net.WebException socketEx)
            {
                read += socketEx.Message + "\r\n" + socketEx.StackTrace;
            }
            catch (AggregateException ex)
            {
                foreach (Exception inner in ex.InnerExceptions)
                {
                    Console.WriteLine("Exception type {0} from {1}", inner.GetType(), inner.Source);
                    read += inner.GetType() + " " + inner.Source;
                }
            }

            ////catch (SystemException sysEx)
            ////{ }
            ////catch (Exception ex)
            ////{ }
            //catch (System.Net.Sockets.SocketException socketEx)
            //{
            //    read += socketEx.Message + "\r\n";
            //}
            //catch (System.Net.WebException socketEx)
            //{
            //    read += socketEx.Message + "\r\n";
            //}

            return(read);
        }