Example #1
0
 public ActionResult NewComponents(ComponentsModel components)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // var componentexist =   _componentsService.GetAllComponents().Where(fetch => fetch.ComponentName.ToLower() == componentsModel.ComponentName.ToLower()).ToList().FirstOrDefault();
             _componentsService.createComponents(components);
             TempData["Message"]     = "Component type created successfully.";
             TempData["MessageType"] = (int)AlertMessageTypes.Success;
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("NewComponents"));
         }
     }
     catch (Exception e)
     {
         _logger.Error(e);
         TempData["Message"]     = "Internal server error. Component type not created. Please contact administrator.";
         TempData["MessageType"] = (int)AlertMessageTypes.Danger;
         return(View("Index"));
     }
 }
        protected override void InternalHandleImport(ComponentsModel packageModel, ImportFilter importFilter, out int importedCount)
        {
            importedCount = 0;
            if (!Directory.Exists(this.ComponentsFolder))
            {
                return;
            }
            var resultLocalizationStrings = this.GetComponentModelList(packageModel);
            var groupFolders = Directory.EnumerateDirectories(this.ComponentsFolder);

            foreach (var groupFolder in groupFolders)
            {
                if (importFilter.NeedImport(groupFolder, this.DevelopmentPath))
                {
                    var groupCode           = new DirectoryInfo(groupFolder).Name;
                    var localizationStrings = this.LoadLocalizationStringsByGroup(groupCode);
                    foreach (var localizationString in localizationStrings)
                    {
                        this.PrepareForImport(groupFolder, localizationString);
                        resultLocalizationStrings.Add(localizationString);
                        importedCount++;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Выполнить преобразование структуры папок в пакет разработки для импорта.
        /// </summary>
        private void HandleImportPackage()
        {
            var componentsModel = new ComponentsModel();

            var packageInfoModel = this.LoadPackageInfoModel();

            componentsModel.SetupPackageInfo(packageInfoModel);

            Parallel.ForEach <IPackageHandler>(this.packageHandlers,
                                               (handler) => handler.HandleImport(componentsModel, this.importFilter));

            componentsModel.ClearEmptyLists();

            using (var fileStream = new FileStream(this.PackageFileName, FileMode.Create))
            {
                var packageSerializer = new XmlSerializer(typeof(ComponentsModel));
                using (var writer = XmlWriter.Create(fileStream, GetXmlWriterSettings()))
                {
                    try
                    {
                        Log.Info("  Запись пакета разработки: запущена.");
                        packageSerializer.Serialize(writer, componentsModel, GetXmlSerializerNamespaces());
                        Log.Info("  Запись пакета разработки: завершена.");
                    }
                    catch (Exception ex)
                    {
                        Log.Error("  Запись пакета разработки: ошибка.", ex);
                        throw;
                    }
                }
            }
        }
Example #4
0
        public IEnumerable <Script> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.Scripts)
            {
                var entity = PackageHandlerUtils.CreateEntity <Script>(model);

                var stateReq = model.Card.Requisites
                               .FirstOrDefault(r => r.Code == StateReqName);
                if (stateReq != null)
                {
                    entity.State = stateReq.ValueLocalizeID == Active ? ComponentState.Active : ComponentState.Closed;
                }

                var calculationTextReq = model.Card.Requisites
                                         .FirstOrDefault(r => r.Code == CalculationTextReqName);
                if (calculationTextReq != null)
                {
                    entity.CalculationText = calculationTextReq.DecodedText;
                }
                else
                {
                    entity.CalculationText = string.Empty;
                }

                yield return(entity);
            }
        }
Example #5
0
        public List <ComponentsModel> GetAllComponents()
        {
            var getComponents = this._componentRepository.GetComponents();
            List <ComponentsModel> getAllComponents = new List <ComponentsModel>();

            getComponents.ForEach(components =>
            {
                ComponentsModel componentsViewModel = new ComponentsModel();
                componentsViewModel.ID                = components.ID;
                componentsViewModel.ComponentName     = components.ComponentName;
                componentsViewModel.ComponentTypeID   = components.ComponentTypeID;
                componentsViewModel.ComponentTypeName = components.ComponentType.Name;
                componentsViewModel.Description       = components.Description;

                //componentsViewModel.IsActive = components.ComponentType.IsActive;
                //componentsViewModel.AssetID = components.ComponentAssetMapping.Where(cam => cam.ComponentID == components.ID).Select(cam=> cam.AssignedAssetID).FirstOrDefault();
                //componentsViewModel.AssetName = (from s in components.ComponentAssetMapping where s.ComponentID.Equals(components.ID) select s.Assets.AssetName).SingleOrDefault();
                //componentsViewModel.ComponentStatusID = (from s in components.ComponentAssetMapping where s.ComponentID.Equals(components.ID) select s.ComponentStatusId).SingleOrDefault();
                //componentsViewModel.ComponentStatus = (from s in components.ComponentAssetMapping where s.ComponentID.Equals(components.ID) select s.ComponentStatus.Description).SingleOrDefault();


                getAllComponents.Add(componentsViewModel);
            });

            return(getAllComponents);
        }
Example #6
0
        public ActionResult NewComponents()
        {
            ComponentsModel components = new ComponentsModel
            {
                ComponentType = _componentTypeService.GetDropdownComponentTypes()
            };

            return(View(components));
        }
Example #7
0
        public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, ComponentsModel viewModel)
        {
            var error = this.LoadModel<ComponentsModel, bool>(false).Delete(viewModel, this.ModelState);

            if (error != null)
            {
                return this.Json(error);
            }

            return this.GridOperation(viewModel, request);
        }
        public IEnumerable <CommonReport> Read(ComponentsModel packageModel)
        {
            var models = packageModel.Reports
                         .Where(m => m.Card.Requisites.First(r => r.Code == IsIntegratedReqName).DecodedText == IsCommon);

            foreach (var model in models)
            {
                var entity = this.Read <CommonReport>(model);

                yield return(entity);
            }
        }
        protected override void InternalHandleExport(ComponentsModel packageModel, XmlWriterSettings settings, XmlSerializerNamespaces namespaces, out int exportedCount)
        {
            var models = packageModel.LocalizationStrings;

            exportedCount = models.Count;

            var stringsGrouppedByCode =
                models.GroupBy(
                    model => model.DetailDataSets.DetailDataSet1.Rows[0].Requisites
                    .Find(x => x.Code == "ISBGroupCode").DecodedText.ToUpper());

            var stringsToExport = new Dictionary <string, LocalizationStringsExportModel>();

            foreach (var stringsGroup in stringsGrouppedByCode)
            {
                var oldLocalizationStrings = this.LoadLocalizationStringsByGroup(stringsGroup.Key);

                Predicate <RequisiteModel> getLanguageRequisite = x => x.Code == "ISBLanguage";
                // Компаратор для строк локализации.
                // В нашем случае всегда будет идти сначала "ru", потом "en".
                Comparison <RowModel> languageCodeComparer =
                    (reqA, reqB) => - 1 * string.Compare(
                        reqA.Requisites.Find(getLanguageRequisite).Value,
                        reqB.Requisites.Find(getLanguageRequisite).Value,
                        StringComparison.OrdinalIgnoreCase);
                var newLocalizationStrings = new List <ComponentModel>();
                foreach (var localizationString in stringsGroup)
                {
                    this.PrepareForExport("notRequired", localizationString);
                    // Сортируем локализацию внутри строки локализации, т.к. иногда в isx-файлах
                    // порядок следования "ru" и "en" локализаций для одной строки может различаться.
                    localizationString.DetailDataSets.DetailDataSet1.Rows.Sort(languageCodeComparer);
                    newLocalizationStrings.Add(localizationString);
                }
                // Найдём дельту, которую допишем к новым данным - это старые данные за исключением новых с таким же KeyValue.
                var unchanged = oldLocalizationStrings?.Except(newLocalizationStrings, new LocalizationStringComparer()).ToList() ?? new List <ComponentModel>();
                stringsToExport.Add(stringsGroup.Key, new LocalizationStringsExportModel());
                stringsToExport[stringsGroup.Key].LocalizationStrings.AddRange(newLocalizationStrings.Union(unchanged).OrderBy(x => x.KeyValue));
            }

            foreach (var model in stringsToExport)
            {
                // Получаем путь к компоненте.
                var componentFolder = Path.Combine(this.ComponentsFolder, model.Key);
                if (!Directory.Exists(componentFolder))
                {
                    Directory.CreateDirectory(componentFolder);
                }
                // Выполнить обработку модели.
                var serializer = new XmlSerializer(typeof(LocalizationStringsExportModel));
                this.HandleExportModel(componentFolder, model.Value, settings, namespaces, serializer);
            }
        }
Example #10
0
        /// <summary>
        /// Выполнить экспорт из пакета разработки в структуру папок.
        /// </summary>
        private void HandleExportPackage(XmlReaderSettings packageReaderSettings)
        {
            using (var fileStream = File.OpenRead(this.PackageFileName))
            {
                var packageSerializer = new XmlSerializer(typeof(ComponentsModel));
                using (var reader = XmlReader.Create(fileStream, packageReaderSettings))
                {
                    ComponentsModel packageModel = null;
                    try
                    {
                        Log.Info("  Чтение пакета разработки: запущено.");
                        packageModel = (ComponentsModel)packageSerializer.Deserialize(reader);
                        Log.Info("  Чтение пакета разработки: завершено.");
                    }
                    catch (Exception ex)
                    {
                        Log.Error("  Чтение пакета разработки: ошибка.", ex);
                        throw;
                    }

                    var settings   = GetXmlWriterSettings();
                    var namespaces = GetXmlSerializerNamespaces();

                    Parallel.ForEach <IPackageHandler>(this.packageHandlers,
                                                       (handler) => handler.HandleExport(packageModel, settings, namespaces));

                    var packageInfoModel = PackageInfoModel.CreateFromComponentsModel(packageModel);
                    this.SavePackageInfoModel(packageInfoModel);

                    if (this.CommandLineOptions.AuthType == AuthenticationType.Windows)
                    {
                        Log.Warn("  Обработка удаления элементов разработки не будет выполнена, так как используется Windows-аутентификация.");
                        return;
                    }

                    if (string.IsNullOrEmpty(this.CommandLineOptions.Server) ||
                        string.IsNullOrEmpty(this.CommandLineOptions.Database) ||
                        string.IsNullOrEmpty(this.CommandLineOptions.UserName))
                    {
                        Log.Warn("  Обработка удаления элементов разработки не будет выполнена, так как не заданы параметры подключения к БД.");
                        return;
                    }

                    var connectionParams = new ConnectionParams(
                        this.CommandLineOptions.Server,
                        this.CommandLineOptions.Database,
                        this.CommandLineOptions.UserName,
                        this.CommandLineOptions.Password);
                    Parallel.ForEach <IPackageHandler>(this.packageHandlers,
                                                       (handler) => handler.HandleDelete(connectionParams, settings, namespaces));
                }
            }
        }
Example #11
0
        private void DisplaySelectedView(int id)
        {
            details.HidePointPrice();
            details.ShowPortions();
            details.ShowGroup();
            details.Reset();

            ItemModelBase tempModel = new ComponentsModel(id);

            ((ComponentsModel)tempModel).SortByPosition();

            Populate(tempModel, null, false);
        }
        private void DisplaySelectedView(int id)
        {
            ItemModelBase model = new ComponentsModel(id, true);

            if (model.HasChildren)
            {
                ItemModelBase tempModel = new ComponentModel(0, id);
                ((ComponentModel)tempModel).SortByPosition();

                title.Text       = tempModel.DisplayName;
                upOne.Visibility = Visibility.Visible;
                Populate(tempModel, null, false);
            }
        }
Example #13
0
        public int createComponents(ComponentsModel componentsModel)
        {
            var components = _componentRepository.CreateComponent(new Components
            {
                ComponentName = componentsModel.ComponentName,
                ComponentTypeID = componentsModel.ComponentTypeID,
                Description = componentsModel.Description,
                CreatedBy = _employeeService.GetEmployeeByCorpId(HttpContext.Current.User.Identity.Name).ID,
                CreatedDate = DateTime.Now,
            });
            componentsModel.ID = components.ID;

            return componentsModel.ID;
        }
Example #14
0
        public string UpdateComponents(ComponentsModel componentsModel)
        {
            Components UpdateComponents = _componentRepository.GetComponentsByID(componentsModel.ID);

            if (UpdateComponents != null)
            {
                UpdateComponents.ID              = componentsModel.ID;
                UpdateComponents.ComponentName   = componentsModel.ComponentName;
                UpdateComponents.ComponentTypeID = componentsModel.ComponentTypeID;
                UpdateComponents.Description     = componentsModel.Description;
            }
            _componentRepository.UpdateComponent(UpdateComponents);
            return(componentsModel.ToString());
        }
Example #15
0
        public int createComponents(ComponentsModel componentsModel)
        {
            Components _component = new Components
            {
                ComponentName   = componentsModel.ComponentName,
                ComponentTypeID = componentsModel.ComponentTypeID,
                Description     = componentsModel.Description,
                CreatedDate     = DateTime.Now,
                CreatedBy       = GetLoginEmployeeId()
            };
            var objcomponentName = this._componentRepository.CreateComponent(_component);

            return(_component.ID);
        }
Example #16
0
        public ComponentsModel GetComponents(Components componentsModel, SelectList ddltypes)
        {
            ComponentsModel componetModel = new ComponentsModel
            {
                ID                = componentsModel.ID,
                ComponentName     = componentsModel.ComponentName,
                ComponentTypeID   = componentsModel.ComponentTypeID,
                ComponentTypeName = componentsModel.ComponentType.Name,
                Description       = componentsModel.Description,
                ComponentType     = ddltypes
            };

            return(componetModel);
        }
Example #17
0
        public int UpdateComponents(ComponentsModel componentsModel)
        {
            Components UpdateComponents = _componentRepository.GetComponentsByID(componentsModel.ID);

            if (UpdateComponents != null)
            {
                UpdateComponents.ID = componentsModel.ID;
                UpdateComponents.ComponentName = componentsModel.ComponentName;
                UpdateComponents.ComponentTypeID = componentsModel.ComponentTypeID;
                UpdateComponents.Description = componentsModel.Description;
            }
            UpdateComponents = _componentRepository.UpdateComponent(UpdateComponents);
            componentsModel.ID = UpdateComponents.ID;
            return componentsModel.ID;
        }
        public void HandleImport(ComponentsModel packageModel, ImportFilter importFilter)
        {
            const string ImportStageName = "Импорт";

            try
            {
                int importedCount;
                this.InternalHandleImport(packageModel, importFilter, out importedCount);
                Log.Info(string.Format("  {0} {1}: завершен (импортировано {2})", ImportStageName, this.ElementNameInGenitive, importedCount));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("  {0} {1}: ошибка. Подробнее: {2}", ImportStageName, this.ElementNameInGenitive, ex.Message));
                throw;
            }
        }
        public void HandleExport(ComponentsModel packageModel, XmlWriterSettings settings, XmlSerializerNamespaces namespaces)
        {
            const string ExportStageName = "Экспорт";

            try
            {
                int exportedCount;
                this.InternalHandleExport(packageModel, settings, namespaces, out exportedCount);
                Log.Info(string.Format("  {0} {1}: завершен (экспортировано {2})", ExportStageName, this.ElementNameInGenitive, exportedCount));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("  {0} {1}: ошибка. Подробнее: {2}", ExportStageName, this.ElementNameInGenitive, ex.Message));
                throw;
            }
        }
