예제 #1
0
    /// <summary>
    /// Retrieve Entity from ICrmservice
    /// </summary>
    /// <param name="iservice">ICrmService</param>
    /// <param name="entityName">Entity Name</param>
    /// <param name="entityGuid">Entity Guid(Guid)</param>
    /// <param name="retrieveAllColumns">True to retrieve all columns </param>
    /// <returns></returns>
    public static DynamicEntity RetriveDynamicEntity(this ICrmService iservice, String entityName, Guid entityGuid, Boolean retrieveAllColumns)
    {
        // Create/Set the Target object.
        TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic
        {
            EntityName = entityName,
            EntityId   = (entityGuid)
        };

        // Create/Set the Retrieve object.
        RetrieveRequest retrieve = new RetrieveRequest();

        retrieve.Target = targetRetrieve;
        if (retrieveAllColumns == true)
        {
            retrieve.ColumnSet = new AllColumns();
        }                                          //// Indicate to retrieve all columns
        retrieve.ReturnDynamicEntities = true;     // Indicate that the BusinessEntity should be retrieved as a DynamicEntity.

        // Execute the request.
        RetrieveResponse retrieved = (RetrieveResponse)iservice.Execute(retrieve);
        // Extract the DynamicEntity from the request.
        DynamicEntity retriveEntity = (DynamicEntity)retrieved.BusinessEntity;

        return(retriveEntity);
    }
예제 #2
0
 public ActivitySyncService(ILog log, RetrieverSettings settings, ICrmService crmService, IAnytimeCollectService anytimeCollectService)
 {
     _log                   = log;
     _settings              = settings;
     _crmService            = crmService;
     _anytimeCollectService = anytimeCollectService;
 }
예제 #3
0
 public CustomerWithCRMService(
     ICustomerService customerService,
     ICrmService crmService) : base(customerService)
 {
     //crm servis call
     _crmServices = crmService;
 }
예제 #4
0
        public bool ExportPagesFromOrders(
            IEnumerable <Order> orders,
            ICrmService crmService,
            ILocationService locationService)
        {
            IEnumerable <PageXml> pages = GetPagesFromOrders(orders, crmService, locationService);

            foreach (var pageXml in pages)
            {
                string customerName = pageXml.Customer.Name;
                string fileName     = string.Format("CustomerOrders-{0}-{1}.xml", customerName, DateTime.Now);
                string filePath     = Path.Combine(exportFolder, fileName);

                if (!overwrite && File.Exists(filePath))
                {
                    return(false);
                }

                XmlSerializer serializer = new XmlSerializer(typeof(PageXml));
                using (StreamWriter sw = File.CreateText(filePath))
                {
                    serializer.Serialize(sw, pageXml);
                }
            }
            return(true);
        }
예제 #5
0
        public ExportDataProvider(IRepository repository, ICrmService crmService)
        {
            this.repository = repository;
            this.crmService = crmService;

            Settings = ExportSettings.Default;
        }
        public void EnrichWithExternalData(PageXml content, PageData externalData, IRepository repository,
                                           ICrmService crmService, int salesOrders, bool addCustomerDetails, ILocationService locationService)
        {
            // enrich with  externalData other than customer


            if (externalData.CustomerData != null)
            {
                // enrich with externalData.CustomerData
            }
            else
            {
                CustomerInfo customerData = crmService.GetCustomerInfo(content.Customer.Name);
            }

            if (salesOrders > 0)
            {
                var orders = repository.GetEntities <Order>()
                             .Where(o => o.Customer.CompanyName == content.Customer.Name)
                             .OrderBy(o => o.OrderDate)
                             .Take(salesOrders);

                //enrich with orders
            }
        }
예제 #7
0
        public async Task <CrmEntityCollection> ExecuteAsync(ICrmService crmService, string entityName, XDocument document, Guid?userId = null)
        {
            try
            {
                var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);
                var dicHead  = new Dictionary <string, IEnumerable <string> >();
                dicHead.Add("Prefer", new List <string>()
                {
                    "odata.include-annotations=\"*\""
                });
                var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage()
                {
                    EntityName  = entityName,
                    FetchXml    = document,
                    ProxyUserId = userInfo?.systemuserid
                };
                fetchRequest.Headers.Add("Prefer", dicHead["Prefer"]);
                var crmResponseMessage = await crmService.Execute(fetchRequest);

                var resultsList = crmResponseMessage as CrmRetrieveMultipleFetchResponseMessage;
                return(resultsList.Value);
            }
            catch (Exception ex)
            {
                return(new CrmEntityCollection());
            }
        }
