示例#1
0
        private async void btnTestBills_Click(object sender, EventArgs e)
        {
            OpenStateClientLib.OpenStateClient cli;
            cli = new OpenStateClientLib.OpenStateClient();
            // bool keepgoing = true;
            rtbResults.Clear();

            string Cursor = "";

            var ResultsC = await cli.GetBillsAllAsync("Texas", "851", Cursor, ExtraGuiAction);
        }
        /// <summary>
        /// get all bills filtered by both subject and start dates.
        /// The start dates of the sessions helps keep us from making quite so many
        /// bill queries.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="startdate"></param>
        /// <param name="subjects">each space delimited token is searched for and all bill subjects that contain any token are returned</param>
        /// <param name="cursor"></param>
        /// <param name="f">action for each bill. null means no action.</param>
        public async Task <Newtonsoft.Json.Linq.JArray> GetBillsFilteredAsync(string state, DateTime startdate, DateTime enddate, string subjects, string cursor, ExtraActionPerBill f)
        {
            OpenStateClientLib.OpenStateClient cli;
            cli = new OpenStateClientLib.OpenStateClient();

            Newtonsoft.Json.Linq.JArray AllBills = new Newtonsoft.Json.Linq.JArray();

            var results = await cli.GetStateLegesAsync(state);

            var aaa = results.Data;

            List <string>   SessionNames;
            List <string>   SessionIds;
            List <DateTime> SessionStarts;
            bool            Ok = ExtractSessionNames(results, out SessionNames, out SessionIds, out SessionStarts);

            if (SessionNames != null && SessionIds != null)
            {
                int nn = SessionNames.Count;
                for (int ii = 0; ii < nn; ii++)
                {
                    string SessionI   = SessionNames[ii];
                    string SessionIdI = SessionIds[ii];
                    if (startdate <= SessionStarts[ii])
                    {
                        Newtonsoft.Json.Linq.JArray Bills = await cli.GetBillsAllAsync(state, SessionIdI, "", null);

                        if (Bills != null)
                        {
                            int n = Bills.Count;
                            for (int i = 0; i < n; i++)
                            {
                                Newtonsoft.Json.Linq.JToken OneBill = Bills[i]["node"];

                                Newtonsoft.Json.Linq.JArray SubjectsFound = OneBill["subject"] as Newtonsoft.Json.Linq.JArray;
                                string          updatedAt = OneBill["updatedAt"].ToString();
                                System.DateTime updatedAtDate;
                                bool            OkUpdatedAtDate = System.DateTime.TryParse(updatedAt, out updatedAtDate);
                                if (OkUpdatedAtDate && updatedAtDate >= startdate &&
                                    updatedAtDate <= enddate &&
                                    OpenStateClientLib.OpenStateClient.IsBillSubjectFound(subjects, SubjectsFound))
                                {
                                    f?.Invoke(OneBill);
                                    AllBills.Add(OneBill);
                                }
                            }
                        }
                    }
                }
            }
            return(AllBills);
        }