Inheritance: IOrganizationService
Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagedTokenCrmService"/> class.
        /// </summary>
        /// <param name="crmService">The CRM service.</param>
        /// <param name="settings">The configuration settings.</param>
        public ManagedTokenCrmService(CrmService crmService, ConfigurationSettings settings)
            : base(settings)
        {
            Assert.ArgumentNotNull(crmService, "crmService");

            this.CrmService = crmService;
        }
Exemplo n.º 2
0
 public GetAuthorizationUrlCommand(
     CrmService crmService,
     AuthorizationService authorizationService)
 {
     this.crmService           = crmService;
     this.authorizationService = authorizationService;
 }
Exemplo n.º 3
0
        public void GetCrmOrganizationService()
        {
            CrmService.Init(new Mock.MockCrmService());
            IOrganizationService service = CrmService.Get();

            Assert.IsNotNull(service);
        }
Exemplo n.º 4
0
        public void DeleteAllEntityRecords()
        {
            if (Logging)
            {
                Console.WriteLine("DELETING ALL ENTITY RECORDS");
            }

            BulkDeleteRequest request = new BulkDeleteRequest
            {
                JobName           = "Delete All",
                ToRecipients      = new Guid[] { },
                CCRecipients      = new Guid[] { },
                RecurrencePattern = string.Empty,
                QuerySet          = new[]
                {
                    new QueryExpression {
                        EntityName = EntityName
                    }
                }
            };

            CrmService.Execute(request);

            if (Logging)
            {
                Console.WriteLine("DELETE REQUEST SENT TO THE SERVER");
            }
        }
Exemplo n.º 5
0
        private void GetFormXml(string formId, out string formXml, out string entityLogicalName)
        {
            formXml           = string.Empty;
            entityLogicalName = string.Empty;
            var fetchData = new
            {
                formid = formId
            };
            var fetchXml = $@"
<fetch>
  <entity name='systemform'>
    <attribute name='formxml' />
    <attribute name='objecttypecode' />
    <filter>
      <condition attribute='formid' operator='eq' value='{fetchData.formid}'/>
    </filter>
  </entity>
</fetch>";
            var rows     = CrmService.RetrieveMultiple(new FetchExpression(fetchXml));

            if (rows.Entities.Count != 1)
            {
                return;
            }
            var entity = rows.Entities[0];

            formXml           = entity.GetAttributeValue <string>("formxml");
            entityLogicalName = entity.GetAttributeValue <string>("objecttypecode");
        }
Exemplo n.º 6
0
    // crm service
    /// <summary>
    ///  Retrieve Entity from Crm service proxy
    /// </summary>
    /// <param name="cservice">Crm Service proxy</param>
    /// <param name="entityName">Entity Name</param>
    /// <param name="entityGuid">Entity Guid (String)</param>
    /// <returns></returns>
    public static DynamicEntity RetriveDynamicEntity(this CrmService cservice, String entityName, String entityGuid)
    {
        // Create/Set the Target object.
        TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic
        {
            EntityName = entityName,
            EntityId   = new Guid(entityGuid)
        };

        // Create/Set the Retrieve object.
        RetrieveRequest retrieve = new RetrieveRequest
        {
            Target = targetRetrieve,
            //ColumnSet = new AllColumns(),
            ReturnDynamicEntities = true        // Indicate that the BusinessEntity should be retrieved as a DynamicEntity.
        };


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

        return(retriveEntity);
    }
Exemplo n.º 7
0
    // crm service
    /// <summary>
    ///  Retrieve Entity from Crm service proxy
    /// </summary>
    /// <param name="cservice">Crm Service proxy</param>
    /// <param name="entityName">Entity Name</param>
    /// <param name="entityGuid">Entity Guid (Guid)</param>
    /// <returns></returns>
    public static DynamicEntity RetriveDynamicEntity(this CrmService cservice, 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)cservice.Execute(retrieve);
        // Extract the DynamicEntity from the request.
        DynamicEntity retriveEntity = (DynamicEntity)retrieved.BusinessEntity;

        return(retriveEntity);
    }