예제 #8
0
        private void MapRelationshipAttributesToEntity(Entity source, ICrmService crm, OrganizationServiceContext context)
        {
            foreach (var property in GetProperties(this))
            {
                var attribute = EntityRelationshipAttribute(property);
                var value     = property.GetValue(this);

                if (attribute == null || value == null)
                {
                    continue;
                }

                foreach (var relatedModel in EnumerableRelationshipModels(value))
                {
                    var shouldMap = ShouldMapRelationship(property.Name, relatedModel, crm);
                    if (!shouldMap)
                    {
                        continue;
                    }

                    var target = relatedModel.ToEntity(crm, context);
                    crm.AddLink(source, new Relationship(attribute.Name), target, context);
                }
            }
        }
예제 #9
0
 public CrmController(ICrmService crmService,
                      ICrmTypeService crmTypeService,
                      ICrmStatusService crmStatusService,
                      ICrmPriorityService crmPriorityService,
                      ICustomerSourceService customerSourceService,
                      IProductGroupService productGroupService,
                      ICustomerGroupService customerGroupService,
                      ICustomerVipService customerVipService,
                      IProvinceService provinceService,
                      IUserService userService,
                      IMapper mapper,
                      ILogger <CrmController> logger) : base(logger)
 {
     _crmService            = crmService;
     _crmTypeService        = crmTypeService;
     _crmStatusService      = crmStatusService;
     _crmPriorityService    = crmPriorityService;
     _customerSourceService = customerSourceService;
     _productGroupService   = productGroupService;
     _customerGroupService  = customerGroupService;
     _customerVipService    = customerVipService;
     _provinceService       = provinceService;
     _userService           = userService;
     _mapper = mapper;
 }
        public void ExecuteDeleteSteps(ICrmService crmService)
        {
            var requestsQueue = new Queue <OrganizationRequest>(deleteStageSteps);

            while (requestsQueue.Count > 0)
            {
                var request = requestsQueue.Dequeue();
                try
                {
                    var res = crmService.ExecuteRequest(request);
                }
                catch (Exception e)
                {
                    string message = e.Message;

                    if (request is DeleteRequest deleteRequest)
                    {
                        var target = deleteRequest.Target;
                        message = $"Error while trying to delete {target.LogicalName}/{target.Id}: {message}";
                    }

                    Log.Error(message, e);
                    Debugger.Break();
                }
            }
        }
예제 #11
0
        public PageXml GetPageForOrders(IEnumerable <Order> orders, ICrmService crmService, ILocationService locationService)
        {
            string customerName = GetCustomerNameFromFirstOrder();

            PageXml content = new PageXml {
                Customer = new CustomerXml {
                    Name = customerName
                }
            };

            if (crmService != null)
            {
                CustomerInfo customerData = crmService.GetCustomerInfo(content.Customer.Name);
                //enrich with data from crm
            }

            //enrich content with orders

            if (locationService != null)
            {
                foreach (var address in content.Customer.Addresses)
                {
                    Coordinates coordinates = locationService.GetCoordinates(address.City, address.Street, address.Number);
                    if (coordinates != null)
                    {
                        address.Coordinates = string.Format("{0},{1}", coordinates.Latitude, coordinates.Longitude);
                    }
                }
            }

            return(content);
        }
예제 #12
0
        public string ProcessSurvey(string surveyData, ICrmService crmService)
        {
            var failedSurveys = string.Empty;

            if (string.IsNullOrWhiteSpace(surveyData))
            {
                throw new ArgumentNullException(Constants.Parameters.DataJson);
            }
            if (crmService == null)
            {
                throw new ArgumentNullException(Constants.Parameters.CrmService);
            }
            try
            {
                var response = crmService.ExecuteActionForSurveyCreate(surveyData);
                if (response == null)
                {
                    throw new InvalidOperationException(Constants.Messages.ResponseNull);
                }
                failedSurveys = ProcessResponse(response);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Unexpected error occured at ProcessSurvey::Message:{0}||Trace:{1}", ex.Message, ex.StackTrace.ToString());
                return(Constants.General.Error);
            }
            return(failedSurveys);
        }
