コード例 #1
0
        /*SavePost: calculates when the expiration time will be for a given post */
        public static void SavePost(Post post)
        {
            //bizlogic to compute expiration time
            Biz.SetPostExpirationTime(post);

            db.Posts.Add(post);
            db.SaveChanges();
        }
コード例 #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     apiManager = new APIManager(axKHOpenAPI1);
     axKHOpenAPI1.CommConnect();
     trBiz  = new TRBiz(apiManager);
     subBiz = new SubBiz(apiManager);
     biz    = new Biz(apiManager, subBiz, trBiz);
 }
コード例 #3
0
        /*GetAllCategories: gets all the categories */
        public static IEnumerable <Category> GetAllCategories()
        {
            var Categories = from category in db.Categories
                             select category;

            //add bizlogic here to sort before returning
            var orderedCategories = Biz.SortCategories(Categories.ToList());

            return(orderedCategories);
        }
コード例 #4
0
        /* GetAllAreas: gets all the areas */
        public static IEnumerable <Area> GetAllAreas()
        {
            var Areas = from area in db.Areas
                        select area;

            //add bizlogic here to sort before returning
            var orderedAreas = Biz.SortAreas(Areas.ToList());

            return(orderedAreas);
        }
コード例 #5
0
        /* GetAllLocales: gets all the Locales */
        public static IEnumerable <Locale> GetAllLocales()
        {
            var Locales = from locale in db.Locales
                          select locale;

            //add bizlogic here to sort before returning
            var orderedlocales = Biz.SortLocales(Locales.ToList());

            return(orderedlocales);
        }
コード例 #6
0
        /*GetsAllSubCategories: returns all the subcategories */
        public static IEnumerable <Subcategory> GetAllSubCategories()
        {
            var SubCategories = from subcategory in db.SubCategories
                                select subcategory;

            //add bizlogic here to sort before returning
            var orderedSubCategories = Biz.SortSubCategories(SubCategories.ToList());

            return(orderedSubCategories);
        }
コード例 #7
0
        /*GetAllPosts:returns all the posts for a given category,subcategory,localeid, or areaId
         * we will add methods that take into account the other combinations */
        //cID can be either categoryID or subcategoryID and lID can be either localeID or areaID
        public static IEnumerable <Post> GetAllPosts(string cID, string lID)
        {
            var Posts = from post in db.Posts
                        where post.locale == lID && post.category == cID
                        select post;

            //bizlogic to sort according to most recent time
            var orderedPosts = Biz.OrderPosts(Posts.ToList());

            return(orderedPosts);
        }
コード例 #8
0
        /* GetAllExpiredPosts: returns all the expired posts for a specific user */
        public static IEnumerable <Post> GetAllExpiredPosts(string userID)
        {
            var Posts = from post in db.Posts
                        where post.isDeletedOrHidden && post.ownerID == userID
                        select post;

            //bizlogic to sort according to most recent time
            var orderedPosts = Biz.OrderPosts(Posts.ToList());

            return(orderedPosts);
        }
コード例 #9
0
        /* GetMessagesToPost: returns all the messages for a given post */
        public static IEnumerable <Message> GetMessagesToPost(int postID)
        {
            //handle error cases
            var Post     = db.Posts.Find(postID);
            var Messages = Post.messages;

            //bizlogic to sort
            var orderedMessages = Biz.OrderMessages(Messages.ToList());

            return(orderedMessages);
        }
コード例 #10
0
        /* GetMessagesFromUser: returns all the messages for a given user */
        public static IEnumerable <Message> GetMessagesFromUser(string userID)
        {
            //handle error cases
            var User     = db.User.Find(userID);
            var Messages = User.messages;

            //bizlogic to sort
            var orderedMessages = Biz.OrderMessages(Messages.ToList());

            return(orderedMessages);
        }
コード例 #11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            log4net.Config.XmlConfigurator.Configure();
            // 在应用程序启动时运行的代码
            Biz.Start();
        }