Example #20
0
 public List<ComponentsModel> GetActiveComponents()
 {
     var components = _componentRepository.GetComponents().Where(fet => fet.ComponentType.IsActive == true).ToList();
     ComponentsModel componentsModel = new ComponentsModel();
     if (components != null && components.Count > 0)
     {
         return components.Select(ac => new ComponentsModel
         {
             ID = ac.ID,
             ComponentName = ac.ComponentName,
             Description = ac.Description,
             ComponentTypeID = ac.ComponentTypeID
         }).ToList();
     }
     else
     {
         return new List<ComponentsModel> { };
     }
 }
Example #21
0
        public IEnumerable <DocumentCardType> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.DocumentCardTypes)
            {
                var entity = PackageHandlerUtils.CreateEntity <DocumentCardType>(model);

                var stateReq = model.Card.Requisites
                               .FirstOrDefault(r => r.Code == StateReqName);
                if (stateReq != null)
                {
                    entity.State = stateReq.ValueLocalizeID == Active ? ComponentState.Active : ComponentState.Closed;
                }

                var numerationMethodReq = model.Card.Requisites
                                          .FirstOrDefault(r => r.Code == NumerationMethodReqName);
                if (numerationMethodReq != null)
                {
                    switch (numerationMethodReq.ValueLocalizeID)
                    {
                    case StronglyAuto:
                        entity.NumerationMethod = NumerationMethod.StronglyAuto;
                        break;

                    case Auto:
                        entity.NumerationMethod = NumerationMethod.Auto;
                        break;

                    case Manual:
                        entity.NumerationMethod = NumerationMethod.Manual;
                        break;
                    }
                }

                ReadMethods(model, entity);
                ReadMethodsParameters(model, entity);
                ReadActions(model, entity);
                ReadEvents(model, entity);
                ReadCardRequisites(model, entity);
                ReadViews(model, entity);

                yield return(entity);
            }
        }
        private void DisplayFullView(int id, bool setParent)
        {
            subViewPanel.Visibility  = Visibility.Visible;
            fullView.Background      = new SolidColorBrush(Colors.Beige);
            selectionView.Background = new SolidColorBrush(Colors.LightGray);
            fullViewSelected         = true;

            ItemModelBase model = new ComponentsModel(id, true);

            ((ComponentsModel)model).SortByName();

            if (model.HasChildren)
            {
                ItemModelBase tempModel = new ComponentModel(0, id);

                title.Text       = tempModel.DisplayName;
                upOne.Visibility = Visibility.Visible;
                Populate(model, new ComponentModel(id, id), setParent);
            }
        }
