当前位置: 首页>>代码示例>>C#>>正文


C# IPTV2_Model.IPTV2Entities类代码示例

本文整理汇总了C#中IPTV2_Model.IPTV2Entities的典型用法代码示例。如果您正苦于以下问题:C# IPTV2Entities类的具体用法?C# IPTV2Entities怎么用?C# IPTV2Entities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IPTV2Entities类属于IPTV2_Model命名空间,在下文中一共展示了IPTV2Entities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

        static string DefaultCurrency = "USD";  // Use for cross conversion

        public static decimal Convert(IPTV2Entities context, string baseCurrency, string targetCurrency, decimal amount)
        {
            decimal  newAmount = amount;

            if (baseCurrency == targetCurrency)
                return amount;

            var thisRate = context.Forexes.Find(new string[] { baseCurrency, targetCurrency });
            if (thisRate != null)
            {
                return (decimal)((double)amount * thisRate.ExchangeRate);
            }
            else
            {
                thisRate = context.Forexes.Find(new string[] { targetCurrency, baseCurrency });
                if (thisRate != null)
                {
                    return (decimal)((double)amount / thisRate.ExchangeRate);
                }
                else
                {
                    // convert baseCurrency to DefaultCurrency first
                    thisRate = context.Forexes.Find(new string[] { DefaultCurrency, baseCurrency });
                    if (thisRate == null) throw new Exception("Cannot convert from base currency.");
                    newAmount = (decimal)((double)amount / thisRate.ExchangeRate);

                    // convert DefaultCurrency to targetCurrency
                    thisRate = context.Forexes.Find(new string[] { DefaultCurrency, targetCurrency });
                    if (thisRate == null) throw new Exception("Cannot convert to target currency.");
                    newAmount = (decimal)((double)newAmount * thisRate.ExchangeRate);
                }
            }

            return (newAmount);
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:37,代码来源:Forex.cs

示例2: TestProducts

        public static void TestProducts()
        {
            var context = new IPTV2Entities();
            var lite1M = context.Products.Find(5);
            var lite3M = context.Products.Find(6);
            var lite12M = context.Products.Find(7);

            var is1MUsAllowed = lite1M.IsAllowed("US"); // false
            var is3MUsAllowed = lite3M.IsAllowed("US"); // false
            var is12MUsAllowed = lite12M.IsAllowed("US"); //false

            var is1MJpAllowed = lite1M.IsAllowed("JP"); // true
            var is3MJpAllowed = lite3M.IsAllowed("JP"); // true
            var is12MJpAllowed = lite12M.IsAllowed("JP"); //true


            var prem1M = context.Products.Find(1);
            var prem3M = context.Products.Find(3);
            var prem12M = context.Products.Find(4);
            var prem10D = context.Products.Find(2);

            var isPrem1M = prem1M.IsAllowed("US"); // true
            var isPrem3M = prem3M.IsAllowed("US"); // true
            var isPrem12M = prem12M.IsAllowed("US");  // true
            var isPrem10D = prem10D.IsAllowed("US");  // true

            var ae = context.Countries.Find("AE");
            var aePricePrem1M = prem1M.GetPrice(ae);

            var us = context.Countries.Find("US");
            var usPriceLite1M = lite1M.GetPrice(us);

        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:33,代码来源:ProductTester.cs

示例3: Verify

        public ActionResult Verify(string id)
        {
            if (String.IsNullOrEmpty(id))
                return new HttpNotFoundResult();
            System.Guid g;
            if (!System.Guid.TryParse(id, out g))
                return new HttpNotFoundResult();

            var context = new IPTV2Entities();
            var tester = context.BetaTesters.FirstOrDefault(b => b.InvitationKey == new System.Guid(id) && b.DateClaimed == null);
            if (tester != null)
            {
                //tester.DateClaimed = DateTime.Now;
                //tester.IpAddress = Request.GetUserHostAddressFromCloudflare();
                //if (context.SaveChanges() > 0)
                //{
                //    HttpCookie cookie = new HttpCookie("testerid");
                //    cookie.Value = id;
                //    cookie.Expires = DateTime.Now.AddYears(10);
                //    this.ControllerContext.HttpContext.Response.SetCookie(cookie);
                //    //return RedirectToAction("Index", "Home");
                //    return RedirectToAction("Register", "User");
                //}

                HttpCookie cookie = new HttpCookie("testerid");
                cookie.Value = id;
                cookie.Expires = DateTime.Now.AddYears(10);
                this.ControllerContext.HttpContext.Response.SetCookie(cookie);
                return RedirectToAction("Register", "User", new { iid = id });
            }
            else
                return Content("Key already used.", "text/html");

            //return new HttpNotFoundResult();
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:35,代码来源:BetaController.cs

示例4: GetPlayList

        public PartialViewResult GetPlayList(int? id)
        {
            var context = new IPTV2Entities();
            if (id == null)
            {
                id = GlobalConfig.FreeTVPlayListId;
            }
            var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible);
            if (feature == null)
                return null;

            List<FeatureItem> featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).ToList();
            List<JsonFeatureItem> jfi = new List<JsonFeatureItem>();
            foreach (EpisodeFeatureItem f in featureItems)
            {
                if (f is EpisodeFeatureItem)
                {
                    Episode ep = context.Episodes.Find(f.EpisodeId);
                    if (ep != null)
                    {
                        Show show = ep.EpisodeCategories.FirstOrDefault(e => e.CategoryId != GlobalConfig.FreeTvCategoryId).Show;
                        if (show != null)
                        {
                            string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo);
                            string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster);
                            JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = ep.Description, EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = show.CategoryName, EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80) };
                            jfi.Add(j);
                        }
                    }
                }
            }
            ViewBag.FeaturedId = id;
            return PartialView("_GetPlayList", jfi);
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:34,代码来源:FreeTVController.cs

