示例#1
0
 public void Import(string fileName,
     TechnicalServices.Persistence.SystemPersistence.Presentation.Presentation presentation,
     ResourceDescriptor[] resourceDescriptors, DeviceResourceDescriptor[] deviceResourceDescriptors,
     int indent, int height)
 {
     _indent = indent;
     _height = height;
     try
     {
         SlideBulk slideBulk = LoadFromFile(fileName, resourceDescriptors, deviceResourceDescriptors);
         if (slideBulk == null)
         {
             throw new InvalideFileException("Содержание файла некорректно. Импорт сцен невозмлжен");
         }
         CheckSlideNames(slideBulk);
         AddSlideAndLink(presentation, slideBulk);
         _importSlideController.SuccessMessage("Импорт сцен успешно завершен");
     }
     catch (InterruptOperationException)
     { }
     catch (InvalideFileException ex)
     {
         _importSlideController.ErrorMessage(ex.Message);
     }
     catch (Exception ex)
     {
         _importSlideController.ErrorMessage(string.Format("При экспорте сцен произошла неизвестная ошибка: {0}", ex));
     }
 }
        public void Import(Presentation presentation, ResourceDescriptor[] resourceDescriptors,
            DeviceResourceDescriptor[] deviceResourceDescriptors, 
            Func<Slide, Slide> addSlideDelegate, Func<IEnumerable<Slide>, bool> addLinkDelegate,
            Func<string, string, bool> isSlideUniqueName,
            int indent, int height)
        {
            _addSlideDelegate = addSlideDelegate;
            _addLinkDelegate = addLinkDelegate;
            _isSlideUniqueName = isSlideUniqueName;
            string selectedFile = null;
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Filter = "XML Files (*.xml) | *.xml";
                openFileDialog.Multiselect = false;
                if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    selectedFile = openFileDialog.FileName;
                }
            }
            if (string.IsNullOrEmpty(selectedFile)) return;
            ImportSlide importSlide = new ImportSlide(DesignerClient.Instance.StandalonePresentationWorker,
                this);

            importSlide.Import(selectedFile, presentation, resourceDescriptors, deviceResourceDescriptors, indent, height);
        }
 public void UpdateResource(DeviceResourceDescriptor resource)
 {
     _lock.EnterWriteLock();
     try
     {
         if (IsInitialized)
         {
             Add(resource);
         }
     }
     finally
     {
         _lock.ExitWriteLock();
     }
 }
 public override bool DeleteSource(UserIdentity sender, DeviceResourceDescriptor descriptor)
 {
     _sync.AcquireWriterLock(Timeout.Infinite);
     try
     {
         bool isSuccess = base.DeleteSource(sender, descriptor);
         if (isSuccess)
             _cache.DeleteResource(descriptor);
         return isSuccess;
     }
     finally
     {
         _sync.ReleaseWriterLock();
     }
 }
        public override DeviceResourceDescriptor SaveSource(UserIdentity sender, DeviceResourceDescriptor resourceDescriptor, Dictionary<string, string> fileDic)
        {
            _sync.AcquireWriterLock(Timeout.Infinite);
            try
            {

                DeviceResourceDescriptor stored
                    = base.SaveSource(sender, resourceDescriptor, fileDic);
                if (null != stored)
                {
                    _cache.AddResource(stored);
                }
                return stored;
            }
            finally
            {
                _sync.ReleaseWriterLock();
            }
        }
