Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
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);
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
        /// <summary>
        /// Прочитать отчет из модели.
        /// </summary>
        /// <typeparam name="T">Тип отчета.</typeparam>
        /// <param name="model">Модель.</param>
        /// <returns>Отчет.</returns>
        protected T Read <T>(ComponentModel model) where T : Report
        {
            var entity = PackageHandlerUtils.CreateEntity <T>(model);

            var viewerReq = model.Card.Requisites
                            .FirstOrDefault(r => r.Code == ViewerReqName);

            if (viewerReq != null)
            {
                entity.Viewer = viewerReq.DecodedText;
            }

            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;
            }

            var templateTextReq = model.Card.Requisites
                                  .FirstOrDefault(r => r.Code == TemplateTextReqName);

            if (templateTextReq != null)
            {
                entity.TemplateText = templateTextReq.DecodedText;
            }

            return(entity);
        }
Пример #8
0
        public IEnumerable <Constant> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.Constants)
            {
                var entity = PackageHandlerUtils.CreateEntity <Constant>(model);

                var isReplicatedReq = model.Card.Requisites
                                      .FirstOrDefault(r => r.Code == IsReplicatedReqName);
                if (isReplicatedReq != null)
                {
                    entity.IsReplicated = isReplicatedReq.ValueLocalizeID == Replicate;
                }

                var isCommonReq = model.Card.Requisites
                                  .FirstOrDefault(r => r.Code == IsCommonReqName);
                if (isCommonReq != null)
                {
                    entity.IsCommon = isCommonReq.ValueLocalizeID == Common;
                }

                yield return(entity);
            }
        }
Пример #9
0
        public IEnumerable <DocumentRequisite> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.DocumentRequisites)
            {
                var entity = PackageHandlerUtils.CreateEntity <DocumentRequisite>(model);

                var fieldReq = model.Card.Requisites
                               .FirstOrDefault(r => r.Code == FieldReqName);
                if (fieldReq != null)
                {
                    entity.Field = fieldReq.DecodedText;
                }

                var sectionReq = model.Card.Requisites
                                 .FirstOrDefault(r => r.Code == SectionReqName);
                if (sectionReq != null)
                {
                    entity.Section = RequisiteHandlerUtils.GetRequisiteSection(sectionReq.ValueLocalizeID);
                }

                var typeReq = model.Card.Requisites
                              .FirstOrDefault(r => r.Code == TypeReqName);
                if (typeReq != null)
                {
                    entity.Type = RequisiteHandlerUtils.GetRequisiteType(typeReq.ValueLocalizeID);
                }

                var formatReq = model.Card.Requisites
                                .FirstOrDefault(r => r.Code == FormatReqName);
                if (formatReq != null)
                {
                    entity.Format = RequisiteHandlerUtils.GetRequisiteFormat(formatReq.ValueLocalizeID);
                }

                var lengthReq = model.Card.Requisites
                                .FirstOrDefault(r => r.Code == LengthReqName);
                if (!string.IsNullOrEmpty(lengthReq?.Value))
                {
                    entity.Length = int.Parse(lengthReq.Value);
                }

                var precissionReq = model.Card.Requisites
                                    .FirstOrDefault(r => r.Code == PrecissionReqName);
                if (!string.IsNullOrEmpty(precissionReq?.Value))
                {
                    entity.Precission = int.Parse(precissionReq.Value);
                }

                var referenceTypeReq = model.Card.Requisites
                                       .FirstOrDefault(r => r.Code == ReferenceTypeReqName);
                if (referenceTypeReq != null)
                {
                    entity.ReferenceType = referenceTypeReq.Value;
                }

                var referenceViewReq = model.Card.Requisites
                                       .FirstOrDefault(r => r.Code == ReferenceViewReqName);
                if (referenceViewReq != null)
                {
                    entity.ReferenceView = referenceViewReq.Value;
                }

                var pickValuesReq = model.Card.Requisites
                                    .FirstOrDefault(r => r.Code == PickValuesReqName);
                if (!string.IsNullOrEmpty(pickValuesReq?.DecodedText))
                {
                    var pickValues = pickValuesReq.DecodedText.Split(';');
                    foreach (var pickValue in pickValues)
                    {
                        var pickValueParts = pickValue.Split('=', '|');
                        var reqPickValue   = new RequisitePickValue
                        {
                            Id    = pickValueParts[0][0],
                            Value = pickValueParts[1]
                        };
                        entity.PickValues.Add(reqPickValue);
                    }
                }

                var isStoredReq = model.Card.Requisites
                                  .FirstOrDefault(r => r.Code == IsStoredReqName);
                if (isStoredReq != null)
                {
                    entity.IsStored = isStoredReq.ValueLocalizeID == Stored;
                }

                var isGeneratedReq = model.Card.Requisites
                                     .FirstOrDefault(r => r.Code == IsGeneratedReqName);
                if (isGeneratedReq != null)
                {
                    entity.IsGenerated = isGeneratedReq.ValueLocalizeID == Generated;
                }

                yield return(entity);
            }
        }