示例5: List

        public ActionResult List(int id = 1)
        {
            int page = id;

            var context = new IPTV2Entities();
            var episodeIds = context.EpisodeCategories1.Where(e => e.CategoryId == GlobalConfig.KwentoNgPaskoCategoryId && e.Episode.OnlineStatusId == GlobalConfig.Visible).OrderByDescending(e => e.Episode.AuditTrail.CreatedOn)
                .Skip((page - 1) * pageSize)
                .Take(pageSize)
                .Select(e => e.EpisodeId);

            var totalCount = context.EpisodeCategories1.Count(e => e.CategoryId == GlobalConfig.KwentoNgPaskoCategoryId && e.Episode.OnlineStatusId == GlobalConfig.Visible);
            ViewBag.CurrentPage = page;
            ViewBag.PageSize = pageSize;

            var totalPage = Math.Ceiling((double)totalCount / pageSize);
            ViewBag.TotalPages = totalPage;
            ViewBag.TotalCount = totalCount;
            var maxCount = page * pageSize > totalCount ? totalCount : page * pageSize;
            ViewBag.OutOf = String.Format("{0} - {1}", (page * pageSize) + 1 - pageSize, maxCount);
            var episodes = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible);

            ViewBag.Previous = page == 1 ? String.Empty : (page - 1) == 1 ? String.Empty : (page - 1).ToString();
            ViewBag.Next = page == (int)totalPage ? (int)totalPage : page + 1;

            if ((page * pageSize) + 1 - pageSize > totalCount)
                return RedirectToAction("List", "KuwentongPasko", new { id = String.Empty });
            if (episodes != null)
                return View(episodes);
            return RedirectToAction("Index", "Home");
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:30,代码来源:KuwentongPaskoController.cs

示例6: EntitlePackage

 public static void EntitlePackage()
 {
     var context = new IPTV2Entities();
     var user = context.Users.First(u => u.EMail == "[email protected]");
     var product = context.Products.Find(5);
     // user.Entitle((PackageSubscriptionProduct)product);
 }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:7,代码来源:UserTester.cs

