Example #1
0
 public GlobalExceptionFilter(ILogger <GlobalExceptionFilter> logger, IErrorInfoBuilder errorInfoBuilder,
                              IOptions <ServiceInformation> options)
 {
     _logger           = logger;
     _errorInfoBuilder = errorInfoBuilder;
     _serviceInfo      = options.Value;
 }
Example #2
0
        static void Main(string[] args)
        {
            //服务发现
            string             serviceKey = "Foo.Services";
            ServiceInformation service    = ServiceBus.Get(serviceKey).Result.FeelingLucky();

            //service = new ServiceInformation()
            //{
            //    Host = "localhost",
            //    Port = 50051,
            //};
            while (true)
            {
                string  target  = $"{service.Host}:{service.Port}";
                Channel channel = new Channel(target, ChannelCredentials.Insecure);
                var     client  = new Greeter.GreeterClient(channel);

                Console.Write("Input your name: ");
                String user = Console.ReadLine();

                var request = new HelloRequest {
                    Name = user
                };
                Console.WriteLine($"request: \n{JsonConvert.SerializeObject(request)}");

                var reply = client.SayHello(request);
                Console.WriteLine($"reply: \n{JsonConvert.SerializeObject(reply)}");

                channel.ShutdownAsync().Wait();
            }
        }
        private T ServiceProxyFactory(IOrderedEnumerable <IProxyInterceptor> interceptors = null,
                                      Dictionary <string, string> headers = null, ServiceInformation <T> serviceInformation = null)
        {
            Stopwatch sp = new Stopwatch();

            sp.Start();
            var clientType = typeof(T);

            if (_clients.ContainsKey(clientType))
            {
                return(_clients[clientType] as T);
            }

            T proxy = null;

            lock (_lockObj)
            {
                if (_clients.ContainsKey(clientType))
                {
                    return(_clients[clientType] as T);
                }

                proxy = CreateInterceptor(interceptors, new Headers(headers), serviceInformation, clientType);
                _clients.TryAdd(clientType, proxy);
            }

            sp.Stop();
            //Console.WriteLine($"proxy creation time {sp.ElapsedMilliseconds}");
            return(proxy);
        }
Example #4
0
        public ServiceInformation GetService(string serviceName)
        {
            ServiceInformation si = null;
            var osInfo            = systemInformation.GetOSInfo();

            //Window
            if (osInfo.Platform == OSPlatformType.Windows)
            {
                var service = new ServiceController(serviceName);

                if (ExistsService(service))
                {
                    si = GetService(service);
                }
            }
            else if (osInfo.Platform == OSPlatformType.Linux)
            {
                si = GetServiceWithListUnits(serviceName);
                if (si == null)
                {
                    si = GetServiceWithListUnitsFile(serviceName);
                    if (si != null)
                    {
                        si.Description = "Not available";
                        si.State       = GetServiceState(serviceName);
                    }
                }
            }
            return(si);
        }
        public int UpdateServiceInformationBuIndID(ServiceInformation serviceInformation)
        {
            iwaywardDataContext db = new iwaywardDataContext();

            try
            {
                var result = db.ServiceInformation.Single(c => c.ServicID == serviceInformation.ServicID && c.UserID == serviceInformation.UserID);

                result.title       = serviceInformation.title;
                result.serviceTyoe = serviceInformation.serviceTyoe;
                result.sendTime    = serviceInformation.sendTime;
                result.IndID       = serviceInformation.IndID;
                result.region      = serviceInformation.region;
                result.city        = serviceInformation.city;
                result.province    = serviceInformation.province;
                result.macrk       = serviceInformation.macrk;
                result.longitude   = serviceInformation.longitude;
                result.latitude    = serviceInformation.latitude;

                db.SubmitChanges();
                return(result.ServicID);
            }
            catch
            {
                return(0);
            }
        }
        public void Concurrent_Select_Test()
        {
            var services = new List <ServiceInformation>()
            {
                new ServiceInformation()
                {
                    Host = "192.168.1.5", Port = 80, Id = "testService2.192.168.1.5.80", Name = "testService2", Version = "v1.0"
                },
                new ServiceInformation()
                {
                    Host = "192.168.1.6", Port = 80, Id = "testService2.192.168.1.6.80", Name = "testService2", Version = "v1.0"
                },
                new ServiceInformation()
                {
                    Host = "192.168.1.7", Port = 80, Id = "testService2.192.168.1.7.80", Name = "testService2", Version = "v1.0"
                },
            };
            var serviceArr = services.ToArray();
            PollingServiceSelector polling = new PollingServiceSelector();
            ServiceInformation     service = null;
            int count      = 100;
            int totalCount = 0;

            for (int i = 1; i < count; i++)
            {
                Parallel.For(0, i, index => {
                    service = polling.SelectAsync(services);
                });
                totalCount += i;
                Assert.AreEqual(service.Id, serviceArr[(totalCount - 1) % services.Count].Id);
            }
        }
