Exemplo n.º 1
0
        private void ProcessCrmTerms(PropertyListType lst)
        {
            var termsType = _ctx.ValueTypes.First(x => x.Name == lst.Type);

            foreach (var source in lst.Items)
            {
                var target = _ctx.Values.FirstOrDefault(t => t.ListPropertyId == source.Guid);
                if (target == null)
                {
                    target = new ListProperty
                    {
                        ListPropertyId = source.Guid,
                        Value          = source.Value,
                        IsFromCrm      = true
                    };
                    _ctx.Values.Add(target);
                }
                else
                {
                    target.Value = source.Value;
                }
                target.Types.Add(termsType);

                UpdateUrlsFromService(target, source);
            }
        }
Exemplo n.º 2
0
        private static void ProcessTags(DocumentsContext ctx, Document masterDoc, ObjectVersionWrapper sourceDoc)
        {
            masterDoc.Tags.Clear();
            var propertyType = ctx.ValueTypes.First(x => x.Name == ListPropertyTypesNames.Tag);

            foreach (var source in sourceDoc.Tags)
            {
                var values = (source.IsStringProperty
                    ? source.Value.Split(',').Select(x => x.Trim().ToLower()).Where(x => !String.IsNullOrEmpty(x)).ToArray()
                    : new[] { source.Value.ToLower() });
                foreach (var value in values)
                {
                    var target = ctx.Values.FirstOrDefault(t => t.Value == value);
                    if (target == null)
                    {
                        var listPropertyId = Guid.NewGuid();
                        if (!source.IsStringProperty && source.Guid.HasValue)
                        {
                            listPropertyId = source.Guid.Value;
                        }
                        target = new Documents.ListProperty
                        {
                            ListPropertyId = listPropertyId,
                            Value          = value.Trim()
                        };
                        ctx.Values.Add(target);
                    }
                    target.Types.Add(propertyType);
                    masterDoc.Tags.Add(target);
                }
            }
        }
Exemplo n.º 3
0
        private void UpdateUrlsFromService(ListProperty target, PropertyListItem source)
        {
            var   serviceTerms = _parent.Conferences.Terms;
            Terms termsInService;

            serviceTerms.TryGetValue(source.Guid, out termsInService);

            if (termsInService == null)
            {
                ClassLogger.Warn(
                    $"Not found {source.Guid} ({source.Value}) in the service {_parent.Conferences.ServiceUri}");
            }

            var urlBrs = termsInService != null
                ? _parent.BrsTermsUrlPattern.Replace("{term}", TermToUri(termsInService.name))
                : null;

            target.Url = urlBrs;
            target.LeoTerms.Clear();

            if (!string.IsNullOrEmpty(termsInService?.informeaTerm))
            {
                var leoTerms = termsInService.informeaTerm.Split(',');
                foreach (var lterm in leoTerms)
                {
                    var leoName = lterm.Trim();
                    var leoUrl  = _parent.LeoTermsUrlPattern.Replace("{term}", TermToUri(leoName));

                    Uri leoTryUrl;
                    if (Uri.TryCreate(leoName, UriKind.Absolute, out leoTryUrl))
                    {
                        leoUrl  = leoTryUrl.AbsoluteUri;
                        leoName = leoUrl.Split('/').Last().Replace("-", " ");
                    }

                    var leoTerm = _ctx.LeoTerms.FirstOrDefault(t => t.Name == leoName);
                    if (leoTerm == null)
                    {
                        leoTerm = new LeoTerm {
                            LeoTermId = Guid.NewGuid(), Name = leoName, Url = leoUrl
                        };
                        _ctx.LeoTerms.Add(leoTerm);
                    }
                    target.LeoTerms.Add(leoTerm);
                }
            }
        }
Exemplo n.º 4
0
        private static void ProcessMeetingTypes(DocumentsContext ctx, Document masterDoc, ObjectVersionWrapper sourceDoc)
        {
            masterDoc.MeetingsTypes.Clear();
            var propertyType = ctx.ValueTypes.First(x => x.Name == ListPropertyTypesNames.MeetingType);

            foreach (var source in sourceDoc.MeetingsTypes)
            {
                var target = ctx.Values.FirstOrDefault(t => t.Value == source.Value);
                if (target == null)
                {
                    target = new Documents.ListProperty
                    {
                        ListPropertyId = source.Guid ?? Guid.NewGuid(),
                        Value          = source.Value
                    };
                    ctx.Values.Add(target);
                }
                target.Types.Add(propertyType);
                masterDoc.MeetingsTypes.Add(target);
            }
        }
Exemplo n.º 5
0
        private void ProcessCrmMeetings(PropertyListType lst)
        {
            var meetingsType = _ctx.ValueTypes.FirstOrDefault(x => x.Name == lst.Type);

            var serviceMeetings = _parent.Conferences.Meetings;

            foreach (var source in lst.Items)
            {
                Meetings meetingInService;
                serviceMeetings.TryGetValue(source.Guid, out meetingInService);
                if (meetingInService == null)
                {
                    ClassLogger.Warn(
                        $"Not found {source.Guid} ({source.Value}) in the service {_parent.Conferences.ServiceUri}");
                }

                var url    = meetingInService != null? $"{_parent.Conferences.ServiceUri}/Meetings(guid'{source.Guid}')":null;
                var target = _ctx.Values.FirstOrDefault(t => t.ListPropertyId == source.Guid);
                if (target == null)
                {
                    target = new ListProperty
                    {
                        ListPropertyId = source.Guid,
                        Value          = source.Value,
                        Url            = url,
                        IsFromCrm      = true
                    };
                    _ctx.Values.Add(target);
                }
                else
                {
                    target.Value = source.Value;
                    target.Url   = url;
                }

                target.Types.Add(meetingsType);
            }
        }
Exemplo n.º 6
0
        private void ProcessList(PropertyListType lst)
        {
            var listType = _ctx.ValueTypes.First(x => x.Name == lst.Type);

            foreach (var source in lst.Items)
            {
                var target = _ctx.Values.OfType <ListProperty>().FirstOrDefault(t => t.ListPropertyId == source.Guid);
                if (target == null)
                {
                    target = new ListProperty
                    {
                        ListPropertyId = source.Guid,
                        Value          = source.Value,
                        IsFromCrm      = true
                    };
                    _ctx.Values.Add(target);
                }
                else
                {
                    target.Value = source.Value;
                }
                target.Types.Add(listType);
            }
        }