private void UpdateMedia(string source)
 {
     try
     {
         if (File.Exists(source))
         {
             this.mediaElement.LoadedBehavior   = MediaState.Manual;
             this.mediaElement.UnloadedBehavior = MediaState.Manual;
             this.mediaElement.Close();
             GC.Collect();
             this.mediaElement.Source = new Uri(source);
             this.AdvertisementContainer.Children.Clear();
             this.AdvertisementContainer.Children.Add(this.mediaElement);
             this.mediaElement.HorizontalAlignment = HorizontalAlignment.Stretch;
             this.mediaElement.VerticalAlignment   = VerticalAlignment.Stretch;
             this.mediaElement.Play();
         }
         MsgDisplay.ContentUpdate("");
     }
     catch (Exception exception)
     {
         string msg = "UpdateMedia: " + exception.Message;
         MsgDisplay.ContentUpdate(msg);
         this.log.Error(msg);
     }
 }
        private void handleGetDefault(string baseURL, string path)
        {
            string type = "getDefault";
            string url  = baseURL + "/file/" + type + "/?1=1";

            Console.WriteLine("开始处理默认广告的播放 本地默认文件不存在,尝试下载:" + path);
            if (!this.httpUtils.HttpDownload(url, path))
            {
                MsgDisplay.ContentUpdate("拉取失败,请联系管理员");
                Console.WriteLine("开始处理默认广告的播放  本地默认文件不存在:尝试下载失败!" + path);
            }
            else
            {
                Console.WriteLine("拉取成功 尝试更新资源");
                MsgDisplay.ContentUpdate("拉取成功 尝试更新资源");
                Common.DownLoadStatusUpdate(type, "1");
                this.UpdateMedia(new FileInfo(path).FullName);
            }
        }
        private void AdvertismentDirDelete()
        {
            string machineCode = MicroPrinter.App.AppContext.Instance.MachineCode;
            string json        = HttpUtils.Get(MicroPrinter.App.AppContext.Instance.BaseURL + "/adv/dirDelete/?1=1", "1");

            try
            {
                JObject obj2 = JObject.Parse(json);
                if ((obj2 == null) || (obj2["data"].ToString() == "[]"))
                {
                    Console.WriteLine("AdvertismentDirDelete:deewe");
                    MsgDisplay.ContentUpdate("提示:" + obj2["msg"].ToString());
                }
                else
                {
                    string str2   = @"\download\adv\";
                    JArray source = obj2["data"]["items"] as JArray;
                    for (int i = 0; i < source.Count <JToken>(); i++)
                    {
                        JObject obj1 = source[i] as JObject;
                        string  str3 = obj1["status"].ToString();
                        string  str4 = obj1["path"].ToString();
                        Console.WriteLine("status:" + str3, ",path:" + str4);
                        string file = Environment.CurrentDirectory + str2 + str4;
                        if (str3 == "true")
                        {
                            CommonUtil.DeleteDir(file);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.log.Error("AdvertismentDirDelete: " + exception.Message);
            }
        }
        private void CommonAdvertismentUpdate()
        {
            string baseURL     = MicroPrinter.App.AppContext.Instance.BaseURL;
            string machineCode = MicroPrinter.App.AppContext.Instance.MachineCode;

            Console.WriteLine("共用广告更新 MachineCode:" + machineCode + " end");
            if ((machineCode != null) && (machineCode != string.Empty))
            {
                while (!this.cancellationToken.IsCancellationRequested)
                {
                    string json = HttpUtils.Get(baseURL + "/adv/common/?1=1", "1");
                    try
                    {
                        JObject obj2 = JObject.Parse(json);
                        if ((obj2 == null) || (obj2["data"].ToString() == "[]"))
                        {
                            Console.WriteLine("CommonAdvertismentUpdate:i8d2dioedew");
                            MsgDisplay.ContentUpdate("提示:" + obj2["msg"].ToString());
                        }
                        else
                        {
                            JArray source = obj2["data"]["items"] as JArray;
                            this.commAdvItems = new List <WybAdvGroupItem>();
                            int num2 = 0;
                            while (true)
                            {
                                if (num2 >= source.Count <JToken>())
                                {
                                    this.commAdvItems.Sort((x, y) => x.Order.CompareTo(y.Order));
                                    int num = 0;
                                    for (int i = 1; i < this.commAdvItems.Count <WybAdvGroupItem>(); i++)
                                    {
                                        this.commAdvItems[i].PlayOrder = num + this.commAdvItems[i - 1].DurationCount;
                                        num += this.commAdvItems[i - 1].DurationCount;
                                    }
                                    break;
                                }
                                JObject         obj3  = source[num2] as JObject;
                                WybAdvGroupItem item1 = new WybAdvGroupItem();
                                item1.Id       = obj3["id"].ToString();
                                item1.Order    = (int.Parse(obj3["inGroupOrder"].ToString()) * 20) + (num2 * 10);
                                item1.Type     = obj3["type"].ToString();
                                item1.Duration = int.Parse(obj3["duration"].ToString());
                                WybAdvGroupItem item = item1;
                                item.DurationCount = (int)Math.Ceiling((double)((item.Duration * 1f) / 10f));
                                item.Thumbnail     = obj3["thumbnail"].ToString();
                                char[] separator = new char[] { ';' };
                                item.FileList = obj3["fileUrls"].ToString().Split(separator).ToList <string>();
                                this.commAdvItems.Add(item);
                                num2++;
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        this.log.Error("CommonAdvertismentUpdate: " + exception.Message);
                    }
                    Thread.Sleep(0x2bf20);
                }
            }
        }