Exemplo n.º 8
0
        public void AddEntityRecord(string documentNumber, string batch, DocumentType typeOfDocument, DateTime date)
        {
            OptionSetValue documentType = new OptionSetValue {
                Value = (int)typeOfDocument
            };

            Entity entityRecord = new Entity(EntityName)
            {
                Attributes =
                {
                    ["acm_documentnumber"]   = documentNumber,
                    ["acm_batch"]            = batch,
                    ["acm_documenttype"]     = documentType,
                    ["acm_invalidationdate"] = date
                }
            };

            Guid id = Guid.Empty;

            try
            {
                id = CrmService.Create(entityRecord);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine($"RECORD CREATED - Guid: {id}");
        }
        private WebRioSsoConfig GetWebRioSsoConfiguration(RequestActionEventArgs args)
        {
            var configuration = new WebRioSsoConfig();

            configuration.JSessionId  = GetParamValue(args, UsdParameter.WebRioJSessionId);
            configuration.RequestType = GetRequestType(args);
            if (configuration.RequestType == RequestType.TravelPlanner)
            {
                configuration.TravelPlannerId = GetParamValue(args, UsdParameter.EntityId);
                if (!string.IsNullOrWhiteSpace(configuration.TravelPlannerId))
                {
                    CrmService.GetInitialsFrom(_client.CrmInterface, configuration);
                }
            }
            if (configuration.RequestType == RequestType.Booking)
            {
                GetBookingDetails(args, configuration);
            }
            else if (configuration.RequestType == RequestType.TravelPlanner)
            {
                GetTravelPlannerDetails(args, configuration);
            }
            CrmService.GetWebRioSsoConfiguration(_client.CrmInterface, configuration);

            configuration.Login      = CrmService.GetSsoLoginDetails(_client.CrmInterface, _client.CrmInterface.GetMyCrmUserId());
            configuration.PrivateKey = CrmService.GetWebRioPrivateKey(_client.CrmInterface);
            ValidateConfiguration(configuration);
            return(configuration);
        }
        static void Main(string[] args)
        {
            UpdateOrganizationSettingApp app = new UpdateOrganizationSettingApp();
            Logger   logger   = app.Logger;
            ExitCode exitCode = ExitCode.None;

            try
            {
                logger.Info("Application started.");

                CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");

                Options options = new Options();

                Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed);

                Connection connection = null;

                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix,
                                                options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout);
                }
                else
                {
                    connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout);
                }

                //TO-DO: this is in experimental mode
                //Console.ReadLine();

                using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService))
                    using (CrmService crmService = new CrmService(organizationServiceContext, connection))
                        using (DeploymentService deploymentService = new DeploymentService(organizationServiceContext, crmService))
                        {
                            var organizationSettings = new Organization
                            {
                                BlockAttachments = options.BlockAttachments,
                                EnableAccessToLegacyWebClientUI = options.EnableAccessToLegacyWebClientUI,
                                LegacyFormRendering             = options.LegacyFormRendering,
                                OrganizationName                = options.OrganizationName,
                                SessionTimeoutEnabled           = options.SessionTimeoutEnabled,
                                SessionTimeoutInMinutes         = options.SessionTimeoutInMinutes,
                                SessionTimeoutReminderInMinutes = options.SessionTimeoutReminderInMinutes,
                                SLAPauseStates = options.SLAPauseStates
                            };
                            deploymentService.UpdateOrganizationSettings(organizationSettings);
                            exitCode = ExitCode.Success;
                        }
            }
            catch (Exception ex)
            {
                exitCode = new ExceptionHandlingService(ex).GetExitCode();
            }
            finally
            {
                logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode);
                Environment.Exit((int)exitCode);
            }
        }
Exemplo n.º 11
0
        public IEnumerable<Order> GetCustomersOrders(CrmService.Contracts.Customer customer)
        {
            var channelFactory = new ChannelFactory<CrmService.Contracts.ICrmService>("CrmEP");

            CrmService.Contracts.ICrmService proxy = channelFactory.CreateChannel();
            return proxy.GetCustomerOrders(customer.ID, null, null);
        }