Example #7
0
        public async Task GreeterServiceTest()
        {
            //服务信息
            var serviceInfo = new ServiceInformation()
            {
                Host        = "127.0.0.1",
                Port        = 1234,
                Description = "我的小服务, 老火了",
                Key         = "Foo.Services",
                Name        = "我的小服务",
                ServiceType = ServiceType.Grpc,
            };

            //启动服务
            Server server = new Server
            {
                Services = { Greeter.BindService(new GreeterImpl()) },
                Ports    = { new ServerPort(serviceInfo.Host, serviceInfo.Port, ServerCredentials.Insecure) }
            };

            server.Start();

            //注册服务
            using (var zon = await ServiceBus.Register(serviceInfo))
            {
                //发现服务
                string             serviceKey = serviceInfo.Key;
                ServiceInformation service    = ServiceBus.Get(serviceKey).Result.FeelingLucky();

                //使用服务

                string  target  = $"{service.Host}:{service.Port}";
                Channel channel = new Channel(target, ChannelCredentials.Insecure);
                Greeter.GreeterClient client = new Greeter.GreeterClient(channel);

                HelloRequest request = new HelloRequest()
                {
                    Name         = "徐云金",
                    SecretSignal = "天王盖地虎",
                };
                request.Gifts.AddRange(new List <Gift>()
                {
                    new Gift {
                        Name = "兔子"
                    },
                    new Gift {
                        Name = "橘猫"
                    },
                });

                Console.WriteLine($"request: \n{JsonConvert.SerializeObject(request)}");

                HelloReply reply = client.SayHello(request);

                Console.WriteLine($"reply: \n{JsonConvert.SerializeObject(reply)}");

                Assert.AreEqual(request.Name, reply.Name);
                channel.ShutdownAsync().Wait();
            }
        }
Example #8
0
        private static async Task StartService(string host, int port)
        {
            //服务信息
            var serviceInfo = new ServiceInformation()
            {
                Host        = host,
                Port        = port,
                Description = "我的小服务, 老火了",
                Key         = "Foo.Services",
                Name        = "我的小服务",
                ServiceType = ServiceType.Grpc,
            };

            //启动服务
            Server service = new Server
            {
                Services = { Greeter.BindService(new GreeterImpl()) },
                Ports    = { new ServerPort(serviceInfo.Host, port, ServerCredentials.Insecure) }
            };

            service.Start();

            using (IZookeeperClient zon = await ServiceBus.Register(serviceInfo))
            {
                Console.WriteLine("Greeter server listening on port " + port);
                Console.WriteLine("Press any key to stop the server...");
                Console.ReadKey();
                service.ShutdownAsync().Wait();
            }
        }
 private void AbortService(ServiceInformation si)
 {
     if (si != null)
     {
         serviceController.AbortService(si);
         Console.WriteLine($"Service aborted");
     }
 }
 private void StopService(ServiceInformation si)
 {
     if (si != null)
     {
         serviceController.StopService(si);
         Console.WriteLine("Stopped the service");
     }
 }
