예제 #1
0
        public AppVM()
        {
            string type = Res.DEFAULT_TYPE;

            if (ConfigurationManager.AppSettings["DefaultType"]?.Length > 0)
            {
                type = ConfigurationManager.AppSettings["DefaultType"];
            }
            this.Type = Convert.ToInt32(type);

            string url = Res.DEFAULT_URL;

            if (ConfigurationManager.AppSettings["DefaultURL"]?.Length > 0)
            {
                url = ConfigurationManager.AppSettings["DefaultURL"];
            }
            this.URL = url;

            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if (ConfigurationManager.AppSettings["DefaultPath"]?.Length > 0)
            {
                path = ConfigurationManager.AppSettings["DefaultPath"];
            }
            this.OutputPath = path;

            this.ds = BuildSet.New();
            foreach (DataColumn c in ds.Tables[0].Columns)
            {
                this.Fields.Add(c.ColumnName);
            }
            this.CanLoad = File.Exists(Path.Combine(this.outputPath, Res.SessionData));
        }
예제 #2
0
        internal async void LoadSessions()
        {
            try
            {
                this.Status = "Loading sessions from file...";
                await Task.Run(() =>
                {
                    this.ds = BuildSet.New();
                    ds.ReadXml(Path.Combine(this.outputPath, Res.SessionData));
                });

                this.DV     = new DataView(this.ds.Tables["B"]);
                this.Status = "";
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
예제 #3
0
        internal async Task DownloadSessions()
        {
            string     json, json2;
            dynamic    o;
            HttpClient c;
            int        i          = 0;
            bool       hasSlides  = false;
            bool       hasVideo   = false;
            bool       hasChanged = false;
            string     d;
            DataRow    r;

            c = new HttpClient();

            json = await c.GetStringAsync(this.url);

            json2       = json.Replace("OMG", "").Replace("\\\"\\\"", "");  //Cleanup
            this.Status = " Processing session data...";
            o           = Tool.JsonConvertToClass <dynamic>(json2);
            Tool.CreateFolder(this.outputPath);
            File.WriteAllText(Path.Combine(this.outputPath, Res.SessionJson), json2);
            this.ds = BuildSet.New();

            foreach (dynamic item in o)
            {
                i++;
                try
                {
                    hasSlides = item.slideDeck?.ToString().Length > 0;
                    if (item.downloadVideoLink != null)
                    {
                        hasVideo = item.downloadVideoLink.ToString().Length > 0;
                    }
                    if (item.description.ToString().Contains("’"))
                    {
                        //TODO: Find a way to remove unwanted characters
                        d = item.description.ToString().Replace("’", "'").Replace("’", "'");
                    }

                    r = ds.Tables["B"].NewRow();

                    r["sessionId"]               = item.sessionId;
                    r["sessionCode"]             = item.sessionCode;
                    r["title"]                   = item.title;
                    r["sortRank"]                = item.sortRank;
                    r["level"]                   = item.level;
                    r["sessionTypeId"]           = item.sessionTypeId;
                    r["sessionType"]             = item.sessionType;
                    r["durationInMinutes"]       = item.durationInMinutes;
                    r["lastUpdate"]              = item.lastUpdate;
                    r["visibleInSessionListing"] = item.visibleInSessionListing;
                    r["slideDeck"]               = item.slideDeck;

                    if (this.Type == 1)
                    {
                        r["downloadVideoLink"] = item.downloadVideoLink;
                        r["onDemandThumbnail"] = item.onDemandThumbnail;
                    }
                    r["captionFileLink"] = item.captionFileLink;
                    r["hasSlides"]       = hasSlides;
                    r["hasVideo"]        = hasVideo;
                    r["hasChanged"]      = hasChanged;
                    r["desciption"]      = item.description;

                    ds.Tables["B"].Rows.Add(r);

                    Trace.WriteLine($"INF {i} {item.sessionId}");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine($"ERR {i} {item.sessionId} {ex.Message}");
                }
            }
            ds.WriteXmlSchema(Path.Combine(this.outputPath, Res.SessionSchema));
            ds.WriteXml(Path.Combine(this.outputPath, Res.SessionData));
        }