Example #23
0
 public List<ComponentsModel> GetAllComponents()
 {
     var getComponents = this._componentRepository.GetComponents();
     List<ComponentsModel> getAllComponents = new List<ComponentsModel>();
     getComponents.ForEach(components =>
     {
         ComponentsModel componentsViewModel = new ComponentsModel
         {
             ID = components.ID,
             ComponentName = components.ComponentName,
             ComponentTypeID = components.ComponentTypeID,
             ComponentTypeName = components.ComponentType.Name,
             Description = components.Description,
             AssignedCount = components.ComponentAssetMapping.Where(cap => cap.ComponentStatusId == (int)AMSUtilities.Enums.ComponentTrackingStatus.Assign).Count(),
             AssetTypeName = components.ComponentType.AssetTypes.Description
         };
         getAllComponents.Add(componentsViewModel);
     });
     return getAllComponents;
 }
Example #24
0
 public JsonResult CreateComponent(ComponentsModel component)
 {
     try
     {
         var createdComponent = _assetService.CreateComponent(component);
         if (createdComponent != 0)
         {
             return(Json(createdComponent, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json("Error", JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         return(Json("Error", JsonRequestBehavior.AllowGet));
     }
 }
        /// <summary>
        /// Обработать экспорт моделей (внутренний метод).
        /// </summary>
        /// <param name="packageModel">Модель пакета разработки.</param>
        /// <param name="settings">Настройки сериализации XML.</param>
        /// <param name="namespaces">Пространства имен сериализации.</param>
        /// <param name="exportedCount">Количество экспортированных элементов.</param>
        protected virtual void InternalHandleExport(ComponentsModel packageModel, XmlWriterSettings settings, XmlSerializerNamespaces namespaces, out int exportedCount)
        {
            var serializer = this.CreateSerializer();
            var models     = this.TakeComponentModels(packageModel);

            exportedCount = 0;
            foreach (var model in models)
            {
                // Получаем путь к компоненте.
                var componentFolder = Path.Combine(this.ComponentsFolder, Utils.EscapeFilePath(model.KeyValue));
                if (!Directory.Exists(componentFolder))
                {
                    Directory.CreateDirectory(componentFolder);
                }

                // Выполнить обработку модели.
                this.HandleExportModel(componentFolder, model, settings, namespaces, serializer);
                exportedCount++;
            }
        }
        /// <summary>
        /// Обработать импорт моделей (внутренний метод).
        /// </summary>
        /// <param name="packageModel">Модель пакета разработки.</param>
        /// <param name="importFilter">Фильтр импорта.</param>
        /// <param name="importedCount">Количество импортированных элементов.</param>
        protected virtual void InternalHandleImport(ComponentsModel packageModel, ImportFilter importFilter, out int importedCount)
        {
            importedCount = 0;
            var serializer = this.CreateSerializer();
            var models     = this.GetComponentModelList(packageModel);

            if (!Directory.Exists(this.ComponentsFolder))
            {
                return;
            }

            foreach (var componentFolder in Directory.EnumerateDirectories(this.ComponentsFolder))
            {
                if (importFilter.NeedImport(componentFolder, this.DevelopmentPath))
                {
                    models.Add(this.HandleImportModel(componentFolder, serializer));
                    importedCount++;
                }
            }
        }
Example #27
0
        public IEnumerable <LocalizationString> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.LocalizationStrings)
            {
                var entity = PackageHandlerUtils.CreateEntity <LocalizationString>(model);

                if (model.DetailDataSets?.DetailDataSet1 != null)
                {
                    var stringModels = model.DetailDataSets.DetailDataSet1.Rows;
                    foreach (var stringModel in stringModels)
                    {
                        var localizationValue = new LocalizationValue();

                        var groupReq = stringModel.Requisites
                                       .FirstOrDefault(r => r.Code == GroupReqName);
                        if (groupReq != null)
                        {
                            entity.Group = groupReq.DecodedText;
                        }

                        var languageReq = stringModel.Requisites
                                          .FirstOrDefault(r => r.Code == LanguageReqName);
                        if (languageReq != null)
                        {
                            localizationValue.Language = languageReq.DecodedText;
                        }

                        var valueReq = stringModel.Requisites
                                       .FirstOrDefault(r => r.Code == ValueReqName);
                        if (valueReq != null)
                        {
                            localizationValue.Value = valueReq.DecodedText;
                        }

                        entity.Values.Add(localizationValue);
                    }
                }

                yield return(entity);
            }
        }
        public IEnumerable <Viewer> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.Viewers)
            {
                var entity = PackageHandlerUtils.CreateEntity <Viewer>(model);

                var extensionReq = model.Card.Requisites
                                   .FirstOrDefault(r => r.Code == ExtensionReqName);
                if (extensionReq != null)
                {
                    entity.Extension = extensionReq.DecodedText;
                }

                var viewerTypeReqName = model.Card.Requisites
                                        .FirstOrDefault(r => r.Code == ViewerTypeReqName);
                if (viewerTypeReqName != null)
                {
                    switch (viewerTypeReqName.ValueLocalizeID)
                    {
                    case CrystalReports:
                        entity.ViewerType = ViewerType.CrystalReports;
                        break;

                    case MicrosoftExcel:
                        entity.ViewerType = ViewerType.Excel;
                        break;

                    case MicrosoftWord:
                        entity.ViewerType = ViewerType.Word;
                        break;

                    case Internal:
                        entity.ViewerType = ViewerType.Internal;
                        break;
                    }
                }

                yield return(entity);
            }
        }
