Ejemplo n.º 1
0
        private void OnCurrentItemChangedAsync(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            var newItem = args.NewItem;

            if (newItem == null)
            {
                return;
            }
            ChangeSelectItem();
            if (newItem.Source.CustomProperties["Message"] is MusicBoardParameter para)
            {
                AppResources.MusicIsCurrent = para;
            }
            if (ServiceType == MusicServiceType.MHz)
            {
                ActionForMHz?.Invoke();
            }
            CacheItems.Add(newItem);
            if (CacheItems.Count <= CacheMax || CacheItems.ToList().Exists(i => i.Source.CustomProperties["SHA256"] as string == newItem.Source.CustomProperties["SHA256"] as string))
            {
                return;
            }
            CacheItems[0].Source.Reset();
            CacheItems.RemoveAt(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 設定簡訊應用程式列表資料
        /// </summary>
        void CreateSmsAppInfo()
        {
            try
            {
                DataTable dt = Dao.SelectUSP("dbo.uspSmsPlatformAppInfoList", null, null, Setting.ConnectionString("SmsPlatform"));
                List <SmsPlatformAppInfoModel> smsAppInfoDataList           = new List <SmsPlatformAppInfoModel> {
                };
                List <SmsPlatformAppSmsCorpModel> smsPlatformAppSmsCorpList = GetValidSmsAppSmsCorp();
                if (dt != null)
                {
                    foreach (DataRow cd in dt.Rows)
                    {
                        smsAppInfoDataList.Add(new SmsPlatformAppInfoModel
                        {
                            Id = Convert.ToInt32(cd["Id"].ToString()),
                            ApplicationName    = cd["ApplicationName"].ToString(),
                            DepartmentId       = Convert.ToInt32(cd["DepartmentId"].ToString()),
                            ApplicationSn      = new Guid(cd["ApplicationSn"].ToString()),
                            IsValid            = Convert.ToBoolean(cd["Valid"]),
                            IsTest             = Convert.ToBoolean(cd["IsTest"]),
                            SentCount          = Convert.ToInt32(cd["Count"].ToString()),
                            CreatorId          = Convert.ToInt32(cd["CreatorId"].ToString()),
                            CreateOn           = Convert.ToDateTime(cd["CreateOn"]).ToString("yyyy/MM/dd HH:mm:ss"),
                            LastEditorId       = cd["LastEditorId"] == DBNull.Value ? new int?() : Convert.ToInt32(cd["LastEditorId"]),
                            LastEditOn         = cd["LastEditorId"] == DBNull.Value ? "" : Convert.ToDateTime(cd["LastEditOn"]).ToString("yyyy/MM/dd HH:mm:ss"),
                            AppSmsCorps        = smsPlatformAppSmsCorpList.FindAll(p => p.AppInfoId == Convert.ToInt32(cd["Id"].ToString())),
                            ActivityCount      = Convert.ToInt32(cd["ActivityCount"].ToString()),
                            ActivityEndTime    = cd["ActivityEndTime"] == DBNull.Value ? "" : Convert.ToDateTime(cd["ActivityEndTime"]).ToString("yyyy/MM/dd HH:mm:ss"),
                            ActivityUpperLimit = cd["ActivityUpperLimit"] == DBNull.Value ? new int?() : Convert.ToInt32(cd["ActivityUpperLimit"]),
                            Reason             = cd["Reason"].ToString()
                        });
                    }
                }
                else
                {
                    smsAppInfoDataList.Add(_defaultData);
                }

                DateTimeOffset policyDay = new DateTimeOffset(DateTime.Now.AddDays(Convert.ToDouble((Setting.GetConfig("CacheItemPolicy", "AbsoluteExpiration", "SmsPlatformAppInfo")))));
                CacheItems.Add(smsAppInfoDataList, "SmsAppInfoList", policyDay, true);
            }
            catch (Exception ex)
            {
                throw new Exception("[SmsPlatformAppInfoDataCache.CreateSmsAppInfo]Error," + ex.Message);
            }
        }