public void UpdateDatesDS() { List <Order> orders = dal.GetAllOrders(); foreach (Order order in orders) { HostingUnit unit = getHostingUnit(order.HostingUnitKey); GuestRequest guest = getGR(order.GuestRequestKey); //DateTime dtStart = ConveryDateStrToDateTime(guest.EntryDate); //DateTime dtEnd = ConveryDateStrToDateTime(guest.ReleaseDate); order.Status = OrderStatusCode.CloseDueGuestResponding; UpdateOrder(order); //order //while(dtStart < dtEnd) } }
public HostingUnit UpdateHostingUnit(HostingUnit hu) { HostingUnit item = DS.DataSource.AllHostingUnitsList.Find(x => x.HostingUnitKey == hu.HostingUnitKey); if (item == null) { hu = AddHostingUnit(hu); throw new MyException("This hosting unit does not exist", hu); } else { DS.DataSource.AllHostingUnitsList.Remove(item); DS.DataSource.AllHostingUnitsList.Add(hu); return(hu); } }
public bool sent_mail(GuestRequest status)//l'hote regarde si il est daccord ou pas { HostingUnit selctione = new HostingUnit(); foreach (Order unit in DataSource.orders) { if (unit.status == Status.MailSent) { if (status.interessing == true) { return(true); } } } return(false); }
public bool AvailableDate(HostingUnit T, GuestRequest F)//ימים פנויים { DateTime Date = F.EntryDate; while (Date < F.ReleaseDate) { int day = Date.Day; int month = Date.Month; if (T.Diary[day, month] == true) { return(false); } Date = Date.AddDays(1); } return(true); }
/// <summary> /// Updates Hosting Unit Diary with dates order /// </summary> /// <param name="ord"> update order </param> public void SetDiary(Order ord) { HostingUnit temp = GetHostingUnit(ord.HostingUnitKey); DateTime current = GetEntry(ord.GuestRequestKey); DateTime end = GetRelease(ord.GuestRequestKey); end = end.AddDays(1); for (; current < end;) { temp.Diary[current.Month - 1, current.Day - 1] = true; current = current.AddDays(1); } UpdateHostUnit(temp); }
private void OffersGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { Order order = OffersGrid.SelectedItem as Order; if (order == null) { ; } else { HostingUnit hostingUnit = bl.GetHostingUnits().Find(x => x.HostingUnitKey == order.HostingUnitKey); Window watchHostingUnitWindow = new WatchHostingUnitWindow(hostingUnit, guest); watchHostingUnitWindow.Show(); Close(); } }
/// <summary> /// Add a new host unit to Data Base /// </summary> /// <param name="addHostingUnit">host unit to be added</param> public void AddAHostingUnit(HostingUnit addHostingUnit) { //check if the price for the unit is not less than 0 if (addHostingUnit.UnitPrice < 0) { throw new Exception("Price must be greater than or equal to zero"); } addHostingUnit.Diary = new bool[12, 31]; addHostingUnit.DiaryFlatten = new bool[12 * 31]; addHostingUnit.SumOfferOrders = 0; addHostingUnit.SumCompletedOrders = 0; addHostingUnit.HostingUnitKey = IDAL.Configuration.HostingUnitKey++; _idalImp.AddAHostingUnit(addHostingUnit.Clone()); }
//----------------------------------------------------------------- /// <summary> /// This function returns the annual occupancy to a certain hosting unit /// </summary> /// <param name="hu"></param> public int AnnnualOccupancyToHostingUnit(HostingUnit hu) { int sum = 0; for (int i = 1; i < 13; i++) { for (int j = 1; j < 31; j++) { if (hu.Diary[i, j]) { sum++; } } } return(sum); }
public void updateHostingUnit(HostingUnit unit) { if (getAllHostingUnit(x => x.hostingUnitKey == unit.hostingUnitKey).FirstOrDefault() == null) { throw new Exception("There is no such HostingUnit."); } // remove the HostingUnit before updating it (from item in hostingUnitRoot.Elements() where long.Parse(item./*Element("HostingUnit").*/ Element("hostingUnitKey").Value) == unit.hostingUnitKey select item).FirstOrDefault().Remove(); //implement the update according to the demand hostingUnitRoot.Add(ConvertHostingUnitToXAML(unit)); hostingUnitRoot.Save(hostingUnitPath); }
/// <summary> /// Function who returns the total number of busy days per year for one hosting unit. /// </summary> /// <param name="hostingUnit">hosting unit</param> /// <returns>the number of ocuupied days in a yeat at a specepic unit.</returns> public int GetNumberOfTakenDays(HostingUnit hostingUnit) { int NumberOfTakenDays = 0; for (int i = 0; i < 11; i++) { for (int j = 0; j < 30; j++) { if (hostingUnit.Diary[i, j]) { NumberOfTakenDays++; } } } return(NumberOfTakenDays); }
public void AddHostingUnit(HostingUnit newHostingUnit) { newHostingUnit.HostingUnitKey = getKeyFromConfig("HostingUnitId"); newHostingUnit.Diary = Utils.CreateMatrix(); var hostingUnitsList = GetHostingUnitsList(); if (hostingUnitsList.Any(x => x.HostingUnitKey == newHostingUnit.HostingUnitKey)) { throw new TzimerException($"Hosting Unit with the ID: {newHostingUnit.HostingUnitKey} - already exists!", "dal"); } HostingUnits hostingUnitsLists = (HostingUnits)GetHostingUnitsList(); hostingUnitsLists.Add(newHostingUnit); SaveToXML(hostingUnitsLists, HOSTING_UNITS_FILENAME); }
public newHostingUnit() { hu = new HostingUnit(); nhu = new HostingUnit(); InitializeComponent(); foreach (var n in Enum.GetNames(typeof(enum_s.Area))) { ComboBoxArea.Items.Add(n); } foreach (var n in Enum.GetNames(typeof(enum_s.Type))) { ComboBoxType.Items.Add(n); } }
public void RemoveHostingUnit(HostingUnit hu) { try { if (!RemoveUnitCheck(hu)) { throw new InvalidOperationException("cannot delete this hosting unit, there are active orders connected to it"); } dal_bl.RemoveHostingUnit(hu); } catch (InvalidOperationException a) { throw a; } }
public void deleteHostingUnit(HostingUnit My_HostingUnit) { var L = from item in Dal_XML_imp.GetHostingUnitFromXml() where My_HostingUnit.hosting_unit_key == item.hosting_unit_key select item; if (L == null) { throw new NotImplementedException("not found"); } else { Dal_XML_imp.RemoveHostingUnitToXml(My_HostingUnit.hosting_unit_key); --Configuration.HostingUnitKey; } }
private bool IsRequestSuitable(HostingUnit hostingUnit, GuestRequest request) { if (request.Status != GuestRequestStatus.YetToBeAttendedTo) { return(false); } if (!IsVacationAvailable(hostingUnit, request.EntryDate, Math.Abs(request.EntryDate.Subtract(request.ReleaseDate).Days))) { return(false); } if (!DoPropertiesFit(hostingUnit, request)) { return(false); } return(true); }
private void Delete_Click(object sender, RoutedEventArgs e) { if (MainWindow.bl.GetHostingUnits().Exists(item => item.HostingUnitKey == long.Parse(hostingunitk.Password))) { deletehostingkey.Visibility = Visibility.Collapsed; DeleteHosting.Visibility = Visibility.Visible; this.Type.ItemsSource = Enum.GetValues(typeof(BE.TypeStatus)); this.Area.ItemsSource = Enum.GetValues(typeof(BE.AreaStatus)); h = MainWindow.bl.GetHostingUnits().Find(item => item.HostingUnitKey == long.Parse(hostingunitk.Password)); DeleteHosting.DataContext = h; } else { MessageBox.Show("לא קיים"); } }
public void UpdateHost(Host host) { XElement host1; host1 = (from h in HostingUnitsRoot.Elements() where int.Parse(h.Element("Owner").Element("HostKey").Value) == host.HostKey select h).FirstOrDefault(); if (host1 == null) { throw new KeyNotFoundException(" לא קיים במערכת מארח שמספרו" + host.HostKey); } HostingUnit hos = new HostingUnit(); hos.Owner = host; AddHostUnit(hos); }
public double ThePercentOfCapacity(HostingUnit hu) { double mone = 0; for (int i = 0; i < 12; i++) { for (int j = 0; j < 31; j++) { if (hu.Diary[i, j] == true) { mone++; } } } return((mone / 365) * 100); }
public void AddNewHostingUnit(HostingUnit TheHostingUnit) { try { List <HostingUnit> L = DS.DataSource.ListHostingUnits; for (int i = 0; i < L.Count; i++) { if (L[i].HostingUnitKey == TheHostingUnit.HostingUnitKey) { throw new IDalreadyExistsException("HostingUnit", TheHostingUnit.HostingUnitKey); } } DS.DataSource.ListHostingUnits.Add(TheHostingUnit); } catch (IDalreadyExistsException E) { throw E; } }
public static HostingUnit Clone(this HostingUnit original) { HostingUnit target = new HostingUnit(); target.HostingUnitKey1 = original.HostingUnitKey1; target.Owner1 = original.Owner1; target.HostingUnitName1 = original.HostingUnitName1; target.Diary1 = original.Diary1; target.hasPool1 = original.hasPool1; target.hasJaccuzzi1 = original.hasJaccuzzi1; target.hasGarden1 = original.hasGarden1; target.hasChildrensAttractions1 = original.hasChildrensAttractions1; target.Commission1 = original.Commission1; target.AreaOfHostingUnit = original.AreaOfHostingUnit; return(target); }
public bool UpdateHostingUnit(HostingUnit item) { hostingUnitHandler.Load(); HostingUnitXml findHostingUnit = (from unit in hostingUnits where unit.Key == item.Key select unit).FirstOrDefault(); if (findHostingUnit != null) { hostingUnits.Remove(findHostingUnit); hostingUnits.Add(Tools.conv_DO_To_Xml(item.Clone())); hostingUnitHandler.Save(); return(true); } throw new Exception("היחידה אינה קיימת במערכת"); }
public void addHostingUnit(HostingUnit hostingUnit) //addHostingUnit the function get HostingUnit object and input it to data base { //incorrect mail if (!MailValidition(hostingUnit.Owner.MailAddress)) { throw new MailValiditionException("incorrect mail");//TODO DateMismatchException } } // //incorrect Phon if (!IsDigitsOnly(hostingUnit.Owner.phoneNumber)) { throw new IncorrectPhoneException("incorrect phone");//TODO DateMismatchException } } // dal.addHostingUnit(hostingUnit); }
public bool UpdateHostingUnit(HostingUnit Uunit) { List <HostingUnit> lis = XmlDataSource.LoadFromXML <List <HostingUnit> >(HostingUnitPath); HostingUnit unit = lis.FirstOrDefault(item => item.HostingUnitKey == Uunit.HostingUnitKey); foreach (var Property in unit.GetType().GetProperties()) { ParameterInfo[] myParameters = Property.GetIndexParameters(); if (myParameters.Length == 0) { Property.SetValue(unit, Property.GetValue(Uunit)); } } XmlDataSource.SaveToXML <List <HostingUnit> >(lis, HostingUnitPath); return(true); }
/// <summary> /// A function that goes through the order list and checks for each unit how many orders it has closed. /// </summary> /// <param name="h">hosting unit</param> /// <param name="orderList">list of orders</param> /// <returns>the amount of cloesed order for each unit.</returns> int amountOfOrders(HostingUnit hostingunit, List <Order> orderList) { int sumOfOrders = 0; foreach (var order in orderList) { if (order.HostingUnitKey == hostingunit.HostingUnitKey) { if (order.Status == OrderStatus.Canceled || order.Status == OrderStatus.DoneDeal) { sumOfOrders++; } } } return(sumOfOrders); }
public int GetAnnualBusyDays(HostingUnit h) { int sum = 0; for (int i = 0; i < 12; i++) { for (int j = 0; j < 31; j++) { if (h.Diary[i, j]) { sum++; } } } return(sum); }
public void UpdateOrder(Order or, OrderStatus ortStatus) { try { GuestRequest gr = dal.GetGuestRequests().Find(item => item.GuestRequestKey == or.GuestRequestKey); HostingUnit ho = dal.GetHostingUnits().Find(item => item.HostingUnitKey == or.HostingUnitKey); if (ortStatus == OrderStatus.MailHasBeenSent) { if (ho.Owner.CollectionClearance == true) { dal.UpdateOrder(or, ortStatus); Console.WriteLine(or.ToString()); } else { throw new Exception("You have not erranged the collection clearance with the bank - you can not send an email!"); } } if (or.Status == OrderStatus.ClosesOutOfResponsiveness || or.Status == OrderStatus.ClosesWithResponse) { throw new Exception("can't change the order status because the order is closed "); } if (ortStatus == OrderStatus.ClosesWithResponse) { for (DateTime i = gr.EntryDate.AddDays(1); i < gr.ReleaseDate; i = i.AddDays(1)) { ho.Diary[i.Day, i.Month] = true; } ho.Owner.Payment += Configuration.fee * NumOfDays(gr.EntryDate, gr.ReleaseDate); var v = from item in dal.GetOrders() where item.GuestRequestKey == gr.GuestRequestKey && item.OrderKey != or.OrderKey select item; foreach (var item in v) { item.Status = OrderStatus.ClosesOutOfResponsiveness; } gr.Status = RequestStatus.SiteClose; dal.UpdateOrder(or, ortStatus); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void UpdateOrder(Order order) { //if closed then closed, doesnt matter how //if (dal.GetOrderByKey(order.OrderKey1).Status1 == BEEnum.Status.dealMade || dal.GetOrderByKey(order.OrderKey1).Status1 == BEEnum.Status.closedByClientsLackOfResponse)//may need to change it from mail sent //{ // throw new UnexceptableDetailsException("order cannot be changed once deal is closed."); //} try { if (order.Status1 == BEEnum.Status.dealMade) { GuestRequest temp = dal.GetGuestRequestByKey(order.GuestRequestKey1); //a guest request HostingUnit hosting = dal.GetHostingUnitByKey(order.HostingUnitKey1); //a hosting unit hosting.Commission1 = Configuration.commmission * calcNumOfDaysBetween(temp.EntryDate1, temp.ReleaseDate1); //dont knwo what to do with this UpdateHostingUnit(dal.updateDiary(hosting, dal.GetGuestRequestByKey(order.GuestRequestKey1))); //update the HU diary temp.status1 = BEEnum.Status.dealMade; //order.Status1;//changing the GR status to deal made UpdateGuestRequest(temp); //updating the GR foreach (var item in dal.GetAllOrders()) //a list of all the orders in the system { if (item.GuestRequestKey1 == order.GuestRequestKey1) //find the order associated with the GR { item.Status1 = BEEnum.Status.dealMade; //order.Status1;//changing the orders status } order.OrderDate1 = DateTime.Now; //update the order date once the deal is made } dal.UpdateOrder(order); //this is where we acctually change the orders status // the orders status is the only thing we are able to update in the order } if (order.Status1 == BEEnum.Status.mailSent) //comes here after the mail is sent { foreach (var item in dal.GetAllOrders()) //a list of all the orders in the system { if (item.GuestRequestKey1 == order.GuestRequestKey1) //find the order associated with the GR { item.Status1 = BEEnum.Status.mailSent; //changing the orders status } } dal.UpdateOrder(order);//this is where we acctually change the orders status } //uneccesery //if (order.Status1 == BEEnum.Status.mailSent && dal.GetHostingUnitByKey(order.HostingUnitKey1).Owner1.CollectionClearance1 == false) // throw new UnexceptableDetailsException("you can't send a mail, until you have signed a permission to charge the bank"); } catch (Exception) { throw; } }
public void UpdateUnitDiary(long key, DateTime date, int days) { HostingUnit unit = FindUnitByKey(key); DateTime tmpDate = date; for (int i = 1; i <= days; i++) { if (unit.Diary[tmpDate.Month, tmpDate.Day]) { throw new ArgumentException("The days is allready invited"); } tmpDate = tmpDate.AddDays(i); } for (int i = 1; i <= days; i++) { unit.Diary[date.Month, date.Day] = true; date = date.AddDays(i); } try { dal.UpdateUnit(unit); } catch (Exception exc) { if (exc is KeyNotFoundException) { throw exc; } if (exc is ArgumentNullException) { throw new ArgumentNullException("The key exists, /n Unable to find content by key"); } if (exc is ArgumentException) { throw new ArgumentException("The key exists, /n Unable to remone oldest content by key"); } if (exc is ArgumentOutOfRangeException) { throw new ArgumentOutOfRangeException("The key exists, / n the index is out of range"); } else { throw exc; } } }
/// <summary> /// Returns orders sent by mail/closed with success to this unit /// </summary> /// <param name="unit"></param> /// <returns></returns> public int Orders_Sent_And_Closed_With_Success(HostingUnit unit) { int sum = 0; List <Order> orderList = Dal.Get_Order_List(); foreach (Order order in orderList) { if (order.HostingUnitKey == unit.HostingUnitKey) { if (order.Status == Order_Status.Mail_Sent || order.Status == Order_Status.Closed_With_Success) { sum++; } } } return(sum); }
/// <summary> /// Return all orders sent to a specific host /// </summary> /// <param name="unit"></param> /// <returns></returns> public List <Order> Orders_Sent_To_Host(Host host) { HostingUnit temp = new HostingUnit(); List <Order> result = new List <Order>(); foreach (Order o in get_All_orders()) { temp = get_All_units().Find(x => x.HostingUnitKey == o.HostingUnitKey); if (temp.Owner.HostKey == host.HostKey) { result.Add(o); } } return(result.ToList <Order>()); }