public IActionResult CreateRule() { var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext); var permission = _partActRepo.GetPartAct("PartnerActivity.Create", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var model = new CreatePartnerActivity2Dto(); var detailModel = new List <CreatePartnerActivityDetailDto>(); var fromRoles = new RoleRepo(db, _partActRepo).GetRoles(); var toRoles = new RoleRepo(db, _partActRepo).GetRoles(); var activities = new ActivityRepo(db, _PartnerManager).GetActivities(); var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration"); var scopes = new CommonCodeRepo(db).GetCodesByType("activity.scope"); model.FromRoles = fromRoles; //detailModel.ToRoles = toRoles; model.Activities = activities; model.MaxQueryDuration = maxQueryDuration; model.Scopes = scopes; model.Details = detailModel; ViewBag.Details = new CreatePartnerActivityDetailDto { ToRoles = new RoleRepo(db, _partActRepo).GetRoles() }; return(View(model)); }
public IActionResult Index(ActivityQuery model) { var activities = new ActivityRepo(db, partnerManager).GetActivities(model.QName, true); model.Results = activities; return(View(model)); }
public IActionResult AssignMessage(int msgid, string st, AssignActivityMessageDto model) { var actMsg = new ActivityMessage(); actMsg.Activity.Id = model.ActivityId; actMsg.Message.Id = msgid; actMsg.SendingTime.Id = "after"; actMsg.CreatedBy.Id = partnerManager.GetCurrentUserId(this.HttpContext); actMsg.CreatedBy.Account = partnerManager.GetCurrentUserAccount(this.HttpContext); actMsg.MessageOrder = -1; var result = new ActivityMessageRepo(db, partnerManager).Create(actMsg); var activity = new ActivityRepo(db, partnerManager).GetActivity(model.ActivityId); model.Activity = activity; var sendingTime = new CommonCodeRepo(db).GetCodesByType("ActivityMessage.SendingTime"); model.SendingTime = sendingTime; var messages = new MessageTemplateRepo(db, partnerManager).GetAll(activity.Id); var listOfSelectedMessage = new List <SelectedMessages>(); if (messages != null) { foreach (var item in messages) { listOfSelectedMessage.Add(new SelectedMessages { Message = item, SendingTime = sendingTime });; } } model.Messages = listOfSelectedMessage; model.ActivityMessages = new ActivityMessageRepo(db, partnerManager).GetList(activity.Id, -1); return(View(model)); }
public ActionResult CreateActivity(FormCollection form) { ActivityRepo activityRepo = new ActivityRepo(context); string Name = form["ActivityName"]; Activity activity = new Activity() { Name = Name.ToLower(), Status = "1", CreatedBy = (string)User.Identity.GetUserId(), CreatedOn = DateTime.Now }; if (activityRepo.findByName(Name)) { SetFlash(FlashMessageType.Error, "this data by this name exists"); } else { activityRepo.Add(activity); SetFlash(FlashMessageType.Success, "Activity has been added"); } return(RedirectToAction("Index")); }
public IActionResult Edit(CreatePartnerActivity2Dto model) { if (ModelState.IsValid) { var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext); var permission = _partActRepo.GetPartAct("PartnerActivity.Edit", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var old = _partActRepo.GetPartAct(model.Id); if (old == null) { return(View(model)); } var pAct = new PartnerActivity(); pAct.Id = model.Id; pAct.Activity.Id = model.ActivityId; pAct.FromRole.Id = model.FromRoleId ?? 0; pAct.MaxQueryRows = model.MaxQueryRowsNo; pAct.MaxQueryDuration.Id = model.MaxQueryDurationId; pAct.Scope.Id = model.ScopeId; pAct.OnlyPartnerChildren = model.OnlyPartnerChildren; pAct.LastEditOn = DateTime.Now; var result = _partActRepo.Edit(pAct); if (result.Success) { var audit = new DataAudit(); audit.Activity.Id = "PartnerActivity.Edit"; audit.PartnerId = _PartnerManager.GetCurrentUserId(this.HttpContext); audit.PartnerAccount = _PartnerManager.GetCurrentUserAccount(this.HttpContext); audit.Action.Id = "Update"; audit.Success = true; audit.OldValue = old.ToString(); audit.NewValue = pAct.ToString(); _auditing.Create(audit); return(RedirectToAction("Index")); } else { model.Error = result.Error; } } var fromRoles = new RoleRepo(db, _partActRepo).GetRoles(); var activities = new ActivityRepo(db, _PartnerManager).GetActivities(); var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration"); var scopes = new CommonCodeRepo(db).GetCodesByType("activity.scope"); model.FromRoles = fromRoles; model.Activities = activities; model.MaxQueryDuration = maxQueryDuration; model.Scopes = scopes; return(View(model)); }
// GET: Activity public ActionResult Index() { ActivityRepo activityRepo = new ActivityRepo(context); var data = activityRepo.GetAll(); ActivityViewModel activityviewmodel = new ActivityViewModel() { activities = data }; return(View(activityviewmodel)); }
public JObject ActivateActivity(int id) { ActivityRepo activityRepo = new ActivityRepo(context); activityRepo.ActivateActivity(id); JObject jObject = new JObject(); jObject.Add("status", "00"); jObject.Add("message", "success"); return(jObject); }
// GET: Pertake public ActionResult Index() { ActivityRepo activityRepo = new ActivityRepo(context); RotterRepo rotterRepo = new RotterRepo(context); ViewBag.Activity = activityRepo.selecItemActivity(); PertakeViewModel pertakeViewModel = new PertakeViewModel() { rotterlist = rotterRepo.GetAll() }; return(View(pertakeViewModel)); }
public void GetEventLines_SingleLineLog_ReturnsOneLIne() { string path = "../../../logs"; // up from bin/netcoreappn.n int ctr = 0; using (ActivityRepo repo = new ActivityRepo(path)) { foreach (var line in repo.GetEventLines(new DateTime(2018, 7, 19))) { ctr++; } } Assert.Equal(1, ctr); }
public ActionResult AssignPersonToActivity(FormCollection form) { string activity = form["Activity"]; string userName = form["txtUserName"]; string name = form["Name"]; PertakeRepo pertakeRepo = new PertakeRepo(context); RotterRepo rotterRepo = new RotterRepo(context); ApplicationUser user = context.Users.Where(e => e.UserName == userName).FirstOrDefault(); Pertake pertake = new Pertake() { UserId = user.Id, status = "1", name = name.ToLower().Trim(), ActivityId = Int32.Parse(activity) }; List <Rotter> rotters = new List <Rotter>(); ActivityRepo activityRepo = new ActivityRepo(context); int size = activityRepo.Get(Int32.Parse(activity)).Tasks.Count; List <Tasks> tasks = activityRepo.Get(Int32.Parse(activity)).Tasks; Console.WriteLine(tasks); foreach (Tasks task in tasks) { Rotter rotter = new Rotter() { PertakerId = user.Id, status = "1", TaskId = task.Id, UserId = task.AssignTo, StartedOn = DateTime.Now, EndedOn = DateTime.Now, }; rotterRepo.add(rotter); } pertakeRepo.Add(pertake); return(RedirectToAction("Index")); }
public IActionResult Create() { var model = new CreatePartnerActivityDto(); var fromRoles = new RoleRepo(db, _partActRepo).GetRoles(); var toRoles = new RoleRepo(db, _partActRepo).GetRoles(); var activities = new ActivityRepo(db, _PartnerManager).GetActivities(); var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration"); var scopes = new CommonCodeRepo(db).GetCodesByType("activity.scope"); model.FromRoles = fromRoles; model.ToRoles = toRoles; model.Activities = activities; model.MaxQueryDuration = maxQueryDuration; model.Scopes = scopes; return(View(model)); }
public IActionResult Edit(int id) { var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext); var permission = _partActRepo.GetPartAct("PartnerActivity.Edit", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var model = new CreatePartnerActivity2Dto(); var result = _partActRepo.GetPartAct(id); if (result != null) { model.Activity = result.Activity; model.ActivityId = result.Activity.Id; model.FromRole = result.FromRole; model.FromRoleId = result.FromRole.Id; model.MaxQueryDurationId = result.MaxQueryDuration.Id; model.MaxQueryRowsNo = result.MaxQueryRows; model.ScopeId = result.Scope.Id; model.OnlyPartnerChildren = result.OnlyPartnerChildren; } var fromRoles = new RoleRepo(db, _partActRepo).GetRoles(); var activities = new ActivityRepo(db, _PartnerManager).GetActivities(); var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration"); var scopes = new CommonCodeRepo(db).GetCodesByType("activity.scope"); model.FromRoles = fromRoles; model.Activities = activities; model.MaxQueryDuration = maxQueryDuration; model.Scopes = scopes; return(View(model)); }
public IActionResult Index(string id) { var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext); var permission = _activityRepo.GetPartAct("Activity.Query", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (!string.IsNullOrEmpty(id)) { var activity = new ActivityRepo(db, partnerManager).GetActivity(id, true); if (activity != null) { var model = new ActivityQuery(); model.Results.Add(activity); return(View(model)); } else { var model = new ActivityQuery(); return(View(model)); } } else { var activities = new ActivityRepo(db, partnerManager).GetActivities(id, true); var model = new ActivityQuery(); model.Results = activities; return(View(model)); } }
public async Task <HttpResponseMessage> GetActivityById(string id) { HttpResponseMessage response = null; try { if (id != null) { Activity activity = await ActivityRepo.getActivityDocument(id); response = Request.CreateResponse(HttpStatusCode.OK, new JHResponseMessage("JH_001", "Success", activity)); } else { response = Request.CreateResponse(HttpStatusCode.OK, new JHResponseMessage("JH_104", "Invalid activity Id", "Invalid activity Id")); } } catch (Exception exception) { Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.InternalServerError, new JHResponseMessage("JH_101", "Application Error", exception.Message)); } return(response); }
public IActionResult AssignMessage(string id) { var activity = new ActivityRepo(db, partnerManager).GetActivity(id); if (activity == null) { toastNotification.AddErrorToastMessage("البيانات غير موجودة ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var model = new AssignActivityMessageDto(); model.ActivityId = activity.Id; model.Activity = activity; var sendingTime = new CommonCodeRepo(db).GetCodesByType("ActivityMessage.SendingTime"); model.SendingTime = sendingTime; var messages = new MessageTemplateRepo(db, partnerManager).GetAll(activity.Id); var listOfSelectedMessage = new List <SelectedMessages>(); if (messages != null) { foreach (var item in messages) { listOfSelectedMessage.Add(new SelectedMessages { Message = item, SendingTime = sendingTime });; } } model.Messages = listOfSelectedMessage; model.ActivityMessages = new ActivityMessageRepo(db, partnerManager).GetList(id, -1); return(View(model)); }
public ActivityViewModel() { var repo = new ActivityRepo(); Activities = new List <Activity>(repo.findAll()); }
public HttpResponseMessage GetProductCount() { HttpResponseMessage response = null; try { response = Request.CreateResponse(HttpStatusCode.OK, new JHResponseMessage("JH_001", "Success", ActivityRepo.getProductCount())); } catch (Exception exception) { Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.InternalServerError, new JHResponseMessage("JH_101", "Application Error", exception.Message)); } return(response); }
public IActionResult CreateRule(CreatePartnerActivity2Dto model) { if (ModelState.IsValid) { var currentRoleId = _PartnerManager.GetCurrentUserRole(this.HttpContext); var permission = _partActRepo.GetPartAct("PartnerActivity.Create", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحية الكافية", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var pAct = new PartnerActivity(); pAct.Activity.Id = model.ActivityId; pAct.FromRole.Id = model.FromRoleId ?? 0; pAct.MaxQueryRows = model.MaxQueryRowsNo; pAct.MaxQueryDuration.Id = model.MaxQueryDurationId; pAct.Scope.Id = model.ScopeId; pAct.OnlyPartnerChildren = model.OnlyPartnerChildren; pAct.CreatedBy.Id = _PartnerManager.GetCurrentUserId(this.HttpContext); pAct.CreatedBy.Account = _PartnerManager.GetCurrentUserAccount(this.HttpContext); var result = _partActRepo.Create(pAct); if (result.Success) { var listModel = new ListPartnerActivityDto(); listModel.Activities = new SelectList(new ActivityRepo(db, _PartnerManager).GetActivities(), "Id", "Name"); listModel.FromRoles = new SelectList(new RoleRepo(db, _partActRepo).GetRoles(), "Id", "Name"); //return View("Index", listModel); return(RedirectToAction("Detail", "PartActivity", new { id = result.AffectedCount })); } else if (result.AffectedCount == -504) { var permission2 = _partActRepo.GetPartAct("PartnerActivity.Query", currentRoleId); if (permission2 == null) { toastNotification.AddErrorToastMessage("تم انشاء هذه الصلاحية مسبقا ", new ToastrOptions { Title = "" }); } else { return(RedirectToAction("Detail", "PartActivity", new { id = permission2.Id })); } } else { toastNotification.AddErrorToastMessage("لم يتم انشاء الصلاحية ، يرجى المحاولة لاحقا ", new ToastrOptions { Title = "" }); } } var fromRoles = new RoleRepo(db, _partActRepo).GetRoles(); var activities = new ActivityRepo(db, _PartnerManager).GetActivities(); var maxQueryDuration = new CommonCodeRepo(db).GetCodesByType("queryduration"); var scopes = new CommonCodeRepo(db).GetCodesByType("activity.scope"); model.FromRoles = fromRoles; model.Activities = activities; model.MaxQueryDuration = maxQueryDuration; model.Scopes = scopes; return(View(model)); }