Exemplo n.º 12
0
        private static void Import(ImportOptions options)
        {
            var crmService            = new CrmService(options.CrmConnectionString);
            var fileService           = new FileService(options.Directory);
            var entityStrategyFactory = new EntityStrategyFactory(crmService);
            var importer = new EntityImporter(crmService, fileService, entityStrategyFactory);

            var commandsList = new List <CrmCommandsQueue>();

            foreach (var entityLogicalName in options.EntitiesList)
            {
                var commands = new CrmCommandsQueue(entityLogicalName);
                importer.Import(commands, entityLogicalName);

                if (!commands.IsEmpty)
                {
                    commandsList.Add(commands);
                }
            }

            using (new DisabledWorkflowsScope(crmService, commandsList.Select(x => x.EntityLogicalName)))
            {
                foreach (var commands in commandsList)
                {
                    commands.ExecuteUpdateSteps(crmService);
                }

                foreach (var commands in commandsList.AsEnumerable().Reverse())
                {
                    commands.ExecuteDeleteSteps(crmService);
                }
            }
        }
Exemplo n.º 13
0
        public static DynamicEntity GetById(CrmService crmService, string entityName, Guid id, params string[] fields)
        {
            QueryExpression query = new QueryExpression(entityName)
            {
                ColumnSet = new ColumnSet(fields),
            };

            ConditionExpression keyExpression    = new ConditionExpression(entityName + "id", ConditionOperator.Equal, id);
            FilterExpression    filterExpression = new FilterExpression();

            filterExpression.Conditions.Add(keyExpression);

            query.Criteria.AddFilter(filterExpression);

            RetrieveMultipleRequest request = new RetrieveMultipleRequest()
            {
                Query = query,
                ReturnDynamicEntities = true
            };

            RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);

            if (response.BusinessEntityCollection.BusinessEntities.Count > 0)
            {
                return(response.BusinessEntityCollection.BusinessEntities[0] as DynamicEntity);
            }

            return(null);
        }
Exemplo n.º 14
0
        public static void SetStateDynamicEntity(CrmService crmService, string entityName, Guid id, string statecode, int statuscode)
        {
            DynamicEntity currentRecord     = GetById(crmService, entityName, id, "statecode", "statuscode");
            bool          shouldUpdateState = true;

            if (currentRecord != null && currentRecord.Properties.Contains("statecode") && currentRecord.Properties.Contains("statuscode"))
            {
                if (statecode != currentRecord.Properties["statecode"].ToString() ||
                    statuscode != ((Status)currentRecord.Properties["statuscode"]).Value)
                {
                    shouldUpdateState = true;
                }
                else
                {
                    shouldUpdateState = false;
                }
            }

            if (shouldUpdateState)
            {
                SetStateDynamicEntityRequest request = new SetStateDynamicEntityRequest()
                {
                    Entity = new Moniker(entityName, id),
                    State  = statecode,
                };

                if (statuscode != -1)
                {
                    request.Status = statuscode;
                }

                crmService.Execute(request);
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            ProcessExecutionContextApp app = new ProcessExecutionContextApp();
            Logger   logger   = app.Logger;
            ExitCode exitCode = ExitCode.None;

            try
            {
                logger.Info("Application started.");

                CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");

                Options options = new Options();

                Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed);

                Connection connection = null;

                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix,
                                                options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout);
                }
                else
                {
                    connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout);
                }

                using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService))
                    using (CrmService crmService = new CrmService(organizationServiceContext, connection))
                        using (IExecutionContextService executionContextService = new ExecutionContextService(organizationServiceContext, connection, crmService))
                        {
                            Console.WriteLine("Press any key to start ...");
                            Console.ReadKey();
                            do
                            {
                                while (!Console.KeyAvailable)
                                {
                                    Console.WriteLine("Press ESC to stop");
                                    executionContextService.ProcessExecutionContexts();
                                    // Wait 5 secs until the next call
                                    // TO-DO: the solution must be more robust to ensure that we are not going to face any pitfalls
                                    Thread.Sleep(5000);
                                }
                            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);

                            exitCode = ExitCode.Success;
                        }
            }
            catch (Exception ex)
            {
                exitCode = new ExceptionHandlingService(ex).GetExitCode();
            }
            finally
            {
                logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode);
                Environment.Exit((int)exitCode);
            }
        }
        public void GetMaxAccountNumber()
        {
            CrmService.Init(new Mock.MockCrmService());

            int maxNumber = new MaxNumberGetter().Get();

            Assert.AreEqual(10, maxNumber);
        }
 public BaseModelTests()
 {
     _mockValidatorFactory = new Mock <IValidatorFactory>();
     _mockValidatorFactory.Setup(m => m.GetValidator(It.IsAny <Type>())).Returns <IValidator>(null);
     _mockService = new Mock <IOrganizationServiceAdapter>();
     _context     = _mockService.Object.Context();
     _crm         = new CrmService(_mockService.Object, _mockValidatorFactory.Object);
 }