예제 #13
0
 public HubService(ICrmService crmService, IHubIntegration crmIntegration, ILogger <HubService> logger, IHostingEnvironment env)
 {
     _env            = env;
     _logger         = logger;
     _crmService     = crmService;
     _crmIntegration = crmIntegration;
 }
예제 #14
0
파일: MainDialog.cs 프로젝트: mluvii/dots
 public MainDialog(IDialogFactory dialogFactory, ICrmService crmService, string personId,
                   DebugOptions debugOptions = DebugOptions.None)
 {
     this.dialogFactory = dialogFactory;
     this.crmService    = crmService;
     this.personId      = personId;
     this.debugOptions  = debugOptions;
 }
예제 #15
0
 public AccountQueries(ICrmService crmService)
 {
     if (crmService == null)
     {
         throw new ArgumentNullException(nameof(crmService));
     }
     _crmService = crmService;
 }
예제 #16
0
        public PortalService(CrmServiceContext organizationServiceContext, ICrmService crmService) : base(organizationServiceContext)
        {
            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);

            CrmService = crmService ?? throw new ArgumentNullException(nameof(crmService));

            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);
        }
예제 #17
0
        public TeachingEventUpsertOperationValidator(ICrmService crm)
        {
            _crm = crm;

            RuleFor(operation => operation.ReadableId)
            .Must((te, _) => BeUniqueReadableId(te))
            .WithMessage("Must be unique");
        }
예제 #18
0
 public CrmFileBlocksStream(string entityName, Guid entityID, string fileAttributeName, long fileSize, ICrmService crmService, Guid?proxyUserId)
 {
     _entityID          = entityID;
     _fileAttributeName = fileAttributeName;
     _entityID          = entityID;
     _fileSize          = fileSize;
     _crmService        = crmService;
     _proxyUserId       = proxyUserId;
 }
예제 #19
0
 public async Task <IServiceproxyService> Create()
 {
     _crmService = StartupHelper.CreateCrmService();
     return(await Task <IServiceproxyService> .Run(() =>
     {
         _serviceproxyService = new ServiceproxyService(_crmService);
         return _serviceproxyService;
     }));
 }
예제 #20
0
 public CandidatesController(
     ICandidateAccessTokenService accessTokenService,
     INotifyService notifyService,
     ICrmService crm)
 {
     _accessTokenService = accessTokenService;
     _notifyService      = notifyService;
     _crm = crm;
 }
예제 #21
0
        public BaseModel(Entity entity, ICrmService crm, IValidatorFactory vaidatorFactory)
            : this()
        {
            Id = entity.Id;

            MapFieldAttributesFromEntity(entity);
            MapRelationshipAttributesFromEntity(entity, crm, vaidatorFactory);
            NullifyInvalidFieldAttributes(vaidatorFactory);
        }
예제 #22
0
 public CandidatesController(
     ICandidateAccessTokenService tokenService,
     ICrmService crm,
     IBackgroundJobClient jobClient)
 {
     _crm          = crm;
     _tokenService = tokenService;
     _jobClient    = jobClient;
 }
예제 #23
0
 public async Task <ICustomerService> Create()
 {
     _crmService = StartupHelper.CreateCrmService();
     return(await Task <ICustomerService> .Run(() =>
     {
         _customerService = new CustomerService(_crmService);
         return _customerService;
     }));
 }
예제 #24
0
 public async Task <ISysConfigService> Create()
 {
     _crmService = StartupHelper.CreateCrmService();
     return(await Task <IStoreService> .Run(() =>
     {
         _sysConfigService = new SysConfigService(_crmService);
         return _sysConfigService;
     }));
 }
예제 #25
0
        public CrmHelper(ICrmService crmService, ILogging logging, ICrmResourceStrings crmResourceStrings)
        {
            if (crmService == null) throw new ArgumentNullException("crmService");
            if (logging == null) throw new ArgumentNullException("logging");
            _crmService = crmService;
            _logging = logging;
            _crmResourceStrings = crmResourceStrings;

            _logging.Write(GetString("LoggingCrmHelperCreated", "Created CrmHelper"));
        }