示例7: Migration

        public ActionResult Migration(string start, string end)
        {
            DateTime StartDate = Convert.ToDateTime(start);
            DateTime EndDate = Convert.ToDateTime(end);

            var context = new IPTV2Entities();
            foreach (DateTime day in MyUtility.EachDay(StartDate, EndDate))
            {
                DateTime startDt = Convert.ToDateTime(String.Format("{0} {1}", day.ToString("yyyy/MM/dd"), "00:00:00"));
                DateTime endDt = Convert.ToDateTime(String.Format("{0} {1}", day.ToString("yyyy/MM/dd"), "23:59:59"));
                var report = context.Users
                .Join(context.Countries, userdetails => userdetails.CountryCode, country => country.Code, (userdetails, country) => new { userdetails, country })
                .Join(context.GomsSubsidiaries, user => user.country.GomsSubsidiaryId, subsidiary => subsidiary.GomsSubsidiaryId, (user, subsidiary) => new { user, subsidiary })
                .Where(result => result.user.userdetails.RegistrationDate >= @startDt && result.user.userdetails.RegistrationDate <= @endDt && result.user.userdetails.TfcNowUserName != null)
                .GroupBy(result => result.subsidiary.Description)
                .Select(result => new { description = result.Key, count = result.Count() })
                .OrderByDescending(result => result.count).ToList();

                string filePath = @"C:\bin\global dropbox\Audie\Migration\";
                string fileName = startDt.ToString("yyyyMMdd") + ".csv";
                using (StreamWriter writer = new StreamWriter(filePath + fileName))
                {
                    var csv = new CsvWriter(writer);
                    csv.WriteRecords(report);
                }
            }

            return null;
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:29,代码来源:ReportController.cs

示例8: FillCache

        public void FillCache(IPTV2Entities context, int offeringId, RightsType rightsType, TimeSpan cacheDuration)
        {
            var packageList = context.PackageTypes.Where(p => p.OfferingId == offeringId).ToList();
            var countries = context.Countries.ToList();
            // fill cache of all packages
            long totalSize = 0;
            foreach (var p in packageList)
            {
                foreach (var c in countries)
                {
                    // loop and fill cache for 1 hour
                    // fill show IDs
                    var shows = p.GetAllShowIds(c.Code, rightsType, false);
                    var cacheKey = p.GetCacheKey(c.Code, rightsType);
                    DataCache.Cache.Put(cacheKey, shows, cacheDuration);
                    totalSize += GetObjectSize(shows);

                    // fill channel IDs
                    cacheKey = p.GetChannelsCacheKey(c.Code, rightsType);
                    var channels = p.GetAllChannelIds(c.Code, rightsType, false);
                    DataCache.Cache.Put(cacheKey, channels, cacheDuration);
                }
            }


        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:26,代码来源:PackageCacheRefresher.cs

示例9: CheckUser_Entitlement

        public static bool CheckUser_Entitlement(Show model)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return false;
            }
            else
            {
                using (IPTV2Entities context = new IPTV2Entities())
                {
                    Guid userID = new Guid(HttpContext.Current.User.Identity.Name);
                    var user = context.Users.FirstOrDefault(u => u.UserId == userID);
                    var off = context.Offerings.Find(GlobalConfig.offeringId);
                    if (user.IsShowEntitled(off, model, RightsType.Online))
                    {
                        if (user.Entitlements.Where(t => t.OfferingId == GlobalConfig.offeringId && t.EndDate >= DateTime.Now).Count() > 0)
                        {
                            return true;
                        }
                    }

                }
            }
            return false;
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:25,代码来源:UserPackages.cs

示例10: Run

        public override void Run()
        {

            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("$projectname$ entry point called", "Information");

            int waitDuration = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("LoopWaitDurationInSeconds"));
            int fillCacheDurationInMinutes = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("FillCacheDurationInMinutes"));
            bool fillCache = Convert.ToBoolean(RoleEnvironment.GetConfigurationSettingValue("FillCache"));
            while (true)
            {
                try
                {
                    Thread.Sleep(TimeSpan.FromSeconds(waitDuration));
                    int offeringId = 2;
                    var service = new GomsTfcTv();
                    var context = new IPTV2Entities();
                    var offering = context.Offerings.Find(offeringId);
                    Trace.WriteLine("Process start.");
                    // Update Forex
                    // service.GetExchangeRates(context, "USD");
                    // Process Transactions
                    // service.ProcessAllPendingTransactionsInGoms(context, offering);
                    Trace.WriteLine("Process finish.");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("fail in Run", ex);
                }
            }
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:31,代码来源:WorkerRole.cs

