Beispiel #1
0
        public async Task <HttpResponseMessage> Download(string templateName)
        {
            BusinessService bizService = new BusinessService(Client);

            CloudBlockBlob blob = bizService.Download(templateName);

            var blobExists = await blob.ExistsAsync();

            if (!blobExists)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "File not found"));
            }

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
            Stream blobStream           = await blob.OpenReadAsync();

            message.Content = new StreamContent(blobStream);
            message.Content.Headers.ContentLength      = blob.Properties.Length;
            message.Content.Headers.ContentType        = new System.Net.Http.Headers.MediaTypeHeaderValue(blob.Properties.ContentType);
            message.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = blob.Name,
                Size     = blob.Properties.Length
            };

            return(message);
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Upload(string templateName)
        {
            string filename = "";

            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            BusinessService bizService = new BusinessService(Client);

            HttpContent ctnt = Request.Content;

            try
            {
                filename = await bizService.Upload(ctnt, templateName);

                //await Request.Content.ReadAsMultipartAsync(provider);
            }
            catch (Exception ex)
            {
                return(BadRequest($"An error has occured. Details: {ex.Message}"));
            }

            // Retrieve the filename of the file you have uploaded
            if (filename == "error")
            {
                return(BadRequest("An error has occured while uploading your file. Please try again."));
            }

            return(Ok($"{filename} has successfully uploaded"));
        }