示例#6
0
        /// <summary>
        /// должно вызываться после десериализации для инициализации ссылочных полей
        /// </summary>
        /// <returns>возвращается список оборудования которое отсутсвует в конфигурации и таким образом было исключено из сценария</returns>
        public string[] InitReference(ModuleConfiguration config, ResourceDescriptor[] descriptors,
            DeviceResourceDescriptor[] deviceResourceDescriptors)
        {
            foreach (KeyValuePair<int, SlideLinkList> pair in _linkDictionary)
            {
                foreach (Link link in pair.Value.LinkList)
                {
                    link.NextSlide = SlideList.Find(sl => sl.Id == link.NextSlideId);
                    if (link.NextSlide == null)
                        throw new KeyNotFoundException("SlideBulk.InitReference: Нет такого слайда в коллекции");
                }
            }

            // Initreference для каждого слайда
            List<string> deletedEquipment = new List<string>();
            foreach (Slide sl in SlideList)
            {
                deletedEquipment.AddRange(sl.InitReference(config, descriptors, deviceResourceDescriptors, true));
            }
            return deletedEquipment.Distinct().ToArray();
        }
 public void DeleteResource(DeviceResourceDescriptor resource)
 {
     _lock.EnterWriteLock();
     try
     {
         if (IsInitialized)
         {
             List<DeviceResourceDescriptor> list;
             if (_resources.TryGetValue(resource.ResourceInfo.Type, out list))
             {
                 int index = list.FindIndex(drd => drd.ResourceInfo.Equals(resource.ResourceInfo));
                 if (index >= 0)
                 {
                     list.RemoveAt(index);
                 }
             }
         }
     }
     finally
     {
         _lock.ExitWriteLock();
     }
 }
示例#8
0
 public bool SaveSlideChanges(UserIdentity userIdentity, string presentationUniqueName, Slide[] slideToSave,
                              out int[] slideIdNotLocked, out ResourceDescriptor[] resourcesNotExists,
                              out DeviceResourceDescriptor[] deviceResourcesNotExists, out int[] labelNotExists)
 {
     return _presentationWorker.SaveSlideChanges(userIdentity,
                                                 presentationUniqueName,
                                                 slideToSave,
                                                 out slideIdNotLocked,
                                                 out resourcesNotExists, out deviceResourcesNotExists,
                                                 out labelNotExists);
 }
 public FileSaveStatus GetDeviceSourceStatus(DeviceResourceDescriptor descriptor)
 {
     return _deviceSourceDAL.GetSourceStatus(descriptor);
 }
        //public IClientResourceCRUD<DeviceResourceDescriptor> GetDeviceResourceCrud()
        //{
        //    return new ClientSideDeviceSourceTransfer(_presentationClient.Channel, _deviceSourceDAL);
        //}

        public FileSaveStatus SaveDeviceSource(DeviceResourceDescriptor descriptor)
        {
            string newResourceId;
            FileSaveStatus saveStatus = _presentationClient.Channel.SaveDeviceSource(UserIdentity, descriptor, SourceStatus.Update);
            if (saveStatus == FileSaveStatus.Ok)
                _deviceDescriptorCache.AddResource(descriptor);
            return saveStatus;
        }
 public SlideBulk LoadSlideBulk(string fileName, ResourceDescriptor[] resourceDescriptors, DeviceResourceDescriptor[] deviceResourceDescriptors)
 {
     throw new System.NotImplementedException();
 }
 public bool SaveSlideChanges(string uniqueName, Slide[] slides, out int[] notLockedSlide, out ResourceDescriptor[] notExistedResources, out DeviceResourceDescriptor[] notExistedDeviceResources, out int[] labelNotExists)
 {
     return _presentationClient.Channel.SaveSlideChanges(UserIdentity, uniqueName, slides, out  notLockedSlide, out notExistedResources, out notExistedDeviceResources, out labelNotExists);
 }
 public bool IsResourceAvailable(DeviceResourceDescriptor descriptor)
 {
     return _presentationClient.Channel.IsResourceAvailable(descriptor);
 }
