Exemple #1
0
        void LoadfromAirTable(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker bw = sender as BackgroundWorker;

                string[] s_MatCategories = new string[] { "CP", "FB", "GS", "LM", "LT", "MT", "PT", "PV", "SS", "ST", "TL", "WC", "WD", "WP", "WDP" };
                string   APPLICATION_ID  = "appLyhgFjSLx0kVBv";

                List <ATTable> tables = new List <ATTable>();

                int index = 0;
                foreach (string matCat in s_MatCategories)
                {
                    ATTable at = DownloadData.GetData(APPLICATION_ID, matCat);
                    if (null != at && !at.IsEmpty())
                    {
                        tables.Add(at);
                    }
                    index++;
                    int percengage = (int)(index * 20 / s_MatCategories.Length);
                    bw.ReportProgress(percengage);
                }

                string jsFile = @"C:\Users\lyan\Source\Repos\airtable.net-master\AirTableTest\bin\Debug\file.json";
                string knFile = @"C:\Users\lyan\Source\Repos\airtable.net-master\AirTableTest\bin\Debug\KeyNote.txt";

                DownloadData.DownloadImages(tables, jsFile, @"C:\Users\lyan\Source\Repos\airtable.net-master\AirTableTest\bin\Debug\images\", bw);
                DownloadData.SaveKeynoteFile(tables, knFile);
                bw.ReportProgress(98);
                DownloadData.SaveJson(tables, jsFile);
                bw.ReportProgress(100);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("GAME OVER");

            Console.Read();
        }