public frmAllotmentRoomTypeEditor(Models.Hotel h)
 {
     InitializeComponent();
     rtbo        = new BO.AllotmentRoomTypeBO();
     _rt         = new Models.AllotmentRoomType();
     _rt.HotelId = h.HotelId;
 }
        List <BindItem> GetBindItemList()
        {
            var entities = new Models.PriceCheckerEntities();
            var arbo     = new BO.AllotmentRecordBO(entities);
            var rtbo     = new BO.AllotmentRoomTypeBO(entities);
            var hbo      = new BO.HotelBO(entities);

            var rr  = arbo.GetQueryable();
            var rts = rtbo.GetQueryable();
            var hh  = hbo.GetQueryable(null);
            var qq  = from r in rr
                      join rt in rts on r.AllotmentRoomTypeId equals rt.RecordId
                      join h in hh on rt.HotelId equals h.HotelId
                      where h.CheckAllotment & r.CurrentAllotment < rt.DefaultAllotment && !r.Acknowledged & !rt.IgnoreThisRoomType
                      select new BindItem
            {
                Acknowledged  = r.Acknowledged,
                HotelId       = h.HotelId,
                HotelName     = h.HotelName,
                AllotmentDate = r.AllotmentDate,
                RecordId      = r.RecordId,
                RoomName      = rt.RoomName,
                //    Allotment = r.CurrentAllotment
            };
            var lst = qq.OrderBy(q => q.HotelName).ThenBy(q => q.RoomName).ToList();

            return(lst);
        }
        List <BindingItem> GetBindingItemList()
        {
            var entities = new Models.PriceCheckerEntities();

            rtbo = new BO.AllotmentRoomTypeBO(entities);
            rbo  = new BO.AllotmentRecordBO(entities);
            var rts = rtbo.GetQueryable();
            var rr  = rbo.GetQueryable();
            var qq  = from r in rr
                      join rt in rts on r.AllotmentRoomTypeId equals rt.RecordId
                      where rt.HotelId == _hotel.HotelId && r.CurrentAllotment < rt.DefaultAllotment
                      & !rt.IgnoreThisRoomType
                      select new { rt, r };

            if (_currentRoomType != null && _currentRoomType.RecordId != 0)
            {
                qq = qq.Where(x => x.rt.RecordId == _currentRoomType.RecordId);
            }

            if (cxNotAcknowledgedOnly.Checked)
            {
                qq = qq.Where(q => !q.r.Acknowledged);
            }

            var items = qq.Select(x => new BindingItem
            {
                Acknowledged     = x.r.Acknowledged,
                CurrentAllotment = x.r.CurrentAllotment,
                Date             = x.r.AllotmentDate,
                RecordId         = x.r.RecordId,
                RoomName         = x.rt.RoomName
            }).OrderBy(x => x.Acknowledged).ThenBy(x => x.RoomName).ThenBy(x => x.Date).ToList();

            return(items);
        }
Beispiel #4
0
        void BindRoomTypes()
        {
            var rbo = new BO.AllotmentRoomTypeBO();
            var rr  = rbo.GetQueryable(_h.HotelId).ToList();
            var bs  = new BindingSource();

            bs.DataSource = rr;
            dgAllotmentRoomTypes.DataSource = bs;
        }
        private void FrmAllotmentRecordViewer_Load(object sender, EventArgs e)
        {
            cxNotAcknowledgedOnly.Checked = true;
            BindData();
            this.Text = "View allotment for hotel \"" + _hotel.HotelName + "\"";
            var itemAll = new Models.AllotmentRoomType {
                RoomName = "All Rooms"
            };

            cmbRoomTypes.Items.Add(itemAll);
            var rtbo = new BO.AllotmentRoomTypeBO();
            var rts  = rtbo.GetQueryable().Where(x => x.HotelId == _hotel.HotelId).ToList();

            foreach (var rt in rts)
            {
                cmbRoomTypes.Items.Add(rt);
            }
            cmbRoomTypes.SelectedIndex = 0;
        }
 public frmAllotmentRoomTypeEditor(int id)
 {
     InitializeComponent();
     rtbo = new BO.AllotmentRoomTypeBO();
     _rt  = rtbo.GetRecord(id);
 }