示例#14
0
        //public bool SavePresentationChanges(UserIdentity userIdentity, byte[] presentation,
        //                                    out ResourceDescriptor[] resourcesNotExists)
        //{
        //    return _presentationWorker.SavePresentationChanges(userIdentity, presentation, out resourcesNotExists);
        //}

        public SavePresentationResult SavePresentationChanges(UserIdentity userIdentity,
                                                              PresentationInfo presentationInfo, Slide[] newSlideArr,
                                                              out ResourceDescriptor[] resourcesNotExists,
                                                              out DeviceResourceDescriptor[] deviceResourcesNotExists,
                                                              out int[] labelNotExists,
                                                              out UserIdentity[] whoLock,
                                                              out int[] slidesAlreadyExistsId)
        {
            return _presentationWorker.SavePresentationChanges(userIdentity, presentationInfo,
                                                               newSlideArr, out resourcesNotExists,
                                                               out deviceResourcesNotExists, out labelNotExists,
                                                               out whoLock, out slidesAlreadyExistsId);
        }
 public SlideBulk LoadSlideBulk(string fileName, ResourceDescriptor[] resourceDescriptors, DeviceResourceDescriptor[] deviceResourceDescriptors)
 {
     return _presentationDAL.LoadSlideBulk(fileName, resourceDescriptors, deviceResourceDescriptors);
 }
示例#16
0
 public SavePresentationResult SavePresentationChanges(UserIdentity userIdentity, PresentationInfo presentationInfo,
     Slide[] newSlideArr, out ResourceDescriptor[] resourcesNotExists,
     out DeviceResourceDescriptor[] deviceResourcesNotExists, out int[] labelNotExists,
     out UserIdentity[] whoLock,
     out int[] slidesAlreadyExistsId)
 {
     resourcesNotExists = new ResourceDescriptor[] { };
     deviceResourcesNotExists = new DeviceResourceDescriptor[] {};
     whoLock = new UserIdentity[] { };
     slidesAlreadyExistsId = new int[] { };
     labelNotExists = presentationInfo.GetUsedLabels().Except(
         _configuration.LabelStorageAdapter.GetLabelStorage().Select(lb => lb.Id)).ToArray();
     if (labelNotExists.Length != 0) return SavePresentationResult.LabelNotExists;
     if (!IsStandAlone)
     {
         // необходим лок уровня презентации
         LockingInfo info = _lockService.GetLockInfo(ObjectKeyCreator.CreatePresentationKey(presentationInfo));
         if (info == null || !info.UserIdentity.Equals(userIdentity)) return SavePresentationResult.PresentationNotLocked;
     }
     string[] deletedEquipment;
     Presentation presentationStored = _presentationDAL.GetPresentation(
         presentationInfo.UniqueName, _sourceDAL, _deviceSourceDAL, out deletedEquipment);
     if (presentationStored == null) return SavePresentationResult.PresentationNotExists;
     resourcesNotExists = GetNotExistedResource(newSlideArr);
     deviceResourcesNotExists = GetNotExistedDeviceResource(newSlideArr, presentationInfo);
     if (resourcesNotExists.Length != 0 || deviceResourcesNotExists.Length != 0) return SavePresentationResult.ResourceNotExists;
     LockingInfo[] lockedSlides;
     Slide[] slideAlreadyExists;
     presentationStored = Merge(userIdentity, presentationInfo, newSlideArr, presentationStored,
         out lockedSlides, out slideAlreadyExists);
     if (presentationStored == null)
     {
         SavePresentationResult result = SavePresentationResult.Unknown;
         if (lockedSlides.Length != 0)
         {
             whoLock = lockedSlides.Select(li => li.UserIdentity).ToArray();
             result = SavePresentationResult.SlideLocked;
         }
         if (slideAlreadyExists.Length != 0)
         {
             slidesAlreadyExistsId = slideAlreadyExists.Select(sl => sl.Id).ToArray();
             result = SavePresentationResult.SlideAlreadyExists;
         }
         return result;
     }
     bool isSuccess = _presentationDAL.SavePresentation(userIdentity, presentationStored);
     if (isSuccess)
     {
         PresentationKey presentationKey = ObjectKeyCreator.CreatePresentationKey(presentationStored);
         ObjectChanged(userIdentity, new List<ObjectInfo> { new ObjectInfo(userIdentity, presentationKey) },
                       new PresentationInfo(presentationStored), true);
     }
     else
     {
         return SavePresentationResult.Unknown;
     }
     return SavePresentationResult.Ok;
 }