Beispiel #3
0
        /// <summary>
        /// Creates the business service.
        /// </summary>
        /// <param name="sName">Name of the service.</param>
        /// <param name="sDescription">The service description.</param>
        /// <returns></returns>
        public static BusinessService CreateBusinessService(string sName, string sDescription)
        {
            BusinessService bService = new BusinessService(sName);

            bService.Descriptions.Add(sDescription);
            return(bService);
        }
 protected bool LoginStatus()
 {
     try
     {
         RegisterViewModel            = GetAdminSession();
         this.CountryService          = new CountryService(Token);
         this.BusinessCategoryService = new BusinessCategoryService(Token);
         this.TimezoneService         = new TimezoneService(Token);
         this.MembershipService       = new MembershipService(Token);
         this.BusinessService         = new BusinessService(Token);
         this.BusinessEmployeeService = new BusinessEmployeeService(Token);
         this.BusinessHourService     = new BusinessHourService(Token);
         this.BusinessHolidayService  = new BusinessHolidayService(Token);
         //Call service;
         if (RegisterViewModel != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Beispiel #5
0
        private void btnRegisterJobSeeker_Click(object sender, EventArgs e)
        {
            if (JobSeekerService.DoesThisNameExist(txtFirstName.Text) || BusinessService.DoesThisNameExist(txtFirstName.Text))
            {
                MessageBox.Show("This Name is already taken.", "Warning");
            }
            else
            {
                string gender = "asd";
                if (rdbMale.Checked)
                {
                    gender = "Male";
                }
                else
                {
                    gender = "Female";
                }
                var jobSeeker = new JobSeeker(gender, txtLastName.Text, cmbCities.SelectedItem.ToString(), txtFirstName.Text, Convert.ToInt32(txtAge.Text), txtUserName.Text, txtPasswordJobSeeker.Text);
                JobSeekerService.RegisterJobSeeker(jobSeeker);
                LoggedData.LoggedJobSeeker = jobSeeker;

                HomeJobSeeker h1 = new HomeJobSeeker();
                //     this.Close();
                h1.Show();
            }
        }
        public async Task ThrowException_WhenBusinessAlreadyExists()
        {
            var businessName     = "business";
            var location         = "tsarigradsko";
            var gpsCoordinates   = "3424444";
            var about            = "about";
            var shortDescription = "shortDescription";
            var coverPicture     = "path";
            var pics             = new List <string>()
            {
                "path", "otherPath"
            };
            var facilities = new List <int>()
            {
                1, 2
            };
            var businessId = 1;

            var mappingProviderMocked = new Mock <IMappingProvider>();
            var dateTimeWrapperMocked = new Mock <IDateTimeWrapper>();
            var paginatedListMocked   = new Mock <IPaginatedList <BusinessShortInfoDTO> >();

            BusinessTestUtils.GetContextWithBusiness(nameof(ThrowException_WhenBusinessAlreadyExists), businessId, businessName);

            using (var assertContext = new AlphaHotelDbContext(BusinessTestUtils.GetOptions(nameof(ThrowException_WhenBusinessAlreadyExists))))
            {
                var businessService = new BusinessService(assertContext, mappingProviderMocked.Object, dateTimeWrapperMocked.Object, paginatedListMocked.Object);

                await Assert.ThrowsExceptionAsync <ArgumentException>(
                    async() => await businessService.CreateBusiness(businessName, location, gpsCoordinates, about, shortDescription, coverPicture, pics, facilities));
            }
        }
Beispiel #7
0
        private BusinessService CreateBusinessService()
        {
            //var userId = Guid.Parse(User.Identity.GetUserId());
            var service = new BusinessService();

            return(service);
        }
Beispiel #8
0
        private void lblBusinessName_Click(object sender, EventArgs e, HomeJobSeeker h1)
        {
            var business = BusinessService.SearchByBusinessName(lblBusinessName.Text);

            MessageBox.Show("hello world ");
            h1.Parent.Controls.Clear();
        }
        public ActionResult <ValidateResult> CheckCreditcard([FromRoute] String cardNumber, [FromRoute] String expireDate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ValidateResult        res             = new ValidateResult();
            BusinessService       bs              = new BusinessService();
            Card                  c               = new Card(cardNumber, expireDate);
            var                   paramCardNumber = new SqlParameter("@CardNumber", cardNumber);
            List <CreditCardItem> CreditCardItems = _context.CreditCardItems.FromSql("GetOfCreditCards @CardNumber", paramCardNumber).ToList();

            int cnt = CreditCardItems.Count();

            if (cnt == 0)
            {
                res.result = "Does not exist";
                return(res);
            }

            /*
             * foreach (var item in CreditCardItems)
             * {
             *
             * }
             */



            return(bs.VerifyResult(c));
        }
        public BusinessServiceTests()
        {
            var businessesList = new List <Business>
            {
                new Business {
                    Id = 1, Name = "test 1", CountryId = 2
                },
                new Business {
                    Id = 2, Name = "test 2", CountryId = 1
                },
                new Business {
                    Id = 3, Name = "test 4", CountryId = 1
                }
            }.AsQueryable();

            var context = Substitute.For <TtContext>();

            _countryRepository  = Substitute.For <Repository <Country> >(context);
            _businessRepository = Substitute.For <Repository <Business> >(context);

            _businessRepository.GetList().Returns(businessesList);
            _businessRepository.GetItem(Arg.Any <int>()).Returns(new Business {
                Id = 1, Name = "test 1", CountryId = 1
            });

            _service = new BusinessService(_businessRepository, _countryRepository);
        }
Beispiel #11
0
        public static string GetServiceLocation()
        {
            Console.WriteLine("Querying UDDI Registry...");
            //Assign the network endpoint of UDDI Web services
            Inquire.Url = "http://test.uddi.microsoft.com/inquire";

            //Find the provider
            FindBusiness findProvider = new FindBusiness();

            findProvider.Names.Add("Vendor A");
            BusinessList providerList    = findProvider.Send();
            BusinessInfo provider        = providerList.BusinessInfos[0];
            ServiceInfo  providerService = provider.ServiceInfos[0];

            //Find the Service details
            GetServiceDetail findService = new GetServiceDetail();

            findService.ServiceKeys.Add(providerService.ServiceKey);
            ServiceDetail   sd       = findService.Send();
            BusinessService service  = sd.BusinessServices[0];
            BindingTemplate template = service.BindingTemplates[0];

            //Retrieve the service URL
            Console.WriteLine("Provider Endpoint : " + template.AccessPoint.Text);
            return(template.AccessPoint.Text);
        }
        private async Task DeleteClientAsync()
        {
            IsProcessing = true;

            var request = new RemoveClientFromBusinessRequestModel()
            {
                BusinessId = _businessId.ToString(),
                ClientId   = _client.ClientId,
            };
            var service  = new BusinessService();
            var responce = await service.RemoveClientFromBusiness(request);

            IsProcessing = false;

            var success = responce.Status == true;

            if (success)
            {
                _parentViewModel.RefreshCommand.Execute(null);
                await App.Current.MainPage.DisplayAlert("Success", responce.GetMessage(), "OK");

                await App.Current.MainPage.Navigation.PopAsync();
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Error", responce.GetMessage(), "OK");
            }
        }
        public BusinessesControllerTests()
        {
            var list = new List <Business>
            {
                new Business {
                    Id = 1, Name = "test 1", CountryId = 2
                },
                new Business {
                    Id = 2, Name = "test 2", CountryId = 1
                }
            }.AsQueryable();

            var mockContext        = Substitute.For <TtContext>();
            var businessRepository = Substitute.For <Repository <Business> >(mockContext);
            var countryRepository  = Substitute.For <Repository <Country> >(mockContext);

            _service = Substitute.For <BusinessService>(businessRepository, countryRepository);
            _service.GetList().Returns(list);
            _service.GetItem(Arg.Any <int>()).Returns(new Business {
                Id = 1, Name = "test 1", CountryId = 1
            });
            _service.Create(Arg.Any <Business>());
            _service.Update(Arg.Any <int>(), Arg.Any <Business>());
            _service.Delete(Arg.Any <int>());

            var mockLogger = Substitute.For <ILoggerFactory>();

            _controller = new BusinessesController(_service, mockLogger);
        }
        public void GetBAU_VerifyCorrectnessOfGeneratedBAUFor(int numberOfDays)
        {
            //arrange
            var mockBAUs    = GetQueryableMockDbSet(new List <BAU>());
            var mockPeople  = GetQueryableMockDbSet(CreatePeople().ToList());
            var mockContext = new Mock <IWheelOfFateContext>();

            mockContext.Setup(x => x.BAU).Returns(mockBAUs.Object);
            mockContext.Setup(x => x.People).Returns(mockPeople.Object);

            BusinessService business = new BusinessService(mockContext.Object);
            var             date     = new DateTime(2017, 11, 23);

            for (int i = 0; i < numberOfDays; i++)
            {
                date = date.AddDays(1);

                //act
                var result = business.GetBAU(date);
                //assert
                Assert.Equal(2, result.Count());
            }

            Assert.Equal(mockPeople.Object.Count(), mockBAUs.Object.GroupBy(x => x.Person).Distinct().Count());

            foreach (var person in mockPeople.Object)
            {
                Assert.True(mockBAUs.Object.Where(x => x.Person.Equals(person) && x.HalfOfTheDay == 1).Any());
                Assert.True(mockBAUs.Object.Where(x => x.Person.Equals(person) && x.HalfOfTheDay == 2).Any());
            }
        }
Beispiel #15
0
        public void TotalShouldReturnCorrectCount()
        {
            // Arrange
            var firstBusinessy = new Business {
                Id = 1, Name = "First"
            };
            var secondBusiness = new Business {
                Id = 2, Name = "Second"
            };
            var thirdBusiness = new Business {
                Id = 3, Name = "Third"
            };
            var userManager = this.GetUserManagerMock();

            this.db.AddRange(firstBusinessy, secondBusiness, thirdBusiness);
            this.db.SaveChanges();

            var businessService = new BusinessService(this.db, userManager.Object);

            // Act
            var result = businessService.TotalAsync();

            // Assert
            result
            .Should()
            .Equals(3);
        }
Beispiel #16
0
        // GET: Event
        public ActionResult Index(int id)
        {
            var businessService = new BusinessService();
            var model           = businessService.GetByID(id);

            return(View(model));
        }
Beispiel #17
0
        public void InsertBusinessService(BusinessService service)
        {
            if (String.IsNullOrEmpty(service.ServiceID))
                service.ServiceID = Guid.NewGuid().ToString();

            //--借用Category字段传递用户ID
            String userID = service.Category;
            service.Category = String.Empty;
            service.DefaultVersion = 1;     //新建服务时默认版本为1
            service.Insert();

            //--在新增服务时建立默认版本
            BusinessServiceVersion version = new BusinessServiceVersion()
            {
                OID = Guid.NewGuid().ToString(),
                ServiceID = service.ServiceID,
                BigVer = 1,
                SmallVer = 0,
                CreateDateTime = DateTime.Now,
                Status = 0,
                CreatePersionID = userID,
                Description = "初始化版本"
            };
            version.Insert();
        }
Beispiel #18
0
        public async Task EditShouldReturnTrueIfItIsSuccessfull()
        {
            // Arrange
            var userManager = this.GetUserManagerMock();
            var business    = new Business()
            {
                Id   = 1,
                Name = "Test"
            };

            var type = new List <PetType>()
            {
                PetType.AllDogs,
                PetType.Cat
            };

            this.db.Businesses.Add(business);
            await db.SaveChangesAsync();

            var businesService = new BusinessService(this.db, userManager.Object);

            // Act
            var result = await businesService.EditAsync(1, "test", TypeBusiness.Cabin, "test", "test", 2d, 2d, type, "test", "test", true, "test", "test");

            // Assert
            result
            .Should()
            .BeTrue();
        }
        private async Task AddClientToBusinessAsync()
        {
            IsProcessing = true;

            var request = new AddClientToBusinessRequestModel()
            {
                BusinessId = _businessId.ToString(),
                ClientId   = lblId.Text,
                IsManager  = SwitchIsManager.IsToggled ? "1" : "0",
            };

            var service  = new BusinessService();
            var responce = await service.AddClientToBusiness(request);

            IsProcessing = false;

            var success = responce.Status == true;

            if (success)
            {
                _parentViewModel.RefreshCommand.Execute(null);
                await App.Current.MainPage.DisplayAlert("Success", responce.GetMessage(), "OK");
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Error", responce.GetMessage(), "OK");
            }
        }
Beispiel #20
0
        // PUT api/users/5
        //修改
        public Object Put(string id, UserApiModel obj)
        {
            string msg;

            try
            {
                User obj4save = obj.ToDto();

                User objinDb = BusinessService.GetUserById(id);
                if (objinDb == null)
                {
                    msg = string.Format(XiaoluResources.MSG_OBJECT_NOT_FOUND_WITH_ID, id);
                    return(new { IsSuccess = false, Message = msg });
                }
                objinDb.Name        = obj4save.Name;
                objinDb.Description = obj4save.Description;
                objinDb.Gender      = obj4save.Gender;
                objinDb.Birthday    = obj4save.Birthday;
                objinDb.Level       = obj4save.Level;
                objinDb.Status      = obj4save.Status;
                objinDb.Mobile      = obj4save.Mobile;
                objinDb.WeixinId    = obj4save.WeixinId;

                BaseActionResult result = BusinessService.UpdateUser(objinDb);
                return(new { IsSuccess = result.IsSuccess, Message = result.Message });
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj.Name) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return(new { IsSuccess = false, Message = msg });
            }
        }
Beispiel #21
0
 public void TestSetup()
 {
     this.loggerService = Substitute.For <ILoggerService>();
     this.loggerService.When(l => l.RunWithExceptionLogging(Arg.Any <Action>())).Do(info => info.Arg <Action>().Invoke());
     this.repository      = Substitute.For <IRepository>();
     this.businessService = new BusinessService(repository, loggerService);
 }
        public ActionResult Save(int?id)
        {
            var obj = new CompanyAuthorize()
            {
                Source = 1, Way = 1, MemberShared = "Y", EffectiveDT = System.DateTime.Now.ToString("yyyy-MM-dd")
            };

            if (id.HasValue)
            {
                obj = CompAuthorService.GetOne(id.Value);
            }
            ViewBag.BusinessModes = ListToSelect(DictionaryService.GetChildList(221, false).Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.DicSN.ToString()
            }));
            ViewBag.OpenScopeIds = ListToSelect(BusinessService.GetList(false).Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.ById
            }));
            ViewBag.users = ListToSelect(UserService.GetList(false).Select(o => new SelectListItem()
            {
                Text = o.FullName, Value = o.UserId
            }), emptyTitle: "请选择");
            ViewBag.states = EnumToSelect(typeof(CompanyAuthorizeState));
            return(View(obj.IsNullThrow()));
        }
