public ActionResult DeleteComplete(int id) { issue issue = db.issues.Find(id); //for adding delete action to activity stream MvcApplicationTest1.DAL.activitystream activitystr = new MvcApplicationTest1.DAL.activitystream(); activitystr.actiontype = "Delete Issue"; activitystr.description = "Deleted an issue"; activitystr.issueid = issue.id; activitystr.issuekey = issue.keyname; activitystr.actiondate = DateTime.Now.ToString(); activitystr.projectid = issue.projectid; int uid = int.Parse(Session["UserId"] + ""); activitystr.userid = uid; db.activitystreams.Add(activitystr); db.SaveChanges(); db.issues.Remove(issue); db.SaveChanges(); return(RedirectToAction("indexproject", "Column", new { id = issue.projectid })); }
public ActionResult assignissuemaster(issue issue) { issue issue1 = db.issues.Find(issue.id); issue1.assignee = issue.assignee; db.SaveChanges(); //for adding edit action to activity stream String username = Convert.ToString(Session["UserName"]); MvcApplicationTest1.DAL.activitystream activitystr = new MvcApplicationTest1.DAL.activitystream(); activitystr.actiontype = "Assign Issue To DEV"; activitystr.description = username + " Assigned Issue " + issue.keyname + " To Developer " + issue.assignee; activitystr.issueid = issue.id; activitystr.issuekey = issue.keyname; activitystr.actiondate = DateTime.Now.ToString(); activitystr.projectid = issue.projectid; int uid = int.Parse(Session["UserId"] + ""); activitystr.userid = uid; db.activitystreams.Add(activitystr); db.SaveChanges(); return(RedirectToAction("Details", new { id = issue.id })); }
public ActionResult Delete(int id = 0) { var issueids = db.issues.Select(x => x).Where(x => x.id == id).FirstOrDefault(); var adminproj = db.projects.Select(x => x).Where(x => x.id == issueids.projectid && x.projectleader == User.Identity.Name).FirstOrDefault(); if (adminproj == null) { return(RedirectToAction("Index", "project")); } issue issue = db.issues.Find(id); if (issue == null) { return(HttpNotFound()); } //for adding delete action to activity stream MvcApplicationTest1.DAL.activitystream activitystr = new MvcApplicationTest1.DAL.activitystream(); String username = Convert.ToString(Session["UserName"]); activitystr.actiontype = "Delete Issue"; activitystr.description = username + " Deleted issue " + issue.keyname; activitystr.issueid = issue.id; activitystr.issuekey = issue.keyname; activitystr.actiondate = DateTime.Now.ToString(); activitystr.projectid = issue.projectid; int uid = int.Parse(Session["UserId"] + ""); activitystr.userid = uid; db.activitystreams.Add(activitystr); db.SaveChanges(); db.issues.Remove(issue); db.SaveChanges(); return(RedirectToAction("indexproject", "Column", new { id = issue.projectid })); }
public override object GetById(string Id) { issue Issue = (from c in dbEntities.issues where c.id.Equals(Id) select c).SingleOrDefault(); return(Issue); }
public ActionResult Create(issue issue) { if (ModelState.IsValid) { // for the keyname error message ViewBag.errormsg = ""; var zzz = db.projects.Select(x => x).Where(x => x.id == issue.projectid).FirstOrDefault(); // for compining the keyname of the project with the keyname of the issue String kname = zzz.projectkey + "_" + issue.keyname; // for checking if the keyname is already in use var mm = db.issues.Select(x => x).Where(x => x.keyname == kname).FirstOrDefault(); if (mm != null) { ViewBag.errormsg = "Key Name is in Use"; // for passing the list of the developers in the project to the view var devsinproj = db.pojectdevs.Where(x => x.projectid == issue.projectid).Select(x => x.devname).ToList(); var users = Roles.GetUsersInRole("developer"); foreach (var user in users) { if (!devsinproj.Contains(user)) { users = users.Select(x => x).Where(x => x != user).ToArray(); } } SelectList slist = new SelectList(users); ViewBag.Usersq = slist; ViewBag.projid = issue.projectid; return(View(issue)); } issue.keyname = kname; //for getting the first column id in the agileboard and save it in the status field , when we add it to the agileboard it // takes place in the first column var zq = db.columns.Select(x => x).Where(x => x.projectid == issue.projectid).FirstOrDefault(); issue.status = zq.colid; if (issue.priority == "High") { issue.priority = "1"; } if (issue.priority == "Medium") { issue.priority = "2"; } if (issue.priority == "Low") { issue.priority = "3"; } HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:4419"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.PostAsJsonAsync("api/Backlogapi", issue).Result; String username = Convert.ToString(Session["UserName"]); MvcApplicationTest1.DAL.activitystream activitystr = new MvcApplicationTest1.DAL.activitystream(); int uid = int.Parse(Session["UserId"] + ""); // if the response successeded if (response.IsSuccessStatusCode) { //for adding create action to activity stream var issueaftersave = db.issues.Select(z => z).Where(z => z.keyname == issue.keyname).FirstOrDefault(); activitystr.actiontype = "Create Issue"; activitystr.description = username + " Created issue " + issue.keyname; activitystr.issueid = issueaftersave.id; activitystr.issuekey = issue.keyname; activitystr.actiondate = DateTime.Now.ToString(); activitystr.projectid = issue.projectid; //int uid = int.Parse(Session["UserId"] + ""); activitystr.userid = uid; db.activitystreams.Add(activitystr); db.SaveChanges(); return(RedirectToAction("indexproject", "Column", new { id = issue.projectid })); } else { return(View(issue)); } //db.issues.Add(issue); //db.SaveChanges(); // String username = Convert.ToString(Session["UserName"]); // MvcApplicationTest1.DAL.activitystream activitystr = new MvcApplicationTest1.DAL.activitystream(); //activitystr.actiontype = "Create Issue"; //activitystr.description = username + " Created issue " + issue.keyname; //activitystr.issueid = issue.id ; //activitystr.issuekey = issue.keyname ; //activitystr.actiondate = DateTime.Now.ToString(); //activitystr.projectid = issue.projectid ; //activitystr.userid = uid; //db.activitystreams.Add(activitystr); //db.SaveChanges(); } return(View(issue)); }
public Task <List <issue> > GetIssuesFromEndpoint(string startDate, string endDate, int first, int offset) { List <issue> issues = new List <issue>(); string url = "http://localhost:2014/api/adenin.GateKeeper.Connector/briefing/issues?"; if (startDate != "") { if (!url.EndsWith("?")) { url += "&"; } url += "startDate=" + startDate; } if (endDate != "") { if (!url.EndsWith("?")) { url += "&"; } url += "endDate=" + endDate; } int page = 0; if (offset > 0) { page = offset / first; } int pageSize = (offset + first) - (page * first); int waste = pageSize - first; if (!url.EndsWith("?")) { url += "&"; } url += "page=" + page; if (!url.EndsWith("?")) { url += "&"; } url += "pageSize=" + pageSize; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url as string); webRequest.ContentType = "application/json"; webRequest.Headers.Add("X-ClusterKey", "srb6enxednjjeeutjkpq4donu55r7of1"); webRequest.Headers.Add("X-UserName", "admin"); using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) { // Get the stream associated with the response. Stream receiveStream = webResponse.GetResponseStream(); StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); // convert stream to JsonObject dynamic response = SimpleJson.SimpleJson.DeserializeObject(readStream.ReadToEnd()); // read items from response and convert them to Issues for (int i = 0; i < response.Data.items.Count; i++) { dynamic item = response.Data.items[i]; issue issue = new issue(); issue.Id = item.id; issue.Title = item.title; issue.Description = item.description; issue.Date = item.date; issue.Link = item.link; issues.Add(issue); } webResponse.Close(); readStream.Close(); } return(Task.FromResult(issues)); }
protected override Panel ShowDetailPanel(object Object) { issue Issue = (issue)Object; Panel DetailPanel = new Panel(); Control[] DetailsCol = new Control[7 * (Issue.book_issue.Count + 1)]; //update string[] ColumnLabels = { "No", "IssueId", "RecId", "Title", "", "Returned", Issue.type.Trim() + " item id" }; for (int i = 0; i < ColumnLabels.Length; i++) { DetailsCol[i] = new TitleLabel(11) { Text = ColumnLabels[i] }; } int ControlIndex = 7; for (int i = 0; i < Issue.book_issue.Count; i++) { book_issue BS = Issue.book_issue[i]; if (Issue.type.Trim().Equals("issue")) { Dictionary <string, object> CheckReturnResponse = Transaction.FetchObj(0, 0, Transaction.URL, "checkReturnedBook", AppUser, new Dictionary <string, object>() { { "book_issue_id", BS.id } }); if (CheckReturnResponse["result"].ToString() == "0") { BS.book_issue_id = StringUtil.JSONStringToMap(CheckReturnResponse["data"].ToString())["book_issue_id"].ToString(); } } DetailsCol[ControlIndex++] = new Label() { Text = (i + 1).ToString() }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_record_id }; DetailsCol[ControlIndex++] = new TextBoxReadonly() { Text = BS.book_record.book.title }; DetailsCol[ControlIndex++] = new BlankControl() { Reserved = ReservedFor.BEFORE_HOR }; string Type = Issue.type.ToLower().Trim(); if (Type == ("return")) { DetailsCol[ControlIndex++] = null; } else { DetailsCol[ControlIndex++] = new Label() { Text = BS.book_return == 1 ? "yes " + BS.ref_issue : "No" }; } DetailsCol[ControlIndex++] = new Label() { Text = BS.book_issue_id }; } // DetailPanel = ControlUtil.GeneratePanel(7, DetailsCol, 5, 80, 20, Color.Orange, 5, 250); student Student = UserClient.StudentById(Issue.student_id, AppUser); Panel StudentDetail = ControlUtil.GeneratePanel(1, new Control[] { new Label() { Text = Issue.type.ToUpper().Trim() + " ID" }, new TextBoxReadonly(13) { Text = Issue.id }, new Label() { Text = "Date" }, new TextBoxReadonly(13) { Text = Issue.date.ToString() }, new Label() { Text = "Student ID" }, new TextBoxReadonly(13) { Text = Student.id }, new Label() { Text = "Student Name" }, new TextBoxReadonly(13) { Text = Student.name }, new Label() { Text = "Student ClassId" }, new TextBoxReadonly(13) { Text = Student.class_id }, }, 5, 200, 17, Color.Yellow, 5, 5, 500); Panel Wrapper = new Panel(); Wrapper.Controls.Add(StudentDetail); Wrapper.Controls.Add(DetailPanel); Wrapper.SetBounds(5, 5, 500, 500); Wrapper.AutoScroll = false; Wrapper.VerticalScroll.Visible = true; Wrapper.VerticalScroll.Enabled = true; Wrapper.AutoScroll = true; return(Wrapper); }
private void PopulateIssueList() { int No = 0; PanelIssueLis.Controls.Clear(); int BookStillIssued = 0; foreach (issue Issue in Issues) { if (null == Issue.book_issue || Issue.book_issue.Count == 0) { continue; } No++; Panel PanelIssue = new Panel(); PanelIssue.Controls.Add(ControlUtil.GenerateLabel("<b>" + No + ". Issue ID: " + Issue.id + " (" + Issue.type + ")</b><br/>date: " + Issue.date + "<ol>")); Panel PanelIssueItem = new Panel(); foreach (book_issue Bs in Issue.book_issue) { List <book_issue> BooksReturned = BookIssueService.GetByBookIssueIdReturned(Bs.id); bool BookReturned = BooksReturned.Count == 1; string labelHtml = "<li class=\"book_issue-item\" id=\"Book_Issue_Rec_" + Bs.id + "\"> Issue Rec Id: " + Bs.id + "<br/>Book Rec Id: " + Bs.book_record_id + "<br/>" + Bs.book_record.book.title + " - returned: <code>" + BookReturned + "</code>";// + DateTime.Now.ToString(); if (!BookReturned) { string[] Attrs = new string[] { "href=\"#\"", "onclick=SetTextInput('" + Bs.book_record_id + "','MainContent_TextBoxIssueRecordId')" }; string anchor = ControlUtil.GenerateHtmlTag("a", Attrs, " return now "); labelHtml += "<br/>" + anchor; BookStillIssued++; } else { string[] Attrs = new string[] { "class=\"pointerable\"", "onclick=\"ScrollToElement('Book_Return_Rec_" + BooksReturned[0].id + "')\"" }; string anchor = ControlUtil.GenerateHtmlTag("span", Attrs, BooksReturned[0].id); labelHtml += "<br/> Return ref: " + anchor; } labelHtml += "</li>"; PanelIssueItem.Controls.Add(ControlUtil.GenerateLabel(labelHtml)); } PanelIssue.Controls.Add(PanelIssueItem); DateTime MaxReturn = DateUtil.PlusDay(Issue.date, int.Parse(TextBoxDuration.Text)); bool Late = false; if (Issue.date.CompareTo(MaxReturn) > 0) { Late = true; } PanelIssue.Controls.Add(ControlUtil.GenerateLabel("</ol>Max return: " + MaxReturn + ", Late:" + Late + "<hr/>")); PanelIssueLis.Controls.Add(PanelIssue); } issueCount.InnerHtml = BookStillIssued.ToString(); //BOOK RETURNED No = 0; PanelIssueReturn.Controls.Clear(); foreach (issue Issue in IssuesReturn) { if (null == Issue.book_issue || Issue.book_issue.Count == 0) { continue; } No++; Panel PanelIssue = new Panel(); PanelIssue.Controls.Add(ControlUtil.GenerateLabel("<b>" + No + ". Issue ID: " + Issue.id + " (" + Issue.type + ")</b><br/>date: " + Issue.date + "<ol>")); Panel PanelIssueItem = new Panel(); foreach (book_issue Bs in Issue.book_issue) { Bs.book_issue2 = (book_issue)BookIssueService.GetById(Bs.book_issue_id); if (null != Bs.book_issue2) { book_issue BookIssueRef = Bs.book_issue2; issue IssueRef = (issue)IssueService.GetById(BookIssueRef.issue_id); DateTime IssuedDate = IssueRef.date; DateTime MaxReturn = DateUtil.PlusDay(IssuedDate, int.Parse(TextBoxDuration.Text)); bool Late = false; if (Issue.date.CompareTo(MaxReturn) > 0) { Late = true; } string[] Attrs = new string[] { "class=\"pointerable\"", "onclick=\"ScrollToElement('Book_Issue_Rec_" + Bs.book_issue_id + "')\"" }; string anchor = ControlUtil.GenerateHtmlTag("span", Attrs, Bs.book_issue_id); PanelIssueItem.Controls.Add(ControlUtil.GenerateLabel("<li class=\"book_issue-item\" id=\"Book_Return_Rec_" + Bs.id + "\"> Return Rec Id: " + Bs.id + "<br/>Book Rec Id: " + Bs.book_record_id + " - Returned From Issue Rec Id: " + anchor + "<br/>" + Bs.book_record.book.title + "<br/>Issued: " + IssuedDate + "<br/>Max return: " + MaxReturn + " - late: <code>" + Late + "</code></li>")); } } PanelIssue.Controls.Add(PanelIssueItem); PanelIssue.Controls.Add(ControlUtil.GenerateLabel("</ol><hr/>")); PanelIssueReturn.Controls.Add(PanelIssue); } }
public void SaveIssue(issue issue) { IssueRepository.Save(issue); }
private issue IssueBook() { if (StringUtil.NotNullAndNotBlank(Request.Form["student_id"]) && StringUtil.NotNullAndNotBlank(Request.Form["book_recs"])) { issueService = new IssueService(); studentService = new StudentService(); bookRecordService = new Book_recordService(); BookIssueService = new book_issueService(); string StudentId = Request.Form["student_id"]; student Student = (student)studentService.GetById(StudentId); if (Student == null) { return(null); } string IssueID = StringUtil.GenerateRandomNumber(9); issue Issue = new issue(); Issue.user_id = User.id; Issue.id = IssueID; Issue.type = "issue"; Issue.date = DateTime.Now; Issue.student_id = Student.id; Issue.addtional_info = "test"; string[] BookRecIds = Request.Form["book_recs"].Split(';'); if (BookRecIds.Length < 1) { return(null); } if (null == issueService.Add(Issue)) { return(null); } List <book_issue> BookIssues = new List <book_issue>(); foreach (string Id in BookRecIds) { book_record BR = (book_record)bookRecordService.GetById(Id); if (BR == null || BR.available == 0) { continue; } book_issue BookIssue = new book_issue(); BookIssue.id = StringUtil.GenerateRandomChar(10); BookIssue.issue_id = IssueID; BookIssue.book_record_id = Id; BookIssue.qty = 1; BookIssues.Add(BookIssue); BookIssueService.Add(BookIssue); BR.available = 0; bookRecordService.Update(BR); } Issue.book_issue = BookIssues; return(Issue); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (Request.RequestType == "POST") { CheckUser(); string Out = "\"" + GetTime() + "\""; int Result = 1; switch (Request.Form["Action"]) { case "studentVisit": Out = true || UserValid?GetStudentById() : "0"; if (Out != null && Out != "0") { string Visit = StudentVisit(Request.Form["Id"].ToString()); if (Visit != null && Visit != "0") { Out = "{" + "\"student\":" + Out + ", \"visit\":" + Visit + "}"; Result = 0; } } break; case "addStudent": Out = UserValid ? AddStudent() : "0"; if (Out != null && Out != "0") { Out = "{\"student\":" + Out + "}"; Result = 0; } break; case "addAuthor": Out = UserValid ? AddAuthor() : "0"; if (Out != null && Out != "0") { Out = "{\"author\":" + Out + "}"; Result = 0; } break; case "addPublisher": Out = UserValid ? AddPublisher() : "0"; if (Out != null && Out != "0") { Out = "{\"publisher\":" + Out + "}"; Result = 0; } break; case "addClass": Out = UserValid ? AddClass() : "0"; if (Out != null && Out != "0") { Out = "{\"class\":" + Out + "}"; Result = 0; } break; case "addCategory": Out = UserValid ? AddCategory() : "0"; if (Out != null && Out != "0") { Out = "{\"category\":" + Out + "}"; Result = 0; } break; case "addBook": Out = UserValid ? AddBook() : "0"; if (Out != null && Out != "0") { Out = "{\"book\":" + Out + "}"; Result = 0; } break; case "studentById": Out = UserValid ? GetStudentById() : "0"; if (Out != null && Out != "0") { Out = "{\"student\":" + Out + "}"; Result = 0; } break; case "bookRecById": Out = UserValid ? GetBookRecordById() : "0"; if (Out != null && Out != "0") { Out = "{\"book_record\":" + Out + "}"; Result = 0; } break; case "bookList": Out = UserValid ? GetBookList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + BookCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "studentList": Out = UserValid ? GetStudentList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + StudentCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "issuesList": Out = UserValid ? GetIssuesList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + IssueCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "visitList": Out = UserValid ? GetVisitsList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + VisitCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "classList": Out = UserValid ? GetClassList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + ClassCoount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "authorList": Out = UserValid ? GetAuthorList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + AuthorCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "publisherList": Out = UserValid ? GetPublisherList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + PublisherCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "categoryList": Out = UserValid ? GetCategoryList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + CategoryCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "bookIssueList": Out = UserValid ? GetBookIssueList() : "0"; if (Out != null && Out != "0") { Out += ( ",\"offset\":" + Request.Form["offset"] + ",\"count\":" + VisitCount + ",\"limit\":" + Request.Form["limit"] ); Result = 0; } break; case "checkReturnedBook": book_issue ReturnBookIssue = UserValid ? GetBookIssue() : null; if (ReturnBookIssue != null) { Out = ( "{\"book_issue_id\":\"" + ReturnBookIssue.id + "\"}" ); Result = 0; } else { Result = 1; } break; case "getBookIssueByStudentId": string StudentBookIssue = UserValid ? GetBookStudentIssue() : null; if (StudentBookIssue != null && StudentBookIssue != "0") { Out = ( "{\"book_issue\":" + StudentBookIssue + "}" ); Result = 0; } else { Result = 1; } break; case "issueBook": issue Issue = UserValid ? IssueBook() : null; if (Issue != null) { string RecIds = ObjectUtil.ListToDelimitedString(Issue.book_issue, ";", "~", "book_record_id", "id"); Out = ( "{\"issue_id\":\"" + Issue.id + "\",\"date\":\"" + Issue.date + "\", \"items\":\"" + RecIds + "\"}" ); Result = 0; } else { Result = 1; } break; case "returnBook": issue IssueReturn = UserValid ? ReturnBook() : null; if (IssueReturn != null) { string RecIds = ObjectUtil.ListToDelimitedString(IssueReturn.book_issue, ";", "~", "book_record_id", "id"); Out = ( "{\"issue_id\":\"" + IssueReturn.id + "\",\"date\":\"" + IssueReturn.date + "\", \"items\":\"" + RecIds + "\"}" ); Result = 0; } else { Result = 1; } break; } Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write("{\"result\":" + Result + ",\"data\":" + Out + "}"); Response.End(); } else { return; } }