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 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 IEnumerable <AccessMapping> GetAccessMappingList() { return(_accessMappingRepository.GetAccessMappings()); }
public List <KeyValuePair <string, string> > GetConsumersByAccMap(string institution) { var consumers = new Dictionary <string, string>(); var consumersByAccMapp = _accessMappingRepository.GetAccessMappings() .Where(accessMapping => accessMapping.ConsumerCode == institution || accessMapping.ProviderCode == institution) .DistinctBy(accessMapping => accessMapping.ConsumerCode).Select(accessMapping => accessMapping.ConsumerCode).ToList(); if (consumersByAccMapp.Any()) { foreach (var consumer in consumersByAccMapp) { consumers.Add(consumer, _participantsRepository.GetParticipantName(consumer)); } } return(consumers.ToList()); }
public List <string> FillServices(string provider = "", string consumer = "") { string serviceCodeToBeIgnored = ConfigurationManager.AppSettings["MunicipalitiesKey"] ?? "Municipalities"; bool consumerContainsMim = false; bool providerContainsMim = false; var mims = new[] { "MIM1$$", "MIM2$$" }; string serviceName; var services = new List <string>(); if (!string.IsNullOrEmpty(consumer)) { consumerContainsMim = mims.Any(m => consumer.Contains(m)); } if (!string.IsNullOrEmpty(provider)) { providerContainsMim = mims.Any(m => provider.Contains(m)); } if (consumerContainsMim) { consumer = consumer.Remove(0, 6); } if (providerContainsMim) { provider = provider.Remove(0, 6); } if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(consumer)) { IQueryable <AccessMapping> accessMappings = _accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumer && x.ProviderCode == provider && x.ServiceCode != serviceCodeToBeIgnored).AsQueryable(); if (accessMappings.Any()) { services = GetServicesByName(accessMappings); } } else { if (string.IsNullOrEmpty(consumer) && !string.IsNullOrEmpty(provider)) { IQueryable <AccessMapping> accessMappings = _accessMappingRepository.GetAccessMappings().Where(x => x.ProviderCode == provider && x.ServiceCode != serviceCodeToBeIgnored).AsQueryable(); if (accessMappings.Any()) { services = GetServicesByName(accessMappings); } } if (string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(consumer)) { IQueryable <AccessMapping> accessMappings = _accessMappingRepository.GetAccessMappings().Where(x => x.ConsumerCode == consumer && x.ServiceCode != serviceCodeToBeIgnored).AsQueryable(); if (accessMappings.Any()) { services = GetServicesByName(accessMappings); } } if (string.IsNullOrEmpty(provider) && string.IsNullOrEmpty(consumer)) { var allServices = _serviceRepository.GetServices().Where(x => x.Code != serviceCodeToBeIgnored); if (allServices.Any()) { foreach (var service in allServices) { if (!services.Contains(service.Code)) { serviceName = _serviceRepository.GetServiceName(service.Code); services.Add(serviceName); } } } } } return(services); }