Example #11
0
 /// <summary>
 /// Tries to Resolve service info by name
 /// </summary>
 /// <param name="name">Name of service</param>
 /// <param name="serviceInfo">Out argument. With service info</param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException">When name is null or empty</exception>
 public bool TryResolveServiceInfo(string name, out ServiceInformation serviceInfo)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(_registeredServices.TryGetValue(name, out serviceInfo));
 }
Example #12
0
        public async Task TestAddUpdatDelete()
        {
            ServiceInformationModule ServiceInformationMod = new ServiceInformationModule();
            LocationAddressView      locationAddressView   = await ServiceInformationMod.LocationAddress.Query().GetViewById(3);

            CustomerView customerView = await ServiceInformationMod.Customer.Query().GetViewById(3);

            AddressBook addressBook = await ServiceInformationMod.AddressBook.Query().GetEntityById(customerView.AddressId);

            ContractView contractView = await ServiceInformationMod.Contract.Query().GetViewById(1);

            Udc udc = await ServiceInformationMod.Udc.Query().GetEntityById(2);


            ServiceInformationView view = new ServiceInformationView()
            {
                ServiceDescription = " truck oil change",
                Price                 = 80.76M,
                AddOns                = "none",
                ServiceTypeXrefId     = udc.XrefId,
                ServiceType           = udc.Value,
                CreatedDate           = DateTime.Parse("12/25/2019"),
                LocationId            = locationAddressView.LocationAddressId,
                CustomerId            = customerView.CustomerId,
                ContractId            = contractView.ContractId,
                vwCustomer            = customerView,
                vwContract            = contractView,
                vwLocationAddress     = locationAddressView,
                SquareFeetOfStructure = 100,
                LocationDescription   = "Eiensten brothers on orchard",
                LocationGps           = "",
                Comments              = "",
                Status                = true
            };
            NextNumber nnNextNumber = await ServiceInformationMod.ServiceInformation.Query().GetNextNumber();

            view.ServiceInformationNumber = nnNextNumber.NextNumberValue;

            ServiceInformation serviceInformation = await ServiceInformationMod.ServiceInformation.Query().MapToEntity(view);

            ServiceInformationMod.ServiceInformation.AddServiceInformation(serviceInformation).Apply();

            ServiceInformation newServiceInformation = await ServiceInformationMod.ServiceInformation.Query().GetEntityByNumber(view.ServiceInformationNumber);

            Assert.NotNull(newServiceInformation);

            newServiceInformation.ServiceDescription = "ServiceInformation Test Update";

            ServiceInformationMod.ServiceInformation.UpdateServiceInformation(newServiceInformation).Apply();

            ServiceInformationView updateView = await ServiceInformationMod.ServiceInformation.Query().GetViewById(newServiceInformation.ServiceId);

            Assert.Same(updateView.ServiceDescription, "ServiceInformation Test Update");
            ServiceInformationMod.ServiceInformation.DeleteServiceInformation(newServiceInformation).Apply();
            ServiceInformation lookupServiceInformation = await ServiceInformationMod.ServiceInformation.Query().GetEntityById(view.ServiceId);

            Assert.Null(lookupServiceInformation);
        }
 public int IUpdateServiceInformationBuIndID(ServiceInformation serviceInformation)
 {
     try {
         return(sis.UpdateServiceInformationBuIndID(serviceInformation));
     }
     catch {
         return(0);
     }
 }
 public int IInsertServiceInformation(ServiceInformation serInf)
 {
     try {
         return(sis.InsertServiceInformation(serInf));
     }
     catch {
         return(0);
     }
 }
Example #15
0
        public async Task <IActionResult> DeleteServiceInformation([FromBody] ServiceInformationView view)
        {
            ServiceInformationModule invMod             = new ServiceInformationModule();
            ServiceInformation       serviceInformation = await invMod.ServiceInformation.Query().MapToEntity(view);

            invMod.ServiceInformation.DeleteServiceInformation(serviceInformation).Apply();

            return(Ok(view));
        }