コード例 #12
0
 void ILeafPileTypeSelectOberver.onPileTypeSelectChanged(SuperMemory.Entities.CPileType curPileType)
 {
     Biz.CurPileType = curPileType;
     if (Biz.hasPiles())
     {
         this.enableBtns();
     }
     else
     {
         this.unenableBtns();
     }
 }
コード例 #13
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         var entity = PrepareFormData();
         var er     = Biz.UpdateSysSettingEntity(entity);
         lMessage.Text = er.GetDescription();
     }
     catch (Exception ex)
     {
         lMessage.Text = string.Format("保存失败,原因:{0}", ex.Message);
     }
 }
コード例 #14
0
        public void Test_orderMessages()
        {
            List <String> listMessages = new List <String> {
                "4", "62", "23", "17"
            };
            var msgs = from msg in db.Messages
                       select msg;
            var           output        = Biz.OrderMessages(msgs.ToList());
            List <String> messagesNames = new List <String>();

            foreach (var item in output)
            {
                messagesNames.Add(item.senderID.ToString());
            }

            CollectionAssert.AreEqual(listMessages, messagesNames);
        }
コード例 #15
0
ファイル: QQDownloader.cs プロジェクト: tomdeng/gaopincai
        private bool Down11X5(DownParameter param, Biz.D11X5.DwNumberBiz biz, DateTime currentDate)
        {
            int intDate = int.Parse(currentDate.ToString("yyyyMMdd"));
            string url = string.Format(param.Category.DownUrl, intDate, "&");

            try
            {
                string htmlText = Regex.Match(this._webClient.DownloadString(url), "<tbody id=\"row_show\">.*</tbody>",
                    RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (matchs.Count == 0)
                {
                    Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0"));
                    return false;
                }

                long lastP = biz.GetLatestPeroid();
                for (int i = matchs.Count - 1; i >= 0; i--)
                {
                    Match match = matchs[i];
                    string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string code = Regex.Match(match.Value, @"[<spans >|<span >](\d{2},\d{2},\d{2},\d{2},\d{2})[</spans>|<spans>]",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();

                    if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) continue;

                    long p = int.Parse(peroid);
                    //把期号统一成{yyyymmddnn}
                    if (p < 2000000000) p += 2000000000;
                    if (p <= lastP) continue;

                    int n = int.Parse(peroid.Substring(peroid.Length - 2));
                    if (!biz.Add(p, n, code, intDate, datetime)) return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message));
                return false;
            }
        }
