Пример #1
0
 /// <summary>
 /// Gets the list of <see cref="LoadDescription"/>.
 /// </summary>
 /// <param name="edc">The object <see cref="EntitiesDataContext"/> that extends the <see cref="Microsoft.SharePoint.Linq.DataContext"/></param>
 /// <returns></returns>
 public List <LoadDescription> LoadDescriptions(EntitiesDataContext edc)
 {
     return((from _dtx in edc.LoadDescription
             let _sid = _dtx.LoadDescription2ShippingIndex.Id.Value
                        where this.Id.Value == _sid
                        select _dtx).ToList());
 }
Пример #2
0
        /// <summary>
        /// Books the time slots.
        /// </summary>
        /// <param name="EDC">The EDC.</param>
        /// <param name="timeSlot">The time slot.</param>
        /// <param name="isDouble">if set to <c>true</c> [is double].</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException">Time slot has been aleady reserved</exception>
        public static List <TimeSlotTimeSlot> BookTimeSlots(EntitiesDataContext EDC, string timeSlot, bool isDouble)
        {
            TimeSlotTimeSlot _timeSlot = Element.GetAtIndex <TimeSlotTimeSlot>(EDC.TimeSlot, timeSlot);

            if (_timeSlot.Occupied.GetValueOrDefault(Entities.Occupied.None) == Entities.Occupied.Occupied0)
            {
                throw new TimeSlotException("Time slot has been aleady reserved");
            }
            List <TimeSlotTimeSlot> _ret = new List <TimeSlotTimeSlot>();

            _ret.Add(_timeSlot);
            _timeSlot.Occupied = Entities.Occupied.Occupied0;
            if (isDouble)
            {
                Debug.Assert(_timeSlot.StartTime.HasValue, "TimeSlot StartTime has to have Value");
                DateTime _tdy = _timeSlot.StartTime.Value.Date;
                List <TimeSlotTimeSlot> _avlblTmslts = (from _tsidx in EDC.TimeSlot
                                                        let _idx = _tsidx.StartTime.Value.Date
                                                                   where _tsidx.Occupied.GetValueOrDefault(Entities.Occupied.None) == Entities.Occupied.Free &&
                                                                   _idx >= _tdy &&
                                                                   _idx <= _tdy.AddDays(1)
                                                                   orderby _tsidx.StartTime ascending
                                                                   select _tsidx).ToList <TimeSlotTimeSlot>().Where <TimeSlotTimeSlot>(x => x.TimeSlot2ShippingPointLookup == _timeSlot.TimeSlot2ShippingPointLookup).ToList <TimeSlotTimeSlot>();
                TimeSlotTimeSlot _next = FindAdjacent(_avlblTmslts, _timeSlot);
                _ret.Add(_next);
                _next.Occupied = Entities.Occupied.Occupied0;
            }
            return(_ret);
        }
Пример #3
0
 /// <summary>
 /// Shippings the drivers teams.
 /// </summary>
 /// <param name="edc">The object <see cref="EntitiesDataContext"/> that extends the <see cref="Microsoft.SharePoint.Linq.DataContext"/></param>
 /// <returns></returns>
 public List <ShippingDriversTeam> ShippingDriversTeams(EntitiesDataContext edc)
 {
     return((from _dtx in edc.DriversTeam
             let _sid = _dtx.ShippingIndex.Id.Value
                        where this.Id.Value == _sid
                        select _dtx).ToList());
 }
Пример #4
0
 /// <summary>
 /// Reports the exception.
 /// </summary>
 /// <param name="edc">The <see cref="EntitiesDataContext"/> object containing Linq Entities</param>
 /// <param name="source">The source location of the exception.</param>
 /// <param name="ex">The <see cref="Exception "/> to log.</param>
 public static void ReportException(EntitiesDataContext edc, string source, Exception ex)
 {
     try
     {
         Anons.WriteEntry(edc, source, ex.Message);
     }
     catch (Exception) { }
 }
Пример #5
0
 /// <summary>
 /// Reports the action result.
 /// </summary>
 /// <param name="EDC">The <see cref="EntitiesDataContext"/> object.</param>
 public void ReportActionResult(EntitiesDataContext EDC)
 {
     if (this.Count == 0)
     {
         return;
     }
     CreateAnonsEntry(EDC);
 }