Exemplo n.º 18
0
 public ChatbotController(BaiduSession session, ChatService chatService, RobotService robotService, CrmService crmService, ChatLogCache sessionCache)
 {
     _baiduSession = session;
     _chatService  = chatService;
     _robotService = robotService;
     _sessionCache = sessionCache;
     _crmService   = crmService;
 }
Exemplo n.º 19
0
        private static void Btn_OnButtonClick(object sender, BtnClickArgs e)
        {
            var mailService = new MailService();

            mailService.Send();
            var crmService = new CrmService();

            crmService.Send();
        }
Exemplo n.º 20
0
        public void DeleteEntityRecords()
        {
            CsvReader csvrdr = new CsvReader();

            csvrdr.DownloadBaseCsvFiles();

            var collection = csvrdr.ReadCsv("op_vse");

            var requestWithResults = new ExecuteMultipleRequest()
            {
                // Assign settings that define execution behavior: continue on error, return responses.
                Settings = new ExecuteMultipleSettings()
                {
                    ContinueOnError = false,
                    ReturnResponses = true
                },
                // Create an empty organization request collection.
                Requests = new OrganizationRequestCollection()
            };

            EntityCollection entityCollection = new EntityCollection()
            {
                EntityName = "acm_listinvaliddocument"
            };

            foreach (var item in collection)
            {
                if (!string.IsNullOrEmpty(item.DocumentId))
                {
                    Entity tempEntity = new Entity("acm_listinvaliddocument")
                    {
                        Attributes =
                        {
                            ["acm_documentnumber"]   = item.DocumentId,
                            ["acm_documenttype"]     = DocumentType.WithoutSeries,
                            ["acm_invalidationdate"] = item.InvalidationDate
                        }
                    };

                    entityCollection.Entities.Add(tempEntity);
                }

                Console.WriteLine(item.DocumentId);
            }

            foreach (var entity in entityCollection.Entities)
            {
                //RetrieveMultipleRequest and then delete
                DeleteRequest deleteRequest = new DeleteRequest {
                    new EntityReference()
                };
                requestWithResults.Requests.Add(deleteRequest);
            }

            CrmService.Execute(requestWithResults);
        }
Exemplo n.º 21
0
        public static CrmModelApps GetApps(CrmService service)
        {
            var query = new QueryExpression("appmodule");

            query.ColumnSet.AddColumns("uniquename");

            var result = service.RetrieveMultiple(query);

            return(new CrmModelApps(result.Entities));
        }
Exemplo n.º 22
0
        public BaseModelTests()
        {
            var mockAppSettings = new Mock <IAppSettings>();

            _mockValidatorFactory = new Mock <IValidatorFactory>();
            _mockValidatorFactory.Setup(m => m.GetValidator(It.IsAny <Type>())).Returns <IValidator>(null);
            _mockService = new Mock <IOrganizationServiceAdapter>();
            _context     = _mockService.Object.Context();
            _crm         = new CrmService(_mockService.Object, _mockValidatorFactory.Object, mockAppSettings.Object, new DateTimeProvider());
        }
 public CheckSubmittedDailyReportsTask(
     CrmService crmService,
     TelegramBot telegramBot,
     NotificationSubscriptionService subscriptionService,
     TelemetryClient telemetry)
 {
     this.crmService          = crmService;
     this.telegramBot         = telegramBot;
     this.subscriptionService = subscriptionService;
     this.telemetry           = telemetry;
 }
Exemplo n.º 24
0
 public DriveRecordService(CrmService crmService, IDriveRecordRepository driveRecordRepository)
 {
     _crmService            = crmService;
     _driveRecordRepository = driveRecordRepository;
     dicHeadKey             = "Prefer";
     dicHead = new Dictionary <string, IEnumerable <string> >();
     dicHead.Add(dicHeadKey, new List <string>()
     {
         "odata.include-annotations=\"*\""
     });
 }
Exemplo n.º 25
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=\"*\""
     });
 }
