public AccessMappingController(IAccessMappingRepository accessMappingRepository, IParticipantRepository participantRepository, IServiceRepository serviceRepository, ILogger logger) { _accessMappingRepository = accessMappingRepository; _participantRepository = participantRepository; _serviceRepository = serviceRepository; _logger = logger; }
public List <string> GetServiceRoles(IAccessMappingRepository accessMappingRepository, IServiceRepository servicesRepository, List <string> providersCodes, string consumerId) { var roles = new List <string>(); var services = servicesRepository.GetServices(); var csServices = services as CSService[] ?? services.ToArray(); foreach (var pCode in providersCodes) { string code = pCode.Contains("MIM1$$") ? pCode.Remove(0, 6) : pCode; var serviceCodes = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumerId && x.ProviderCode == code && x.IsActive) .Select(x => new { ProviderService = x.ProviderCode + " - " + x.ServiceCode }).Distinct().ToList(); foreach (var sCode in serviceCodes) { if (csServices.Any()) { string serviceCode = sCode.ProviderService.Split('-').Skip(1).First().Trim(); string providerCode = sCode.ProviderService.Split('-').First(); var cyrilicCode = (CyrilicInstitutionCode)Enum.Parse(typeof(CyrilicInstitutionCode), providerCode, true); var serviceByCode = csServices.FirstOrDefault(x => x.Code == serviceCode); if (serviceByCode != null) { var serviceName = serviceByCode.Name; roles.Add(Helper.GetCyrilicCode(cyrilicCode) + " - " + serviceName); } } } } return(roles); }
public StatisticsController(IParticipantRepository participantsRepository, IAccessMappingRepository accessMappingRepository, IMessageLogStatisticRepository messageLogStatisticRepository, IServiceRepository serviceRepository, ILogger logger) { _participantsRepository = participantsRepository; _accessMappingRepository = accessMappingRepository; _messageLogStatisticRepository = messageLogStatisticRepository; _serviceRepository = serviceRepository; _logger = logger; }
public CSMetaService(IServiceRepository servicesRepository, IAccessMappingRepository accessMappingRepository, IParticipantRepository participantRepository, ICSRepoFactory csRepoFactory, IBusesRepository busesRepository, ILogger logger) { _servicesRepository = servicesRepository; _accessMappingRepository = accessMappingRepository; _participantRepository = participantRepository; _csRepoFactory = csRepoFactory; _busesRepository = busesRepository; _logger = logger; }
public List <ProviderCSDTO> GetProviders(IAccessMappingRepository accessMappingRepository, IParticipantRepository participantRepository, IBusesRepository busesRepository, string consumerId) { var nameLogerError1 = "GetProviders" + "_ " + DateTime.Now; using (var logger = LoggingFactory.GetNLogger(nameLogerError1)) { logger.Info("dosol vo get providers za " + consumerId); } List <ProviderCSDTO> output; try { var accessMappings = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumerId); var participants = participantRepository.GetParticipants(); var accessMappingList = new List <AccessMapping>(); foreach (var am in accessMappings) { var amm = new AccessMapping() { ProviderCode = am.ProviderCode, ProviderBusCode = am.ProviderBusCode, ConsumerCode = am.ConsumerCode }; amm.ProviderCode = amm.ProviderBusCode + "$$" + amm.ProviderCode; accessMappingList.Add(amm); } var accessMappet = accessMappingList.Select(s => s.ProviderCode).Distinct(); var joinedAccessMappingsAndParticipants = accessMappet.Join(participants, am => am, p => p.Code, (am, p) => new ProviderCSDTO { Code = am, PublicKey = p.PublicKey, Name = p.Name }).ToList(); output = joinedAccessMappingsAndParticipants.ToList(); //foreach (var k in accessMapBusExt) //{ // var busURL = k.Url; // //the call is made with MIM1$$consumerId // // get lists from other busses and add them to output //} // } //else //{//call from external BUS, to be tested // string[] stringSeparators = new string[] { "$$" }; // string[] result; // result = consumerId.Split(stringSeparators, StringSplitOptions.None); // var busC = result[0]; // var consumer = result[1]; // var accessMappings = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumer); // var accessMapBus = accessMappings.Where(x => x.ProviderBusCode == ourBus && x.ConsumerBusCode == busC); // var accessMappet = accessMapBus.Select(s => s.ProviderCode).Distinct(); // var participants = participantRepository.GetParticipants(); // var joinedAccessMappingsAndParticipants = accessMappet.Join(participants, am => am, // p => p.Code, (am, p) => new ProviderCSDTO { Code = ourBus + "$$" + am, PublicKey = p.PublicKey }).ToList(); // output = joinedAccessMappingsAndParticipants.ToList(); //} } catch (Exception ex) { var nameLogerError = "GetProviders" + "_ " + DateTime.Now; using (var logger = LoggingFactory.GetNLogger(nameLogerError)) { logger.Info("consumerId = " + consumerId); } throw new FaultException(ex.Message); } return(output); }
public List <string> ListConsumers(IAccessMappingRepository accessMappingRepository, string providerId, string serviceId) { return(accessMappingRepository.GetAccessMappings().Where(x => x.ProviderCode == providerId && x.ServiceCode == serviceId).Select(x => x.ConsumerCode).ToList()); }
public string GetService(IAccessMappingRepository accessMappingRepository, IServiceRepository serviceRepository, IBusesRepository busesRepository, string providerId, string consumerId, string serviceId) { //var ourBus = AppSettings.Get<string>("Bus"); //string[] stringSeparators = new string[] { "$$" }; //string[] result; var map = accessMappingRepository.GetAccessMappings().ToList(); var busP = ""; var provider = ""; //if (providerId.Contains("$$")) //{ string[] stringSeparators = new string[] { "$$" }; string[] result; result = providerId.Split(stringSeparators, StringSplitOptions.None); busP = result[0]; provider = result[1]; //} //if (String.IsNullOrEmpty(busP)) // busP = ourBus; //if (String.IsNullOrEmpty(provider)) //provider = providerId; //if (!providerId.Contains("$$") && !consumerId.Contains("$$")) //{ //var allAvilableServices = map.Where(x => x.ConsumerCode == consumerId && x.ConsumerBusCode == ourBus && x.ProviderCode == providerId && x.ProviderBusCode == ourBus && x.ServiceCode == serviceId); var allAvilableServices = map.Where(x => x.ConsumerCode == consumerId && x.ProviderCode == provider && x.ProviderBusCode == busP && x.ServiceCode == serviceId && x.IsActive); var serviceMethodsFromAvilableServices = allAvilableServices.Select(service => service.MethodCode).ToArray(); if (allAvilableServices.Any()) { //var temp = serviceRepository.GetServices(); //foreach (var ser in temp) //{ // if (ser.ParticipantCode.Contains("$$")) // { // string[] stringSeparators = new string[] { "$$" }; // string[] result; // result = ser.ParticipantCode.Split(stringSeparators, StringSplitOptions.None); // ser.ParticipantCode = result[1]; // } //} //var temp1 = temp.FirstOrDefault(x => x.ParticipantCode == providerId && x.Code == serviceId); var originalWsdl = serviceRepository.GetServices().FirstOrDefault(x => x.ParticipantCode == providerId && x.Code == serviceId).Wsdl; if (serviceMethodsFromAvilableServices.Any()) { return(RecreateWsdl(originalWsdl, serviceMethodsFromAvilableServices)); } } //} //else if (providerId.Contains("$$")) //{ // result = providerId.Split(stringSeparators, StringSplitOptions.None); // var busC = result[0]; // var busURL = busesRepository.GetBuses().Where(x => x.Code == busC).Select(x => x.Url); // // Make call to external Bus with parametars GetService(ourBus$$consumerId, providerId, ServY) // // get list of strings from the external call // return ""; //} //else if (providerId.Contains("$$") && consumerId.Contains("$$")) //{//call from external BUS, to be tested // result = providerId.Split(stringSeparators, StringSplitOptions.None); // var provId = result[1]; // result = consumerId.Split(stringSeparators, StringSplitOptions.None); // var consId = result[1]; // var consBus = result[0]; // var allAvilableServices = map.Where(x => x.ConsumerCode == consId && x.ConsumerBusCode == consBus && x.ProviderCode == provId && x.ProviderBusCode == ourBus && x.ServiceCode == serviceId); // var serviceMethodsFromAvilableServices = allAvilableServices.Select(service => service.MethodCode).ToArray(); // if (allAvilableServices.Any()) // { // var originalWsdl = serviceRepository.GetServices().FirstOrDefault(x => x.ParticipantCode == provId && x.Code == serviceId).Wsdl; // if (serviceMethodsFromAvilableServices.Any()) // { // return RecreateWsdl(originalWsdl, serviceMethodsFromAvilableServices); // } // } //} var nameLogerError = "GetService_ " + DateTime.Now; using (var logger = LoggingFactory.GetNLogger(nameLogerError)) { logger.Info("There is no access maping for that provider and consumer"); } throw new FaultException("There is no access maping for that provider and consumer"); }
public List <SelectListItem> GetServices(IAccessMappingRepository accessMappingRepository, IBusesRepository busesRepository, IServiceRepository servicesRepository, string providerId, string consumerId) { //var ourBus = AppSettings.Get<string>("Bus"); //string[] stringSeparators = new string[] { "$$" }; //string[] result; var nameLogerError = "Vlezni parametri na GetServices" + "_ " + DateTime.Now; using (var logger = LoggingFactory.GetNLogger(nameLogerError)) { logger.Info("provider: " + providerId + "; consumer: " + consumerId); } var output = new List <string>(); var busP = ""; //if (providerId.Contains("$$")) //{ string[] stringSeparators = new string[] { "$$" }; string[] result; result = providerId.Split(stringSeparators, StringSplitOptions.None); busP = result[0]; providerId = result[1]; //} //if (String.IsNullOrEmpty(busP)) //busP = ourBus; using (var logger = LoggingFactory.GetNLogger(nameLogerError)) { logger.Info("busP: " + busP + "; providerId: " + providerId); } output = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumerId && x.ProviderCode == providerId && x.ProviderBusCode == busP && x.IsActive).Select(x => x.ServiceCode).Distinct().ToList(); using (var logger = LoggingFactory.GetNLogger(nameLogerError)) { logger.Info("output: " + output.Count); } var allservices = servicesRepository.GetServices(); var newOutput = new List <SelectListItem>(); foreach (var service in allservices) { if (output.Contains(service.Code)) { var item = new SelectListItem(); item.Value = service.Code; item.Text = service.Name; newOutput.Add(item); } } //if(!providerId.Contains("$$") && !consumerId.Contains("$$")) //{ // output = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumerId && x.ProviderCode == providerId && x.ProviderBusCode == ourBus).Select(x => x.ServiceCode).Distinct().ToList(); //} //else if(providerId.Contains("$$")) //{ //result = providerId.Split(stringSeparators, StringSplitOptions.None); //var busC = result[0]; //var busURL = busesRepository.GetBuses().Where(x => x.Code == busC).Select(x => x.Url); // Make call to external Bus with parametars GetServices(ourBus$$consumerId, providerId) // get list of strings from the external call //} //else if(providerId.Contains("$$") && consumerId.Contains("$$")) //{//call from external BUS, to be tested // result = providerId.Split(stringSeparators, StringSplitOptions.None); // var provId = result[1]; // result = consumerId.Split(stringSeparators, StringSplitOptions.None); // var consId = result[1]; // var consBus = result[0]; // output = accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consId && x.ConsumerBusCode == consBus && x.ProviderCode == provId && x.ProviderBusCode == ourBus).Select(x => x.ServiceCode).Distinct().ToList(); //} return(newOutput); }
public HelperController(IParticipantRepository participantsRepository, IAccessMappingRepository accessMappingRepository, IServiceRepository serviceRepository) { _participantsRepository = participantsRepository; _accessMappingRepository = accessMappingRepository; _serviceRepository = serviceRepository; }