Beispiel #1
0
        // ---------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OperationResult UpdateLocation(DTOLocation locationDTO)
        {
            ServiceLogger.Log(string.Format("Updating location {0}...", locationDTO.Name));

            //..........................................

            OperationResult result = new OperationResult();

            //::::::::::::::::::::::::::::::::::::::::::

            Location updatedLocation = null;

            using (TransactionScope scope = new TransactionScope(TransactionMode.New, OnDispose.Commit))
            {
                try
                {
                    updatedLocation = Location.Find(locationDTO.Id);

                    updatedLocation.Name            = locationDTO.Name;
                    updatedLocation.DefaultDuration = locationDTO.DefaultDuration;

                    updatedLocation.PlanWidth  = locationDTO.Width;
                    updatedLocation.PlanHeight = locationDTO.Height;

                    updatedLocation.BackgroundImg = locationDTO.BackgroundImg;

                    result.Success        = true;
                    result.ObjectAffected = updatedLocation.Id;
                    result.Message        = string.Format("Location {0} updated ok.", updatedLocation.Name);

                    ServiceLogger.Log(result.Message);
                }
                catch (ObjectNotFoundException onfe)
                {
                    scope.VoteRollBack();

                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = string.Format("Location {0} not updated{1}{2}.", updatedLocation.Name, Environment.NewLine, onfe.ToString());

                    ServiceLogger.LogException(string.Format("Location {0} not updated.", updatedLocation.Name), onfe);
                }
                catch (ActiveRecordException are)
                {
                    scope.VoteRollBack();

                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = string.Format("Location {0} not updated{1}{2}.", updatedLocation.Name, Environment.NewLine, are.ToString());

                    ServiceLogger.LogException(string.Format("Location {0} not updated.", updatedLocation.Name), are);
                }
                catch (Exception exc)
                {
                    scope.VoteRollBack();

                    result.Success        = false;
                    result.ObjectAffected = 0;
                    result.Message        = string.Format("Location {0} not updated{1}{2}.", updatedLocation.Name, Environment.NewLine, exc.ToString());

                    ServiceLogger.LogException(string.Format("Location {0} not updated.", updatedLocation.Name), exc);
                }
            }

            //::::::::::::::::::::::::::::::::::::::::::

            ServiceLogger.Log(string.Format("Finished updating location {0}...", locationDTO.Name));

            //..........................................

            return(result);
        }
Beispiel #2
0
        // ---------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OperationResult AddLocation(DTOLocation locationDTO)
        {
            OperationResult result = new OperationResult();

            //::::::::::::::::::::::::::::::::::::::::::

            using (TransactionScope scope = new TransactionScope(TransactionMode.New, OnDispose.Commit))
            {
                try
                {
                    Location[] locations = Location.FindAll();

                    //.....................................

                    Location newLocation = new Location(locationDTO.Name);
                    newLocation.DefaultDuration = locationDTO.DefaultDuration;
                    newLocation.PlanWidth       = locationDTO.Width;
                    newLocation.PlanHeight      = locationDTO.Height;

                    if (locations.Contains <Location>(newLocation, new LocationComparer()))
                    {
                        throw new LocationAlreadyExistsException(String.Format("Location {0} already exists", newLocation.Name));
                    }

                    newLocation.Save();
                    result.Success        = true;
                    result.ObjectAffected = newLocation.Id;
                    result.Message        = "Location added successfully.";

                    ServiceLogger.Log(string.Format("Location {0} added sucessfully", newLocation.ToString()));
                }
                catch (ActiveRecordException are)
                {
                    scope.VoteRollBack();
                    result.Success = false;
                    result.Message = are.ToString();

                    ServiceLogger.LogException(string.Format("Exception while adding new location{0}{1}", Environment.NewLine, locationDTO.Name), are);
                }
                catch (LocationAlreadyExistsException laee)
                {
                    string message = string.Format("Location already exists; {0}.", locationDTO);

                    scope.VoteRollBack();
                    result.Success     = false;
                    result.Message     = message;
                    result.LongMessage = laee.ToString();

                    ServiceLogger.LogException(message, laee);
                }
                catch (InvalidDTOException ide)
                {
                    scope.VoteRollBack();
                    result.Success = false;
                    result.Message = ide.ToString();

                    ServiceLogger.LogException(string.Format("Error adding location;{0}{1}", Environment.NewLine, locationDTO.Name), ide);
                }
            }

            //::::::::::::::::::::::::::::::::::::::::::

            return(result);
        }
Beispiel #3
0
 public void Log(string _msg)
 {
     ServiceLogger.Log(_msg);
 }
Beispiel #4
0
 protected virtual ServiceHost CreateServiceHost()
 {
     ServiceLogger.Log(@"public override void MenumateWCFRunner.CreateServiceHost {");
     return(null);
 }
Beispiel #5
0
        //.............................................................................................

        /// <summary>
        ///
        /// </summary>
        /// <param name="inFolder"></param>
        void setWatchedFolder(string inFolder)
        {
            watched_folder = inFolder;

            ServiceLogger.Log(string.Format(@"Watched folder set: {0}", watched_folder));
        }