示例11: Index

        public ActionResult Index()
        {
            var ReturnCode = new TransactionReturnType()
            {
                StatusCode = (int)ErrorCodes.NotAuthenticated,
                StatusMessage = String.Empty,
                info = "IT&E Validation",
                TransactionType = "Validation"
            };

            if (User.Identity.IsAuthenticated)
            {
                DateTime registDt = DateTime.Now;
                IPTV2Entities context = new IPTV2Entities();
                var promo = context.Promos.FirstOrDefault(p => p.PromoId == GlobalConfig.ITEPromoId && p.StartDate < registDt && registDt < p.EndDate && p.StatusId == GlobalConfig.Visible);
                if (promo != null)
                    return View();
                else { ReturnCode.StatusCode = (int)ErrorCodes.UnauthorizedCountry; }
            }
            ReturnCode.StatusMessage = MyUtility.getErrorMessage((ErrorCodes)ReturnCode.StatusCode);
            if (!String.IsNullOrEmpty(ReturnCode.StatusMessage))
            {
                TempData["ErrorMessage"] = ReturnCode;
            }
            return RedirectToAction("Index", "Home");
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:26,代码来源:ITEController.cs

示例12: ExtendTFCnowLicenses

        private static void ExtendTFCnowLicenses()
        {
            DateTime registDt = DateTime.Now;
            var absnow_context = new ABSNowEntities();
            var context = new IPTV2Entities();

            var migrated_users = context.Users.Where(i => !String.IsNullOrEmpty(i.TfcNowUserName)).OrderBy(i => i.EMail);

            Console.WriteLine(String.Format("Total migrated users: {0}", migrated_users.Count()));
            int ctr = 1;
            foreach (var user in migrated_users)
            {
                //Get Entitlements
                Console.WriteLine(String.Format("{1} TFC.tv Email Address: {0}", user.EMail, ctr));
                Console.WriteLine(String.Format("TFCnow Email Address: {0}", user.TfcNowUserName));
                ctr++;
                var entitlements = user.PackageEntitlements.Where(i => i.EndDate > registDt);
                if (entitlements != null)
                {
                    foreach (var item in entitlements)
                    {
                        Console.WriteLine(String.Format("Package Id: {0}", item.PackageId));
                        Console.WriteLine(String.Format("Expiration Date: {0}", item.EndDate));
                        int TFCnowPackageId = GetTFCnowPackageId(item.PackageId);
                        absnow_context.TFCnowExtendLicense(user.TfcNowUserName, TFCnowPackageId, item.EndDate);
                    }
                }
                //absnow_context.SaveChanges();
            }
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:30,代码来源:Program.cs

示例13: GetDynamicNodeCollection

 public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
 {
     List<DynamicNode> returnValue = null;
     var cache = DataCache.Cache;
     string cacheKey = "SMAPCELEB:O:00";
     returnValue = (List<DynamicNode>)cache[cacheKey];
     // Build value 
     if (returnValue == null)
     {
         try
         {
             returnValue = new List<DynamicNode>();
             var context = new IPTV2_Model.IPTV2Entities();
             // Create a node for each celebrity 
             var celebs = context.Celebrities.ToList();
             foreach (var celeb in celebs)
             {
                 DynamicNode node = new DynamicNode();
                 node.Key = "Celebrity-" + celeb.CelebrityId;
                 node.Title = "Celebrity - " + celeb.FullName;
                 //node.Controller = "Celebrity";
                 //node.Action = "Profile";
                 node.RouteValues.Add("id", celeb.CelebrityId);
                 returnValue.Add(node);
             }
             var cacheDuration = new TimeSpan(2, 0, 0);
             cache.Put(cacheKey, returnValue, cacheDuration);
         }
         catch (Exception) { returnValue = new List<DynamicNode>(); }
     }
     // Return 
     return returnValue;
 }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:33,代码来源:CelebritySitemap.cs

示例14: ProcessAllGomsPendingTransactions

 public static void ProcessAllGomsPendingTransactions()
 {
     var context = new IPTV2Entities();
     var service = new GomsTfcTv();
     var offering = context.Offerings.Find(2);
     service.ProcessAllPendingTransactionsInGoms(context, offering);
 }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:7,代码来源:Transaction.cs

示例15: FillCache

        public void FillCache(IPTV2Entities context, int offeringId, int serviceId, IEnumerable<int> categoryIds, RightsType rightsType, TimeSpan cacheDuration)
        {
            var countries = context.Countries;
            var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == offeringId);
            var service = offering.Services.FirstOrDefault(s => s.PackageId == serviceId);
            // fill cache of all categories
            foreach (int categoryId in categoryIds)
            {
                try
                {
                    var cat = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == categoryId && c is Category);
                    if (cat != null)
                    {
                        var category = (Category)cat;
                        foreach (var c in countries)
                        {
                            try
                            {
                                // loop and fill cache for 1 hour
                                var shows = service.GetAllShowIds(c.Code, category, rightsType, false);
                                var cacheKey = service.GetCacheKey(c.Code, category, rightsType);
                                DataCache.Cache.Put(cacheKey, shows, cacheDuration);
                            }
                            catch (Exception) { }
                        }
                    }
                }
                catch (Exception) { }
            }

        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:31,代码来源:CategoryCacheRefresher.cs


注:本文中的IPTV2_Model.IPTV2Entities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。