Exemplo n.º 26
0
 public BaseDataService(CrmService crmService, IBaseDataRepository baseDataRepository)
 {
     _crmService         = crmService;
     _baseDataRepository = baseDataRepository;
     dicHeadKey          = "Prefer";
     dicHead             = new Dictionary <string, IEnumerable <string> >();
     dicHead.Add(dicHeadKey, new List <string>()
     {
         "odata.include-annotations=\"*\""
     });
 }
Exemplo n.º 27
0
 public UpdateDailyReportCommand(
     CrmService crmService,
     ConversationService conversationService,
     IAppUnitOfWorkFactory uowFactory,
     TelemetryClient telemetry)
 {
     this.crmService          = crmService;
     this.conversationService = conversationService;
     this.uowFactory          = uowFactory;
     this.telemetry           = telemetry;
 }
Exemplo n.º 28
0
 public OnlyLeadService(CrmService crmService, IOnlyLeadRepository onlyLeadRepository)
 {
     _crmService         = crmService;
     _onlyLeadRepository = onlyLeadRepository;
     dicHeadKey          = "Prefer";
     dicHead             = new Dictionary <string, IEnumerable <string> >();
     dicHead.Add(dicHeadKey, new List <string>()
     {
         "odata.include-annotations=\"*\""
     });
 }
        private WebRioResponse OpenNewConsultation(CrmServiceClient crmInterface, WebRioSsoConfig configuration, string token)
        {
            Customer cust = CrmService.GetCustomerDataForWebRioNewConsultation(_client.CrmInterface, configuration.CustomerId);

            configuration.Data = SerializeNewConsultationSsoRequestToJson(cust);

            var url      = $"{configuration.ServiceUrl}/{configuration.NewConsultationApi}";
            var response = SendRequest(url, token, configuration.JSessionId, configuration.Data);
            var content  = GetResponseContent(response);

            return(GetWebRioSsoResponse(content));
        }
Exemplo n.º 30
0
        public override string[] GetUsersInRole(string roleName)
        {
            Assert.ArgumentNotNull(roleName, "roleName");
            ConditionalLog.Info(string.Format("GetUsersInRole({0}). Started.", roleName), this, TimerAction.Start, "getUsersInRole");
            string text = base.CacheService.MembersCache.Get(roleName);

            if (text != null)
            {
                ConditionalLog.Info(string.Format("GetUsersInRole({0}). Finished (users have been retrieved from cache).", roleName), this, TimerAction.Stop, "getUsersInRole");
                return(text.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
            }

            // set up a query for the list to check type
            ColumnSet columnSet = new ColumnSet();

            columnSet.Attributes = new string[]
            { "listname", "query", "type" };

            QueryExpression query = new QueryExpression();

            query.ColumnSet = columnSet;

            ConditionExpression listnameCondition = new ConditionExpression();

            listnameCondition.AttributeName = "listname";
            listnameCondition.Operator      = ConditionOperator.Equal;
            listnameCondition.Values        = new String[] { roleName };

            FilterExpression filterList = new FilterExpression();

            filterList.Conditions = new ConditionExpression[]
            {
                listnameCondition
            };
            filterList.FilterOperator = LogicalOperator.And;
            query.EntityName          = "list";
            query.Criteria            = filterList;

            // Execute the query
            RetrieveMultipleRequest req = new RetrieveMultipleRequest();

            req.Query = query;
            req.ReturnDynamicEntities = true;

            RetrieveMultipleResponse res
                = (RetrieveMultipleResponse)CrmService.Execute(req);

            if (res.BusinessEntityCollection.BusinessEntities.GetLength(0) > 0)
            {
                DynamicEntity myList = (DynamicEntity)res.BusinessEntityCollection.BusinessEntities[0];
            }
            return(base.GetUsersInRole(roleName));
        }
Exemplo n.º 31
0
        private string GetLogicalCollectionName(string entity)
        {
            var request = new RetrieveEntityRequest
            {
                EntityFilters = EntityFilters.Attributes,
                LogicalName   = entity
            };
            var response = (RetrieveEntityResponse)CrmService.Execute(request);

            IsCustomEntity = response.EntityMetadata.IsCustomEntity ?? false;
            return(response.EntityMetadata.LogicalCollectionName);
        }
Exemplo n.º 32
0
        /// <summary>
        /// The class constructor.
        /// It initializes the connection parameters
        /// </summary>
        public ESC_CRM(string crmURL, string crmURLMD, string crmName, string crmLogin, string crmPassword, string crmDomain)
        {
            m_crmService = new CrmService();
            m_crmURL = crmURL; 				//ex : http://crm.domain.net/[OrganizationName]/XRMServices/2011/Organization.svc
            m_crmURL_MD = crmURLMD;			//ex : https://crm.domain.net/mscrmservices/2007/metadataservice.asmx
            m_crmName = crmName;			//OrganizationName
            m_crmLogin = crmLogin;
            m_crmPassword = crmPassword;
            m_crmDomain = crmDomain;
            m_isconnected = false;

            m_propertyList = new ArrayList();
            m_filterExpression = new FilterExpression();
        }
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            CrmService myService = new CrmService();
            myService.Credentials = new NetworkCredential("Administrator", "mypassword");

            CrmQueryProvider provider = new CrmQueryProvider(myService);
            var results = from a in provider.Linq<account>()
                          where a.name == "Paul"
                          select new { a.name, a.accountid };

            foreach (var account in results)
            {
                Console.WriteLine("Name: " + account.name);
            }
        }
