Esempio n. 1
0
        public void InsertService(IServiceRepository serviceRepository, IParticipantRepository participantRepository, CSService cSservice)
        {
            //Downloading the WSDL form WSDL URL taken form CC Register Service
            //string wsdlURL = null;
            //if (cSservice.Wsdl.EndsWith("?wsdl"))
            //    wsdlURL = cSservice.Wsdl.Replace("?wsdl", "?singlewsdl");
            //string wsdl = null;
            //using (var wc = new WebClient())
            //{
            //    using (var stream = wc.OpenRead(wsdlURL))
            //    {
            //        using (var sr = new StreamReader(stream))
            //        {
            //            wsdl = sr.ReadToEnd();
            //        }
            //    }
            //}

            var participantExist =
                participantRepository.GetParticipants().Any(x => x.Code == cSservice.ParticipantCode);

            if (participantExist)
            {
                var service = new CSService
                {
                    ParticipantCode = cSservice.ParticipantCode,
                    Code            = cSservice.Code,
                    Name            = cSservice.Name,
                    Wsdl            = cSservice.Wsdl
                };

                try
                {
                    serviceRepository.CreateService(service);
                }
                catch (Exception e)
                {
                    var nameLogerError = service.Name + "_ " + DateTime.Now;
                    using (var logger = LoggingFactory.GetNLogger(nameLogerError))
                    {
                        logger.Error(JsonConvert.SerializeObject(service), e);
                    }
                    throw new FaultException(e.Message);
                }
            }
            else
            {
                throw new FaultException("Не постои учесник со име: " + cSservice.ParticipantCode);
            }
        }
Esempio n. 2
0
        //Опис: Методот креира нов сервис
        //Влезни параметри: Објект од класата Сервис
        public void CreateService(CSService service)
        {
            var serviceExists = _uow.Context.Services.Find(service.Code, service.ParticipantCode);

            if (serviceExists != null)
            {
                throw new DuplicateCSServiceException(service);
            }

            try
            {
                _uow.Context.Services.Add(service);
                _uow.Context.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                SqlException s = ex.InnerException.InnerException as SqlException;
                if (s != null && s.Number == 2627)
                {
                    throw new DuplicateCSServiceException(service);
                }
            }
        }
Esempio n. 3
0
        public void RegisterService(CSService service)
        {
            var csRepoFactory = _csRepoFactory.GetMetaServiceHelper();

            csRepoFactory.InsertService(_servicesRepository, _participantRepository, service);
        }
 public OrganController()
 {
     _cityService = new CSService();
 }
 public DuplicateCSServiceException(CSService service)
 {
     _service = service;
 }