// GET: TasksToDoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TasksToDo tasksToDo = db.TasksToDoes.Find(id);

            if (tasksToDo == null)
            {
                return(HttpNotFound());
            }
            //ApplicationUser user = db.Users.Find(User.Identity.GetUserId());
            //if (tasksToDo.UserId != user.Id)
            //{
            //    this.AddToastMessage("Warning", "You Dont Have Permision to edit this!", ToastType.Warning);
            //    return RedirectToAction("Index");
            //}
            ViewBag.StatusId     = new SelectList(db.StatusOfStoriesTasks, "Id", "Status", tasksToDo.StatusId);
            ViewBag.PrioritiesId = new SelectList(db.Priorities, "Id", "Name", tasksToDo.PrioritiesId);
            ViewBag.ReleaseId    = new SelectList(db.Releases, "Id", "Version", tasksToDo.ReleaseId);
            ViewBag.SprintsId    = new SelectList(db.Sprints, "Id", "Name", tasksToDo.SprintsId);
            ViewBag.StoriesId    = new SelectList(db.Stories, "StoryId", "Name", tasksToDo.StoriesId);
            ViewBag.ProjectId    = new SelectList(db.Projects, "ProjectId", "ProjectTitle", tasksToDo.ProjectId);
            ViewBag.UserId       = new SelectList(db.Users, "Id", "Name", tasksToDo.UserId);
            return(View(tasksToDo));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutTask(int id, TasksToDo updatedTask)
        {
            if (id != updatedTask.TaskId)
            {
                return(BadRequest());
            }

            if (updatedTask.UserId != UserId)
            {
                return(Unauthorized("You cannot update task which are not assigned to you"));
            }

            _context.Entry(updatedTask).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TasksToDoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Statistics()
        {
            var statsModel = new TasksToDo();

            statsModel.Id = (db.TasksToDoes).Count();
            return(View(statsModel));
        }
        public override async Task Process(TasksToDo task, string configID, string customerId, string guid)
        {
            if (!await IsDoTaskOk(task, configID, customerId))
            {
                return;
            }

            var url = task.HostName;
            var res = ValidateCertificateByUrl(url);

            MonitoringReport abMonitorResult = new MonitoringReport
            {
                Id        = new Guid(guid),
                ConfigId  = new Guid(configID),
                TaskId    = task.Id,
                TimeStamp = DateTime.Now,
                TaskType  = task.Type,
                Result    = res ? "Verified" : "failed",
                Level     = 1,
                ClientId  = new Guid(customerId)
            };
            //if (!_dataCtr.CreateResult(abMonitorResult))
            //    _logger.LogError("Something went wrong while trying to save the data.");

            await Task.CompletedTask;
        }
Exemplo n.º 5
0
        protected async Task <bool> IsDoTaskOk(TasksToDo task, string configId, string customerId)
        {
            if (!await IsInitDataOk(task, configId, customerId))
            {
                return(await System.Threading.Tasks.Task.FromResult(false));
            }

            var latestTask = await _dataCtr.GetLatestTask(task.Id, new Guid(configId), task.Type);

            if (latestTask?.TimeStamp == null)
            {
                return(await System.Threading.Tasks.Task.FromResult(true));
            }
            ;

            var latestDate = latestTask.TimeStamp;
            var ckDate     = DateTime.Now.AddMinutes(-(task.Interval.Minutes));

            if (DateTime.Compare(latestDate, ckDate) <= 0)
            {
                return(await System.Threading.Tasks.Task.FromResult(true));
            }

            _logger.LogInformation($"{task.Type.ToUpper()} with Task ID: [{task.Id}] is uptodate.");
            return(await System.Threading.Tasks.Task.FromResult(false));;
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Start,DeadLine,Status,UserId")] TasksToDo tasksToDo)
        {
            if (id != tasksToDo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _tasksToDoService.UpdateAsync(tasksToDo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TasksToDoExists(tasksToDo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tasksToDo));
        }
Exemplo n.º 7
0
        public override void DoTask(TasksToDo task)
        {
            //ActionModel model = new ActionModel();
            if (task == TasksToDo.DownloadSingleAction)
            {
                try
                {
                    actionModel = GetSingleAction(DownloadActionName);
                }
                catch (Exception)
                {
                    NextProvider.DoTask(task);
                }

                if (actionModel.Name != null)
                {
                    Console.WriteLine($"Information downloaded from {ProviderName}");
                    Console.WriteLine($"Action name: {actionModel.Name} Date: {actionModel.Date} Maximum Price: {actionModel.MaximumPrice} Open Price: {actionModel.OpenPrice} Close Price: {actionModel.MinPrice} TKO: {actionModel.Tko} Trading Volume: {actionModel.TradingVolume}");
                    Logger.Instance.AppendLoggerMessage($"Information downloaded from: {ProviderName} Action Name: {actionModel.Name}");
                }
                else
                {
                    Console.WriteLine($"ERROR - {ProviderName} - dont have any information about this action or server not response");
                    Logger.Instance.AppendLoggerMessage($"ERROR - {ProviderName} - dont have any information about this action or server not response");
                    NextProvider.DoTask(task);
                }
            }
            else if (NextProvider != null)
            {
                NextProvider.DoTask(task);
            }
        }
 public TasksToDo CreateTasksToDo()
 {
     TasksToDo = new TasksToDo()
     {
         Title = "Task from Builder", Start = DateTime.Now, DeadLine = DateTime.Now
     };
     return(TasksToDo);
 }
 public TasksToDo CreateTasksToDoWithUser(int id)
 {
     TasksToDo = new TasksToDo()
     {
         Title = "Task from Builder", Start = DateTime.Now, DeadLine = DateTime.Now, UserId = id
     };
     return(TasksToDo);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            TasksToDo tasksToDo = db.TasksToDoes.Find(id);

            db.TasksToDoes.Remove(tasksToDo);
            db.SaveChanges();
            this.AddToastMessage("Success.", "You have successfully deleted Task!", ToastType.Success);
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Start,DeadLine,Status,UserId")] TasksToDo tasksToDo)
        {
            if (ModelState.IsValid)
            {
                await _tasksToDoService.AddAsync(tasksToDo);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tasksToDo));
        }
Exemplo n.º 12
0
        public IActionResult Create(TasksToDo task)
        {
            // logika za dodavanje na nov task vo listata
            if (ModelState.IsValid)
            {
                _tasks.Add(task);
                return(View("List", _tasks));
            }

            return(View("CreateForm", task));
        }
Exemplo n.º 13
0
        public async Task <ActionResult <TasksToDo> > PostTasksToDo(TasksToDo tasksToDo)
        {
            if (tasksToDo.UserId != UserId)
            {
                return(Unauthorized("You cannot create task which are not assigned to you"));
            }

            _context.TasksToDo.Add(tasksToDo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTasksToDo", new { id = tasksToDo.TaskId }, tasksToDo));
        }
        // GET: TasksToDoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TasksToDo tasksToDo = db.TasksToDoes.Find(id);

            if (tasksToDo == null)
            {
                return(HttpNotFound());
            }
            return(View(tasksToDo));
        }
        public ActionResult Notifications()
        {
            ApplicationUser user       = db.Users.Find(User.Identity.GetUserId());
            var             statsModel = new TasksToDo();

            statsModel.Id = (db.TasksToDoes).Count();
            //var i = from task in db.TasksToDoes
            //        group task by task.IsDone == false
            //            into notyGrouop
            //            select new TasksToDo { UserId = user.Id, Id = statsModel.Id };
            ViewBag.Count = statsModel;
            var tasksToDoes = db.TasksToDoes.Include(t => t.User);

            return(View(tasksToDoes));
        }
Exemplo n.º 16
0
 public IActionResult Edit(TasksToDo task)
 {
     // logika za edit na task vo listata. Prvo go naogame odredeniot task pa prajme re assign na editiranite polinja
     foreach (var item in _tasks)
     {
         if (item.RedenBroj == task.RedenBroj)
         {
             item.Description   = task.Description;
             item.StartDate     = task.StartDate;
             item.EndDate       = task.EndDate;
             item.IsFinished    = task.IsFinished;
             item.NumberOfHours = task.NumberOfHours;
         }
     }
     return(View("List", _tasks));
 }
Exemplo n.º 17
0
        public override void DoTask(TasksToDo task)
        {
            if (task == TasksToDo.DownloadSingleAction)
            {
                HtmlDocument html = DownloadHtml(url);

                var model = GetSingleAction(DownloadActionName, html);
                Console.WriteLine($"Information downloaded from {ProviderName}");
                Console.WriteLine($"Action name: {model.Name} Date: {model.Date} Maximum Price: {model.MaximumPrice} Open Price: {model.OpenPrice} Close Price: {model.MinPrice} TKO: {model.Tko} Trading Volume: {model.TradingVolume}");
                Logger.Instance.AppendLoggerMessage($"Information downloaded from: {ProviderName} Action Name: {model.Name}");
            }
            else if (NextProvider != null)
            {
                NextProvider.DoTask(task);
                Logger.Instance.AppendLoggerMessage($"ERROR - {ProviderName} - dont have any information about this action or server not response");
            }
        }
Exemplo n.º 18
0
        public override async Task <bool> IsInitDataOk(TasksToDo task, string configID, string customerID)
        {
            async Task <bool> IsValidAsync(string config)
            {
                return(await Task.FromResult(Guid.TryParse(config, out Guid guid)));
            }

            if (string.IsNullOrWhiteSpace(task.HostName) || string.IsNullOrWhiteSpace(configID) || string.IsNullOrWhiteSpace(customerID))
            {
                return(await Task.FromResult(false));
            }
            if (await IsValidAsync(configID) && await IsValidAsync(customerID))
            {
                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
        public override async Task <bool> IsInitDataOk(TasksToDo task, string configID, string customerID)
        {
            bool IsValid(string config)
            {
                return(Guid.TryParse(config, out Guid guid));
            }

            if (string.IsNullOrWhiteSpace(task.HostName) || string.IsNullOrWhiteSpace(configID) || string.IsNullOrWhiteSpace(customerID) || !task.HostName.StartsWith("https://"))
            {
                return(await Task.FromResult(false));
            }
            if (IsValid(configID) && IsValid(customerID))
            {
                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
 public ActionResult Edit([Bind(Include = "Id,Title,Description,IsDone,UserId,ProjectId,TestReference,UnitTestReference,StatusId,PrioritiesId,ReleaseId,SprintsId,StoriesId,Backlog")] TasksToDo tasksToDo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tasksToDo).State = EntityState.Modified;
         db.SaveChanges();
         this.AddToastMessage("Congratulations", "You have successfully finished your Task!", ToastType.Success);
         return(RedirectToAction("Index"));
     }
     ViewBag.StatusId     = new SelectList(db.StatusOfStoriesTasks, "Id", "Status", tasksToDo.StatusId);
     ViewBag.PrioritiesId = new SelectList(db.Priorities, "Id", "Name", tasksToDo.PrioritiesId);
     ViewBag.ReleaseId    = new SelectList(db.Releases, "Id", "Version", tasksToDo.ReleaseId);
     ViewBag.SprintsId    = new SelectList(db.Sprints, "Id", "Name", tasksToDo.SprintsId);
     ViewBag.StoriesId    = new SelectList(db.Stories, "StoryId", "Name", tasksToDo.StoriesId);
     ViewBag.ProjectId    = new SelectList(db.Projects, "ProjectId", "ProjectTitle", tasksToDo.ProjectId);
     ViewBag.UserId       = new SelectList(db.Users, "Id", "Name", tasksToDo.UserId);
     this.AddToastMessage("Warning", "You must enter all fields correctly in order to edit Support Task!", ToastType.Warning);
     return(View(tasksToDo));
 }
        // GET: TasksToDoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TasksToDo tasksToDo = db.TasksToDoes.Find(id);

            if (tasksToDo == null)
            {
                return(HttpNotFound());
            }
            //ApplicationUser user = db.Users.Find(User.Identity.GetUserId());
            //if (tasksToDo.UserId != user.Id)
            //{
            //    this.AddToastMessage("Warning", "You Dont Have Permision to edit this!", ToastType.Warning);
            //    return RedirectToAction("Index");
            //}
            this.AddToastMessage("Warning!", "You are deleting from database and if you delete it can not be undone!", ToastType.Warning);
            return(View(tasksToDo));
        }
Exemplo n.º 22
0
 public abstract Task <bool> IsInitDataOk(TasksToDo task, string configID, string clientID);
Exemplo n.º 23
0
 public abstract void DoTask(TasksToDo task);
Exemplo n.º 24
0
        public override async Task Process(TasksToDo task, string configID, string customerId, string guid)
        {
            PingReply   pingreply;
            IPHostEntry iPHostEntry;

            try
            {
                if (!await IsDoTaskOk(task, configID, customerId))
                {
                    return;
                }

                //int timeOut = 120;
                var server = task.HostName;

                iPHostEntry = GetIPAddress(task.HostName);

                foreach (var item in iPHostEntry.AddressList)
                {
                    if (item.IsIPv6SiteLocal == false)
                    {
                        _ip = item;
                    }
                }
                _logger.LogInformation("IP : " + _ip);

                lock (_ping)
                {
                    pingreply = _ping.Send(_ip /*, timeOut*/);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Something went wrong while trying to Ping.");
                return;
            }

            //var res = new ResultSet() { Duration = pingreply.RoundtripTime };
            //if (pingreply.Status == IPStatus.Success)
            //    res.Result = true;
            //else
            //    res.Result = false;

            ////TODO
            //guid = Guid.NewGuid().ToString();
            //AbMonitorResult abMonitorResult = new AbMonitorResult
            //{
            //    ResultId = new Guid(guid),
            //    ConfigId = new Guid(configID),
            //    TaskId = new Guid(task.Id),
            //    TimeStamp = DateTime.Now,
            //    TaskType = task.Type,
            //    Result = res.ToString(),
            //    Level = 1,
            //    CustomerId = new Guid(customerId)
            //};

            //if (!_dataCtr.CreateResult(abMonitorResult))
            //    _logger.LogError("Something went wrong while trying to save the data.");
            await Task.CompletedTask;
        }
Exemplo n.º 25
0
 public abstract Task StartTask(TasksToDo task, string configID, string clientID, string guid);
 public abstract Task Process(TasksToDo task, string configID, string customerId, string guid);
Exemplo n.º 27
0
 public abstract Task <bool> IsInitDataOk(TasksToDo task, string configID, string customerID);
Exemplo n.º 28
0
 public abstract System.Threading.Tasks.Task StartTask(TasksToDo task, string configID, string customerId, string guid);
        public override async Task StartTask(TasksToDo task, string configID, string customerId, string guid)
        {
            await Process(task, configID, customerId, guid);

            await Task.CompletedTask;
        }
Exemplo n.º 30
0
        public override async Task Process(TasksToDo task, string configID, string customerId, string guid)
        {
            if (!await IsDoTaskOk(task, configID, customerId))
            {
                return;
            }
            SqlConnection connection = new SqlConnection(task.ConnectionString);

            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = task.Query;

                using (SqlDataReader dataReader = command.ExecuteReader()) { }
                command.CommandText = "select @@ROWCOUNT";

                var totalRow = command.ExecuteScalar();

                stopwatch.Stop();

                _logger.LogInformation("CommandText: " + task.Query + "Found :" + (int)totalRow + " Row(s).");

                ResultSet result = new ResultSet()
                {
                    Duration = stopwatch.ElapsedMilliseconds
                };

                if ((int)totalRow > 0)
                {
                    result.Result = true;
                }
                else
                {
                    result.Result = false;
                }

                connection.Close();

                //AbMonitorResult abMonitorResult = new AbMonitorResult
                //{
                //    ResultId = new Guid(guid),
                //    ConfigId = new Guid(configID),
                //    TaskId = new Guid(task.Id),
                //    TimeStamp = DateTime.Now,
                //    TaskType = task.Type,
                //    Result = result.ToString(),
                //    Level = 1,
                //    CustomerId = new Guid(customerId)
                //};

                //if (!_dataCtr.CreateResult(abMonitorResult))
                //    _logger.LogError("Something went wrong while trying to save the data.");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Something went wrong");
                throw;
            }
            await Task.CompletedTask;
        }