Beispiel #7
0
        void CrawlSingleHotel(Models.Hotel h)
        {
            _wk.ReportProgress(0, "Crawl hotel " + h.HotelName);
            objBrowse._inputDatas["HMSID"] = h.HMSID;
            objBrowse.ExecuteAction(false);
            objGetWebRoomTypes.ExecuteAction(false);
            //Find out what room types are available
            var crTypes = h.ContractRooms.ToList();
            var opthtml = objGetWebRoomTypes._ReturnDataCollection["cmbRoomTypeInnerHtml"] as string;
            var rtdoc   = new HtmlAgilityPack.HtmlDocument();

            rtdoc.LoadHtml(opthtml);
            var opts = rtdoc.DocumentNode.SelectNodes("//option");
            var rts  = opts.Select(o => o.InnerText).ToList();

            foreach (var cr in crTypes)
            {
                if (!opts.Any(x => x.InnerText == cr.RoomName))
                {
                    var editor = new frmRoomTypeReMatch(cr, rts);
                    if (editor.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
            var validDate = h.ContractValidTo;

            if (validDate < DateTime.Now.Date)
            {
                return;
            }
            //here is the limit of HMS
            if (validDate > DateTime.Today.AddDays(365))
            {
                validDate = DateTime.Today.AddDays(365);
            }
            var fromDate = h.ContractValidFrom;
            var minDt    = DateTime.UtcNow.Date.AddDays(h.MinCutOffDates);

            if (fromDate < minDt)
            {
                fromDate = minDt;
            }
            //reload room types to update
            var crbo = new BO.ContractRoomBO();

            crTypes = crbo.GetQueryable(h.HotelId).ToList();
            objEnterData._inputDatas["ToDate"]   = validDate.ToString("MM/dd/yyyy");
            objEnterData._inputDatas["FromDate"] = fromDate.ToString("MM/dd/yyyy");
            objEnterData.ExecuteAction(false);
            foreach (var cr in crTypes)
            {
                objClickCmbRoomTypes.ExecuteAction(false);
                /* We don't want to get text into XPath because it can causes err*/
                var cmbXPath = objGetWebRoomTypes._ActionData.ElementLabels.FirstOrDefault().XPath;
                cmbXPath += "/option";
                var elmOption = Modules.BrowserSupport.FindElementInCollection(cmbXPath, cr.RoomName);
                elmOption.Click();
                objClick.ExecuteAction(false);
                objGetHtml.ExecuteAction(false);
                var html     = objGetHtml._ReturnDataCollection["PageHtml"] as string;
                var analyzer = new Modules.AllotmentAnalyzer(true);
                var records  = analyzer.AnalyzeData(html);
                foreach (var record in records)
                {
                    var rbo   = new BO.AllotmentRoomTypeBO();
                    var rtype = rbo.GetRecord(h.HotelId, record.RoomName);
                    if (rtype == null)
                    {
                        rtype                  = new Models.AllotmentRoomType();
                        rtype.RoomName         = record.RoomName;
                        rtype.HotelId          = h.HotelId;
                        rtype.DefaultAllotment = 1;
                        rbo.Add(rtype);
                    }
                    if (record.Allotment >= rtype.DefaultAllotment)
                    {
                        continue;
                    }
                    var arbo = new BO.AllotmentRecordBO();
                    //while record date is 12:00:00AM, saving in db will change it to 00:00:00
                    //so we never get the record. need to reset all to zero here
                    var dt = record.Date;
                    dt = new DateTime(dt.Year, dt.Month, dt.Day);

                    if (record.Allotment < rtype.DefaultAllotment)
                    {
                        var r = arbo.GetRecord(dt, rtype.RecordId);
                        if (r == null)
                        {
                            r = new Models.AllotmentRecord();
                            r.CurrentAllotment    = record.Allotment;
                            r.AllotmentDate       = dt;
                            r.Acknowledged        = false;
                            r.AllotmentRoomTypeId = rtype.RecordId;
                            arbo.Add(r);
                        }
                        else
                        {
                            //REcord existed, may be acknowledged may be not. Just leave it there
                            if (record.Allotment < r.CurrentAllotment)
                            {
                                //Need to notify us again
                                r.Acknowledged = false;
                                arbo.Save();
                            }
                        }
                    }
                }
            }
            // var path = @"C:\Users\Thuy Tran\Documents\AllDocs\Disposable\Test\allotment" + h.HotelId + "-" + DateTime.Now.ToString("mm-dd-yyyy-hh-mm-ss") + ".txt";
            //System.IO.File.WriteAllText(path, html);
        }