Beispiel #23
0
        public async Task FindAsyncShouldReturnCorrectResultWithFilterAndOrder()
        {
            // Arrange

            var userManager = this.GetUserManagerMock();

            var firstBusiness = new Business {
                Id = 1, City = "First", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };
            var secondBusiness = new Business {
                Id = 2, City = "Second", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };
            var thirdBusiness = new Business {
                Id = 3, City = "Third", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };

            db.AddRange(firstBusiness, secondBusiness, thirdBusiness);

            await db.SaveChangesAsync();

            var businessService = new BusinessService(this.db, userManager.Object);

            // Act
            var result = await businessService.FindAsync("t");

            // Assert
            result
            .Should()
            .Match(r => r.ElementAt(0).Id == 3 &&
                   r.ElementAt(1).Id == 1)
            .And
            .HaveCount(2);
        }
Beispiel #24
0
        private void KonfiguracjaZwrotowForm_Load(object sender, EventArgs e)
        {
            grupyTowaroweBindingSource.DataSource = BusinessService.GetGrupyTowarowe(Session).OrderBy(r => r.Name).ToList();
            int?     defaultGroup         = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigInt("ZWROT_DEFAULT_PRODUCT_GROUP");
            int?     defaultStatusDopPrzj = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigInt("ZWROT_STATUS_DOPIERO_PRZYJEDZIE");
            DateTime?defaultFrom          = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigDate("ZWROT_DEFAULT_SPAN_FROM");
            DateTime?defaultTo            = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigDate("ZWROT_DEFAULT_SPAN_TO");



            if (defaultGroup != null)
            {
                domyslnaGrupaComboBox.SelectedValue = defaultGroup.Value;
            }

            if (defaultStatusDopPrzj != null)
            {
                tbStatusDopieroPrzyjedzie.Text = defaultStatusDopPrzj.Value.ToString();
            }

            if (defaultFrom != null)
            {
                domyslnyOkrOddDatePicker.Value = defaultFrom.Value;
            }

            if (defaultTo != null)
            {
                domyslnyOkrDoDatePicker.Value = defaultTo.Value;
            }
        }