Пример #6
0
        /// <summary>
        /// Deletes all not used time slots.
        /// </summary>
        /// <param name="EDC">The <see cref="EntitiesDataContext "/> object representing Linq entities.</param> DeletesExpired
        public static void DeleteExpired(EntitiesDataContext EDC)
        {
            IEnumerable <TimeSlotTimeSlot> _2Delete =
                from _tsx in EDC.TimeSlot
                where (_tsx.StartTime < DateTime.Now - new TimeSpan(72, 0, 0)) && _tsx.Occupied.Value == Entities.Occupied.Free
                select _tsx;

            EDC.TimeSlot.DeleteAllOnSubmit(_2Delete);
        }
Пример #7
0
 /// <summary>
 /// Finds for user.
 /// </summary>
 /// <param name="edc">The edc.</param>
 /// <param name="user">The user.</param>
 /// <returns></returns>
 public static Partner FindForUser(EntitiesDataContext edc, SPUser user)
 {
     if (edc.Partner == null)
     {
         return(null);
     }
     else
     {
         return(edc.Partner.FirstOrDefault(idx => idx.ShepherdUserTitle.IsNullOrEmpty() ? false : idx.ShepherdUserTitle.Contains(user.Name)));
     }
 }
Пример #8
0
 private void CreateAnonsEntry(EntitiesDataContext EDC)
 {
     foreach (string _msg in this)
     {
         Anons _entry = new Anons()
         {
             Title = m_Source, Body = _msg, Expires = DateTime.Now + new TimeSpan(2, 0, 0, 0)
         };
         EDC.EventLogList.InsertOnSubmit(_entry);
     }
 }
Пример #9
0
 /// <summary>
 /// Creates the cities.
 /// </summary>
 /// <param name="EDC">The EDC.</param>
 public static void CreateCities(EntitiesDataContext EDC)
 {
     for (int i = 0; i < 10; i++)
     {
         CityType _cmm = new CityType()
         {
             Title = String.Format("City {0}", i)
         };
         EDC.City.InsertOnSubmit(_cmm);
         EDC.SubmitChanges();
     }
 }
Пример #10
0
        /// <summary>
        /// Writes an entry with the given message text and application-defined event identifier to the event log list.
        /// </summary>
        /// <param name="edc">Provides LINQ (Language Integrated Query) access to, and change tracking for,
        /// the lists and document libraries of a Windows SharePoint Services "14" Web site.</param>
        /// <param name="source">The source denominator of the message.</param>
        /// <param name="message">The string to write to the event log.</param>
        public static void WriteEntry(EntitiesDataContext edc, string source, string message)
        {
            if (edc == null)
            {
                EventLog.WriteEntry("CAS.SmartFActory", "Cannot open \"Event Log List\" list", EventLogEntryType.Error, 40);
                return;
            }
            Anons log = CreateAnons(source, message);

            edc.EventLogList.InsertOnSubmit(log);
            edc.SubmitChangesSilently(Microsoft.SharePoint.Linq.RefreshMode.OverwriteCurrentValues);
        }
Пример #11
0
        /// <summary>
        /// Gets the email.
        /// </summary>
        /// <param name="ccRole">The cc role.</param>
        /// <param name="EDC">The EDC.</param>
        /// <returns></returns>
        public static string GetEmail(ShepherdRole ccRole, EntitiesDataContext EDC)
        {
            var _ccdl = (from _ccx in EDC.DistributionList
                         where _ccx.ShepherdRole.GetValueOrDefault(Entities.ShepherdRole.Invalid) == ccRole
                         select new { Email = _ccx.EmailAddress }).FirstOrDefault();

            if (_ccdl == null || String.IsNullOrEmpty(_ccdl.Email))
            {
                _ccdl = (from _ccx in EDC.DistributionList
                         where _ccx.ShepherdRole.GetValueOrDefault(Entities.ShepherdRole.Invalid) == Entities.ShepherdRole.Administrator
                         select new { Email = _ccx.EmailAddress }).FirstOrDefault();
            }
            return((_ccdl == null ? String.Empty : _ccdl.Email).UnknownIfEmpty());
        }
