Beispiel #1
0
        /// <summary>
        /// Выполнить инициализацию компонента
        /// </summary>
        public void Initialize()
        {
            try
            {
                app = Application.CreateInstance();
                if (app != null)
                {
                    app.Converter.OnComplete += new EventHandler(Converter_OnComplete);
                    if (app.Repository != null)
                    {
                        place = app.Repository.InstancePlace();
                    }

                    host = new ServiceHost(typeof(Service));
                    host.AddServiceEndpoint(typeof(IService), new NetTcpBinding(SecurityMode.None), new Uri("net.tcp://localhost:57000"));

                    host.Open();
                }
                else
                    if (OnError != null)
                    {
                        OnError(this, new ErrorArgs("Службe сетевого взаимодействия DeviceManager " +
                            "не удалось выполнить инициализацию!", ErrorType.Fatal));
                    }
            }
            catch (Exception ex)
            {
                if (OnError != null)
                {
                    OnError(this, new ErrorArgs(ex.Message, ErrorType.NotFatal));
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Освободить место в репозитарии
 /// </summary>
 /// <param name="place">Освобождаемое место</param>
 public void RemovePlace(Place place)
 {
     if (mutex.TryEnterWriteLock(500))
     {
         try
         {
             places.Remove(place);
         }
         catch (Exception ex)
         {
             if (onError != null)
             {
                 string message = "(репозитарий RemovePlace) + " + ex.Message;
                 onError(this, new Errors.ErrorArgs(message, Errors.ErrorType.NotFatal));
             }
         }
         finally
         {
             mutex.ExitWriteLock();
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Получить место в репозитарии
        /// </summary>
        public Place InstancePlace()
        {
            if (mutex.TryEnterWriteLock(500))
            {
                try
                {
                    Place place = new Place();
                    places.Add(place);

                    return place;
                }
                catch (Exception ex)
                {
                    if (onError != null)
                    {
                        string message = "(репозитарий InstancePlace) + " + ex.Message;
                        onError(this, new Errors.ErrorArgs(message, Errors.ErrorType.NotFatal));
                    }
                }
                finally
                {
                    mutex.ExitWriteLock();
                }
            }
            return null;
        }