コード例 #16
0
ファイル: CP360Downloader.cs プロジェクト: tomdeng/gaopincai
        private bool Down3D(DownParameter param, Biz.D3.DwNumberBiz biz, DateTime currentDate)
        {
            string url = param.Category.DownUrl;

            try
            {
                string htmlText = Regex.Match(this._webClient.DownloadString(url), "<div id=\"conKjlist\" class=\"kjlist\">.*?</table>",
                    RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (matchs.Count == 0)
                {
                    Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0"));
                    return false;
                }

                long lastP = biz.GetLatestPeroid();
                for (int i = matchs.Count - 1; i >= 0; i--)
                {
                    Match match = matchs[i];
                    string peroid = Regex.Match(match.Value, "<td>(\\d{7})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string datetime = Regex.Match(match.Value, "<td>(\\d{4}-\\d{2}-\\d{2})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string code = Regex.Match(match.Value, "<div class=\"aball\">.*?</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Value;
                    code = Regex.Replace(code, "<.*?>", "");
                    code = string.Join(",", code.ToArray());

                    if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) continue;

                    int intDate = int.Parse(datetime.Replace("-", ""));
                    int p = int.Parse(peroid);

                    //把期号统一成{yyyynnn}
                    if (p < 2000000) p += 2000000;
                    if (p <= lastP) continue;

                    int n = int.Parse(peroid.Substring(peroid.Length - 3));
                    if (!biz.Add(p, n, code, intDate, datetime)) return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message));
                return false;
            }
        }
コード例 #17
0
        public void Test_orderPosts()
        {
            List <String> listPosts = new List <String> {
                "14", "24", "52"
            };

            var posts = from post in db.Posts
                        select post;
            var           output    = Biz.OrderPosts(posts.ToList());
            List <String> postNames = new List <String>();

            foreach (var item in output)
            {
                postNames.Add(item.postNumber.ToString());
            }

            CollectionAssert.AreEqual(listPosts, postNames);
        }
コード例 #18
0
 private void FillFormData()
 {
     try
     {
         var entity = Biz.GetSysSettingEntity();
         txtSysName.Text          = entity.SysName;
         txtSysDescription.Text   = entity.SysDescription;
         txtErrorPage.Text        = entity.ErrorPage;
         txtBuildingPage.Text     = entity.BuildingPage;
         txtErrorLogPath.Text     = entity.ErrorLogPath;
         txtSuperAdmins.Text      = entity.SuperAdmins;
         txtGridviewPageSize.Text = entity.GridViewPageSize;
     }
     catch (Exception ex)
     {
         lMessage.Text = string.Format("数据加载失败,原因:{0}", ex.Message);
     }
 }
コード例 #19
0
        public void Test_SortLocales()
        {
            List <String> listLocales = new List <String> {
                "Balboa Park", "Brooklyn", "Nob Hill", "Pike Place", "South Side"
            };

            var locales = from locale in db.Locales
                          select locale;
            var output = Biz.SortLocales(locales.ToList());

            List <String> LocaleNames = new List <String>();

            foreach (var item in output)
            {
                LocaleNames.Add(item.name);
            }

            CollectionAssert.AreEqual(listLocales, LocaleNames);
        }
コード例 #20
0
        public void Test_sortCategories()
        {
            List <String> listCategories = new List <String> {
                "Electronics", "For Sale", "Gigs", "Housing", "Jobs"
            };

            var cats = from cat in db.Categories
                       select cat;
            var output = Biz.SortCategories(cats.ToList());

            List <String> CatNames = new List <String>();

            foreach (var item in output)
            {
                CatNames.Add(item.name);
            }

            CollectionAssert.AreEqual(listCategories, CatNames);
        }
コード例 #21
0
        public void Test_sortSubcategories()
        {
            List <String> listSubcategories = new List <String> {
                "Apartments", "Bands", "Computer Parts", "Resume Workshops", "Vehicles"
            };

            var subs = from sub in db.SubCategories
                       select sub;
            var output = Biz.SortSubCategories(subs.ToList());

            List <String> SubCatNames = new List <String>();

            foreach (var item in output)
            {
                SubCatNames.Add(item.name);
            }

            CollectionAssert.AreEqual(listSubcategories, SubCatNames);
        }
コード例 #22
0
        public void Test_SortAreas()
        {
            List <String> listAreas = new List <String> {
                "Chicago", "Los Angeles", "New York", "San Francisco", "Seattle"
            };

            var areas = from area in db.Areas
                        select area;

            var output = Biz.SortAreas(areas.ToList());

            List <String> AreaNames = new List <String>();

            foreach (var item in output)
            {
                AreaNames.Add(item.name);
            }

            CollectionAssert.AreEqual(listAreas, AreaNames);
        }
コード例 #23
0
ファイル: UnitTest1.cs プロジェクト: netinthakur/VideoRental
        public void Test_LoginWithIncorrectCorrectCredentails()
        {
            Biz bl       = new Biz();
            var loginID  = "admin";
            var password = "******";

            DataTable dt = new DataTable();

            SqlParameter[] sp = new SqlParameter[2];
            sp[0] = new SqlParameter("@userid", loginID);

            sp[1] = new SqlParameter("@pwd", password);
            dt    = bl.getExecutSP_DataTableWithParamter("userLogin", sp);
            if (dt != null && dt.Rows.Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(false);
            }
        }
コード例 #24
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _db = this.InitBiz();
 }
コード例 #25
0
 private void btnStartTrainning_Click(object sender, EventArgs e)
 {
     Biz.beginTrainning();
 }
コード例 #26
0
 override protected void on1PileChosen()
 {
     Biz.onAnswerPileChosen(this.curChosenPileView);
 }
