Exemple #1
0
        protected override Clue MakeClueImpl(StreamingChannel value, Guid id)
        {
            var clue = _factory.Create(EntityType.Channel, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name = value.Name;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");

            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Solution.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Solution.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Solution.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(Product value, Guid id)
        {
            var clue = _factory.Create(EntityType.Product, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Product.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.CanUseQuantitySchedule != null)
            {
                data.Properties[SalesforceVocabulary.Product.CanUseQuantitySchedule] = value.CanUseQuantitySchedule;
            }
            if (value.CanUseRevenueSchedule != null)
            {
                data.Properties[SalesforceVocabulary.Product.CanUseRevenueSchedule] = value.CanUseRevenueSchedule;
            }
            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Product.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Product.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.CurrencyIsoCode != null)
            {
                data.Properties[SalesforceVocabulary.Product.CurrencyIsoCode] = value.CurrencyIsoCode;
            }
            if (value.DefaultPrice != null)
            {
                data.Properties[SalesforceVocabulary.Product.DefaultPrice] = value.DefaultPrice;
            }
            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.Family != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Family);
                data.Properties[SalesforceVocabulary.Product.Family] = value.Family;
            }

            if (value.IsActive != null)
            {
                data.Properties[SalesforceVocabulary.Product.IsActive] = value.IsActive;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Product.IsDeleted] = value.IsDeleted;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Product.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Product.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.NumberOfQuantityInstallments != null)
            {
                data.Properties[SalesforceVocabulary.Product.NumberOfQuantityInstallments] = value.NumberOfQuantityInstallments;
            }
            if (value.NumberOfRevenueInstallments != null)
            {
                data.Properties[SalesforceVocabulary.Product.NumberOfRevenueInstallments] = value.NumberOfRevenueInstallments;
            }
            if (value.ProductCode != null)
            {
                data.Properties[SalesforceVocabulary.Product.ProductCode] = value.ProductCode;
                data.Aliases.Add(value.ProductCode);
                data.Codes.Add(new EntityCode(EntityType.Product, SalesforceConstants.CodeOrigin, value.ProductCode));
            }
            if (value.QuantityInstallmentPeriod != null)
            {
                data.Properties[SalesforceVocabulary.Product.QuantityInstallmentPeriod] = value.QuantityInstallmentPeriod;
            }
            if (value.QuantityScheduleType != null)
            {
                data.Properties[SalesforceVocabulary.Product.QuantityScheduleType] = value.QuantityScheduleType;
            }
            if (value.RecalculateTotalPrice != null)
            {
                data.Properties[SalesforceVocabulary.Product.RecalculateTotalPrice] = value.RecalculateTotalPrice;
            }
            if (value.RevenueInstallmentPeriod != null)
            {
                data.Properties[SalesforceVocabulary.Product.RevenueInstallmentPeriod] = value.RevenueInstallmentPeriod;
            }
            if (value.RevenueScheduleType != null)
            {
                data.Properties[SalesforceVocabulary.Product.RevenueScheduleType] = value.RevenueScheduleType;
            }

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Product.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(Contract value, Guid id)
        {
            var clue = _factory.Create(EntityType.Sales.Contract, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.ContractTerm != null)
            {
                data.Name        = value.ContractTerm;
                data.DisplayName = value.ContractTerm;
                data.Aliases.Add(value.ContractTerm);
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }
            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            if (value.ActivatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOn, value, value.ActivatedById);
            }

            if (value.ActivatedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ActivatedDate] = DateUtilities.GetFormattedDateString(value.ActivatedDate);
            }
            if (value.BillingAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingAddress] = value.BillingAddress;
            }
            if (value.BillingCity != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingCity] = value.BillingCity;
            }
            if (value.BillingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingCountry] = value.BillingCountry;
            }
            if (value.BillingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingCountryCode] = value.BillingCountryCode;
            }
            if (value.BillingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingLatitude] = value.BillingLatitude;
            }
            if (value.BillingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingLongitude] = value.BillingLongitude;
            }
            if (value.BillingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingPostalCode] = value.BillingPostalCode;
            }
            if (value.BillingState != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingState] = value.BillingState;
            }
            if (value.BillingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingStateCode] = value.BillingStateCode;
            }
            if (value.BillingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contract.BillingStreet] = value.BillingStreet;
            }
            if (value.CompanySignedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.CompanySignedDate] = DateUtilities.GetFormattedDateString(value.CompanySignedDate);
            }
            if (value.CompanySignedId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.CompanySignedId);
            }

            if (value.ContractNumber != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ContractNumber] = value.ContractNumber;
                data.Codes.Add(new EntityCode(EntityType.Sales.Contract, SalesforceConstants.CodeOrigin, value.ContractNumber));
            }

            if (value.ContractTerm != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ContractTerm] = value.ContractTerm;
            }
            if (value.CustomerSignedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.CustomerSignedDate] = DateUtilities.GetFormattedDateString(value.CustomerSignedDate);
            }
            if (value.CustomerSignedId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For, value, value.CustomerSignedId);
            }

            if (value.CustomerSignedTitle != null)
            {
                data.Properties[SalesforceVocabulary.Contract.CustomerSignedTitle] = value.CustomerSignedTitle;
            }
            if (value.EndDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.EndDate] = DateUtilities.GetFormattedDateString(value.EndDate);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Contract.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Contract.IsDeleted] = value.IsDeleted;
            }
            if (value.LastApprovedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.LastApprovedDate] = DateUtilities.GetFormattedDateString(value.LastApprovedDate);
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Contract.RecordTypeId] = value.RecordTypeId;
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Contract.SystemModstamp] = value.SystemModstamp;
            }
            if (value.OwnerExpirationNotice != null)
            {
                data.Properties[SalesforceVocabulary.Contract.OwnerExpirationNotice] = value.OwnerExpirationNotice;
            }
            if (value.Pricebook2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.Pricebook2Id);
                data.Properties[SalesforceVocabulary.Contract.Pricebook2Id] = value.Pricebook2Id;
            }

            if (value.ShippingAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingAddress] = value.ShippingAddress;
            }
            if (value.ShippingCity != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingCity] = value.ShippingCity;
            }
            if (value.ShippingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingCountry] = value.ShippingCountry;
            }
            if (value.ShippingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingCountryCode] = value.ShippingCountryCode;
            }
            if (value.ShippingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingLatitude] = value.ShippingLatitude;
            }
            if (value.ShippingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingLongitude] = value.ShippingLongitude;
            }
            if (value.ShippingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingPostalCode] = value.ShippingPostalCode;
            }
            if (value.ShippingState != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingState] = value.ShippingState;
            }
            if (value.ShippingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingStateCode] = value.ShippingStateCode;
            }
            if (value.ShippingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contract.ShippingStreet] = value.ShippingStreet;
            }
            if (value.SpecialTerms != null)
            {
                data.Properties[SalesforceVocabulary.Contract.SpecialTerms] = value.SpecialTerms;
            }
            if (value.StartDate != null)
            {
                data.Properties[SalesforceVocabulary.Contract.StartDate] = DateUtilities.GetFormattedDateString(value.StartDate);
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Contract.Status] = value.Status;
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Status);
                data.Tags.Add(new Tag(value.Status));
            }

            if (value.StatusCode != null)
            {
                data.Properties[SalesforceVocabulary.Contract.StatusCode] = value.StatusCode;
            }
            if (value.Type != null)
            {
                data.Properties[SalesforceVocabulary.Contract.Type] = value.Type;
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
                data.Tags.Add(new Tag(value.Type));
            }

            if (value.TotalAmount != null)
            {
                data.Properties[SalesforceVocabulary.Contract.TotalAmount] = value.TotalAmount;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Contract.RecordTypeId] = value.RecordTypeId;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(SalesForceTask value, Guid id)
        {
            var clue = _factory.Create(EntityType.Task, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Subject != null)
            {
                data.Name        = value.Subject;
                data.DisplayName = value.Subject;
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.AccountId);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Task.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.ActivityDate != null)
            {
                data.Properties[SalesforceVocabulary.Task.ActivityDate] = DateUtilities.GetFormattedDateString(value.ActivityDate);
            }
            if (value.CallDisposition != null)
            {
                data.Properties[SalesforceVocabulary.Task.CallDisposition] = value.CallDisposition;
            }
            if (value.CallDurationInSeconds != null)
            {
                data.Properties[SalesforceVocabulary.Task.CallDurationInSeconds] = value.CallDurationInSeconds;
            }
            if (value.CallObject != null)
            {
                data.Properties[SalesforceVocabulary.Task.CallObject] = value.CallObject;
            }
            if (value.CallType != null)
            {
                data.Properties[SalesforceVocabulary.Task.CallType] = value.CallType;
            }
            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Task.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Task.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.IsArchived != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsArchived] = value.IsArchived;
            }
            if (value.IsClosed != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsClosed] = value.IsClosed;
            }
            if (value.IsHighPriority != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsHighPriority] = value.IsHighPriority;
            }
            if (value.IsRecurrence != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsRecurrence] = value.IsRecurrence;
            }
            if (value.IsReminderSet != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsReminderSet] = value.IsReminderSet;
            }
            if (value.IsVisibleInSelfService != null)
            {
                data.Properties[SalesforceVocabulary.Task.IsVisibleInSelfService] = value.IsVisibleInSelfService;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);

                data.Properties[SalesforceVocabulary.Task.OwnerName] = value.OwnerId;
            }

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);

                data.Properties[SalesforceVocabulary.Task.CreatedByName] = value.CreatedById;
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Task.SystemModstamp] = value.SystemModstamp;
            }
            if (value.Priority != null)
            {
                data.Properties[SalesforceVocabulary.Task.Priority] = value.Priority;
            }
            if (value.RecurrenceActivityId != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceActivityId] = value.RecurrenceActivityId;
            }
            if (value.RecurrenceDayOfMonth != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceDayOfMonth] = value.RecurrenceDayOfMonth;
            }
            if (value.RecurrenceDayOfWeekMask != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceDayOfWeekMask] = value.RecurrenceDayOfWeekMask;
            }
            if (value.RecurrenceEndDateOnly != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceEndDateOnly] = value.RecurrenceEndDateOnly;
            }
            if (value.RecurrenceInstance != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceInstance] = value.RecurrenceInstance;
            }
            if (value.RecurrenceInterval != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceInterval] = value.RecurrenceInterval;
            }
            if (value.RecurrenceMonthOfYear != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceMonthOfYear] = value.RecurrenceMonthOfYear;
            }
            if (value.RecurrenceRegeneratedType != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceRegeneratedType] = value.RecurrenceRegeneratedType;
            }
            if (value.RecurrenceStartDateOnly != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceStartDateOnly] = value.RecurrenceStartDateOnly;
            }
            if (value.RecurrenceTimeZoneSidKey != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceTimeZoneSidKey] = value.RecurrenceTimeZoneSidKey;
            }
            if (value.RecurrenceType != null)
            {
                data.Properties[SalesforceVocabulary.Task.RecurrenceType] = value.RecurrenceType;
            }
            if (value.ReminderDateTime != null)
            {
                data.Properties[SalesforceVocabulary.Task.ReminderDateTime] = DateUtilities.GetFormattedDateString(value.ReminderDateTime);
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Task.Status] = value.Status;
            }
            if (value.TaskSubtype != null)
            {
                data.Properties[SalesforceVocabulary.Task.TaskSubtype] = value.TaskSubtype;
            }
            if (value.TaskWhoIds != null)
            {
                data.Properties[SalesforceVocabulary.Task.TaskWhoIds] = value.TaskWhoIds;
            }
            if (value.Type != null)
            {
                data.Properties[SalesforceVocabulary.Task.Type] = value.Type;
            }
            if (value.WhatCount != null)
            {
                data.Properties[SalesforceVocabulary.Task.WhatCount] = value.WhatCount;
            }
            if (value.WhatId != null)
            {
                data.Properties[SalesforceVocabulary.Task.WhatId] = value.WhatId;
            }
            if (value.WhoCount != null)
            {
                data.Properties[SalesforceVocabulary.Task.WhoCount] = value.WhoCount;
            }
            if (value.WhoId != null)
            {
                data.Properties[SalesforceVocabulary.Task.WhoId] = value.WhoId;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #5
0
        protected override Clue MakeClueImpl(ContentDocument value, Guid id)
        {
            var clue = _factory.Create(EntityType.Files.File, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Title != null)
            {
                data.Name        = value.Title;
                data.DisplayName = value.Title;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Document.SystemModstamp] = value.SystemModstamp;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Document.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Document.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Document.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }


            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(Opportunity value, Guid id)
        {
            var clue = _factory.Create(EntityType.Sales.Opportunity, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Opportunity.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.AccountId);
            }

            if (value.Amount != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.Amount] = value.Amount;
            }
            if (value.CampaignId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Marketing.Campaign, EntityEdgeType.For, value, value.CampaignId);
            }

            if (value.CloseDate != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.CloseDate] = DateUtilities.GetFormattedDateString(value.CloseDate);
            }
            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.ContractId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Contract, EntityEdgeType.For, value, value.ContractId);
            }

            if (value.CurrencyIsoCode != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.CurrencyIsoCode] = value.CurrencyIsoCode;
            }
            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.ExpectedRevenue != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.ExpectedRevenue] = value.ExpectedRevenue;
            }
            if (value.Fiscal != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.Fiscal] = value.Fiscal;
            }
            if (value.FiscalQuarter != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.FiscalQuarter] = value.FiscalQuarter;
            }
            if (value.FiscalYear != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.FiscalYear] = value.FiscalYear;
            }
            if (value.ForecastCategory != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.ForecastCategory] = value.ForecastCategory;
                data.Tags.Add(new Tag(value.ForecastCategory));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.ForecastCategory);
            }
            if (value.ForecastCategoryName != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.ForecastCategoryName] = value.ForecastCategoryName;
                data.Tags.Add(new Tag(value.ForecastCategoryName));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.ForecastCategoryName);
            }

            if (value.HasOpenActivity != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.HasOpenActivity] = value.HasOpenActivity;
            }
            if (value.HasOpportunityLineItem != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.HasOpportunityLineItem] = value.HasOpportunityLineItem;
            }
            if (value.HasOverdueTask != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.HasOverdueTask] = value.HasOverdueTask;
            }
            if (value.IsClosed != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.IsClosed] = value.IsClosed;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.IsDeleted] = value.IsDeleted;
            }
            if (value.IsExcludedFromTerritory2Filter != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.IsExcludedFromTerritory2Filter] = value.IsExcludedFromTerritory2Filter;
            }
            if (value.IsSplit != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.IsSplit] = value.IsSplit;
            }
            if (value.IsWon != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.IsWon] = value.IsWon;
            }
            if (value.LastActivityDate != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.LastActivityDate] = DateUtilities.GetFormattedDateString(value.LastActivityDate);
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.LeadSource != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.LeadSource] = value.LeadSource;
                data.Tags.Add(new Tag(value.LeadSource));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.LeadSource);
            }

            if (value.NextStep != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.NextStep] = value.NextStep;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.Pricebook2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.Pricebook2Id);
            }
            if (value.PricebookId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.PricebookId);
            }
            if (value.Probability != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.Probability] = value.Probability;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.RecordTypeId] = value.RecordTypeId;
            }
            if (value.SpecialTerms != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.SpecialTerms] = value.SpecialTerms;
            }
            if (value.StageName != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.StageName] = value.StageName;
                data.Tags.Add(new Tag(value.StageName));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.StageName);
            }
            if (value.StartDate != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.StartDate] = DateUtilities.GetFormattedDateString(value.StartDate);
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.Status] = value.Status;
                data.Tags.Add(new Tag(value.Status));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Status);
            }

            if (value.StatusCode != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.StatusCode] = value.StatusCode;
            }
            if (value.SyncedQuoteID != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.SyncedQuoteID] = value.SyncedQuoteID;
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.SyncedQuoteID);
            }
            if (value.Territory2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Infrastructure.Location, EntityEdgeType.For, value, value.Territory2Id);
            }
            if (value.TotalAmount != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.TotalAmount] = value.TotalAmount;
            }
            if (value.TotalOpportunityQuantity != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.TotalOpportunityQuantity] = value.TotalOpportunityQuantity;
            }
            if (value.Type != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.Type] = value.Type;
                data.Tags.Add(new Tag(value.Type));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Opportunity.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(Event value, Guid id)
        {
            var clue = _factory.Create(EntityType.Calendar.Event, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Subject != null)
            {
                data.Name        = value.Subject;
                data.DisplayName = value.Subject;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.AcceptedEventInviteeIds != null)
            {
                var acceptedEventIds = value.AcceptedEventInviteeIds.Split(',');
                foreach (var acceptedId in acceptedEventIds)
                {
                    _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.InvitedTo, value, acceptedId);
                }

                data.Properties[SalesforceVocabulary.Event.AcceptedEventInviteeIds] = value.AcceptedEventInviteeIds;
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            if (value.ActivityDate != null)
            {
                data.Properties[SalesforceVocabulary.Event.ActivityDate] = DateUtilities.GetFormattedDateString(value.ActivityDate);
            }

            if (value.ActivityDateTime != null)
            {
                data.Properties[SalesforceVocabulary.Event.ActivityDateTime] = DateUtilities.GetFormattedDateString(value.ActivityDateTime);
            }
            if (value.ClientGuid != null)
            {
                data.Properties[SalesforceVocabulary.Event.ClientGuid] = value.ClientGuid;
            }
            if (value.CurrencyIsoCode != null)
            {
                data.Properties[SalesforceVocabulary.Event.CurrencyIsoCode] = value.CurrencyIsoCode;
            }
            if (value.DeclinedEventInviteeIds != null)
            {
                data.Properties[SalesforceVocabulary.Event.DeclinedEventInviteeIds] = value.DeclinedEventInviteeIds;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Event.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.Division != null)
            {
                data.Properties[SalesforceVocabulary.Event.Division] = value.Division;
            }
            if (value.DurationInMinutes != null)
            {
                data.Properties[SalesforceVocabulary.Event.DurationInMinutes] = value.DurationInMinutes;
            }
            if (value.EndDateTime != null)
            {
                data.Properties[SalesforceVocabulary.Event.EndDateTime] = DateUtilities.GetFormattedDateString(value.EndDateTime);
            }

            data.Properties[SalesforceVocabulary.Event.EventSubtype]             = value.EventSubtype;
            data.Properties[SalesforceVocabulary.Event.EventWhoIds]              = value.EventWhoIds;
            data.Properties[SalesforceVocabulary.Event.GroupEventType]           = value.GroupEventType;
            data.Properties[SalesforceVocabulary.Event.IsAllDayEvent]            = value.IsAllDayEvent;
            data.Properties[SalesforceVocabulary.Event.IsArchived]               = value.IsArchived;
            data.Properties[SalesforceVocabulary.Event.IsChild]                  = value.IsChild;
            data.Properties[SalesforceVocabulary.Event.IsClientManaged]          = value.IsClientManaged;
            data.Properties[SalesforceVocabulary.Event.IsGroupEvent]             = value.IsGroupEvent;
            data.Properties[SalesforceVocabulary.Event.IsPrivate]                = value.IsPrivate;
            data.Properties[SalesforceVocabulary.Event.IsRecurrence]             = value.IsRecurrence;
            data.Properties[SalesforceVocabulary.Event.IsReminderSet]            = value.IsReminderSet;
            data.Properties[SalesforceVocabulary.Event.IsVisibleInSelfService]   = value.IsVisibleInSelfService;
            data.Properties[SalesforceVocabulary.Event.Location]                 = value.Location;
            data.Properties[SalesforceVocabulary.Event.RecurrenceActivityId]     = value.RecurrenceActivityId;
            data.Properties[SalesforceVocabulary.Event.RecurrenceDayOfMonth]     = value.RecurrenceDayOfMonth;
            data.Properties[SalesforceVocabulary.Event.RecurrenceDayOfWeekMask]  = value.RecurrenceDayOfWeekMask;
            data.Properties[SalesforceVocabulary.Event.RecurrenceEndDateOnly]    = value.RecurrenceEndDateOnly;
            data.Properties[SalesforceVocabulary.Event.RecurrenceInstance]       = value.RecurrenceInstance;
            data.Properties[SalesforceVocabulary.Event.RecurrenceMonthOfYear]    = value.RecurrenceMonthOfYear;
            data.Properties[SalesforceVocabulary.Event.RecurrenceStartDateTime]  = DateUtilities.GetFormattedDateString(value.RecurrenceStartDateTime);
            data.Properties[SalesforceVocabulary.Event.RecurrenceTimeZoneSidKey] = value.RecurrenceTimeZoneSidKey;
            data.Properties[SalesforceVocabulary.Event.RecurrenceType]           = value.RecurrenceType;
            data.Properties[SalesforceVocabulary.Event.ReminderDateTime]         = DateUtilities.GetFormattedDateString(value.ReminderDateTime);
            data.Properties[SalesforceVocabulary.Event.ShowAs] = value.ShowAs;

            DateTime startDate;

            if (DateTime.TryParse(value.StartDateTime, out startDate))
            {
                data.Properties[SalesforceVocabulary.Event.DayOfWeek] = startDate.DayOfWeek.ToString();
            }

            data.Properties[SalesforceVocabulary.Event.StartDateTime]            = DateUtilities.GetFormattedDateString(value.StartDateTime);
            data.Properties[SalesforceVocabulary.Event.Type]                     = value.Type;
            data.Properties[SalesforceVocabulary.Event.UndecidedEventInviteeIds] = value.UndecidedEventInviteeIds;
            data.Properties[SalesforceVocabulary.Event.WhatCount]                = value.WhatCount;
            data.Properties[SalesforceVocabulary.Event.WhatId]                   = value.WhatId;
            data.Properties[SalesforceVocabulary.Event.WhoCount]                 = value.WhoCount;
            data.Properties[SalesforceVocabulary.Event.WhoId]                    = value.WhoId;

            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Event.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #8
0
        protected override Clue MakeClueImpl(Account value, Guid id)
        {
            var clue = _factory.Create(EntityType.Organization, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }


            // TODO: Could this fail? Is this the right name of the JobData?
            //data.Uri = new Uri($"{_jobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Account.EditUrl] = $"{_jobData.Token.Data}/{value.ID}";

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);

                data.LastChangedBy = createdBy;
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);

                data.LastChangedBy = createdBy;
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Account.SystemModstamp] = value.SystemModstamp;
            }
            if (value.AccountNumber != null)
            {
                data.Properties[SalesforceVocabulary.Account.AccountNumber] = value.AccountNumber;
            }
            if (value.AccountSource != null)
            {
                data.Properties[SalesforceVocabulary.Account.AccountSource] = value.AccountSource;
            }
            if (value.AnnualRevenue != null)
            {
                data.Properties[SalesforceVocabulary.Account.AnnualRevenue] = value.AnnualRevenue;
            }
            if (value.BillingCity != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingCity] = value.BillingCity;
            }
            if (value.BillingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingCountry] = value.BillingCountry;
            }
            if (value.BillingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingLatitude] = value.BillingLatitude;
            }
            if (value.BillingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingLongitude] = value.BillingLongitude;
            }
            if (value.BillingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingPostalCode] = value.BillingPostalCode;
            }
            if (value.BillingState != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingState] = value.BillingState;
            }
            if (value.BillingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Account.BillingStreet] = value.BillingStreet;
            }
            if (value.CleanStatus != null)
            {
                data.Properties[SalesforceVocabulary.Account.CleanStatus] = value.CleanStatus;
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.CleanStatus);
                data.Tags.Add(new Tag(value.CleanStatus));
            }
            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.DunsNumber != null)
            {
                data.Properties[SalesforceVocabulary.Account.DunsNumber] = value.DunsNumber;
            }
            if (value.Fax != null)
            {
                data.Properties[SalesforceVocabulary.Account.Fax] = value.Fax;
            }
            if (value.Industry != null)
            {
                data.Properties[SalesforceVocabulary.Account.Industry] = value.Industry;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Account.IsDeleted] = value.IsDeleted;
            }
            if (value.Jigsaw != null)
            {
                data.Properties[SalesforceVocabulary.Account.Jigsaw] = value.Jigsaw;
            }
            if (value.LastActivityDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }

            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Account.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Account.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.MasterRecordId != null)
            {
                data.Properties[SalesforceVocabulary.Account.MasterRecordId] = value.MasterRecordId;
            }
            if (value.NaicsCode != null)
            {
                data.Properties[SalesforceVocabulary.Account.NaicsCode] = value.NaicsCode;
            }
            if (value.NaicsDesc != null)
            {
                data.Properties[SalesforceVocabulary.Account.NaicsDesc] = value.NaicsDesc;
            }
            if (value.NumberOfEmployees != null)
            {
                data.Properties[SalesforceVocabulary.Account.NumberOfEmployees] = value.NumberOfEmployees;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.Ownership != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Ownership);
                data.Properties[SalesforceVocabulary.Account.Ownership] = value.Ownership;
            }
            if (value.ParentId != null)
            {
                // TODO: This is wrong! ParentId refers to the parent account
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.Parent, value, value.ParentId);
            }

            data.Properties[SalesforceVocabulary.Account.Phone] = value.Phone;

            //if (value.PhotoUrl != null)
            //{
            //    if (value.PhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + _jobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.PhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception exception)
            //        {
            //        }
            //    }
            //}

            if (value.Rating != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Rating);
                data.Properties[SalesforceVocabulary.Account.Rating] = value.Rating;
                data.Tags.Add(new Tag(value.Rating));
            }

            if (value.ShippingCity != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingCity] = value.ShippingCity;
            }
            if (value.ShippingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingCountry] = value.ShippingCountry;
            }
            if (value.ShippingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingLatitude] = value.ShippingLatitude;
            }
            if (value.ShippingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingLongitude] = value.ShippingLongitude;
            }
            if (value.ShippingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingPostalCode] = value.ShippingPostalCode;
            }
            if (value.ShippingState != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingState] = value.ShippingState;
            }
            if (value.ShippingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Account.ShippingStreet] = value.ShippingStreet;
            }
            if (value.Sic != null)
            {
                data.Properties[SalesforceVocabulary.Account.Sic] = value.Sic;
            }
            if (value.SicDesc != null)
            {
                data.Properties[SalesforceVocabulary.Account.SicDesc] = value.SicDesc;
            }
            if (value.Site != null)
            {
                data.Properties[SalesforceVocabulary.Account.Site] = value.Site;
            }
            if (value.TickerSymbol != null)
            {
                data.Properties[SalesforceVocabulary.Account.TickerSymbol] = value.TickerSymbol;
            }
            if (value.Tradestyle != null)
            {
                data.Properties[SalesforceVocabulary.Account.Tradestyle] = value.Tradestyle;
            }
            if (value.Type != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
                data.Properties[SalesforceVocabulary.Account.Type] = value.Type;
                data.Tags.Add(new Tag(value.Type));
            }

            if (value.Website != null)
            {
                data.Properties[SalesforceVocabulary.Account.Website] = value.Website;

                Uri website;

                if (Uri.TryCreate(value.Website, UriKind.Absolute, out website))
                {
                    data.ExternalReferences.Add(new Uri(value.Website));
                }
            }

            if (value.YearStarted != null)
            {
                data.Properties[SalesforceVocabulary.Account.YearStarted] = value.YearStarted;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #9
0
        protected override Clue MakeClueImpl(Idea value, Guid id)
        {
            var clue = _factory.Create(EntityType.Issue, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Title != null)
            {
                data.Name        = value.Title;
                data.DisplayName = value.Title;
                data.Aliases.Add(value.Title);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Idea.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.AttachmentBody != null)
            {
                data.Properties[SalesforceVocabulary.Idea.AttachmentBody] = value.AttachmentBody;
            }
            if (value.AttachmentContentType != null)
            {
                data.Properties[SalesforceVocabulary.Idea.AttachmentContentType] = value.AttachmentContentType;
            }
            if (value.AttachmentLength != null)
            {
                data.Properties[SalesforceVocabulary.Idea.AttachmentLength] = value.AttachmentLength;
            }
            if (value.AttachmentName != null)
            {
                data.Properties[SalesforceVocabulary.Idea.AttachmentName] = value.AttachmentName;
            }
            if (value.Body != null)
            {
                data.Description = value.Body;
            }

            if (value.Categories != null)
            {
                data.Properties[SalesforceVocabulary.Idea.Categories] = value.Categories;
            }
            if (value.Category != null)
            {
                data.Properties[SalesforceVocabulary.Idea.Category] = value.Category;
            }
            if (value.CommunityId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Infrastructure.Group, EntityEdgeType.For, value, value.CommunityId);
            }

            if (value.CreatorFullPhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.Idea.CreatorFullPhotoUrl] = value.CreatorFullPhotoUrl;
            }
            if (value.CreatorName != null)
            {
                data.Properties[SalesforceVocabulary.Idea.CreatorName] = value.CreatorName;
            }
            if (value.CreatorSmallPhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.Idea.CreatorSmallPhotoUrl] = value.CreatorSmallPhotoUrl;
            }
            if (value.CurrencyIsoCode != null)
            {
                data.Properties[SalesforceVocabulary.Idea.CurrencyIsoCode] = value.CurrencyIsoCode;
            }
            if (value.IdeaThemeID != null)
            {
                data.Properties[SalesforceVocabulary.Idea.IdeaThemeID] = value.IdeaThemeID;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Idea.IsDeleted] = value.IsDeleted;
            }
            if (value.IsHtml != null)
            {
                data.Properties[SalesforceVocabulary.Idea.IsHtml] = value.IsHtml;
            }
            if (value.IsMerged != null)
            {
                data.Properties[SalesforceVocabulary.Idea.IsMerged] = value.IsMerged;
            }
            if (value.LastCommentDate != null)
            {
                data.Properties[SalesforceVocabulary.Idea.LastCommentDate] = DateUtilities.GetFormattedDateString(value.LastCommentDate);
            }
            if (value.LastCommentId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Comment, EntityEdgeType.For, value, value.LastCommentId);
            }

            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Idea.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Idea.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.NumComments != null)
            {
                data.Properties[SalesforceVocabulary.Idea.NumComments] = value.NumComments;
            }
            if (value.ParentIdeaId != null)
            {
                data.Properties[SalesforceVocabulary.Idea.ParentIdeaId] = value.ParentIdeaId;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Idea.RecordTypeId] = value.RecordTypeId;
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Idea.Status] = value.Status;
            }
            if (value.VoteScore != null)
            {
                data.Properties[SalesforceVocabulary.Idea.VoteScore] = value.VoteScore;
            }
            if (value.VoteTotal != null)
            {
                data.Properties[SalesforceVocabulary.Idea.VoteTotal] = value.VoteTotal;
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Idea.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #10
0
        protected override Clue MakeClueImpl(Contact value, Guid id)
        {
            var clue = _factory.Create(EntityType.Infrastructure.Contact, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Contact.SystemModstamp] = value.SystemModstamp;
            }

            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsDeleted] = value.IsDeleted;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.OwnerId != null)
            {
                if (value.OwnerId != value.ID)
                {
                    _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.OwnerId);
                }

                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.RecordTypeId] = value.RecordTypeId;
            }
            if (value.AssistantName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.AssistantName] = value.AssistantName;
            }
            if (value.AssistantPhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.AssistantPhone] = value.AssistantPhone;
            }
            if (value.Birthdate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Birthdate] = value.Birthdate;
            }
            if (value.CanAllowPortalSelfReg != null)
            {
                data.Properties[SalesforceVocabulary.Contact.CanAllowPortalSelfReg] = value.CanAllowPortalSelfReg;
            }
            if (value.CleanStatus != null)
            {
                data.Properties[SalesforceVocabulary.Contact.CleanStatus] = value.CleanStatus;
            }
            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.Department != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Department] = value.Department;
            }
            if (value.DoNotCall != null)
            {
                data.Properties[SalesforceVocabulary.Contact.DoNotCall] = value.DoNotCall;
            }
            if (value.Email != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Email] = value.Email;
            }
            if (value.EmailBouncedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.EmailBouncedDate] = DateUtilities.GetFormattedDateString(value.EmailBouncedDate);
            }
            if (value.EmailBouncedReason != null)
            {
                data.Properties[SalesforceVocabulary.Contact.EmailBouncedReason] = value.EmailBouncedReason;
            }
            if (value.Fax != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Fax] = value.Fax;
            }
            if (value.FirstName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.FirstName] = value.FirstName;
            }
            if (value.HasOptedOutOfEmail != null)
            {
                data.Properties[SalesforceVocabulary.Contact.HasOptedOutOfEmail] = value.HasOptedOutOfEmail;
            }
            if (value.HasOptedOutOfFax != null)
            {
                data.Properties[SalesforceVocabulary.Contact.HasOptedOutOfFax] = value.HasOptedOutOfFax;
            }
            if (value.HomePhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.HomePhone] = value.HomePhone;
            }
            if (value.IsEmailBounced != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsEmailBounced] = value.IsEmailBounced;
            }
            if (value.IsPersonAccount != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsPersonAccount] = value.IsPersonAccount;
            }
            if (value.Jigsaw != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Jigsaw] = value.Jigsaw;
            }
            if (value.LastActivityDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }

            if (value.LastCURequestDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastCURequestDate] = DateUtilities.GetFormattedDateString(value.LastCURequestDate);
            }
            if (value.LastCUUpdateDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastCUUpdateDate] = DateUtilities.GetFormattedDateString(value.LastCUUpdateDate);
            }
            if (value.LastName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastName] = value.LastName;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.LeadSource != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.LeadSource);
                data.Properties[SalesforceVocabulary.Contact.LeadSource] = value.LeadSource;
            }

            if (value.MailingAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingAddress] = value.MailingAddress;
            }
            if (value.MailingCity != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCity] = value.MailingCity;
            }
            if (value.MailingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCountry] = value.MailingCountry;
            }
            if (value.MailingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCountryCode] = value.MailingCountryCode;
            }
            if (value.MailingGeocodeAccuracy != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingGeocodeAccuracy] = value.MailingGeocodeAccuracy;
            }
            if (value.MailingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingLatitude] = value.MailingLatitude;
            }
            if (value.MailingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingLongitude] = value.MailingLongitude;
            }
            if (value.MailingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingPostalCode] = value.MailingPostalCode;
            }
            if (value.MailingState != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingState] = value.MailingState;
            }
            if (value.MailingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingStateCode] = value.MailingStateCode;
            }
            if (value.MailingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingStreet] = value.MailingStreet;
            }
            if (value.MasterRecordId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MasterRecordId] = value.MasterRecordId;
            }
            if (value.MiddleName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MiddleName] = value.MiddleName;
            }
            if (value.MobilePhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MobilePhone] = value.MobilePhone;
            }
            if (value.OtherAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherAddress] = value.OtherAddress;
            }
            if (value.OtherCity != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCity] = value.OtherCity;
            }
            if (value.OtherCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCountry] = value.OtherCountry;
            }
            if (value.OtherCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCountryCode] = value.OtherCountryCode;
            }
            if (value.OtherGeocodeAccuracy != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherGeocodeAccuracy] = value.OtherGeocodeAccuracy;
            }
            if (value.OtherLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherLatitude] = value.OtherLatitude;
            }
            if (value.OtherLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherLongitude] = value.OtherLongitude;
            }
            if (value.OtherPhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherPhone] = value.OtherPhone;
            }
            if (value.OtherPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherPostalCode] = value.OtherPostalCode;
            }
            if (value.OtherState != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherState] = value.OtherState;
            }
            if (value.OtherStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherStateCode] = value.OtherStateCode;
            }
            if (value.OtherStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherStreet] = value.OtherStreet;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.Phone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Phone] = value.Phone;
            }
            //if (value.PhotoUrl != null)
            //{
            //    if (value.PhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.PhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception exception)
            //        {
            //            state.Log.Warn(() => "Could not download Contact Thumbnail Preview from SalesForce.", exception);
            //        }
            //    }
            //}

            if (value.ReportsToId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ManagedBy,
                                                       value, value.ReportsToId);
            }

            if (value.Salutation != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Salutation] = value.Salutation;
            }
            if (value.Suffix != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Suffix] = value.Suffix;
            }
            if (value.Title != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Title] = value.Title;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Contact.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #11
