Exemple #1
0
        public List <string> LCOPending()
        {
            List <string> lcolsit = new List <string>();
            string        str     = RestAPICall.MakeRequest("http://" + severname + "/lco/files/pending/appx003-090-" + entity, null, "GET", "application/json", typeof(Program), entity);

            try
            {
                JObject o = JObject.Parse(str);
                if ((Boolean)o["success"])
                {
                    var items = o["result"].ToList();
                    foreach (JToken val in items)
                    {
                        JObject v = val as JObject;
                        lcolsit.Add((string)v["GULCOID"]);
                    }
                }
                else
                {
                    cmd.WriteLine("Error : " + (string)o["result"]);
                }
            }
            catch (Exception ex)
            {
                cmd.WriteLine("Error Retriving GULCOIDs : " + ex.Message, Info.Error);
            }
            return(lcolsit);
        }
Exemple #2
0
        public string MakeRequestTread(string lcoid, string call)
        {
            try
            {
                string str = RestAPICall.MakeRequest("http://" + severname + "/lco/accounts_v1/" + lcoid + "/" + call + "/" + LastID, null, "GET", "application/json", typeof(Program), entity);

                JObject       o  = JObject.Parse(str);
                StringBuilder sb = new StringBuilder();
                if ((Boolean)o["success"])
                {
                    IList <JToken> items = o["result"]["results"].Children().ToList();
                    if (o["result"]["record_count"] != null)
                    {
                        RecordCount = (int)o["result"]["record_count"];
                        FileName    = (string)o["result"]["Name"];
                        try
                        {
                            string error = (string)o["result"]["Error"];
                            if (error != null)
                            {
                                cmd.WriteLine("http://" + severname + "/lco/accounts_v1/" + lcoid + "/" + call + "/" + LastID + error, Info.Error);

                                cmd.WriteLine("Bulk Insert Failed: " + lcoid + "page id" + LastID + " - " + error, Info.Error);
                            }
                        }catch (Exception ex)
                        {
                            cmd.WriteLine("Error Not Found:" + ex.Message, Info.Error);
                        }
                        //JToken val in items[0]
                        if (RecordCount != 0)
                        {
                            JObject v          = items[0] as JObject;
                            string  HeaderList = "";
                            foreach (JProperty prop in v.Properties())
                            {
                                HeaderList += prop.Name + ",";
                            }
                            sw.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                            swDayExp7.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                            swexp.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                        }
                        else
                        {
                            return("");
                        }
                        //Console.WriteLine();
                    }
                    foreach (JToken val in items)
                    {
                        JObject  v          = val as JObject;
                        string   HeaderList = "";
                        DateTime expdate    = DateTime.Now;
                        if (v["ExpiryDate"].GetType() == typeof(JObject))
                        {
                            string expiry = Convert.ToString(v["ExpiryDate"]["date"]);
                            DateTime.TryParse(expiry, out expdate);
                        }


                        string Status = (string)v["Status"];

                        foreach (JProperty prop in v.Properties())
                        {
                            if (val[prop.Name].GetType() != typeof(JArray) || val[prop.Name].GetType() != typeof(JObject))
                            {
                                try
                                {
                                    if (prop.Name == "ExpiryDate")
                                    {
                                        HeaderList += expdate.ToString("MM/dd/yyyy") + ",";
                                    }
                                    else
                                    {
                                        HeaderList += (string)val[prop.Name] + ",";
                                    }
                                }
                                catch (Exception e)
                                {
                                    HeaderList += ",";
                                }
                            }
                            else
                            {
                                HeaderList += ",";
                            }
                        }
                        if (Status.ToLower() != "active")
                        {
                            swexp.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                        }
                        else
                        {
                            var days = (expdate - DateTime.Now).TotalDays;
                            if (days <= 7)
                            {
                                swDayExp7.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                            }
                            sw.WriteLine(HeaderList.Substring(0, HeaderList.Length - 1));
                        }
                    }
                    LastID += 1;
                }
                else
                {
                    //throw
                    cmd.WriteLine((string)o["result"], Info.Error);
                    return(null);
                    //throw new Exception((string)o["result"]);
                }

                return(sb.ToString());
            }
            catch (Exception Ex)
            {
                cmd.WriteLine("Error ." + Ex.Message + "-" + lcoid, Info.Error);
                return(null);
                //throw Ex;
            }
        }