Exemplo n.º 1
0
        /// <summary>
        /// load files from FieldManagmentService
        /// </summary>
        /// <param name="service"></param>
        private static void CallFieldManagementService(ServiceConfig service)
        {
            var crmOnDemandFieldManagementService = new CrmOnDemandFieldManagementService.FieldManagementService();

            var requestContext = crmOnDemandFieldManagementService.RequestSoapContext;

            UsernameToken userToken = new UsernameToken(service.Username, service.Password, PasswordOption.SendPlainText);

            requestContext.Security.Tokens.Add(userToken);

            var fieldManagementReadAll_Input = new CrmOnDemandFieldManagementService.FieldManagementReadAll_Input();
            fieldManagementReadAll_Input.IncludeAll = true;

            log.Info("Making service call to " + FIELD_MANAGEMENT_READ_ALL);
            var fieldManagementReadAll_Output = crmOnDemandFieldManagementService.FieldManagementReadAll(fieldManagementReadAll_Input);

            log.Debug("Service call to " + FIELD_MANAGEMENT_READ_ALL + " returned successfully");

            XmlTextWriter writer = new XmlTextWriter(service.ResponseFileName, null);
            writer.Formatting = Formatting.Indented;
            crmOnDemandFieldManagementService.ResponseSoapContext.Envelope.WriteContentTo(writer);
            writer.Flush();

            var msg = FIELD_MANAGEMENT_READ_ALL + " output saved to file: " + service.ResponseFileName;
            log.Info(msg);
            Console.WriteLine(msg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// load the web service configuration.
        /// each wb service is identified by name. it also needs username and pwd and the name of the output file.
        /// </summary>
        /// <param name="ignoreFile"></param>
        /// <returns></returns>
        private static List<ServiceConfig> LoadServiceConfig(string serviceFile)
        {
            var Services = new List<ServiceConfig>();

            XmlDocument doc = new XmlDocument();
            doc.Load(serviceFile);
            XmlNodeList nodes = doc.SelectNodes("/services/service");
            int i = 0;
            foreach (XmlNode service in nodes)
            {
                var serviceConfig = new ServiceConfig
                {
                    ServiceName = service.SelectSingleNode("name").InnerText,
                    Username = service.SelectSingleNode("username").InnerText,
                    Password = service.SelectSingleNode("password").InnerText,
                    ResponseFileName = service.SelectSingleNode("responseFullPathFileName").InnerText
                };

                Services.Add(serviceConfig);
                i++;
                log.InfoFormat("Service[{0}] loaded: {1}", i, serviceConfig.ToString());
            }
            return Services;
        }