Example #16
0
        public void GeneratedPasswordShouldNotBeEmpty()
        {
            var serviceInfo = new ServiceInformation(
                "testService",
                new PasswordRestriction(SymbolsType.LowcaseLatin));

            var password =
                ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword);

            Assert.IsTrue(password.Length > 0);
        }
Example #17
0
        public async Task TestAddUpdatDelete()
        {
            ScheduleEventModule ScheduleEventMod = new ScheduleEventModule();
            Employee            employee         = await ScheduleEventMod.Employee.Query().GetEntityById(3);

            AddressBook addressBookEmployee = await ScheduleEventMod.AddressBook.Query().GetEntityById(employee.AddressId);

            Customer customer = await ScheduleEventMod.Customer.Query().GetEntityById(1);

            AddressBook addressBookCustomer = await ScheduleEventMod.AddressBook.Query().GetEntityById(customer.AddressId);

            ServiceInformation serviceInformation = await ScheduleEventMod.ServiceInformation.Query().GetEntityById(3);

            ScheduleEventView view = new ScheduleEventView()
            {
                EmployeeId         = employee.EmployeeId,
                EmployeeName       = addressBookEmployee.Name,
                EventDateTime      = DateTime.Parse("11/13/2019"),
                ServiceId          = serviceInformation.ServiceId,
                ServiceDescription = serviceInformation.ServiceDescription,
                DurationMinutes    = 30,
                CustomerId         = customer.CustomerId,
                CustomerName       = addressBookCustomer.Name,
            };
            NextNumber nnNextNumber = await ScheduleEventMod.ScheduleEvent.Query().GetNextNumber();

            view.ScheduleEventNumber = nnNextNumber.NextNumberValue;

            ScheduleEvent scheduleEvent = await ScheduleEventMod.ScheduleEvent.Query().MapToEntity(view);

            ScheduleEventMod.ScheduleEvent.AddScheduleEvent(scheduleEvent).Apply();

            ScheduleEvent newScheduleEvent = await ScheduleEventMod.ScheduleEvent.Query().GetEntityByNumber(view.ScheduleEventNumber);

            Assert.NotNull(newScheduleEvent);

            newScheduleEvent.DurationMinutes = 32;

            ScheduleEventMod.ScheduleEvent.UpdateScheduleEvent(newScheduleEvent).Apply();

            ScheduleEventView updateView = await ScheduleEventMod.ScheduleEvent.Query().GetViewById(newScheduleEvent.ScheduleEventId);

            if (updateView.DurationMinutes != 32)
            {
                Assert.True(true);
            }

            ScheduleEventMod.ScheduleEvent.DeleteScheduleEvent(newScheduleEvent).Apply();
            ScheduleEvent lookupScheduleEvent = await ScheduleEventMod.ScheduleEvent.Query().GetEntityById(view.ScheduleEventId);

            Assert.Null(lookupScheduleEvent);
        }
Example #18
0
        public ActionResult Reporting()
        {
            if (Session["UserName"] != null)
            {
                ViewBag.Title = "Reporting";

                MenuAndContent mC = new MenuAndContent(System.Web.HttpContext.Current.Session["LanguageVar"].ToString());
                AllClasses     aC = new AllClasses();
                aC.MenuandContent = mC;

                List <ServiceReportings>   sR = new BusinessLogic().AllSPs();
                List <ServiceInformations> sI = new BusinessLogic().AllSIs();

                List <ServiceReporting>   Sr = new List <ServiceReporting>();
                List <ServiceInformation> Si = new List <ServiceInformation>();

                if (sR != null)
                {
                    foreach (var dfr in sR)
                    {
                        ServiceReporting i = new ServiceReporting();
                        i.ServiceName  = dfr.ServiceName;
                        i.CreatedOn    = dfr.CreatedOn;
                        i.ErrorCode    = dfr.ErrorCode;
                        i.ErrorDetails = dfr.ErrorDetails;
                        Sr.Add(i);
                    }
                }

                if (sI != null)
                {
                    foreach (var dfr in sI)
                    {
                        ServiceInformation i = new ServiceInformation();
                        i.ServiceName = dfr.ServiceName;
                        i.CreatedOn   = dfr.CreatedOn;
                        i.NoOfErrors  = dfr.NoOfErrors;
                        i.NoOfSuccess = dfr.NoOfSuccess;
                        Si.Add(i);
                    }
                }

                aC.SRs = Sr;
                aC.SIs = Si;

                return(View("Reporting", aC));
            }
            else
            {
                return(RedirectToAction("Index", "User"));
            }
        }