コード例 #27
0
ファイル: ValuesController.cs プロジェクト: git-martin/ssc
        public List <MoniModel> Today(int id)
        {
            var data = Biz.MoniBet(1, Biz.CurrentCalculateIssues);

            return(data);
        }
コード例 #28
0
ファイル: ValuesController.cs プロジェクト: git-martin/ssc
        // GET api/values/5
        public string Get(int id)
        {
            var data = Biz.MoniBet(1, Biz.CurrentCalculateIssues);

            return(Newtonsoft.Json.JsonConvert.SerializeObject(data));
        }
コード例 #29
0
ファイル: ValuesController.cs プロジェクト: git-martin/ssc
        public NumAppearModel NoAppear(int id)
        {
            var data = Biz.NoAppear(10, 1, Biz.CurrentCalculateIssues);

            return(data);
        }
コード例 #30
0
 private void updateOrderAreaData()
 {
     this.ucPileOrderAreaSet.updateOrderAreaData(1, Biz.getPilesCount());
 }
コード例 #31
0
ファイル: QQDownloader.cs プロジェクト: tomdeng/gaopincai
        private bool DownSSC(DownParameter param, Biz.SSC.DwNumberBiz biz, DateTime currentDate)
        {
            int intDate = int.Parse(currentDate.ToString("yyyyMMdd"));
            string url = string.Format(param.Category.DownUrl, "&", intDate);

            try
            {
                string htmlText = this._webClient.DownloadString(url);
                MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (matchs.Count == 0)
                {
                    Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0"));
                    return false;
                }

                long lastP = biz.GetLatestPeroid();
                for (int i = matchs.Count - 1; i >= 0; i--)
                {
                    Match match = matchs[i];
                    string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    string code = Regex.Match(match.Value, "<div class=\"numBall_ssc\">(.*?)</div>",
                        RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    code = Regex.Replace(code, "<.*?>|[\\s]", "").Trim();

                    if (string.IsNullOrEmpty(code) || code.Length == 0) continue;

                    long p = long.Parse(peroid);
                    //把期号统一成{yyyymmddnnn}
                    if (p < 20000000000) p += 20000000000;
                    if (p <= lastP) continue;

                    code = string.Join(",", code.ToArray());
                    int n = int.Parse(peroid.Substring(peroid.Length - 3));
                    if (!biz.Add(p, n, code, intDate, datetime)) return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message));
                return false;
            }
        }
コード例 #32
0
 static void Main(string[] args)
 {
     Biz.DoJob();
 }