Beispiel #25
0
 public CustomerController(
     BusinessService businessServices, StripeDataContext db, IConfiguration config)
 {
     _businessServices = businessServices;
     _db     = db;
     _config = config;
 }
Beispiel #26
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // LoggedData.LoggedJobSeeker = null;

            bool Exists = JobSeekerService.DoesThisNameExist(txtUsername.Text);

            if (Exists)
            {
                //MessageBox.Show("Go to joobSeker web");

                //Initialzing object
                var user = JobSeekerService.GetByUsername(txtUsername.Text);
                LoggedData.LoggedJobSeeker.Username = txtUsername.Text;
                LoggedData.LoggedJobSeeker.Name     = user.Name;
                LoggedData.LoggedJobSeeker.Password = user.Password;
                LoggedData.LoggedJobSeeker.LastName = user.LastName;
                LoggedData.LoggedJobSeeker.Id       = user.Id;


                this.Close();
                HomeJobSeeker h = new HomeJobSeeker();
                h.Show();
            }
            else if (BusinessService.DoesThisNameExist(txtUsername.Text))
            {
                LoggedData.LoggedBusiness.Username = txtUsername.Text;
                Home h1 = new Home();
                h1.Show();
            }
        }
        public async System.Threading.Tasks.Task EventsAsync()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();
            var apiSetting = new APISettings(configuration);
            var pbsClient  = new PBSClient();

            var eventService   = new EventService(apiSetting, pbsClient);
            var memberService  = new MemberService(apiSetting, pbsClient);
            var dateTimeHelper = new DateTimeHelper();

            //auto mapper configuration
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new ServiceProfile());
            });
            var mapper          = mockMapper.CreateMapper();
            var businessService = new BusinessService(mapper, eventService, memberService, dateTimeHelper);

            Assert.NotNull(businessService);

            var eventList = await businessService.GetEventsAsync("2019-05-11");

            Assert.NotNull(eventList);
            Assert.NotEmpty(eventList);

            Assert.Equal(0, eventList.Count(x => x.StartDate < new DateTime(2019, 5, 6)));
            Assert.Equal(0, eventList.Count(x => x.EndDate > new DateTime(2019, 5, 12)));
        }
