Exemplo n.º 1
0
        private void btnCheckNow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var session = SharpArch.NHibernate.NHibernateSession.GetDefaultSessionFactory().OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        SiteRepository          siteRepository          = new SiteRepository(session);
                        SiteResponseRepository  siteResponseRepository  = new SiteResponseRepository(session);
                        SiteErrorRepository     siteErrorRepository     = new SiteErrorRepository(session);
                        NotificationsRepository notificationsRepository = new NotificationsRepository(session);

                        Site         siteToUpdate = ((FrameworkElement)sender).DataContext as Site;
                        int          id           = siteToUpdate.Id;
                        Site         site         = siteRepository.Get(id);
                        SiteResponse lastResponse = siteResponseRepository.GetLastResponse(site.Id);

                        ResponseChecker checker = new ResponseChecker(ApplicationLogic.Utils.Logger.Instance, siteRepository, siteResponseRepository, siteErrorRepository, notificationsRepository);
                        checker.CheckResponse(site, lastResponse);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLogic.Utils.Logger.Instance.LogError(ex);
            }

            UpdateDataGrid();
        }
Exemplo n.º 2
0
        public void Get_ReturnNull(int id)
        {
            var repository = new SiteRepository(_dbContext, _cache.Object, _logger.Object);
            var item       = repository.Get(id);

            Assert.Null(item);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Get(int id)
        {
            ResponseHelper objHelper = new ResponseHelper();

            try
            {
                var vList = await SiteRepository.Get(id);

                if (vList == null)
                {
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Get Empty Data";
                }
                else
                {
                    objHelper.Status  = StatusCodes.Status200OK;
                    objHelper.Message = "Get Successfully";
                    objHelper.Data    = vList;
                }
                return(Ok(objHelper));
            }
            catch
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = "Get Unsuccessful";
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> UpdateStatus(int id, short isActive)
        {
            ResponseHelper objHelper = new ResponseHelper();

            if (!ModelState.IsValid)
            {
                objHelper.Status  = StatusCodes.Status424FailedDependency;
                objHelper.Message = "Invalid Model State";
                return(BadRequest(objHelper));
            }
            try
            {
                await SiteRepository.ToogleStatus(id, isActive);

                objHelper.Status  = StatusCodes.Status200OK;
                objHelper.Message = "Saved Successfully";
                objHelper.Data    = await SiteRepository.Get(id);

                return(Ok(objHelper));
            }
            catch
            {
                objHelper.Status  = StatusCodes.Status500InternalServerError;
                objHelper.Message = "Save Unsuccessful";
                return(StatusCode(StatusCodes.Status500InternalServerError, objHelper));
            }
        }
Exemplo n.º 5
0
        private void buttonEdit_Click(object sender, RoutedEventArgs e)
        {
            using (var session = SharpArch.NHibernate.NHibernateSession.GetDefaultSessionFactory().OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    SiteRepository siteRepository = new SiteRepository(session);
                    Site           site           = siteRepository.Get(SiteId);
                    site.SiteName      = textBoxSiteName.Text;
                    site.SiteUrl       = textBoxSiteUrl.Text;
                    site.CheckInterval = Convert.ToInt32(textBoxCheckInterval.Text);
                    if (checkBoxCheckSpecificElement.IsChecked.GetValueOrDefault())
                    {
                        site.CheckSpecificElement = true;
                        site.SpecificElement      = textBoxSpecificElement.Text;
                        site.SpecificElementType  = (SpecificElementType)comboBoxSpecificElementType.SelectedValue;
                    }
                    site.Enabled = checkBoxEnabled.IsChecked.GetValueOrDefault();
                    if (checkBoxSendtoOtherEmail.IsChecked.GetValueOrDefault())
                    {
                        site.NotificationEmail = textBoNotificationEmail.Text;
                    }
                    else
                    {
                        site.NotificationEmail = site.User.Email;
                    }
                    siteRepository.SaveOrUpdate(site);
                    transaction.Commit();
                }
            }

            this.Close();
        }
Exemplo n.º 6
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            comboBoxSpecificElementType.ItemsSource = Enum.GetValues(typeof(SpecificElementType));

            using (var session = SharpArch.NHibernate.NHibernateSession.GetDefaultSessionFactory().OpenSession())
            {
                SiteRepository siteRepository = new SiteRepository(session);
                Site           site           = siteRepository.Get(SiteId);
                checkBoxEnabled.IsChecked                 = site.Enabled;
                textBoNotificationEmail.Text              = site.NotificationEmail;
                textBoxSiteName.Text                      = site.SiteName;
                textBoxSiteUrl.Text                       = site.SiteUrl;
                textBoxCheckInterval.Text                 = site.CheckInterval.ToString();
                checkBoxCheckSpecificElement.IsChecked    = site.CheckSpecificElement;
                comboBoxSpecificElementType.SelectedValue = site.SpecificElementType;
                if (!String.IsNullOrEmpty(site.NotificationEmail))
                {
                    if (!site.NotificationEmail.Equals(site.User.Email))
                    {
                        checkBoxSendtoOtherEmail.IsChecked = true;
                    }
                }
                textBoxSpecificElement.Text = site.SpecificElement;
            }
        }
Exemplo n.º 7
0
        //
        // GET: /Site/Edit/5

        public ActionResult Edit(int id)
        {
            Site e = repo.Get(id);

            e.NewGeoFullName = e.GeoFullName;
            //e.NewCategoryFullName = e.CategoryFullName;
            return(View(e));
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            var siteRepo = new SiteRepository();

            foreach (var site in siteRepo.Get().Where(x => x.Name == "Nettavisen"))
            {
                var parser = ImageParser.Create(site);
                var task   = parser.Run();
                task.Wait();
            }
        }
Exemplo n.º 9
0
 private void btnOpenSite_Click(object sender, RoutedEventArgs e)
 {
     using (var session = SharpArch.NHibernate.NHibernateSession.GetDefaultSessionFactory().OpenSession())
     {
         SiteRepository siteRepository = new SiteRepository(session);
         Site           site           = siteRepository.Get(SiteId);
         if (site != null && !String.IsNullOrEmpty(site.SiteUrl))
         {
             System.Diagnostics.Process.Start(new Uri(site.SiteUrl).ToString());
         }
     }
 }
Exemplo n.º 10
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to permanently delete this site checker?", "Are you sure?", MessageBoxButton.OKCancel);

            if (messageBoxResult == MessageBoxResult.OK)
            {
                using (var session = SharpArch.NHibernate.NHibernateSession.GetDefaultSessionFactory().OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        SiteRepository siteRepository = new SiteRepository(session);
                        Site           siteToDelete   = ((FrameworkElement)sender).DataContext as Site;
                        int            id             = siteToDelete.Id;
                        Site           site           = siteRepository.Get(id);
                        siteRepository.Delete(site);
                        transaction.Commit();
                    }
                }

                UpdateDataGrid();
            }
        }
Exemplo n.º 11
0
 public IEnumerable <Site> Get(int page, int pageLength)
 {
     return(siteRepository.Get(page, pageLength));
 }