Example #19
0
        public void SecondaryGeneratedPasswordShouldBeSame()
        {
            var serviceInfo = new ServiceInformation(
                "testService",
                new PasswordRestriction(SymbolsType.LowcaseLatin));

            var password =
                ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword);
            var secondaryGenerated =
                ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword);

            Assert.AreEqual(password, secondaryGenerated);
        }
Example #20
0
        //TODO: Need to get all service, Include not installed service by error
        public List <ServiceInformation> GetServices()
        {
            List <ServiceInformation> servicesInformations = new List <ServiceInformation>();
            var osInfo = systemInformation.GetOSInfo();

            //Window
            if (osInfo.Platform == OSPlatformType.Windows)
            {
                var services = ServiceController.GetServices();

                foreach (var service in services)
                {
                    ServiceInformation serviceInformation = GetService(service);
                    servicesInformations.Add(serviceInformation);
                }
            }
            else if (osInfo.Platform == OSPlatformType.Linux)
            {
                ProcessOutput output = terminal.Execute(new ProcessInput
                {
                    Command   = "systemctl list-units --type=service | grep ''",
                    ShellName = "/bin/bash",
                    Arguments = ""
                });

                foreach (var line in output.StandardOutput.Skip(1))
                {
                    if (!line.Contains("service"))
                    {
                        continue;
                    }
                    var cleanedLine = line.Replace("●", ""); ///systemctl list failed service with "●", and It cannot parse normally
                    var lineSplited = cleanedLine.Split(new char[] { ' ' }, 5, StringSplitOptions.RemoveEmptyEntries);
                    if (lineSplited.Length != 5)
                    {
                        throw new SystemInformationException("Service Output Failed, The systemctl Output has changed");
                    }

                    servicesInformations.Add(new ServiceInformation
                    {
                        ServiceName  = lineSplited[0],
                        Description  = lineSplited[4],
                        State        = GetServiceState(OSPlatformType.Linux, lineSplited[3], lineSplited[0]),
                        StartupState = GetServiceStartupState(OSPlatformType.Linux, lineSplited[2], lineSplited[0])
                    });
                }
            }

            return(servicesInformations.Count > 0 ? servicesInformations : null);
        }
        public int InsertServiceInformation(ServiceInformation serInf)
        {
            ServiceInformationDataContext db = new ServiceInformationDataContext();

            try
            {
                db.ServiceInformation.InsertOnSubmit(serInf);
                db.SubmitChanges();
                return(int.Parse(serInf.IndID.ToString()));
            }
            catch
            {
                return(0);
            }
        }
 private void StartService(ServiceInformation si)
 {
     if (si != null)
     {
         bool isAlreadyRunning = serviceController.StartService(si);
         if (isAlreadyRunning)
         {
             Console.WriteLine("Service is already running");
         }
         else
         {
             Console.WriteLine("Service started");
         }
     }
 }
Example #23
0
        public void ResultPasswordWithOtherUserPasswordShouldNotBeSame()
        {
            var serviceInfo = new ServiceInformation(
                "testService",
                new PasswordRestriction(SymbolsType.LowcaseLatin));

            var password =
                ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword);

            _userPassword = "******";
            var otherPassword =
                ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword);

            Assert.AreNotEqual(password, otherPassword);
        }