Beispiel #28
0
        private void ZwrotFormularzForm_Load(object sender, EventArgs e)
        {
            //grupyTowaroweBindingSource.DataSource = FeatureDefsService.GetGrupyTowaroweQuery().OrderBy(g => g.Nazwa).ToList();
            grupyTowaroweBindingSource.DataSource = BusinessService.GetGrupyTowarowe(Session);
            loadPrzedstawiciele();
            loadKontrahenci();
            if (KontrahentId != null)
            {
                kontrahenciComboBox.SelectedValue = KontrahentId;
            }
            int?     grupa    = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigInt("ZWROT_DEFAULT_PRODUCT_GROUP");
            DateTime?dateFrom = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigDate("ZWROT_DEFAULT_SPAN_FROM");
            DateTime?dateTo   = Enova.Business.Old.Core.ContextManager.WebContext.GetConfigDate("ZWROT_DEFAULT_SPAN_TO");

            if (grupa != null)
            {
                grupyTowaroweComboBox.SelectedValue = grupa.Value;
            }
            if (dateFrom != null)
            {
                dataOdDateTimePicker.Value = dateFrom.Value;
            }

            if (dateTo != null)
            {
                dataDoDateTimePicker.Value = dateTo.Value;
            }

            this.ActiveControl = obliczButton;
        }
        public async System.Threading.Tasks.Task EventDetailsAsync()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();
            var apiSetting = new APISettings(configuration);
            var pbsClient  = new PBSClient();

            var eventService   = new EventService(apiSetting, pbsClient);
            var memberService  = new MemberService(apiSetting, pbsClient);
            var dateTimeHelper = new DateTimeHelper();

            //auto mapper configuration
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new ServiceProfile());
            });
            var mapper = mockMapper.CreateMapper();

            var businessService = new BusinessService(mapper, eventService, memberService, dateTimeHelper);

            Assert.NotNull(businessService);

            var eventList = await businessService.GetEventDetailsAsync("2019-05-13", 26788);

            Assert.NotNull(eventList);
            Assert.NotEmpty(eventList.Members);
            Assert.Single(eventList.Members);

            Assert.Equal("Business Statement", eventList.Category);
            Assert.Equal("Rt Hon Andrea Leadsom MP", eventList.Members[0].FullTitle);
        }
