/// <summary>
 /// Implements the execution of <see cref="GetInvoiceInfoCommand" />
 /// </summary>
 private void GetInvoiceInfoCommand_Execute(object obj)
 {
     if (int.TryParse(InvoiceNumber.ToString(), out int d))
     {
         GetInvoices(StartDatePurchase, EndDatePurchase, d);
     }
 }
예제 #2
0
        /// <summary>
        /// Outputs string containing the following (replace [] with actual values):
        /// Invoice Number: [InvoiceNumber], InvoiceDate: [dd/MM/yyyy], LineItemCount: [Number of items in LineItems]
        /// </summary>
        public override string ToString()
        {
            string invoiceNumber = InvoiceNumber.ToString();
            string invoiceDate   = InvoiceDate.ToString("dd/MM/yyyy");
            string lineItems     = LineItems.Count().ToString();

            return($"Invoice Number: {invoiceNumber}, InvoiceDate: {invoiceDate}, LineItemCount: {lineItems}");
        }
예제 #3
0
 /// <summary>
 /// Returns the invoice number.
 /// </summary>
 public override string ToString() => InvoiceNumber.ToString();
        protected override void Execute(CodeActivityContext context)
        {
            string     password = new NetworkCredential(string.Empty, Password.Get(context)).Password;
            string     AT       = "";
            WebRequest request  = WebRequest.Create("http://104.197.60.212/token");

            request.Method = "POST";
            string postData = "grant_type=password&username="******"&password="******"text/plain";
            request.ContentLength = byteArray.Length;
            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            using (WebResponse response = request.GetResponse())
            {
                dataStream = response.GetResponseStream();
                using (StreamReader reader = new StreamReader(dataStream))
                {
                    var at = JObject.Parse(reader.ReadToEnd());
                    AT = at["access_token"].ToString();
                }
                dataStream.Close();
            }
            //////////////////////////////////////////////////////////////////////////////////////////////
            DateTime fromDate = FromDate.Get(context);
            DateTime toDate   = ToDate.Get(context);
            string   data     = string.Empty;
            string   url      = string.Empty;

            if (FromDate.Get(context) == null && ToDate.Get(context) == null)
            {
                url = @"http://104.197.60.212/api/invoice_header";
            }
            else if (FromDate.Get(context) != null && ToDate.Get(context) != null)
            {
                url = @"http://104.197.60.212/api/invoice_header?from=" + fromDate.ToString("yyyy-MM-dd") + "&to=" + toDate.ToString("yyyy-MM-dd");
            }
            else if (FromDate.Get(context) != null && ToDate.Get(context) == null)
            {
                url = @"http://104.197.60.212/api/invoice_header?from=" + fromDate.ToString("yyyy-MM-dd");
            }
            else if (FromDate.Get(context) == null && ToDate.Get(context) != null)
            {
                url = @"http://104.197.60.212/api/invoice_header?to=" + toDate.ToString("yyyy-MM-dd");
            }
            HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url);

            request1.Headers.Add("Authorization", "Bearer " + AT);
            request1.AutomaticDecompression = DecompressionMethods.GZip;
            using (HttpWebResponse response = (HttpWebResponse)request1.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        data = reader.ReadToEnd();
                    }
            List <int> InvoiceNumbers = JsonConvert.DeserializeObject <List <int> >(data);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            List <invoice_header> output1 = new List <invoice_header>();

            foreach (int InvoiceNumber in InvoiceNumbers)
            {
                string         IH            = GetInvoiceH(AT, InvoiceNumber.ToString());
                string         II            = GetInvoiceI(AT, InvoiceNumber.ToString());
                invoice_header invoiceheader = JsonConvert.DeserializeObject <invoice_header>(IH);
                invoiceheader.invoice_details_list = JsonConvert.DeserializeObject <List <invoice_details> >(II);
                output1.Add(invoiceheader);
            }
            Invoices.Set(context, output1);
        }
예제 #5
0
 public override string ToString()
 {
     return(InvoiceNumber.ToString());
 }