Example #24
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            var    interceptors = _serviceProvider.GetService <IEnumerable <ServerInterceptor> >();
            Server server       = new Server
            {
                Ports = { new ServerPort(_grpcHostOption.IpAddress, _grpcHostOption.Port, ServerCredentials.Insecure) }
            };

            foreach (var grpcserver in _grpcHostOption.GrpcServers)
            {
                server.Services.Add(grpcserver.Invoke(_serviceProvider).Intercept(interceptors.ToArray()));
            }
            server.Start();
            _serviceInformation = await _serviceProvider.GetService <IServiceRegistrar>().RegisterServiceAsync(_grpcHostOption.ServiceName, _grpcHostOption.ServiceVersion, _grpcHostOption.IpAddress, _grpcHostOption.Port);

            Console.WriteLine($"GrpcServer is listen on { _grpcHostOption.IpAddress }:{ _grpcHostOption.Port}");
        }
Example #25
0
        /// <summary>
        /// Erstellt eine neue Dienstbeschreibung.
        /// </summary>
        /// <param name="service">Die Beschreibung des Dienstes.</param>
        /// <returns>Der gewünschte Dienst.</returns>
        public static ZappingService Create(ServiceInformation service)
        {
            // Validate
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            // Create new
            return
                (new ZappingService
            {
                Source = SourceIdentifier.ToString(service.Service).Replace(" ", ""),
                Index = GetServiceIndex(service.UniqueName),
                Name = service.UniqueName
            });
        }
Example #26
0
        public static string AddHealthCheck(this IApplicationBuilder app, ServiceInformation registryInformation, Uri checkUri, TimeSpan?interval = null, string notes = null)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (registryInformation == null)
            {
                throw new ArgumentNullException(nameof(registryInformation));
            }

            var    serviceRegistry = app.ApplicationServices.GetRequiredService <ServiceRegistry>();
            string checkId         = serviceRegistry.RegisterHealthCheckAsync(registryInformation.Name, registryInformation.Id, checkUri, interval, notes)
                                     .Result;

            return(checkId);
        }
Example #27
0
        public async Task <IActionResult> AddServiceInformation([FromBody] ServiceInformationView view)
        {
            ServiceInformationModule invMod = new ServiceInformationModule();

            NextNumber nnServiceInformation = await invMod.ServiceInformation.Query().GetNextNumber();

            view.ServiceInformationNumber = nnServiceInformation.NextNumberValue;

            ServiceInformation serviceInformation = await invMod.ServiceInformation.Query().MapToEntity(view);

            invMod.ServiceInformation.AddServiceInformation(serviceInformation).Apply();

            ServiceInformationView newView = await invMod.ServiceInformation.Query().GetViewByNumber(view.ServiceInformationNumber);


            return(Ok(newView));
        }
Example #28
0
        public void PasswordWithEqualsMinAndMaxLengthShouldBeSameLength()
        {
            var serviceWithLotSymbolTypes = new ServiceInformation(
                "testService",
                new PasswordRestriction(
                    SymbolsType.LowcaseLatin |
                    SymbolsType.UpcaseLatin |
                    SymbolsType.Digital,
                    passwordMinLength: 5,
                    passwordMaxLength: 5));

            var password = ServicePasswordGenerator.GeneratePassword(
                serviceWithLotSymbolTypes,
                _userPassword);

            Assert.IsTrue(password.Length == 5);
        }
Example #29
0
        public void LongPasswordShouldBeSuccessfulGenerated()
        {
            var serviceWithLotSymbolTypes = new ServiceInformation(
                "testService",
                new PasswordRestriction(
                    SymbolsType.LowcaseLatin |
                    SymbolsType.UpcaseLatin |
                    SymbolsType.Digital,
                    passwordMinLength: 2000,
                    passwordMaxLength: 3000));

            var password = ServicePasswordGenerator.GeneratePassword(
                serviceWithLotSymbolTypes,
                _userPassword);

            Assert.IsTrue(password.Length >= 2000);
            Assert.IsTrue(password.Length <= 3000);
        }