Пример #12
0
        /// <summary>
        /// Get all Delayeds  <see cref="TimeSlotTimeSlot"/> for this <see cref="Shipping"/>.
        /// </summary>
        /// <param name="edc">The edc.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">edc;calling Shipping.TimeSlots( EntitiesDataContext edc ) edc cannot be null</exception>
        public List <TimeSlotTimeSlot> DelayedTimeSlots(EntitiesDataContext edc)
        {
            if (edc == null)
            {
                throw new ArgumentNullException("edc", "calling Shipping.TimeSlots( EntitiesDataContext edc ) edc cannot be null");
            }

            List <TimeSlotTimeSlot> _retTimeSlots = (from _ts in edc.TimeSlot
                                                     where _ts.Occupied.GetValueOrDefault(Occupied.Free) == Occupied.Delayed
                                                     select _ts).ToList();

            return((from _ts in _retTimeSlots
                    where (this == _ts.TimeSlot2ShippingIndex)
                    orderby _ts.StartTime.Value ascending
                    select _ts).ToList());
        }
Пример #13
0
        /// <summary>
        /// Writes an entry with the given message text and application-defined event identifier to the event log list.
        /// </summary>
        /// <param name="edc">Provides LINQ (Language Integrated Query) access to, and change tracking for,
        /// the lists and document libraries of a Windows SharePoint Services "14" Web site.</param>
        /// <param name="title">The evrnt title.</param>
        /// <param name="partner">The partner associated with the event.</param>
        /// <param name="shippingIndex">Index of the shipping.</param>
        internal static void WriteEntry(EntitiesDataContext edc, string title, Partner partner, Shipping shippingIndex)
        {
            if (edc == null)
            {
                EventLog.WriteEntry("CAS.SmartFActory", "Cannot open \"Event Log List\" list", EventLogEntryType.Error, 114);
                return;
            }
            AlarmsAndEvents _log = new AlarmsAndEvents()
            {
                Title = title,
                AlarmsAndEventsList2PartnerTitle = partner,
                AlarmsAndEventsList2Shipping     = shippingIndex
            };

            edc.AlarmsAndEvents.InsertOnSubmit(_log);
            edc.SubmitChanges(Microsoft.SharePoint.Linq.ConflictMode.ContinueOnConflict);
        }
Пример #14
0
 /// <summary>
 /// Releases the booking.
 /// </summary>
 /// <exception cref="System.ApplicationException"></exception>
 public void ReleaseBooking(EntitiesDataContext edc)
 {
     foreach (var item in this.OccupiedTimeSlots(edc))
     {
         //item.Tytuł = "-- not assigned --";
         if (ForFuture())
         {
             item.Occupied = Entities.Occupied.Delayed;
         }
         else
         {
             item.Occupied = Entities.Occupied.Free;
             item.TimeSlot2ShippingIndex = null;
             item.IsDouble = false;
         }
     }
 }
Пример #15
0
 /// <summary>
 /// Changes the escort.
 /// </summary>
 /// <param name="nr">The nr.</param>
 /// <param name="EDC">The EDC.</param>
 public void ChangeEscort(SecurityEscortCatalog nr, EntitiesDataContext EDC)
 {
     if (this.SecurityEscortCatalogTitle == nr)
     {
         return;
     }
     this.Shipping2TruckTitle = null;
     EDC.SubmitChanges();
     RemoveDrivers(EDC, this.Shipping2PartnerTitle);
     this.SecurityEscortCatalogTitle = nr;
     if (nr == null)
     {
         this.Shipping2PartnerTitle = null;
         return;
     }
     this.SecurityEscortCatalogTitle = nr;
     this.Shipping2PartnerTitle      = nr == null ? null : nr.PartnerTitle;
 }
Пример #16
0
        private void RemoveDrivers(EntitiesDataContext EDC, Partner partner)
        {
            if (partner == null)
            {
                return;
            }
            List <ShippingDriversTeam> _2Delete = new List <ShippingDriversTeam>();

            foreach (ShippingDriversTeam _drv in this.ShippingDriversTeams(EDC))
            {
                if (partner == _drv.DriverTitle.Driver2PartnerTitle)
                {
                    _2Delete.Add(_drv);
                }
            }
            EDC.DriversTeam.DeleteAllOnSubmit(_2Delete);
            EDC.SubmitChanges();
        }
Пример #17
0
 /// <summary>
 /// Changes the rout.
 /// </summary>
 /// <param name="nr">The nr.</param>
 /// <param name="EDC">The EDC.</param>
 public void ChangeRout(Route nr, EntitiesDataContext EDC)
 {
     if (this.Shipping2RouteTitle == nr)
     {
         return;
     }
     this.TrailerTitle = null;
     this.TruckTitle   = null;
     EDC.SubmitChanges();
     RemoveDrivers(EDC, this.PartnerTitle);
     this.Shipping2RouteTitle = nr;
     if (nr == null)
     {
         this.BusinessDescription = String.Empty;
         this.PartnerTitle        = null;
         return;
     }
     this.BusinessDescription = Shipping2RouteTitle.Route2BusinessDescriptionTitle == null ? String.Empty : Shipping2RouteTitle.Route2BusinessDescriptionTitle.Title;
     this.PartnerTitle        = Shipping2RouteTitle.PartnerTitle;
 }