示例#17
0
 public RemoveResult DeleteDeviceSource(UserIdentity sender, DeviceResourceDescriptor descriptor)
 {
     PresentationInfo[] presentationInfos = _presentationDAL.GetPresentationWhichContainsSource(descriptor);
     if (presentationInfos != null && presentationInfos.Length != 0) return RemoveResult.LinkedToPresentation;
     return _deviceSourceDAL.DeleteSource(sender, descriptor) ? RemoveResult.Ok : RemoveResult.NotExists;
 }
示例#18
0
 public RemoveResult DeleteDeviceSource(UserIdentity sender, DeviceResourceDescriptor descriptor)
 {
     return _presentationWorker.DeleteDeviceSource(sender, descriptor);
 }
示例#19
0
 private void Add(DeviceResourceDescriptor resource)
 {
     List<DeviceResourceDescriptor> list;
     if (!_resources.TryGetValue(resource.ResourceInfo.Type, out list))
     {
         _resources[resource.ResourceInfo.Type] = list = new List<DeviceResourceDescriptor>();
     }
     int index = list.FindIndex(drd => drd.ResourceInfo.Equals(resource.ResourceInfo));
     if (index >= 0)
     {
         list[index] = resource;
     }
     else
     {
         list.Add(resource);
     }
 }
示例#20
0
 public FileSaveStatus SaveDeviceSource(UserIdentity userIdentity, DeviceResourceDescriptor resourceDescriptor, SourceStatus status)
 {
     string otherResourceId;
     return _presentationWorker.SaveDeviceSource(userIdentity, resourceDescriptor, status, out otherResourceId);
 }
示例#21
0
 public bool IsResourceAvailable(DeviceResourceDescriptor descriptor)
 {
     return _presentationWorker.IsResourceAvailable(descriptor);
 }
示例#22
0
 public FileSaveStatus GetDeviceSourceStatus(DeviceResourceDescriptor descriptor)
 {
     return _presentationWorker.GetDeviceSourceStatus(descriptor);
 }
示例#23
0
 public bool SaveSlideChanges(UserIdentity userIdentity, string presentationUniqueName,
     Slide[] slideToSave, out int[] slideIdNotLocked,
     out ResourceDescriptor[] resourcesNotExists,
     out DeviceResourceDescriptor[] deviceResourcesNotExists,
     out int[] labelNotExists)
 {
     resourcesNotExists = new ResourceDescriptor[] { };
     deviceResourcesNotExists = new DeviceResourceDescriptor[] {};
     labelNotExists =
         slideToSave.Select(sl => sl.LabelId).Where(id=>id>0).Distinct().Except(
             _configuration.LabelStorageAdapter.GetLabelStorage().Select(lb => lb.Id)).ToArray();
     List<int> slideNotLocked = new List<int>(slideToSave.Length);
     slideIdNotLocked = slideNotLocked.ToArray();
     if (labelNotExists.Length != 0) return false;
     if (slideToSave.Length == 0) return true;
     if (!IsStandAlone)
     {
         //Presentation pres = BinarySerializer.Deserialize<Presentation>(presentation);
         // проверка что слайды залочены данным пользователем
         foreach (Slide slide in slideToSave)
         {
             LockingInfo info =
                 _lockService.GetLockInfo(ObjectKeyCreator.CreateSlideKey(presentationUniqueName, slide.Id));
             if (info == null || !info.UserIdentity.Equals(userIdentity))
                 slideNotLocked.Add(slide.Id);
         }
     }
     slideIdNotLocked = slideNotLocked.ToArray();
     string[] deletedEquipment;
     Presentation presentation = _presentationDAL.GetPresentation(presentationUniqueName,
         _sourceDAL, _deviceSourceDAL, out deletedEquipment);
     if (presentation == null) return false;
     PresentationInfo presentationInfo = new PresentationInfo(presentation);
     resourcesNotExists = GetNotExistedResource(slideToSave);
     deviceResourcesNotExists = GetNotExistedDeviceResource(slideToSave, presentationInfo);
     if (slideIdNotLocked.Length != 0 || resourcesNotExists.Length != 0 || deviceResourcesNotExists.Length != 0)
         return false;
     presentation = Merge(presentation, slideToSave);
     if (presentation == null) return false;
     bool isSuccess = _presentationDAL.SavePresentation(userIdentity, presentation);
     if (isSuccess)
     {
         List<ObjectInfo> objectInfoList = new List<ObjectInfo>();
         foreach (Slide slide in slideToSave)
         {
             objectInfoList.Add(new ObjectInfo(userIdentity,
                                               ObjectKeyCreator.CreateSlideKey(presentationUniqueName, slide.Id)));
         }
         PresentationKey presentationKey = ObjectKeyCreator.CreatePresentationKey(presentationUniqueName);
         ObjectChanged(userIdentity, objectInfoList, new PresentationInfo(presentation), false);
     }
     return isSuccess;
 }