Example #30
0
        public async Task RegisterTest()
        {
            //服务信息
            var serviceInfo = new ServiceInformation()
            {
                Host        = "127.0.0.1",
                Port        = 1234,
                Description = "我的小服务, 老火了",
                Key         = "Foo.Services",
                Name        = "我的小服务",
                ServiceType = ServiceType.Grpc,
            };

            using (var zon = await ServiceBus.Register(serviceInfo))
            {
                var serviceLoaded = (await ServiceBus.Get(serviceInfo.Key)).FeelingLucky();
                Assert.AreEqual(serviceInfo.Key, serviceLoaded.Key);
            }
        }
Example #31
0
        private ServiceInformation parseServiceInformation(string responseStr, NameValueCollection headers)
        {
            try
            {
                XmlDocument d = new XmlDocument();
                d.LoadXml(responseStr);

                ServiceInformation si = new ServiceInformation();

                XmlNodeList olist = d.GetElementsByTagName("Atmos");
                log.TraceEvent(TraceEventType.Verbose, 0, "Found " + olist.Count + " results");
                foreach (XmlNode xn in olist)
                {
                    si.AtmosVersion = xn.InnerText;
                }

                foreach(string name in headers.AllKeys) {
                    if ("x-emc-support-utf8".Equals(name, StringComparison.OrdinalIgnoreCase) && "true".Equals(headers[name]))
                        si.UnicodeMetadataSupported = true;

                    else if ("x-emc-features".Equals(name, StringComparison.OrdinalIgnoreCase)) {
                        foreach (String feature in headers[name].Split(',')) {
                            si.AddFeature(feature);
                        }
                    }
                }

                return si;
            }
            catch (XmlException e)
            {
                throw new EsuException("Error parsing xml object list", e);
            }
        }
Example #32
0
 public ServiceBase()
 {
     Information = new ServiceInformation();
 }