0
        protected override Clue MakeClueImpl(User value, Guid id)
        {
            var clue = _factory.Create(EntityType.Person, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            if (value.AboutMe != null)
            {
                data.Description = value.AboutMe;
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.User.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            data.Properties[SalesforceVocabulary.User.Address] = value.Address;

            if (value.Alias != null)
            {
                data.Aliases.Add(value.Alias);
            }

            data.Properties[SalesforceVocabulary.User.BadgeText] = value.BadgeText;

            if (value.CallCenterId != null)
            {
                // TODO:Edge?
                data.Properties[SalesforceVocabulary.User.CallCenterId] = value.CallCenterId;
            }

            data.Properties[SalesforceVocabulary.User.City] = value.City;

            if (value.CommunityNickname != null)
            {
                data.Properties[SalesforceVocabulary.User.CommunityNickname] = value.CommunityNickname;
                data.Codes.Add(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CommunityNickname));
                data.Aliases.Add(value.CommunityNickname);
            }

            data.Properties[SalesforceVocabulary.User.CompanyName] = value.CompanyName;

            if (value.ContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For, value, value.ContactId);
            }

            data.Properties[SalesforceVocabulary.User.Country]                           = value.Country;
            data.Properties[SalesforceVocabulary.User.CountryCode]                       = value.CountryCode;
            data.Properties[SalesforceVocabulary.User.CurrentStatus]                     = value.CurrentStatus;
            data.Properties[SalesforceVocabulary.User.DefaultCurrencyIsoCode]            = value.DefaultCurrencyIsoCode;
            data.Properties[SalesforceVocabulary.User.DefaultDivision]                   = value.DefaultDivision;
            data.Properties[SalesforceVocabulary.User.DefaultGroupNotificationFrequency] = value.DefaultGroupNotificationFrequency;

            if (value.DelegatedApproverId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOnBy, value, value.DelegatedApproverId);
            }

            data.Properties[SalesforceVocabulary.User.Department]      = value.Department;
            data.Properties[SalesforceVocabulary.User.DigestFrequency] = value.DigestFrequency;
            data.Properties[SalesforceVocabulary.User.Division]        = value.Division;

            if (value.Email != null)
            {
                data.Codes.Add(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.Email));
                data.Properties[SalesforceVocabulary.User.Email] = value.Email;
            }

            data.Properties[SalesforceVocabulary.User.EmailEncodingKey]                    = value.EmailEncodingKey;
            data.Properties[SalesforceVocabulary.User.EmailPreferencesAutoBcc]             = value.EmailPreferencesAutoBcc;
            data.Properties[SalesforceVocabulary.User.EmailPreferencesAutoBccStayInTouch]  = value.EmailPreferencesAutoBccStayInTouch;
            data.Properties[SalesforceVocabulary.User.EmailPreferencesStayInTouchReminder] = value.EmailPreferencesStayInTouchReminder;
            data.Properties[SalesforceVocabulary.User.EmployeeNumber]       = value.EmployeeNumber;
            data.Properties[SalesforceVocabulary.User.Extension]            = value.Extension;
            data.Properties[SalesforceVocabulary.User.Fax]                  = value.Fax;
            data.Properties[SalesforceVocabulary.User.FederationIdentifier] = value.FederationIdentifier;
            data.Properties[SalesforceVocabulary.User.FirstName]            = value.FirstName;
            data.Properties[SalesforceVocabulary.User.ForecastEnabled]      = value.ForecastEnabled;

            //if (value.FullPhotoUrl != null)
            //{
            //    if (value.FullPhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.FullPhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }
            //        }
            //        catch (Exception exception)
            //        {
            //            state.Log.Warn(() => "Could not download FullPhotoUrl for Salesforce User", exception);
            //        }
            //    }
            //}

            data.Properties[SalesforceVocabulary.User.IsActive]                  = value.IsActive;
            data.Properties[SalesforceVocabulary.User.IsPartner]                 = value.IsPartner;
            data.Properties[SalesforceVocabulary.User.IsPortalEnabled]           = value.IsPortalEnabled;
            data.Properties[SalesforceVocabulary.User.IsPortalSelfRegistered]    = value.IsPortalSelfRegistered;
            data.Properties[SalesforceVocabulary.User.IsPrmSuperUser]            = value.IsPrmSuperUser;
            data.Properties[SalesforceVocabulary.User.JigsawImportLimitOverride] = value.JigsawImportLimitOverride;
            data.Properties[SalesforceVocabulary.User.LanguageLocaleKey]         = value.LanguageLocaleKey;
            data.Properties[SalesforceVocabulary.User.LastName]                  = value.LastName;
            data.Properties[SalesforceVocabulary.User.LastReferencedDate]        = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            data.Properties[SalesforceVocabulary.User.LastViewedDate]            = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            data.Properties[SalesforceVocabulary.User.Latitude]                  = value.Latitude;
            data.Properties[SalesforceVocabulary.User.LocaleSidKey]              = value.LocaleSidKey;
            data.Properties[SalesforceVocabulary.User.Longitude]                 = value.Longitude;
            data.Properties[SalesforceVocabulary.User.Manager] = value.Manager;


            if (value.ManagerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ManagedBy, value, value.ManagerId);
            }

            data.Properties[SalesforceVocabulary.User.MiddleName]  = value.MiddleName;
            data.Properties[SalesforceVocabulary.User.MobilePhone] = value.MobilePhone;
            data.Properties[SalesforceVocabulary.User.OfflineTrialExpirationDate] = DateUtilities.GetFormattedDateString(value.OfflineTrialExpirationDate);
            data.Properties[SalesforceVocabulary.User.Phone]      = value.Phone;
            data.Properties[SalesforceVocabulary.User.PortalRole] = value.PortalRole;
            data.Properties[SalesforceVocabulary.User.PostalCode] = value.PostalCode;

            if (value.ProfileId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.Has, value, value.ProfileId);
            }

            data.Properties[SalesforceVocabulary.User.ReceivesAdminInfoEmails] = value.ReceivesAdminInfoEmails;
            data.Properties[SalesforceVocabulary.User.ReceivesInfoEmails]      = value.ReceivesInfoEmails;
            data.Properties[SalesforceVocabulary.User.SenderEmail]             = value.SenderEmail;
            data.Properties[SalesforceVocabulary.User.SenderName] = value.SenderName;
            data.Properties[SalesforceVocabulary.User.Signature]  = value.Signature;

            if (value.SmallPhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.User.SmallPhotoUrl] = value.SmallPhotoUrl;
            }

            data.Properties[SalesforceVocabulary.User.State]                = value.State;
            data.Properties[SalesforceVocabulary.User.StateCode]            = value.StateCode;
            data.Properties[SalesforceVocabulary.User.StayInTouchNote]      = value.StayInTouchNote;
            data.Properties[SalesforceVocabulary.User.StayInTouchSignature] = value.StayInTouchSignature;
            data.Properties[SalesforceVocabulary.User.StayInTouchSubject]   = value.StayInTouchSubject;
            data.Properties[SalesforceVocabulary.User.Street]               = value.Street;
            data.Properties[SalesforceVocabulary.User.Suffix]               = value.Suffix;
            data.Properties[SalesforceVocabulary.User.TimeZoneSidKey]       = value.TimeZoneSidKey;
            data.Properties[SalesforceVocabulary.User.Title]                = value.Title;

            if (value.UserRoleId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Infrastructure.Group, EntityEdgeType.Has, value, value.UserRoleId);
            }

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                if (value.CreatedById != value.ID)
                {
                    _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                    var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                    data.Authors.Add(createdBy);
                }
            }

            if (value.LastModifiedById != null)
            {
                if (value.LastModifiedById != value.ID)
                {
                    _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                    var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                    data.Authors.Add(createdBy);
                }
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }

            data.Properties[SalesforceVocabulary.User.SystemModstamp] = value.SystemModstamp;
            data.Properties[SalesforceVocabulary.User.UserType]       = value.UserType;
            data.Properties[SalesforceVocabulary.User.UserName]       = value.Username;

            if (value.WirelessEmail != null)
            {
                data.Aliases.Add(value.WirelessEmail);
                data.Properties[SalesforceVocabulary.User.WirelessEmail] = value.WirelessEmail;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #12
0
        protected override Clue MakeClueImpl(Solution value, Guid id)
        {
            var clue = _factory.Create(EntityType.Note, value.ID, id);
            var data = clue.Data.EntityData;

            data.Name        = value.SolutionName;
            data.Description = value.SolutionNote;
            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Solution.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }

            data.Properties[SalesforceVocabulary.Solution.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            data.Properties[SalesforceVocabulary.Solution.LastViewedDate]     = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            data.Properties[SalesforceVocabulary.Solution.Status]             = value.Status;
            data.Properties[SalesforceVocabulary.Solution.SystemModstamp]     = value.SystemModstamp;
            data.Properties[SalesforceVocabulary.Solution.ID]                    = value.ID;
            data.Properties[SalesforceVocabulary.Solution.IsDeleted]             = value.IsDeleted;
            data.Properties[SalesforceVocabulary.Solution.IsHtml]                = value.IsHtml;
            data.Properties[SalesforceVocabulary.Solution.IsOutOfDate]           = value.IsOutOfDate;
            data.Properties[SalesforceVocabulary.Solution.IsPublished]           = value.IsPublished;
            data.Properties[SalesforceVocabulary.Solution.IsPublishedInPublicKb] = value.IsPublishedInPublicKb;
            data.Properties[SalesforceVocabulary.Solution.IsReviewed]            = value.IsReviewed;
            data.Properties[SalesforceVocabulary.Solution.ParentId]              = value.ParentId;
            data.Properties[SalesforceVocabulary.Solution.RecordTypeId]          = value.RecordTypeId;
            data.Properties[SalesforceVocabulary.Solution.SolutionLanguage]      = value.SolutionLanguage;
            data.Properties[SalesforceVocabulary.Solution.SolutionNumber]        = value.SolutionNumber;
            data.Properties[SalesforceVocabulary.Solution.TimesUsed]             = value.TimesUsed;

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);

                data.Properties[SalesforceVocabulary.Solution.CreatedByName] = value.CreatedById;
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var ownedBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(ownedBy);

                data.Properties[SalesforceVocabulary.Solution.OwnedByName] = value.OwnerId;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(Case value, Guid id)
        {
            var clue = _factory.Create(EntityType.Issue, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Subject != null)
            {
                data.Name        = value.Subject;
                data.DisplayName = value.Subject;
            }
            else
            {
                data.Name        = $"New Case with ID of {value.ID}";
                data.DisplayName = $"New Case with ID of {value.ID}";
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Case.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Case.Status] = value.Status;
                data.Tags.Add(new Tag(value.Status));
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Case.SystemModstamp] = value.SystemModstamp;
            }
            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            if (value.CaseNumber != null)
            {
                data.Properties[SalesforceVocabulary.Case.CaseNumber] = value.CaseNumber;
            }
            if (value.ClosedDate != null)
            {
                data.Properties[SalesforceVocabulary.Case.ClosedDate] = DateUtilities.GetFormattedDateString(value.ClosedDate);
            }
            if (value.CommunityId != null)
            {
                // TODO: Should this reference an org?
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.PartOf, value, value.CommunityId);
            }

            if (value.ConnectionReceivedId != null)
            {
                data.Properties[SalesforceVocabulary.Case.ConnectionReceivedId] = value.ConnectionReceivedId;
            }
            if (value.ConnectionSentId != null)
            {
                data.Properties[SalesforceVocabulary.Case.ConnectionSentId] = value.ConnectionSentId;
            }
            if (value.ContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For,
                                                       value, value.ContactId);
            }

            //if (value.CreatorFullPhotoUrl != null)
            //{
            //    if (value.CreatorFullPhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.CreatorFullPhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception ex)
            //        {
            //            state.Log.Warn(() => "Could not download Full Photo Url for Creator of Case in Salesforce", ex);
            //        }
            //    }
            //}

            if (value.CreatorName != null)
            {
                data.Properties[SalesforceVocabulary.Case.CreatorName] = value.CreatorName;
            }
            if (value.CreatorSmallPhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.Case.CreatorSmallPhotoUrl] = value.CreatorSmallPhotoUrl;
            }
            if (value.FeedItemId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.News, EntityEdgeType.For,
                                                       value, value.FeedItemId);
            }

            if (value.HasCommentsUnreadByOwner != null)
            {
                data.Properties[SalesforceVocabulary.Case.HasCommentsUnreadByOwner] = value.HasCommentsUnreadByOwner;
            }
            if (value.HasSelfServiceComments != null)
            {
                data.Properties[SalesforceVocabulary.Case.HasSelfServiceComments] = value.HasSelfServiceComments;
            }
            if (value.IsClosed != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsClosed] = value.IsClosed;
            }
            if (value.IsClosedOnCreate != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsClosedOnCreate] = value.IsClosedOnCreate;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsDeleted] = value.IsDeleted;
            }
            if (value.IsEscalated != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsEscalated] = value.IsEscalated;
            }
            if (value.IsSelfServiceClosed != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsSelfServiceClosed] = value.IsSelfServiceClosed;
            }
            if (value.IsStopped != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsStopped] = value.IsStopped;
            }
            if (value.IsVisibleInSelfService != null)
            {
                data.Properties[SalesforceVocabulary.Case.IsVisibleInSelfService] = value.IsVisibleInSelfService;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Case.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Case.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.Origin != null)
            {
                data.Tags.Add(new Tag(value.Origin));
                data.Properties[SalesforceVocabulary.Case.Origin] = value.Origin;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.ParentId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Issue, EntityEdgeType.Parent,
                                                       value, value.ParentId);
            }

            if (value.Priority != null)
            {
                data.Tags.Add(new Tag(value.Priority));
                data.Properties[SalesforceVocabulary.Case.Priority] = value.Priority;
            }

            if (value.QuestionId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Question, EntityEdgeType.For,
                                                       value, value.QuestionId);
            }

            if (value.Reason != null)
            {
                if (value.Description == null)
                {
                    data.Description = value.Reason;
                }

                data.Properties[SalesforceVocabulary.Case.Reason] = value.Reason;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Case.RecordTypeId] = value.RecordTypeId;
            }
            if (value.SlaStartDate != null)
            {
                data.Properties[SalesforceVocabulary.Case.SlaStartDate] = DateUtilities.GetFormattedDateString(value.SlaStartDate);
            }
            if (value.StopStartDate != null)
            {
                data.Properties[SalesforceVocabulary.Case.StopStartDate] = DateUtilities.GetFormattedDateString(value.StopStartDate);
            }
            if (value.Subject != null)
            {
                if (value.Description == null)
                {
                    data.Description = value.Subject;
                }

                data.Properties[SalesforceVocabulary.Case.Subject] = value.Subject;
            }

            if (value.SuppliedCompany != null)
            {
                data.Properties[SalesforceVocabulary.Case.SuppliedCompany] = value.SuppliedCompany;
            }
            if (value.SuppliedEmail != null)
            {
                data.Properties[SalesforceVocabulary.Case.SuppliedEmail] = value.SuppliedEmail;
            }
            if (value.SuppliedName != null)
            {
                data.Properties[SalesforceVocabulary.Case.SuppliedName] = value.SuppliedName;
            }
            if (value.SuppliedPhone != null)
            {
                data.Properties[SalesforceVocabulary.Case.SuppliedPhone] = value.SuppliedPhone;
            }
            if (value.Type != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
                data.Properties[SalesforceVocabulary.Case.Type] = value.Type;
                data.Tags.Add(new Tag(value.Type));
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #14
0
        protected override Clue MakeClueImpl(Order value, Guid id)
        {
            var clue = _factory.Create(EntityType.Sales.Order, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }
            else
            {
                if (value.Description != null)
                {
                    data.Name        = value.Description;
                    data.DisplayName = value.Description;
                    data.Aliases.Add(value.Description);
                }
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Order.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.AccountId);
            }

            if (value.ActivatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOn, value, value.ActivatedById);
            }
            if (value.ActivatedDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.ActivatedDate] = DateUtilities.GetFormattedDateString(value.ActivatedDate);
            }
            if (value.BillToContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For, value, value.BillToContactId);
            }

            if (value.BillingCity != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingCity] = value.BillingCity;
            }
            if (value.BillingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingCountry] = value.BillingCountry;
            }
            if (value.BillingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingCountryCode] = value.BillingCountryCode;
            }
            if (value.BillingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingLatitude] = value.BillingLatitude;
            }
            if (value.BillingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingLongitude] = value.BillingLongitude;
            }
            if (value.BillingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingPostalCode] = value.BillingPostalCode;
            }
            if (value.BillingState != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingState] = value.BillingState;
            }
            if (value.BillingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingStateCode] = value.BillingStateCode;
            }
            if (value.BillingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Order.BillingStreet] = value.BillingStreet;
            }
            if (value.CompanyAuthorizedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOn, value, value.CompanyAuthorizedById);
            }
            if (value.CompanyAuthorizedDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.CompanyAuthorizedDate] = DateUtilities.GetFormattedDateString(value.CompanyAuthorizedDate);
            }
            if (value.ContractId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Contract, EntityEdgeType.For, value, value.ContractId);
            }

            if (value.CustomerAuthorizedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOn, value, value.CustomerAuthorizedById);
            }

            if (value.CustomerAuthorizedDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.CustomerAuthorizedDate] = DateUtilities.GetFormattedDateString(value.CustomerAuthorizedDate);
            }
            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.EffectiveDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.EffectiveDate] = DateUtilities.GetFormattedDateString(value.EffectiveDate);
            }
            if (value.EndDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.EndDate] = DateUtilities.GetFormattedDateString(value.EndDate);
            }
            if (value.IsReductionOrder != null)
            {
                data.Properties[SalesforceVocabulary.Order.IsReductionOrder] = value.IsReductionOrder;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.OpportunityId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Deal, EntityEdgeType.For, value, value.OpportunityId);
            }

            if (value.OrderNumber != null)
            {
                data.Properties[SalesforceVocabulary.Order.OrderNumber] = value.OrderNumber;
                data.Codes.Add(new EntityCode(EntityType.Sales.Order, SalesforceConstants.CodeOrigin, value.OrderNumber));
            }

            if (value.OrderReferenceNumber != null)
            {
                data.Properties[SalesforceVocabulary.Order.OrderReferenceNumber] = value.OrderReferenceNumber;
            }
            if (value.OriginalOrderId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Order, EntityEdgeType.For, value, value.OriginalOrderId);
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.PoDate != null)
            {
                data.Properties[SalesforceVocabulary.Order.PoDate] = value.PoDate;
            }
            if (value.PoNumber != null)
            {
                data.Properties[SalesforceVocabulary.Order.PoNumber] = value.PoNumber;
            }

            if (value.Pricebook2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.Pricebook2Id);
            }
            if (value.QuoteId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.QuoteId);
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Order.RecordTypeId] = value.RecordTypeId;
            }
            if (value.ShipToContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.WorkedOn, value, value.ShipToContactId);
            }

            if (value.ShippingCity != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingCity] = value.ShippingCity;
            }
            if (value.ShippingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingCountry] = value.ShippingCountry;
            }
            if (value.ShippingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingCountryCode] = value.ShippingCountryCode;
            }
            if (value.ShippingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingLatitude] = value.ShippingLatitude;
            }
            if (value.ShippingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingLongitude] = value.ShippingLongitude;
            }
            if (value.ShippingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingPostalCode] = value.ShippingPostalCode;
            }
            if (value.ShippingState != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingState] = value.ShippingState;
            }
            if (value.ShippingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingStateCode] = value.ShippingStateCode;
            }
            if (value.ShippingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Order.ShippingStreet] = value.ShippingStreet;
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Order.Status] = value.Status;
                data.Tags.Add(new Tag(value.Status));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Status);
            }

            if (value.StatusCode != null)
            {
                data.Properties[SalesforceVocabulary.Order.StatusCode] = value.StatusCode;
            }
            if (value.TotalAmount != null)
            {
                data.Properties[SalesforceVocabulary.Order.TotalAmount] = value.TotalAmount;
            }
            if (value.Type != null)
            {
                data.Properties[SalesforceVocabulary.Order.Type] = value.Type;
                data.Tags.Add(new Tag(value.Type));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
            }

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Order.SystemModstamp] = value.SystemModstamp;
            }

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #15
0
        protected override Clue MakeClueImpl(Campaign value, Guid id)
        {
            var clue = _factory.Create(EntityType.Marketing.Campaign, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Campaign.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Campaign.Status] = value.Status;
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Status);
                data.Tags.Add(new Tag(value.Status));
            }

            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Campaign.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }

            // TODO: This might cause a lot of noise.
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Campaign.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.ParentId != null)
            {
                // TODO: This is wrong. ParentId is not a person
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.Parent,
                                                       value, value.ParentId);
            }
            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Campaign.SystemModstamp] = value.SystemModstamp;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Campaign.RecordTypeId] = value.RecordTypeId;
            }
            if (!string.IsNullOrEmpty(value.Type))
            {
                data.Tags.Add(new Tag(value.Type));
                data.Properties[SalesforceVocabulary.Campaign.Type] = value.Type;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #16
0
        protected override Clue MakeClueImpl(Document value, Guid id)
        {
            var clue = _factory.Create(EntityType.Document, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.AuthorId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.Action.CreatedBy, value, value.AuthorId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.AuthorId));
                data.Authors.Add(createdBy);
            }

            //Index this?
            //if (value.Body != null)
            //{
            //    try
            //    {
            //        using (var tempFile = new TemporaryFile(value.Name))
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead($"{this.state.JobData.Token.Data}{value.Body}"))
            //                {
            //                    using (var fs = new FileStream(tempFile.FileInfo.FullName, FileMode.OpenOrCreate, FileAccess.Write))
            //                    {
            //                        stream.CopyTo(fs);
            //                    }
            //                }
            //            }

            //            FileCrawlingUtility.IndexFile(tempFile, clue.Data, clue, state, this.context);
            //        }

            //    }
            //    catch (Exception ex)
            //    {
            //        state.Log.Warn(() => "Could not download Salesforce Document", ex);
            //    }

            //    data.Properties[SalesforceVocabulary.Document.Body] = value.Body;
            //}

            if (value.BodyLength != null)
            {
                data.Properties[SalesforceVocabulary.Document.BodyLength] = value.BodyLength;
            }
            if (value.ContentType != null)
            {
                data.Properties[SalesforceVocabulary.Document.ContentType] = value.ContentType;
            }
            if (value.DeveloperName != null)
            {
                data.Properties[SalesforceVocabulary.Document.DeveloperName] = value.DeveloperName;
            }
            if (value.FolderId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Files.Directory, EntityEdgeType.Parent, value, value.FolderId);
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Document.SystemModstamp] = value.SystemModstamp;
            }

            //https://eu5.salesforce.com/
            //https://c.eu5.content.force.com/servlet/servlet.FileDownload?file=015240000018dcd

            //var embedUrl = $"{this.state.JobData.Token.Data.Replace("//", "//c.").Replace("salesforce", "content").Replace(".com", ".force.com")}/servlet/servlet.FileDownload?file={value.ID}";
            //data.Properties[SalesforceVocabulary.Document.EmbedUrl] = embedUrl;

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Document.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.IsBodySearchable != null)
            {
                data.Properties[SalesforceVocabulary.Document.IsBodySearchable] = value.IsBodySearchable;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Document.IsDeleted] = value.IsDeleted;
            }
            if (value.IsInternalUseOnly != null)
            {
                data.Properties[SalesforceVocabulary.Document.IsInternalUseOnly] = value.IsInternalUseOnly;
            }
            if (value.IsPublic != null)
            {
                data.Properties[SalesforceVocabulary.Document.IsPublic] = value.IsPublic;
            }
            if (value.Keywords != null)
            {
                data.Properties[SalesforceVocabulary.Document.Keywords] = value.Keywords;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Document.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Document.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.NamespacePrefix != null)
            {
                data.Properties[SalesforceVocabulary.Document.NamespacePrefix] = value.NamespacePrefix;
            }
            if (value.Type != null)
            {
                data.Properties[SalesforceVocabulary.Document.Type] = value.Type;
            }
            if (value.Url != null)
            {
                Uri uri;

                if (Uri.TryCreate(value.Url, UriKind.Absolute, out uri))
                {
                    data.Uri = uri;
                }
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #17
0
        protected override Clue MakeClueImpl(Lead value, Guid id)
        {
            var clue = _factory.Create(EntityType.Sales.Lead, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Lead.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            data.Properties[SalesforceVocabulary.Lead.Address]       = value.Address;
            data.Properties[SalesforceVocabulary.Lead.AnnualRevenue] = value.AnnualRevenue;
            data.Properties[SalesforceVocabulary.Lead.City]          = value.City;

            if (value.CleanStatus != null)
            {
                data.Properties[SalesforceVocabulary.Lead.CleanStatus] = value.CleanStatus;
                data.Tags.Add(new Tag(value.CleanStatus));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.CleanStatus);
            }

            data.Properties[SalesforceVocabulary.Lead.Company]              = value.Company;
            data.Properties[SalesforceVocabulary.Lead.CompanyDunsNumber]    = value.CompanyDunsNumber;
            data.Properties[SalesforceVocabulary.Lead.ConnectionReceivedId] = value.ConnectionReceivedId;
            data.Properties[SalesforceVocabulary.Lead.ConnectionSentId]     = value.ConnectionSentId;

            if (value.ConvertedAccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.ConvertedAccountId);
            }
            if (value.ConvertedContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.ConvertedContactId);
            }

            if (value.ConvertedDate != null)
            {
                data.Properties[SalesforceVocabulary.Lead.ConvertedDate] = DateUtilities.GetFormattedDateString(value.ConvertedDate);
            }
            if (value.ConvertedOpportunityId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Deal, EntityEdgeType.For, value, value.ConvertedOpportunityId);
            }

            data.Properties[SalesforceVocabulary.Lead.Country]            = value.Country;
            data.Properties[SalesforceVocabulary.Lead.CountryCode]        = value.CountryCode;
            data.Properties[SalesforceVocabulary.Lead.CurrencyIsoCode]    = value.CurrencyIsoCode;
            data.Properties[SalesforceVocabulary.Lead.Division]           = value.Division;
            data.Properties[SalesforceVocabulary.Lead.Email]              = value.Email;
            data.Properties[SalesforceVocabulary.Lead.EmailBouncedDate]   = DateUtilities.GetFormattedDateString(value.EmailBouncedDate);
            data.Properties[SalesforceVocabulary.Lead.EmailBouncedReason] = value.EmailBouncedReason;
            data.Properties[SalesforceVocabulary.Lead.Fax]                = value.Fax;
            data.Properties[SalesforceVocabulary.Lead.FirstName]          = value.FirstName;
            data.Properties[SalesforceVocabulary.Lead.GeocodeAccuracy]    = value.GeocodeAccuracy;
            data.Properties[SalesforceVocabulary.Lead.HasOptedOutOfEmail] = value.HasOptedOutOfEmail;
            data.Properties[SalesforceVocabulary.Lead.Industry]           = value.Industry;
            data.Properties[SalesforceVocabulary.Lead.IsConverted]        = value.IsConverted;
            data.Properties[SalesforceVocabulary.Lead.IsDeleted]          = value.IsDeleted;
            data.Properties[SalesforceVocabulary.Lead.IsUnreadByOwner]    = value.IsUnreadByOwner;
            data.Properties[SalesforceVocabulary.Lead.Jigsaw]             = value.Jigsaw;

            if (value.LastActivityDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }

            data.Properties[SalesforceVocabulary.Lead.LastName]           = value.LastName;
            data.Properties[SalesforceVocabulary.Lead.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            data.Properties[SalesforceVocabulary.Lead.LastViewedDate]     = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            data.Properties[SalesforceVocabulary.Lead.Latitude]           = value.Latitude;

            if (value.LeadSource != null)
            {
                data.Properties[SalesforceVocabulary.Lead.LeadSource] = value.LeadSource;
                data.Tags.Add(new Tag(value.LeadSource));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.LeadSource);
            }

            data.Properties[SalesforceVocabulary.Lead.Longitude]         = value.Longitude;
            data.Properties[SalesforceVocabulary.Lead.MasterRecordId]    = value.MasterRecordId;
            data.Properties[SalesforceVocabulary.Lead.MiddleName]        = value.MiddleName;
            data.Properties[SalesforceVocabulary.Lead.MobileNumber]      = value.MobilePhone;
            data.Properties[SalesforceVocabulary.Lead.NumberOfEmployees] = value.NumberOfEmployees;

            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }

            if (value.PartnerAccountId != null)
            {
                // TODO: The edge type might need to be different https://help.salesforce.com/apex/HTViewHelpDoc?id=leads_fields.htm
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.Parent, value, value.PartnerAccountId);
            }

            data.Properties[SalesforceVocabulary.Lead.Phone] = value.Phone;

            //if (value.PhotoUrl != null)
            //{
            //    if (value.PhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.PhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception ex)
            //        {
            //            this.state.Log.Warn(() => "Could not download lead image", ex);
            //        }
            //    }
            //}

            data.Properties[SalesforceVocabulary.Lead.PostalCode]   = value.PostalCode;
            data.Properties[SalesforceVocabulary.Lead.Rating]       = value.Rating;
            data.Properties[SalesforceVocabulary.Lead.RecordTypeId] = value.RecordTypeId;
            data.Properties[SalesforceVocabulary.Lead.Salutation]   = value.Salutation;
            data.Properties[SalesforceVocabulary.Lead.State]        = value.State;
            data.Properties[SalesforceVocabulary.Lead.StateCode]    = value.StateCode;

            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Lead.Status] = value.Status;
                data.Tags.Add(new Tag(value.Status));
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Status);
            }

            data.Properties[SalesforceVocabulary.Lead.Street]  = value.Street;
            data.Properties[SalesforceVocabulary.Lead.Suffix]  = value.Suffix;
            data.Properties[SalesforceVocabulary.Lead.Title]   = value.Title;
            data.Properties[SalesforceVocabulary.Lead.Website] = value.Website;

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            data.Properties[SalesforceVocabulary.Lead.SystemModstamp] = value.SystemModstamp;

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #18
0
        protected override Clue MakeClueImpl(Profile value, Guid id)
        {
            var clue = _factory.Create(EntityType.Person, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Profile.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.IsSsoEnabled != null)
            {
                data.Properties[SalesforceVocabulary.Profile.IsSsoEnabled] = value.IsSsoEnabled;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Profile.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Profile.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.PermissionsPermissionName != null)
            {
                data.Properties[SalesforceVocabulary.Profile.PermissionsPermissionName] = value.PermissionsPermissionName;
            }
            if (value.UserLicenseId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Note, EntityEdgeType.For, value, value.UserLicenseId);
            }

            if (value.UserType != null)
            {
                data.Properties[SalesforceVocabulary.Profile.UserType] = value.UserType;
            }
            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Profile.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #19