Beispiel #30
0
 /// <summary>
 /// Adds the service.
 /// </summary>
 /// <param name="pName">Name of the provider.</param>
 /// <param name="sName">Name of the service.</param>
 /// <param name="sDescription">The service description.</param>
 /// <param name="aPoint">Access point of the service.</param>
 /// <param name="categoryName">Name of the category.</param>
 /// <param name="keyName">Name of the key.</param>
 /// <param name="keyValue">The key value.</param>
 public void AddService(string pName, string sName, string sDescription, string aPoint, string categoryName, string keyName, string keyValue)
 {
     if (UDDISearcher.GetServiceKey(UDDIConnection, sName).Equals(String.Empty))
     {
         BusinessService bService = UDDIDataCreater.CreateBusinessService(sName, sDescription);
         string          bKey     = UDDISearcher.GetBusinessKey(UDDIConnection, pName);
         bService.BusinessKey = bKey;
         bService.BindingTemplates.Add(UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint)));
         bService.CategoryBag.KeyedReferences.Add(UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryName), keyValue, keyName));
         try
         {
             UDDIPublisher.SaveBusinessService(UDDIConnection, bService);
         }
         catch (Exception ex)
         {
             throw new Exception("Unable to add the service " + ex.Message);
         }
     }
     else
     {
         BusinessService bService = UDDISearcher.GetService(UDDIConnection, sName);
         bService.BindingTemplates.Add(UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint)));
         bService.CategoryBag.KeyedReferences.Add(UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryName), keyValue, keyName));
         try
         {
             UDDIPublisher.SaveBusinessService(UDDIConnection, bService);
         }
         catch (Exception ex)
         {
             throw new Exception("Unable to add the service " + ex.Message);
         }
     }
 }