コード例 #33
0
        public Biz BizDetails(string id)
        {
            var business = _db.Users.Find(id);

            if (business == null)
            {
                return(null);
            }
            var gallery = _db.Photos.Where(x => x.UserId == business.Id).Take(12).ToList();
            List <OwnedPhoto> galleryPics = new List <OwnedPhoto>();

            foreach (var item in gallery)
            {
                galleryPics.Add(new OwnedPhoto
                {
                    HasPrice = item.HasPrice,
                    PhotoId  = item.Id,
                    PhotoUrl = item.Url,
                    Price    = item.Price,
                    Title    = item.Title,
                });
            }
            var    localTime       = Tools.GetLocalTime(business.TimeZone);
            var    currentDay      = (int)localTime.DayOfWeek;
            string nextDayStarTime = null;
            bool   isNextDayOpened = false;

            currentDay = currentDay + 1;
            var time = _db.UsersHours.FirstOrDefault(x => x.DayId == currentDay && x.UserId == business.Id);

            if (currentDay < 6)
            {
                var nextDay = _db.UsersHours.FirstOrDefault(x => x.UserId == business.Id && x.DayId == (currentDay + 1));
                isNextDayOpened = nextDay.IsOpened;
                nextDayStarTime = nextDay.From;
            }
            else
            {
                if (currentDay == 6)
                {
                    var nextDay = _db.UsersHours.FirstOrDefault(x => x.UserId == business.Id && x.DayId == 7);
                    isNextDayOpened = nextDay.IsOpened;
                    nextDayStarTime = nextDay.From;
                }
                if (currentDay == 7)
                {
                    var nextDay = _db.UsersHours.FirstOrDefault(x => x.UserId == business.Id && x.DayId == 1);
                    isNextDayOpened = nextDay.IsOpened;
                    nextDayStarTime = nextDay.From;
                }
            }

            var isOpenNow = IsBusinessOpenNow(time.IsOpened, time.From, time.To, business.TimeZone);

            ResultItem details = new ResultItem
            {
                Id           = business.Id,
                BusinessName = business.BusinessName,
                Description  = business.BusinessDescription,
                Distance     = "0km",
                IsOpen       = isOpenNow,
                IsPremium    = false,
                Location     = business.Address,
                Rating       = business.Rating,
                Lat          = business.Lat,
                Long         = business.Long,
                ReviewsCount = business.TotalReviewsCount,
                Status       = Tools.GetOpeningStatus(time.From, time.To, nextDayStarTime, business.TimeZone, time.IsOpened, isOpenNow, isNextDayOpened),
                Album        = galleryPics,
                Verified     = business.BusinessVerified,
            };

            var appAmenities           = _db.Amenities.ToList();
            List <BizService> services = new List <BizService>();

            foreach (var am in appAmenities)
            {
                if (_db.UsersAmenities.Any(x => x.AmenitieId == am.Id && x.UserId == business.Id && x.IsChecked == true))
                {
                    services.Add(new BizService {
                        Name = am.FrenchName, Checked = true, AmenitieId = am.Id
                    });
                }
            }
            ;


            int              galleryCount = _db.Photos.Where(x => x.UserId == business.Id).Select(x => x.Url).ToList().Count();
            var              converted    = Convert.ToDouble(galleryCount);
            double           res          = converted / 12;
            double           pages        = Math.Ceiling(res);
            var              hours        = _db.UsersHours.Where(x => x.UserId == business.Id).OrderBy(x => x.DayId).ToList();
            List <TimeTable> table        = new List <TimeTable>();

            foreach (var item in hours)
            {
                table.Add(new TimeTable {
                    UserId   = business.Id,
                    DayId    = item.DayId,
                    From     = item.From,
                    IsOpened = item.IsOpened,
                    To       = item.To,
                    Day      = _db.DaysOfTheWeek.FirstOrDefault(x => x.Id == item.DayId).Name,
                });
            }

            var reviews = _db.Reviews.Where(x => x.BusinessId == business.Id).OrderByDescending(x => x.Date).Take(12).ToList();

            List <ReviewViewModel> list = new List <ReviewViewModel>();

            foreach (var item in reviews)
            {
                var author = _db.Users.Find(item.AuthorId);
                if (author != null)
                {
                    var pics = _db.ReviewsImages.Where(x => x.AuthorId == author.Id && x.ReviewId == item.Id).Select(x => x.imageUrl).ToList();

                    list.Add(new ReviewViewModel
                    {
                        AuthorId         = item.AuthorId,
                        AuthorName       = $"{author.FirstName} {author.LastName}",
                        Date             = Tools.GetTime(item.Date, business.TimeZone),
                        Rating           = item.Rating,
                        AuthorProfileUrl = author.ProfilePictureUrl,
                        Id           = item.Id,
                        PicturesUrls = pics,
                        Text         = item.Text
                    });
                }
            }

            Biz model = new Biz
            {
                BizDetails              = details,
                Services                = services,
                BizEmailAddress         = business.Email,
                BizPhoneNumber          = business.PhoneNumber,
                TotalGalleryImagesCount = galleryCount,
                IsBusinessClaimed       = business.BusinessVerified,
                GalleryPages            = Convert.ToInt32(pages),
                OpeningHours            = table,
                Reviews    = list,
                Joined     = business.Creation.ToString("dd/MM/yyyy"),
                HightLight = _db.Photos.Where(x => x.UserId == business.Id).OrderByDescending(x => x.Date).Take(4).Select(x => x.Url).ToList(),
            };

            return(model);
        }