0
        protected override Clue MakeClueImpl(Contact value, Guid id)
        {
            var clue = _factory.Create(EntityType.Infrastructure.Contact, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            if (value.ID != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ID] = value.ID;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Contact.SystemModstamp] = value.SystemModstamp;
            }
            if (value.AgeC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.AgeC] = value.AgeC;
            }
            if (value.BouncedC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.BouncedC] = value.BouncedC;
            }
            if (value.BrandC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.BrandC] = value.BrandC;
            }
            if (value.Brand2C != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Brand2C] = value.Brand2C;
            }
            if (value.BuyingTimeframeC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.BuyingTimeframeC] = value.BuyingTimeframeC;
            }
            if (value.CompanySizeC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.CompanySizeC] = value.CompanySizeC;
            }
            if (value.ContactRoleC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ContactRoleC] = value.ContactRoleC;
            }
            if (value.CurrentCarBrandC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.CurrentCarBrandC] = value.CurrentCarBrandC;
            }
            if (value.HashedEmailC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.HashedEmailC] = value.HashedEmailC;
            }
            if (value.IdEmailC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IdEmailC] = value.IdEmailC;
            }
            if (value.IdentityKitIdC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IdentityKitIdC] = value.IdentityKitIdC;
            }
            if (value.IdNgC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IdNgC] = value.IdNgC;
            }
            if (value.IndustryC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IndustryC] = value.IndustryC;
            }
            if (value.InteractionScoreC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.InteractionScoreC] = value.InteractionScoreC;
            }
            if (value.InteractionScoreCalculatedC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.InteractionScoreCalculatedC] = value.InteractionScoreCalculatedC;
            }
            if (value.InteractionScoreLastUpdatedC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.InteractionScoreLastUpdatedC] = value.InteractionScoreLastUpdatedC;
            }
            if (value.IsActiveUserC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsActiveUserC] = value.IsActiveUserC;
            }
            if (value.IsMarketingContactC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsMarketingContactC] = value.IsMarketingContactC;
            }
            if (value.IsPartnerC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsPartnerC] = value.IsPartnerC;
            }
            if (value.McApiErrorC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.McApiErrorC] = value.McApiErrorC;
            }
            if (value.McApiStatusC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.McApiStatusC] = value.McApiStatusC;
            }
            if (value.NumberOfCarsC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.NumberOfCarsC] = value.NumberOfCarsC;
            }
            if (value.PreferedOwnershipC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.PreferedOwnershipC] = value.PreferedOwnershipC;
            }
            if (value.ResidenseRegionC != null)
            {
                data.Properties[SalesforceVocabulary.Contact.ResidenseRegionC] = value.ResidenseRegionC;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsDeleted] = value.IsDeleted;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.RecordTypeId] = value.RecordTypeId;
            }
            if (value.AssistantName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.AssistantName] = value.AssistantName;
            }
            if (value.AssistantPhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.AssistantPhone] = value.AssistantPhone;
                data.Aliases.Add(value.AssistantPhone);
            }
            if (value.Birthdate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Birthdate] = value.Birthdate;
            }
            if (value.Department != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Department] = value.Department;
            }
            if (value.DoNotCall != null)
            {
                data.Properties[SalesforceVocabulary.Contact.DoNotCall] = value.DoNotCall;
            }
            if (value.Email != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Email] = value.Email;
                data.Aliases.Add(value.Email);
            }
            if (value.Fax != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Fax] = value.Fax;
                data.Aliases.Add(value.Fax);
            }
            if (value.FirstName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.FirstName] = value.FirstName;
            }
            if (value.HomePhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.HomePhone] = value.HomePhone;
                data.Aliases.Add(value.HomePhone);
            }
            if (value.IsEmailBounced != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsEmailBounced] = value.IsEmailBounced;
            }
            if (value.IsPersonAccount != null)
            {
                data.Properties[SalesforceVocabulary.Contact.IsPersonAccount] = value.IsPersonAccount;
            }
            if (value.LastActivityDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }

            if (value.LastCURequestDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastCURequestDate] = DateUtilities.GetFormattedDateString(value.LastCURequestDate);
            }
            if (value.LastCUUpdateDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastCUUpdateDate] = DateUtilities.GetFormattedDateString(value.LastCUUpdateDate);
            }
            if (value.LastName != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastName] = value.LastName;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.Contact.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.LeadSource != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.LeadSource);
                data.Properties[SalesforceVocabulary.Contact.LeadSource] = value.LeadSource;
            }

            if (value.MailingAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingAddress] = value.MailingAddress;
            }
            if (value.MailingCity != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCity] = value.MailingCity;
            }
            if (value.MailingCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCountry] = value.MailingCountry;
            }
            if (value.MailingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingCountryCode] = value.MailingCountryCode;
            }
            if (value.MailingGeocodeAccuracy != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingGeocodeAccuracy] = value.MailingGeocodeAccuracy;
            }
            if (value.MailingLatitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingLatitude] = value.MailingLatitude;
            }
            if (value.MailingLongitude != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingLongitude] = value.MailingLongitude;
            }
            if (value.MailingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingPostalCode] = value.MailingPostalCode;
            }
            if (value.MailingState != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingState] = value.MailingState;
            }
            if (value.MailingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingStateCode] = value.MailingStateCode;
            }
            if (value.MailingStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MailingStreet] = value.MailingStreet;
            }
            if (value.MasterRecordId != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MasterRecordId] = value.MasterRecordId;
            }
            if (value.MobilePhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.MobilePhone] = value.MobilePhone;
                data.Aliases.Add(value.MobilePhone);
            }
            if (value.OtherAddress != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherAddress] = value.OtherAddress;
            }
            if (value.OtherCity != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCity] = value.OtherCity;
            }
            if (value.OtherCountry != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCountry] = value.OtherCountry;
            }
            if (value.OtherCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherCountryCode] = value.OtherCountryCode;
            }
            if (value.OtherPhone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherPhone] = value.OtherPhone;
                data.Aliases.Add(value.OtherPhone);
            }
            if (value.OtherPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherPostalCode] = value.OtherPostalCode;
            }
            if (value.OtherState != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherState] = value.OtherState;
            }
            if (value.OtherStateCode != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherStateCode] = value.OtherStateCode;
            }
            if (value.OtherStreet != null)
            {
                data.Properties[SalesforceVocabulary.Contact.OtherStreet] = value.OtherStreet;
            }
            if (value.OwnerId != null)
            {
                if (value.OwnerId != value.ID)
                {
                    _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.OwnerId);
                }

                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }
            if (value.Phone != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Phone] = value.Phone;
                data.Aliases.Add(value.Phone);
            }
            if (value.PhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.Contact.PhotoUrl] = value.PhotoUrl;
            }
            //if (value.PhotoUrl != null)
            //{
            //    if (value.PhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + state.JobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.PhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception exception)
            //        {
            //            state.Log.Warn(() => "Could not download Contact Thumbnail Preview from SalesForce.", exception);
            //        }
            //    }
            //}

            if (value.ReportsToId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ManagedBy,
                                                       value, value.ReportsToId);
            }

            if (value.Salutation != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Salutation] = value.Salutation;
            }
            if (value.Title != null)
            {
                data.Properties[SalesforceVocabulary.Contact.Title] = value.Title;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #20
0
        protected override Clue MakeClueImpl(Quote value, Guid id)
        {
            var clue = _factory.Create(EntityType.Sales.Quote, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.OwnedBy, value, value.AccountId);
            }

            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Quote.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            data.Properties[SalesforceVocabulary.Quote.AdditionalAddress]     = value.AdditionalAddress;
            data.Properties[SalesforceVocabulary.Quote.AdditionalCity]        = value.AdditionalCity;
            data.Properties[SalesforceVocabulary.Quote.AdditionalCountry]     = value.AdditionalCountry;
            data.Properties[SalesforceVocabulary.Quote.AdditionalCountryCode] = value.AdditionalCountryCode;
            data.Properties[SalesforceVocabulary.Quote.AdditionalLatitude]    = value.AdditionalLatitude;
            data.Properties[SalesforceVocabulary.Quote.AdditionalLongitude]   = value.AdditionalLongitude;
            data.Properties[SalesforceVocabulary.Quote.AdditionalName]        = value.AdditionalName;
            data.Properties[SalesforceVocabulary.Quote.AdditionalPostalCode]  = value.AdditionalPostalCode;
            data.Properties[SalesforceVocabulary.Quote.AdditionalState]       = value.AdditionalState;
            data.Properties[SalesforceVocabulary.Quote.AdditionalStateCode]   = value.AdditionalStateCode;
            data.Properties[SalesforceVocabulary.Quote.AdditionalStreet]      = value.AdditionalStreet;
            data.Properties[SalesforceVocabulary.Quote.BillingAddress]        = value.BillingAddress;
            data.Properties[SalesforceVocabulary.Quote.BillingCity]           = value.BillingCity;
            data.Properties[SalesforceVocabulary.Quote.BillingCountry]        = value.BillingCountry;
            data.Properties[SalesforceVocabulary.Quote.BillingCountryCode]    = value.BillingCountryCode;
            data.Properties[SalesforceVocabulary.Quote.BillingLatitude]       = value.BillingLatitude;
            data.Properties[SalesforceVocabulary.Quote.BillingLongitude]      = value.BillingLongitude;
            data.Properties[SalesforceVocabulary.Quote.BillingName]           = value.BillingName;
            data.Properties[SalesforceVocabulary.Quote.BillingPostalCode]     = value.BillingPostalCode;
            data.Properties[SalesforceVocabulary.Quote.BillingState]          = value.BillingState;
            data.Properties[SalesforceVocabulary.Quote.BillingStateCode]      = value.BillingStateCode;
            data.Properties[SalesforceVocabulary.Quote.BillingStreet]         = value.BillingStreet;

            if (value.ContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For, value, value.ContactId);
            }

            if (value.ContractId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Contract, EntityEdgeType.For, value, value.ContractId);
            }

            data.Properties[SalesforceVocabulary.Quote.CurrencyIsoCode] = value.CurrencyIsoCode;

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            data.Properties[SalesforceVocabulary.Quote.Discount]           = value.Discount;
            data.Properties[SalesforceVocabulary.Quote.Email]              = value.Email;
            data.Properties[SalesforceVocabulary.Quote.ExpirationDate]     = DateUtilities.GetFormattedDateString(value.ExpirationDate);
            data.Properties[SalesforceVocabulary.Quote.Fax]                = value.Fax;
            data.Properties[SalesforceVocabulary.Quote.GrandTotal]         = value.GrandTotal;
            data.Properties[SalesforceVocabulary.Quote.IsSyncing]          = value.IsSyncing;
            data.Properties[SalesforceVocabulary.Quote.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            data.Properties[SalesforceVocabulary.Quote.LastViewedDate]     = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            data.Properties[SalesforceVocabulary.Quote.LineItemCount]      = value.LineItemCount;

            if (value.OpportunityId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Deal, EntityEdgeType.For, value, value.OpportunityId);
            }

            data.Properties[SalesforceVocabulary.Quote.Phone] = value.Phone;

            if (value.Pricebook2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Sales.Quote, EntityEdgeType.For, value, value.Pricebook2Id);
            }

            data.Properties[SalesforceVocabulary.Quote.QuoteNumber]         = value.QuoteNumber;
            data.Properties[SalesforceVocabulary.Quote.QuoteToAddress]      = value.QuoteToAddress;
            data.Properties[SalesforceVocabulary.Quote.QuoteToCity]         = value.QuoteToCity;
            data.Properties[SalesforceVocabulary.Quote.QuoteToCountry]      = value.QuoteToCountry;
            data.Properties[SalesforceVocabulary.Quote.QuoteToLatitude]     = value.QuoteToLatitude;
            data.Properties[SalesforceVocabulary.Quote.QuoteToLongitude]    = value.QuoteToLongitude;
            data.Properties[SalesforceVocabulary.Quote.QuoteToName]         = value.QuoteToName;
            data.Properties[SalesforceVocabulary.Quote.QuoteToPostalCode]   = value.QuoteToPostalCode;
            data.Properties[SalesforceVocabulary.Quote.QuoteToState]        = value.QuoteToState;
            data.Properties[SalesforceVocabulary.Quote.QuoteToStreet]       = value.QuoteToStreet;
            data.Properties[SalesforceVocabulary.Quote.RecordTypeID]        = value.RecordTypeID;
            data.Properties[SalesforceVocabulary.Quote.ShippingAddress]     = value.ShippingAddress;
            data.Properties[SalesforceVocabulary.Quote.ShippingCity]        = value.ShippingCity;
            data.Properties[SalesforceVocabulary.Quote.ShippingCountry]     = value.ShippingCountry;
            data.Properties[SalesforceVocabulary.Quote.ShippingCountryCode] = value.ShippingCountryCode;
            data.Properties[SalesforceVocabulary.Quote.ShippingHandling]    = value.ShippingHandling;
            data.Properties[SalesforceVocabulary.Quote.ShippingLatitude]    = value.ShippingLatitude;
            data.Properties[SalesforceVocabulary.Quote.ShippingLongitude]   = value.ShippingLongitude;
            data.Properties[SalesforceVocabulary.Quote.ShippingName]        = value.ShippingName;
            data.Properties[SalesforceVocabulary.Quote.ShippingPostalCode]  = value.ShippingPostalCode;
            data.Properties[SalesforceVocabulary.Quote.ShippingState]       = value.ShippingState;
            data.Properties[SalesforceVocabulary.Quote.ShippingStateCode]   = value.ShippingStateCode;
            data.Properties[SalesforceVocabulary.Quote.ShippingStreet]      = value.ShippingStreet;
            data.Properties[SalesforceVocabulary.Quote.Status]     = value.Status;
            data.Properties[SalesforceVocabulary.Quote.Subtotal]   = value.Subtotal;
            data.Properties[SalesforceVocabulary.Quote.Tax]        = value.Tax;
            data.Properties[SalesforceVocabulary.Quote.TotalPrice] = value.TotalPrice;

            if (value.CreatedDate != null)
            {
                data.CreatedDate = DateTime.Parse(value.CreatedDate);
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedDate != null)
            {
                data.ModifiedDate = DateTime.Parse(value.LastModifiedDate);
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Quote.SystemModstamp] = value.SystemModstamp;
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
        protected override Clue MakeClueImpl(PrivateCustomer value, Guid id)
        {
            Clue clue;

            clue = _factory.Create(EntityType.Infrastructure.User, value.ID, id);

            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
                data.Aliases.Add(value.Name);
            }

            // TODO: Could this fail? Is this the right name of the JobData?
            //data.Uri = new Uri($"{_jobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Account.EditUrl] = $"{_jobData.Token.Data}/{value.ID}";
            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }
            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }
            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);

                data.LastChangedBy = createdBy;
            }
            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);

                data.LastChangedBy = createdBy;
            }
            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.SystemModstamp] = value.SystemModstamp;
            }
            if (value.AccountNumber != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.AccountNumber] = value.AccountNumber;
            }
            if (value.AccountSource != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.AccountSource] = value.AccountSource;
            }
            if (value.AgePc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.AgePc] = value.AgePc;
            }
            if (value.AnnualRevenue != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.AnnualRevenue] = value.AnnualRevenue;
            }
            if (value.AudiIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.AudiIdC] = value.AudiIdC;
            }
            if (value.BillingCity != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingCity] = value.BillingCity;
            }
            if (value.BillingCountry != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingCountry] = value.BillingCountry;
            }
            if (value.BillingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingCountryCode] = value.BillingCountryCode;
            }
            if (value.BillingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingPostalCode] = value.BillingPostalCode;
            }
            if (value.BillingAddress != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingAddress] = value.BillingAddress;
            }
            if (value.BillingState != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingState] = value.BillingState;
            }
            if (value.BillingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingStateCode] = value.BillingStateCode;
            }
            if (value.BillingStreet != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BillingStreet] = value.BillingStreet;
            }
            if (value.BouncedPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BouncedPc] = value.BouncedPc;
            }
            if (value.BrandPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BrandPc] = value.BrandPc;
            }
            if (value.Brand2Pc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Brand2Pc] = value.Brand2Pc;
            }
            if (value.BuyingTimeframePc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.BuyingTimeframePc] = value.BuyingTimeframePc;
            }
            if (value.CompanySizePc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.CompanySizePc] = value.CompanySizePc;
            }
            if (value.ContactRolePc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ContactRolePc] = value.ContactRolePc;
            }
            if (value.CurrentCarBrandPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.CurrentCarBrandPc] = value.CurrentCarBrandPc;
            }
            if (value.CustomerCityC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.CustomerCityC] = value.CustomerCityC;
            }
            if (value.CvrC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.CvrC] = value.CvrC;
            }
            if (value.DeadC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.DeadC] = value.DeadC;
            }
            if (value.DealershipidC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.DealershipidC] = value.DealershipidC;
            }
            if (value.Description != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Description] = value.Description;
            }
            if (value.FirstName != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.FirstName] = value.FirstName;
            }
            if (value.HashedEmailPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.HashedEmailPc] = value.HashedEmailPc;
            }
            if (value.ID != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ID] = value.ID;
            }
            if (value.IdEmailC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdEmailC] = value.IdEmailC;
            }
            if (value.IdEmailPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdEmailPc] = value.IdEmailPc;
            }
            if (value.IdentityKitIdPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdentityKitIdPc] = value.IdentityKitIdPc;
            }
            if (value.IdentityKitIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdentityKitIdC] = value.IdentityKitIdC;
            }
            if (value.IdNgC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdNgC] = value.IdNgC;
            }
            if (value.IdNgPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IdNgPc] = value.IdNgPc;
            }
            if (value.Industry != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Industry] = value.Industry;
            }
            if (value.IndustryPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IndustryPc] = value.IndustryPc;
            }
            if (value.InteractionScoreCalculatedPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.InteractionScoreCalculatedPc] = value.InteractionScoreCalculatedPc;
            }
            if (value.InteractionScoreLastUpdatedPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.InteractionScoreLastUpdatedPc] = value.InteractionScoreLastUpdatedPc;
            }
            if (value.InteractionScorePc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.InteractionScorePc] = value.InteractionScorePc;
            }
            if (value.IsActiveUserPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsActiveUserPc] = value.IsActiveUserPc;
            }
            if (value.IsDeleted != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsDeleted] = value.IsDeleted;
            }
            if (value.IsKukCustomerC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsKukCustomerC] = value.IsKukCustomerC;
            }
            if (value.IsMarketingContactPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsMarketingContactPc] = value.IsMarketingContactPc;
            }
            if (value.IsPartner != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsPartner] = value.IsPartner;
            }
            if (value.IsPartnerPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsPartnerPc] = value.IsPartnerPc;
            }
            if (value.IsPersonAccount != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.IsPersonAccount] = value.IsPersonAccount;
            }
            if (value.KukCodeC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.KukCodeC] = value.KukCodeC;
            }
            if (value.KukCustomerIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.KukCustomerIdC] = value.KukCustomerIdC;
            }
            if (value.LastActivityDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastActivityDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }
            if (value.LastName != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.LastName] = value.LastName;
            }
            if (value.LastReferencedDate != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.LastReferencedDate] = DateUtilities.GetFormattedDateString(value.LastReferencedDate);
            }
            if (value.LastViewedDate != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.LastViewedDate] = DateUtilities.GetFormattedDateString(value.LastViewedDate);
            }
            if (value.LeadReassignmentC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.LeadReassignmentC] = DateUtilities.GetFormattedDateString(value.LeadReassignmentC);
            }
            if (value.MarketingContactHemKeyC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.MarketingContactHemKeyC] = DateUtilities.GetFormattedDateString(value.MarketingContactHemKeyC);
            }
            if (value.MarketingContactKeyC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.MarketingContactKeyC] = DateUtilities.GetFormattedDateString(value.MarketingContactKeyC);
            }
            if (value.McApiErrorPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.McApiErrorPc] = DateUtilities.GetFormattedDateString(value.McApiErrorPc);
            }
            if (value.McApiStatusPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.McApiStatusPc] = DateUtilities.GetFormattedDateString(value.McApiStatusPc);
            }
            if (value.NumberOfCarsPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.NumberOfCarsPc] = value.NumberOfCarsPc;
            }
            if (value.NumberOfEmployees != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.NumberOfEmployees] = value.NumberOfEmployees;
            }
            if (value.OrderedLicensesC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.OrderedLicensesC] = value.OrderedLicensesC;
            }
            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.OwnedBy, value, value.OwnerId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.OwnerId));
                data.Authors.Add(createdBy);
            }
            if (value.Ownership != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Ownership);
                data.Properties[SalesforceVocabulary.PrivateCustomer.OwnerShip] = value.Ownership;
            }
            if (value.ParentId != null)
            {
                // TODO: This is wrong! ParentId refers to the parent account
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.Parent, value, value.ParentId);
            }
            if (value.PartnerExtidC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PartnerExtidC] = value.PartnerExtidC;
            }
            if (value.Phone != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Phone] = value.Phone;
                data.Aliases.Add(value.Phone);
            }
            if (value.PhoneFormulaC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PhoneFormulaC] = value.PhoneFormulaC;
            }
            if (value.PhotoUrl != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PhotoUrl] = value.PhotoUrl;
            }
            //if (value.PhotoUrl != null)
            //{
            //    if (value.PhotoUrl != null)
            //    {
            //        try
            //        {
            //            using (var webClient = new WebClient())
            //            {
            //                webClient.Headers.Add("Authorization", "Bearer " + _jobData.Token.AccessToken);
            //                using (var stream = webClient.OpenRead(value.PhotoUrl))
            //                {
            //                    var inArray = StreamUtilies.ReadFully(stream);
            //                    if (inArray != null)
            //                    {
            //                        var rawDataPart = new RawDataPart()
            //                        {
            //                            Type = "/RawData/PreviewImage",
            //                            MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code,
            //                            FileName = "preview_{0}".FormatWith(clue.OriginEntityCode.Key),
            //                            RawDataMD5 = FileHashUtility.GetMD5Base64String(inArray),
            //                            RawData = Convert.ToBase64String(inArray)
            //                        };

            //                        clue.Details.RawData.Add(rawDataPart);

            //                        clue.Data.EntityData.PreviewImage = new ImageReferencePart(rawDataPart);
            //                    }
            //                }
            //            }

            //        }
            //        catch (Exception exception)
            //        {
            //        }
            //    }
            //}
            if (value.PostBoxNameC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PostBoxNameC] = value.PostBoxNameC;
            }
            if (value.PreferedOwnershipPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PreferedOwnershipPc] = value.PreferedOwnershipPc;
            }
            if (value.PersonAssistantPhone != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonAssistantPhone] = value.PersonAssistantPhone;
                data.Aliases.Add(value.PersonAssistantPhone);
            }
            if (value.PersonBirthDate != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonBirthDate] = value.PersonBirthDate;
            }
            //if (value.PersonContactId != null) data.Properties[SalesforceVocabulary.PrivateCustomer.PersonContactId] = value.PersonContactId;

            if (value.PersonContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Infrastructure.Contact, EntityEdgeType.At, value, value.PersonContactId);
                var createdBy = new PersonReference(new EntityCode(EntityType.Infrastructure.Contact, SalesforceConstants.CodeOrigin, value.PersonContactId));
                data.Authors.Add(createdBy);
            }

            if (value.PersonContactIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonContactIdC] = value.PersonContactIdC;
            }
            if (value.PersonDepartment != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonDepartment] = value.PersonDepartment;
            }
            if (value.PersonDonotCall != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonDonotCall] = value.PersonDonotCall;
            }
            if (value.PersonEmail != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonEmail] = value.PersonEmail;
                data.Aliases.Add(value.PersonEmail);
            }
            if (value.PersonEmailBouncedDate != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonEmailBouncedDate] = value.PersonEmailBouncedDate;
            }
            if (value.PersonEmailBouncedReason != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonEmailBouncedReason] = value.PersonEmailBouncedReason;
            }
            if (value.PersonHasOptedOutOfEmail != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonHasOptedOutOfEmail] = value.PersonHasOptedOutOfEmail;
            }
            if (value.PersonHasOptedOutOfFax != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonHasOptedOutOfFax] = value.PersonHasOptedOutOfFax;
            }
            if (value.PersonHomePhone != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonHomePhone] = value.PersonHomePhone;
                data.Aliases.Add(value.PersonHomePhone);
            }
            if (value.PersonLeadSource != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonLeadSource] = value.PersonLeadSource;
            }
            if (value.PersonMailingAddress != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingAddress] = value.PersonMailingAddress;
            }
            if (value.PersonMailingCity != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingCity] = value.PersonMailingCity;
            }
            if (value.PersonMailingCountry != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingCountry] = value.PersonMailingCountry;
            }
            if (value.PersonMailingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingCountryCode] = value.PersonMailingCountryCode;
            }
            if (value.PersonMailingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingPostalCode] = value.PersonMailingPostalCode;
            }
            if (value.PersonMailingState != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingState] = value.PersonMailingState;
            }
            if (value.PersonMailingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingStateCode] = value.PersonMailingStateCode;
            }
            if (value.PersonMailingStreet != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMailingStreet] = value.PersonMailingStreet;
            }
            if (value.PersonMobilePhone != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonMobilePhone] = value.PersonMobilePhone;
                data.Aliases.Add(value.PersonMobilePhone);
            }
            if (value.PersonOtherAddress != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherAddress] = value.PersonOtherAddress;
            }
            if (value.PersonOtherCity != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherCity] = value.PersonOtherCity;
            }
            if (value.PersonOtherCountry != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherCountry] = value.PersonOtherCountry;
            }
            if (value.PersonOtherCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherCountryCode] = value.PersonOtherCountryCode;
            }
            if (value.PersonOtherPhone != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherPhone] = value.PersonOtherPhone;
                data.Aliases.Add(value.PersonOtherPhone);
            }
            if (value.PersonOtherPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherPostalCode] = value.PersonOtherPostalCode;
            }
            if (value.PersonOtherState != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherState] = value.PersonOtherState;
            }
            if (value.PersonOtherStateCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherStateCode] = value.PersonOtherStateCode;
            }
            if (value.PersonOtherStreet != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonOtherStreet] = value.PersonOtherStreet;
            }
            if (value.PersonTitle != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.PersonTitle] = value.PersonTitle;
            }
            if (value.Rating != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Rating);
                data.Properties[SalesforceVocabulary.PrivateCustomer.Rating] = value.Rating;
                data.Tags.Add(new Tag(value.Rating));
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.RecordTypeId] = value.RecordTypeId;
            }
            if (value.ResidenseRegionPc != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ResidenseRegionPc] = value.ResidenseRegionPc;
            }
            if (value.RobinsonC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.RobinsonC] = value.RobinsonC;
            }
            if (value.Salutation != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Salutation] = value.Salutation;
            }
            if (value.SeatIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.SeatIdC] = value.SeatIdC;
            }
            if (value.ShippingAddress != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingAddress] = value.ShippingAddress;
            }
            if (value.ShippingCity != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingCity] = value.ShippingCity;
            }
            if (value.ShippingCountry != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingCountry] = value.ShippingCountry;
            }
            if (value.ShippingCountryCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingCountryCode] = value.ShippingCountryCode;
            }
            if (value.ShippingPostalCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingPostalCode] = value.ShippingPostalCode;
            }
            if (value.ShippingState != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingState] = value.ShippingState;
            }
            if (value.ShippingStateCode != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingStateCode] = value.ShippingStateCode;
            }
            if (value.ShippingStreet != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.ShippingStreet] = value.ShippingStreet;
            }
            if (value.Site != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Site] = value.Site;
            }
            if (value.SkodaIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.SkodaIdC] = value.SkodaIdC;
            }
            if (value.StartedUsingSfC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.StartedUsingSfC] = value.StartedUsingSfC;
            }
            if (value.TickerSymbol != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.TickerSymbol] = value.TickerSymbol;
            }
            if (value.Type != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Tag, EntityEdgeType.For, value, value.Type);
                data.Properties[SalesforceVocabulary.PrivateCustomer.Type] = value.Type;
                data.Tags.Add(new Tag(value.Type));
            }
            if (value.VwEIdCC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.VwEIdCC] = value.VwEIdCC;
            }
            if (value.VwIdC != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.VwIdC] = value.VwIdC;
            }
            if (value.Website != null)
            {
                data.Properties[SalesforceVocabulary.PrivateCustomer.Website] = value.Website;

                Uri website;

                if (Uri.TryCreate(value.Website, UriKind.Absolute, out website))
                {
                    data.ExternalReferences.Add(new Uri(value.Website));
                }
            }
            //if (value.YearStarted != null) data.Properties[SalesforceVocabulary.Account.YearStarted] = value.YearStarted;

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }
Exemple #22
0
        protected override Clue MakeClueImpl(Asset value, Guid id)
        {
            var clue = _factory.Create(EntityType.Note, value.ID, id);
            var data = clue.Data.EntityData;

            if (value.Name != null)
            {
                data.Name        = value.Name;
                data.DisplayName = value.Name;
            }

            if (value.Description != null)
            {
                data.Description = value.Description;
            }

            // TODO: Could this fail? Is this the right name of the JobData?
            //data.Uri = new Uri($"{this.state.JobData.Token.Data}/{value.ID}");
            //data.Properties[SalesforceVocabulary.Asset.EditUrl] = $"{this.state.JobData.Token.Data}/{value.ID}";

            if (value.CreatedDate != null)
            {
                DateTimeOffset createdDate;
                if (DateTimeOffset.TryParse(value.CreatedDate, out createdDate))
                {
                    data.CreatedDate = createdDate;
                }
            }

            if (value.LastModifiedDate != null)
            {
                DateTimeOffset modifiedDate;
                if (DateTimeOffset.TryParse(value.LastModifiedDate, out modifiedDate))
                {
                    data.ModifiedDate = modifiedDate;
                }
            }

            if (value.CreatedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.CreatedBy, value, value.CreatedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.CreatedById));
                data.Authors.Add(createdBy);
            }

            if (value.LastModifiedById != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.ModifiedBy, value, value.LastModifiedById);
                var createdBy = new PersonReference(new EntityCode(EntityType.Person, SalesforceConstants.CodeOrigin, value.LastModifiedById));
                data.Authors.Add(createdBy);
            }

            if (value.AccountId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, value, value.AccountId);
            }

            if (value.ContactId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.For, value, value.ContactId);
            }

            if (value.OwnerId != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.Owns, value, value.OwnerId);
            }

            if (value.ParentId != null)
            {
                // TODO: This is wrong. ParentId refers to the parent asset
                _factory.CreateOutgoingEntityReference(clue, EntityType.Person, EntityEdgeType.Parent, value, value.ParentId);
            }

            if (value.Product2Id != null)
            {
                _factory.CreateOutgoingEntityReference(clue, EntityType.Product, EntityEdgeType.For, value, value.Product2Id);
            }

            if (value.SystemModstamp != null)
            {
                data.Properties[SalesforceVocabulary.Account.SystemModstamp] = value.SystemModstamp;
            }
            if (value.InstallDate != null)
            {
                data.Properties[SalesforceVocabulary.Asset.InstallDate] = DateUtilities.GetFormattedDateString(value.InstallDate);
            }
            if (value.IsCompetitorProduct != null)
            {
                data.Properties[SalesforceVocabulary.Asset.IsCompetitorProduct] = value.IsCompetitorProduct;
            }
            if (value.Price != null)
            {
                data.Properties[SalesforceVocabulary.Asset.Price] = value.Price;
            }
            if (value.PurchaseDate != null)
            {
                data.Properties[SalesforceVocabulary.Asset.PurchaseDate] = DateUtilities.GetFormattedDateString(value.PurchaseDate);
            }
            if (value.Quantity != null)
            {
                data.Properties[SalesforceVocabulary.Asset.Quantity] = value.Quantity;
            }
            if (value.RecordTypeId != null)
            {
                data.Properties[SalesforceVocabulary.Asset.RecordTypeId] = value.RecordTypeId;
            }
            if (value.SerialNumber != null)
            {
                data.Properties[SalesforceVocabulary.Asset.SerialNumber] = value.SerialNumber;
            }
            if (value.Status != null)
            {
                data.Properties[SalesforceVocabulary.Asset.Status] = value.Status;
            }
            if (value.UsageEndDate != null)
            {
                data.Properties[SalesforceVocabulary.Asset.UsageEndDate] = value.UsageEndDate;
            }
            if (value.LastModifiedDate != null)
            {
                DateTime modifiedDateTime;
                if (DateTime.TryParse(value.LastModifiedDate, out modifiedDateTime))
                {
                    data.ModifiedDate = modifiedDateTime;
                }
            }

            _factory.CreateEntityRootReference(clue, EntityEdgeType.ManagedIn);

            return(clue);
        }