示例#24
0
 public PresentationInfo[] GetPresentationWhichContainsDeviceSource(DeviceResourceDescriptor resourceDescriptor)
 {
     return _presentationDAL.GetPresentationWhichContainsSource(resourceDescriptor);
 }
示例#25
0
 public FileSaveStatus SaveDeviceSource(UserIdentity userIdentity, DeviceResourceDescriptor resourceDescriptor, SourceStatus status, out string newResourceId)
 {
     newResourceId = null;
     if (status == SourceStatus.New && _deviceSourceDAL.IsExists(resourceDescriptor)) return FileSaveStatus.Exists;
     return null == _deviceSourceDAL.SaveSource(userIdentity, resourceDescriptor) ? FileSaveStatus.Exists : FileSaveStatus.Ok;
 }
 public FileSaveStatus SaveDeviceSource(DeviceResourceDescriptor descriptor)
 {
     string newResourceId;
     return base.SaveDeviceSource(UserIdentity, descriptor, SourceStatus.Update, out newResourceId);
 }
示例#27
0
 public bool IsResourceAvailable(DeviceResourceDescriptor descriptor)
 {
     return _deviceSourceDAL.IsResourceAvailable(descriptor);
 }
示例#28
0
 private SlideBulk LoadFromFile(string fileName, ResourceDescriptor[] resourceDescriptors,
     DeviceResourceDescriptor[] deviceResourceDescriptors)
 {
     return _standalonePresentationWorker.LoadSlideBulk(fileName, resourceDescriptors, deviceResourceDescriptors);
 }
 public SavePresentationResult SavePresentationChanges(PresentationInfo presentationInfo, Slide[] slides, out ResourceDescriptor[] notExistedResources, out DeviceResourceDescriptor[] notExistedDeviceResources, out int[] labelNotExists,
     out UserIdentity[] whoLock, out int[] slidesAlreadyExistsId)
 {
     return _presentationClient.Channel.SavePresentationChanges(UserIdentity, presentationInfo, slides, out notExistedResources, out notExistedDeviceResources, out labelNotExists,
         out whoLock, out slidesAlreadyExistsId);
 }
示例#30
0
 /// <summary>
 ///  сохранение ресурсов девайсов и на сервер и в кэш
 /// </summary>
 /// <param name="descriptor"></param>
 /// <returns></returns>
 public FileSaveStatus SaveDeviceResourceDescriptor(DeviceResourceDescriptor descriptor)
 {
     return DesignerClient.Instance.PresentationWorker.SaveDeviceSource(descriptor);
 }