예제 #26
0
 public CrmCommonController(ICrmService crmService,
                            ICrmOrganizationService organizationService,
                            ILeadService <Lead> leadService,
                            IMapper mapper)
 {
     _crmService          = crmService;
     _organizationService = organizationService;
     _leadService         = leadService;
     _mapper = mapper;
 }
예제 #27
0
        public CrmServiceTests()
        {
            var mockValidatorFactory = new Mock <IValidatorFactory>();

            mockValidatorFactory.Setup(m => m.GetValidator(It.IsAny <Type>())).Returns <IValidator>(null);

            _mockService = new Mock <IOrganizationServiceAdapter>();
            _context     = new OrganizationServiceContext(new Mock <IOrganizationService>().Object);
            _mockService.Setup(mock => mock.Context()).Returns(_context);
            _crm = new CrmService(_mockService.Object, mockValidatorFactory.Object);
        }
예제 #28
0
        protected override bool ShouldMap(ICrmService crm)
        {
            var alreadyRegistered = !crm.CandidateYetToRegisterForTeachingEvent(CandidateId, EventId);

            if (alreadyRegistered)
            {
                return(false);
            }

            return(base.ShouldMap(crm));
        }
예제 #29
0
 public AppointmentInfoService(CrmService crmService, IAppointmentInfoRepository appointmentInfoRepository)
 {
     _crmService = crmService;
     _appointmentInfoRepository = appointmentInfoRepository;
     dicHeadKey = "Prefer";
     dicHead    = new Dictionary <string, IEnumerable <string> >();
     dicHead.Add(dicHeadKey, new List <string>()
     {
         "odata.include-annotations=\"*\""
     });
 }
 public CandidatesController(
     ICandidateAccessTokenService accessTokenService,
     INotifyService notifyService,
     ICrmService crm,
     IAppSettings appSettings)
 {
     _accessTokenService = accessTokenService;
     _notifyService      = notifyService;
     _crm         = crm;
     _appSettings = appSettings;
 }
예제 #31
0
 public CustomerService(ICrmService crmService)
 {
     _crmService = crmService;
     dicHeadKey  = "Prefer";
     dicHead     = new Dictionary <string, IEnumerable <string> >();
     dicHead.Add(dicHeadKey, new List <string>()
     {
         "odata.include-annotations=\"*\""
     });
     pageCount = 10;
 }
예제 #32
0
        public ViewModelBase()
        {
            _settings = SettingsService.Instance;
            _helper = ActivityTrackerHelper.Instance;

            if (_settings.CrmVersion != null)
            {
                if (_settings.CrmVersion.Major == 8)
                    crmservice = new CrmWebAPIService();
                else
                    crmservice = new CrmSoapService();
            }
        }
예제 #33
0
 public CrmEmailProvider()
 {
     crmService = DependencyResolver.Current.GetService<ICrmService>();
     mailSenderService = DependencyResolver.Current.GetService<IMailSenderService>();
     initLists();
 }
예제 #34
0
파일: Audit.cs 프로젝트: ccellar/crmaudit
        private void CreateNote(ICrmService crmService, string entityName, Guid entityId, string subject, string body)
        {
            // Create the Note object and set the parent object.
            var note = new annotation
            {
                objectid = new Lookup(entityName, entityId),
                objecttypecode = new EntityNameReference(entityName),
                subject = subject,
                notetext = body
            };

            // Set the note text and subject

            // Create the note
            crmService.Create(note);
        }
예제 #35
0
 public MailingController(ICrmService _crmService, IMailSenderService _service, IAlertsProvider _alerts, IArticleService _articleService, IMailAccountsService _mailAccountsService, IAllEmailProvidersService _allEmailProvidersService, ISettingsProvider _settingsProvider, IUsersService _userService, IMailSendingUtilsService _mailSendingUtils)
 {
     this.crmService = _crmService;
     this.settingsProvider = _settingsProvider;
     this._userService = _userService;
     this._mailSendingUtils = _mailSendingUtils;
     service = _service;
     alerts = _alerts;
     articleService = _articleService;
     mailAccountsService = _mailAccountsService;
     allEmailProvidersService = _allEmailProvidersService;
 }
예제 #36
0
 public NewsController(ICrmService _crmService, ISettingsProvider _settingsProvider, ITranslationsService _translations)
 {
     settingsProvider = _settingsProvider;
     this.translations = _translations;
     crmService = _crmService;
 }