Exemplo n.º 34
0
 public static Customer MapToTicketingCustomer(CrmService.Contracts.Customer crm_cust)
 {
     return new TicketingOffice.TicketingService.Contracts.Customer()
     {
         Address = crm_cust.Address,
         BirthDate = crm_cust.BirthDate,
         CellNumber = crm_cust.CellNumber,
         City = crm_cust.City,
         Country = crm_cust.Country,
         Email = crm_cust.Email,
         FirstName = crm_cust.FirstName,
         ID = crm_cust.ID,
         LastName = crm_cust.LastName,
         PhoneNumber = crm_cust.PhoneNumber,
         ReductionCode = crm_cust.ReductionCode
     };
 }
        public IHttpActionResult UpdateBulkEmailForContact(string orgName, string contactId, [FromUri]DynamicsCredentials credentials)
        {
            try
            {
                crmService = new CrmService(credentials, orgName);

                crmService.changeBulkEmail(contactId);
                crmService.logout();

                return Ok();
            }
            catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException)
            {
                return Unauthorized();
            }
            catch (Exception ex) when (ex is NullReferenceException || ex is FormatException || ex is FaultException)
            {
                return BadRequest();
            }
        }
        public IHttpActionResult GetContactsWithAttributes(string orgName, string listId, [FromUri]DynamicsCredentials credentials, [FromUri] int top = 0, [FromUri] bool translate = true, [FromUri] bool allAttributes = true)
        {
            try
            {
                crmService = new CrmService(credentials, orgName);
                helper = new CrmApiHelper(crmService);

                var contacts = crmService.getContactsInList(listId, allAttributes, top);
                var goodLookingContacts = helper.getValuesFromContacts(contacts, translate, allAttributes);
                crmService.logout();

                return Ok(goodLookingContacts);
            }
            catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException)
            {
                return Unauthorized();
            }
            catch (Exception ex) when (ex is NullReferenceException || ex is FormatException)
            {
                return BadRequest();
            }
        }
        public IHttpActionResult GetListsWithAllAttributes(string orgName, [FromUri]DynamicsCredentials credentials, [FromUri] bool translate = false, [FromUri] bool allAttributes = true)
        {
            try
            {
                crmService = new CrmService(credentials, orgName);
                helper = new CrmApiHelper(crmService);

                var lists = crmService.getAllLists(allAttributes);
                var goodLookingLists = helper.getValuesFromLists(lists, translate, allAttributes);
                crmService.logout();

                return Ok(goodLookingLists);
            }
            catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException)
            {
                return Unauthorized();
            }
            catch(NullReferenceException)
            {
                return BadRequest();
            }
        }
Exemplo n.º 38
0
 internal CrmApiHelper(CrmService service)
 {
     crmService = service;
 }
        public IHttpActionResult ValidateCredentials([FromUri]DynamicsCredentials credentials)
        {
            try
            {
                crmService = new CrmService(credentials);
                var organizations = crmService.getOrganizations();
                crmService.logout();

                return Ok(organizations);
            }
            catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException)
            {
                return Unauthorized();
            }
            catch(Exception ex)
            {
                return InternalServerError(ex);
            }
        }