Example #29
0
        public IEnumerable <Dialog> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.Dialogs)
            {
                var entity = PackageHandlerUtils.CreateEntity <Dialog>(model);

                var cardFormReq = model.Card.Requisites
                                  .FirstOrDefault(r => r.Code == ViewCardFormReqName);
                if (cardFormReq != null)
                {
                    entity.CardForm = cardFormReq.DecodedText;
                }

                ReadMethods(model, entity);
                ReadMethodsParameters(model, entity);
                ReadActions(model, entity);
                ReadEvents(model, entity);
                ReadCardRequisites(model, entity);

                yield return(entity);
            }
        }
Example #30
0
        public IEnumerable <RouteBlock> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.RouteBlocks)
            {
                var entity = PackageHandlerUtils.CreateEntity <RouteBlock>(model);

                var stateReq = model.Card.Requisites
                               .FirstOrDefault(r => r.Code == StateReqName);
                if (stateReq != null)
                {
                    entity.State = stateReq.ValueLocalizeID == Active ? ComponentState.Active : ComponentState.Closed;
                }

                var baseBlockTypeReq = model.Card.Requisites
                                       .FirstOrDefault(r => r.Code == BaseBlockTypeReqName);
                if (baseBlockTypeReq != null)
                {
                    entity.BaseBlockType = RouteBlockUtils.GetBaseBlockType(baseBlockTypeReq.ValueLocalizeID);
                }
                else
                {
                    entity.BaseBlockType = RouteBlockType.Unknown;
                }

                var blockPropertiesReq = model.Card.Requisites
                                         .FirstOrDefault(r => r.Code == BlockPropertiesReqName);
                if (blockPropertiesReq != null)
                {
                    var blockProperties = blockPropertiesReq.DecodedText;
                    if (!string.IsNullOrWhiteSpace(blockProperties))
                    {
                        var description = WorkflowDescriptionParser.Parse(blockProperties);
                        entity.WorkflowBlock = description.Blocks.FirstOrDefault();
                    }
                }

                yield return(entity);
            }
        }
Example #31
0
 public void Init()
 {
     _storageMock = new Mock<IStorage<Component>>();
     _model = new ComponentsModel(_storageMock.Object);
 }