Пример #10
0
        public IEnumerable <Function> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.Functions)
            {
                var entity = PackageHandlerUtils.CreateEntity <Function>(model);

                var functionCategoryReq = model.Card.Requisites
                                          .FirstOrDefault(r => r.Code == FunctionCategoryReqName);
                if (functionCategoryReq != null)
                {
                    entity.IsSystem = functionCategoryReq.ValueLocalizeID == SystemCategory;
                }

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

                var functionHelpTextReq = model.Card.Requisites
                                          .FirstOrDefault(r => r.Code == FunctionHelpTextReqName);
                if (functionHelpTextReq != null)
                {
                    entity.Help = functionHelpTextReq.DecodedText;
                }

                var functionCommentReq = model.Card.Requisites
                                         .FirstOrDefault(r => r.Code == FunctionCommentReqName);
                if (functionCommentReq != null)
                {
                    entity.Comment = functionCommentReq.DecodedText;
                }

                if (model.DetailDataSets?.DetailDataSet1 != null)
                {
                    var argModels = model.DetailDataSets.DetailDataSet1.Rows;
                    foreach (var argModel in argModels)
                    {
                        var argument = new FunctionArgument();

                        var argumentNumberReq = argModel.Requisites
                                                .FirstOrDefault(r => r.Code == ArgumentNumberReqName);
                        if (argumentNumberReq != null)
                        {
                            argument.Number = int.Parse(argumentNumberReq.Value);
                        }

                        var argumentNameReq = argModel.Requisites
                                              .FirstOrDefault(r => r.Code == ArgumentNameReqName);
                        if (argumentNameReq != null)
                        {
                            argument.Name = argumentNameReq.DecodedText;
                        }

                        var argumentTypeReq = argModel.Requisites
                                              .FirstOrDefault(r => r.Code == ArgumentTypeReqName);
                        if (argumentTypeReq != null)
                        {
                            switch (argumentTypeReq.ValueLocalizeID)
                            {
                            case VariantArgumentType:
                                argument.Type = FunctionArgumentType.Variant;
                                break;

                            case DateArgumentType:
                                argument.Type = FunctionArgumentType.Date;
                                break;

                            case FloatArgumentType:
                                argument.Type = FunctionArgumentType.Float;
                                break;

                            case BooleanArgumentType:
                                argument.Type = FunctionArgumentType.Boolean;
                                break;

                            case StringArgumentType:
                                argument.Type = FunctionArgumentType.String;
                                break;

                            case IntegerArgumentType:
                                argument.Type = FunctionArgumentType.Integer;
                                break;
                            }
                        }

                        var argumentDefaultValueReq = argModel.Requisites
                                                      .FirstOrDefault(r => r.Code == ArgumentDefaultValueReqName);
                        if (argumentDefaultValueReq != null)
                        {
                            argument.DefaultValue = argumentDefaultValueReq.DecodedText;
                        }
                        if (!string.IsNullOrEmpty(argument.DefaultValue))
                        {
                            argument.HasDefaultValue = true;
                        }

                        entity.Arguments.Add(argument);
                    }
                }

                yield return(entity);
            }
        }
Пример #11
0
        public IEnumerable <ReferenceType> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.ReferenceTypes)
            {
                var entity = PackageHandlerUtils.CreateEntity <ReferenceType>(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;
                    }
                }

                var displayRequisiteReqName = model.Card.Requisites
                                              .FirstOrDefault(r => r.Code == DisplayRequisiteReqName);
                if (displayRequisiteReqName != null)
                {
                    switch (displayRequisiteReqName.ValueLocalizeID)
                    {
                    case RecordName:
                        entity.DisplayRequisite = DisplayRequisite.Name;
                        break;

                    default:
                        entity.DisplayRequisite = DisplayRequisite.Code;
                        break;
                    }
                }

                var leadingReferenceReq = model.Card.Requisites
                                          .FirstOrDefault(r => r.Code == LeadingReferenceReqName);
                if (leadingReferenceReq != null)
                {
                    entity.LeadingReference = leadingReferenceReq.DecodedText;
                }

                var hasLongRecordNamesReq = model.Card.Requisites
                                            .FirstOrDefault(r => r.Code == HasLongRecordNamesReqName);
                if (hasLongRecordNamesReq != null)
                {
                    entity.HasLongRecordNames = hasLongRecordNamesReq.ValueLocalizeID == YesValue;
                }

                var hasUniqueRecordNamesReq = model.Card.Requisites
                                              .FirstOrDefault(r => r.Code == HasUniqueRecordNames);
                if (hasUniqueRecordNamesReq != null)
                {
                    entity.HasUniqueRecordNames = hasUniqueRecordNamesReq.ValueLocalizeID == YesValue;
                }

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

                yield return(entity);
            }
        }