Пример #18
0
 /// <summary>
 /// Get all Occupied <see cref="TimeSlotTimeSlot"/> for this <see cref="Shipping"/>.
 /// </summary>
 /// <param name="edc">The edc.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentNullException">edc;calling Shipping.TimeSlots( EntitiesDataContext edc ) edc cannot be null</exception>
 public List <TimeSlotTimeSlot> OccupiedTimeSlots(EntitiesDataContext edc)
 {
     if (edc == null)
     {
         throw new ArgumentNullException("edc", "calling Shipping.TimeSlots( EntitiesDataContext edc ) edc cannot be null");
     }
     if (m_TimeSlots == null)
     {
         m_TimeSlots = new List <TimeSlotTimeSlot>();
         m_TimeSlots.AddRange((from _ts in edc.TimeSlot
                               where this.StartTime == _ts.StartTime
                               select _ts).ToList());
         m_TimeSlots.AddRange((from _ts in edc.TimeSlot
                               where this.EndTime == _ts.EndTime
                               select _ts).ToList());
         m_TimeSlots = (from _ts in m_TimeSlots
                        where (this == _ts.TimeSlot2ShippingIndex) && _ts.Occupied.GetValueOrDefault(Occupied.Free) == Occupied.Occupied0
                        orderby _ts.StartTime.Value ascending
                        select _ts).ToList();
     }
     return(m_TimeSlots);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntitiesDataDictionary"/> class.
 /// </summary>
 /// <param name="_url">The _url.</param>
 public EntitiesDataDictionary(string _url)
 {
     m_EDC = new EntitiesDataContext(_url);
 }
Пример #20
0
        /// <summary>
        /// Calculates the state.
        /// </summary>
        public void CalculateState(EntitiesDataContext edc, Action <string> at)
        {
            switch (this.ShippingState.GetValueOrDefault(Entities.ShippingState.None))
            {
            case Entities.ShippingState.Confirmed:
            case Entities.ShippingState.Creation:
            case Entities.ShippingState.WaitingForCarrierData:
            case Entities.ShippingState.WaitingForConfirmation:
                int _seDrivers = 0;
                int _crDrivers = 0;
                at("CalculateState.foreach ");
                foreach (ShippingDriversTeam _dr in this.ShippingDriversTeams(edc))
                {
                    at("CalculateState.L155");
                    if (_dr.DriverTitle.Driver2PartnerTitle.ServiceType.Value == ServiceType.SecurityEscortProvider)
                    {
                        _seDrivers++;
                    }
                    else
                    {
                        _crDrivers++;
                    }
                }
                at("CalculateState.L161");
                if (this.PartnerTitle == null)
                {
                    this.ShippingState = Entities.ShippingState.Creation;
                }
                else
                {
                    if (_crDrivers > 0 && this.TruckTitle != null)
                    {
                        at("CalculateState.L168");
                        if (this.SecurityEscortCatalogTitle == null || (_seDrivers > 0 && this.Shipping2TruckTitle != null))
                        {
                            this.ShippingState = Entities.ShippingState.Confirmed;
                        }
                        else
                        {
                            this.ShippingState = Entities.ShippingState.WaitingForConfirmation;
                        }
                    }
                    else if (this.SecurityEscortCatalogTitle == null || (_seDrivers > 0 && this.Shipping2TruckTitle != null))
                    {
                        this.ShippingState = Entities.ShippingState.WaitingForCarrierData;
                    }
                    else
                    {
                        this.ShippingState = Entities.ShippingState.Creation;
                    }
                }
                break;

            case Entities.ShippingState.None:
                this.ShippingState = Entities.ShippingState.Creation;
                break;

            case Entities.ShippingState.Underway:
            case Entities.ShippingState.Delayed:
            case Entities.ShippingState.Invalid:
            case Entities.ShippingState.Cancelation:
            case Entities.ShippingState.Canceled:
            case Entities.ShippingState.Completed:
            default:
                break;
            }
            at("CalculateState.End");
        }