Beispiel #31
0
        public void WhenCreateThenMessages()
        {
            var expectedMessage1 = "Mock Command was processed.  1";
            var expectedMessage2 = "Mock Command was processed.  2";
            var expectedMessage3 = "Mock Command was processed.  3";

            var mockCommand1 = new Mock <ICommand>();

            mockCommand1.Setup(x => x.Process(It.IsAny <ProcessRequest>())).Returns(expectedMessage1);

            var mockCommand2 = new Mock <ICommand>();

            mockCommand2.Setup(x => x.Process(It.IsAny <ProcessRequest>())).Returns(expectedMessage2);

            var mockCommand3 = new Mock <ICommand>();

            mockCommand3.Setup(x => x.Process(It.IsAny <ProcessRequest>())).Returns(expectedMessage3);

            var mockCommandFactory = new Mock <ICommandFactory>();

            mockCommandFactory.Setup(x => x.Create(It.IsAny <Models.CommandType>()))
            .Returns(new List <ICommand> {
                mockCommand1.Object, mockCommand2.Object, mockCommand3.Object
            });

            var businessService = new BusinessService(mockCommandFactory.Object);
            var response        = businessService.Process(new ProcessRequest());

            Assert.AreEqual(expectedMessage1, response.Messages[0]);
            Assert.AreEqual(expectedMessage2, response.Messages[1]);
            Assert.AreEqual(expectedMessage3, response.Messages[2]);
        }
 public int InsertIntoEntity(BusinessService b)
 {
     BusinessMessage bm = new BusinessMessage();
     //bm.StarterID = b.StaterID;
     bm.ReceiveID = b.ReceiveID;
     bm.BusinessID = b.BusinessID;
     bm.TimeStamp = b.TimeStamp;
     bm.State = 0;
     bm.IsRead = 0;
     bm.Type = b.Type;
     context.BusinessMessages.Add(bm);
     context.SaveChanges();
     return bm.Id;
 }
        /// <summary>
        ///   Publica serviciul cu informatiile specificate in campurile corespunzatoare (daca nu exista deja).
        /// </summary>
        public void performPublish()
        {
            String businessName = txbBusinessName.Text.Trim();
            String serviceName  = txbServiceName.Text.Trim();
            String accessPoint  = txbAccessPoint.Text.Trim();

            if (businessName == String.Empty || serviceName == String.Empty || accessPoint == String.Empty) {

                MessageBox.Show("All values must be set", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try {

                FindBusiness findBusiness = new FindBusiness(businessName);

                findBusiness.FindQualifiers.Add(FindQualifier.ExactNameMatch);

                BusinessList businessList = findBusiness.Send(uddiConnection);

                if (0 == businessList.BusinessInfos.Count) {

                    BusinessEntity newBusinessEntity   = new BusinessEntity(businessName);

                    BusinessService newBusinessService = new BusinessService(serviceName);

                    newBusinessEntity.BusinessServices.Add(newBusinessService);

                    BindingTemplate newBindingTemplate = new BindingTemplate();

                    newBindingTemplate.AccessPoint.Text    = accessPoint;
                    newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                    selectOntologyForNewBindingTemplate(newBindingTemplate);

                    newBusinessService.BindingTemplates.Add(newBindingTemplate);

                    SaveBusiness saveNewBusiness = new SaveBusiness(newBusinessEntity);

                    saveNewBusiness.Send(uddiConnection);
                }
                else {

                    MessageBox.Show("Business already exists");

                    GetBusinessDetail getBusinessDetail = new GetBusinessDetail(businessList.BusinessInfos[0].BusinessKey);

                    BusinessDetail businessDetail    = getBusinessDetail.Send(uddiConnection);

                    BusinessEntity oldBusinessEntity = businessDetail.BusinessEntities[0];

                    FindService findService = new FindService(serviceName);

                    findService.FindQualifiers.Add(FindQualifier.ExactNameMatch);

                    findService.BusinessKey = businessDetail.BusinessEntities[0].BusinessKey;

                    ServiceList serviceList = findService.Send(uddiConnection);

                    if (0 == serviceList.ServiceInfos.Count) {

                        BusinessService newBusinessService     = new BusinessService(serviceName);

                        oldBusinessEntity.BusinessServices.Add(newBusinessService);

                        BindingTemplate newBindingTemplate     = new BindingTemplate();

                        newBindingTemplate.AccessPoint.Text    = accessPoint;
                        newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                        selectOntologyForNewBindingTemplate(newBindingTemplate);

                        newBusinessService.BindingTemplates.Add(newBindingTemplate);

                        SaveBusiness saveOldBusiness = new SaveBusiness(oldBusinessEntity);

                        saveOldBusiness.Send(uddiConnection);
                    }
                    else {

                        MessageBox.Show("Service already exists");

                        GetServiceDetail getServiceDetail  = new GetServiceDetail(serviceList.ServiceInfos[0].ServiceKey);

                        ServiceDetail serviceDetail        = getServiceDetail.Send(uddiConnection);

                        BusinessService oldBusinessService = serviceDetail.BusinessServices[0];

                        foreach (BindingTemplate bindingTemplate in oldBusinessService.BindingTemplates) {

                            if (bindingTemplate.AccessPoint.Text == accessPoint) {

                                MessageBox.Show("Binding already exists");
                                return;
                            }
                        }

                        BindingTemplate newBindingTemplate     = new BindingTemplate();

                        newBindingTemplate.AccessPoint.Text    = accessPoint;
                        newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                        selectOntologyForNewBindingTemplate(newBindingTemplate);

                        oldBusinessService.BindingTemplates.Add(newBindingTemplate);

                        SaveService saveOldService = new SaveService(oldBusinessService);

                        saveOldService.Send(uddiConnection);
                    }
                }

                MessageBox.Show("Publish successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (UddiException e) {

                MessageBox.Show("Uddi error: "+ e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception e){

                MessageBox.Show("General exception: " + e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #34
0
 public void DeleteBusinessService(BusinessService service)
 {
     service.Delete();
     esbProxy.RegistryConsumerClient.ResendServiceConfig();
 }