Example #33
0
 public Identity(string userName, ServiceInformation serviceInformation)
 {
     UserName = userName;
     ServiceInfo = serviceInformation;
 }
 /// <summary>
 /// ToDo
 /// </summary>
 /// <param name="serviceInfo"></param>
 public AdalClientAuthenticationProvider(ServiceInformation serviceInfo, AccountSession accountSession = null) : base(serviceInfo, accountSession)
 {
  
 }
        public bool SavePersistedConfig(PersistAndCacheSettings pacs)
        {
            //Save to file
            /*NOTE
              * SECURITY CONSIDERATIONS
              * Stored on file system with read/write permission for only the application/service and IT Administration
              * Stored in DB with read/write permission for only the application/service and IT Administration
            */

            //Save Settings
            XmlDocument doc = new XmlDocument();
            XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            doc.AppendChild(docNode);
            XmlNode transactionProcessingValues = doc.CreateElement("TransactionProcessing");
            doc.AppendChild(transactionProcessingValues);
            XmlNode configuration = doc.CreateElement("Configuration");
            transactionProcessingValues.AppendChild(configuration);

            si = helper.ServiceInformation;
            XmlNode applicationProfielId = doc.CreateElement("ApplicationProfielId");
            applicationProfielId.InnerText = pacs.ApplicationProfileId;
            configuration.AppendChild(applicationProfielId);

            XmlNode serviceId = doc.CreateElement("ServiceId");
            serviceId.InnerText = pacs.ServiceId;
            XmlAttribute multipleServiceId = doc.CreateAttribute("MultipleServiceId");
            multipleServiceId.Value = (si.BankcardServices.Count > 1 ? "True" : "False");
            serviceId.Attributes.Append(multipleServiceId);
            configuration.AppendChild(serviceId);

            XmlNode workflowId = doc.CreateElement("WorkflowId");
            workflowId.InnerText = pacs.WorkflowId;
            XmlAttribute multipleWorkflowId = doc.CreateAttribute("MultipleWorkflowId");
            multipleWorkflowId.Value = (si.BankcardServices.Count > 1 ? "True" : "False");
            workflowId.Attributes.Append(multipleWorkflowId);
            configuration.AppendChild(workflowId);

            XmlNode merchantProfielId = doc.CreateElement("MerchantProfielId");
            merchantProfielId.InnerText = pacs.MerchantProfileId;
            XmlAttribute multipleMerchants = doc.CreateAttribute("MultipleMerchants");
            multipleMerchants.Value = (merchantProfileIds.Count > 2 ? "True" : "False");//Since by default empty comes back we need to validate at 2 and not 1
            merchantProfielId.Attributes.Append(multipleMerchants);
            configuration.AppendChild(merchantProfielId);

            XmlNode identityToken = doc.CreateElement("IdentityToken");
            identityToken.InnerText = pacs.IdentityToken;
            XmlAttribute encrypted = doc.CreateAttribute("Encrypted");
            encrypted.Value = pacs.EncryptedIdentityToken.ToString();//The following is dependant on the software company integration needs.
            identityToken.Attributes.Append(encrypted);
            configuration.AppendChild(identityToken);

            doc.Save(helper.ServiceKey + "_TransactionProcessing.config");

            return true;
        }
        private void GetServiceInformation()
        {
            //Clean up any previous retrievals
            cboAvailableServices.Items.Clear();//Reset The Services Dropdown
            cboAvailableServices.Text = "";

            CboWorkFlowIdsByServiceId.Items.Clear();//Reset The Workflow Dropdown
            CboWorkFlowIdsByServiceId.Text = "";

            if(!_blnPersistedConfigExists)
                Helper.ServiceID = "";
            cboAvailableProfiles.Items.Clear();//Reset The Profiles Dropdown
            cboAvailableProfiles.Text = "";
            if (!_blnPersistedConfigExists) 
                Helper.MerchantProfileId = "";
            lblIsProfileInitialized.Text = "";
            txtAboutTheService.Text = "";

            //Reset previously selected services
            _bcs = null;
            _ecks = null;
            _svas = null;

            //The GetServiceInformation() operation provides information about the services that are available to a specific Service Key. 
            //This operation should be automatically invoked during initial application configuration, and manually by an application 
            //administrator if/when available services are updated.

            _si = Helper.Cwssic.GetServiceInformation(Helper.SessionToken);
            
            if (_si.BankcardServices != null)
            {
                foreach (BankcardService BCS in _si.BankcardServices)
                {
                    cboAvailableServices.Items.Add(new Item(BCS.ServiceId + "-BCS-" + Helper.TranslateServiceIdToFriendlyName(BCS), BCS.ServiceId, ""));
                }
            }
            if (_si.ElectronicCheckingServices != null)
            {
                foreach (ElectronicCheckingService ECKS in _si.ElectronicCheckingServices)
                {
                    cboAvailableServices.Items.Add(new Item(ECKS.ServiceId + "-ECK-" + Helper.TranslateServiceIdToFriendlyName(ECKS), ECKS.ServiceId, ""));
                }
            }
            if (_si.StoredValueServices != null)
            {
                foreach (StoredValueService SVAS in _si.StoredValueServices)
                {
                    cboAvailableServices.Items.Add(new Item(SVAS.ServiceId + "-SVAS-" + Helper.TranslateServiceIdToFriendlyName(SVAS), SVAS.ServiceId, ""));
                }
            }
            txtPersistedAndCached.Text = "ApplicationProfileId : " + Helper.ApplicationProfileId + "\r\nServiceId : " + Helper.ServiceID + "\r\nMerchantProfileId : " + Helper.MerchantProfileId;
        }
        private void GetServiceInformation()
        {
            if (!_blnPersistedConfigExists)
                Helper.ServiceID = "";

            if (!_blnPersistedConfigExists)
                Helper.MerchantProfileId = "";

            //Reset previously selected services
            _bcs = null;
            _ecks = null;
            _svas = null;

            //The GetServiceInformation() operation provides information about the services that are available to a specific Service Key.
            //This operation should be automatically invoked during initial application configuration, and manually by an application
            //administrator if/when available services are updated.

            _si = Helper.Cwssic.GetServiceInformation(Helper.SessionToken);
        }