Example #1
0
 public ActionResult createElement(ElementView elementView)
 {
     ElementView element = null;
     if (elementView != null) {
         try {
             RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
             element = requestMgr.saveElement(elementView);
             TempData["error"] = "New Element created";
             TempData["valid"] = true;
             if (element.AssignedTo != (IUser)Session["User"])
                 EmailSvc.Email((string)MainFactory.getConfiguration().get(CONFIG_EMAIL),
                             element.AssignedTo.EmailAddress,
                             "",
                             "New Element #" + element.ID + " - " + element.Summary,
                             ConsoleFactory.elementEmailSupportBody(element, (IUser)Session["User"]));
             return RedirectToAction("Element", "Console", new { id = element.ID });
         } catch (Exception e) {
             TempData["model"] = elementView;
             TempData["error"] = e.Message;
             TempData["valid"] = false;
             return RedirectToAction("createElement", "Console", new { Id = elementView.Parent.ID });
         }
     }
     return Dashboard(null, null);
 }
Example #2
0
        public ElementView createElement(int parentID)
        {
            EmployeeMgr employeeMgr = new EmployeeMgr(ConsoleFactory.getEmployeeSvc());

            ElementView element = new ElementView(getRequest(parentID));

            return element;
        }
Example #3
0
File: Note.cs Project: tah182/Comet
 public Note(COMET.Server.Domain.NOTE note, IUser updatedBy, ElementView parent)
 {
     //, ElementView parent) {
     this.ID = note.NOTE_ID;
     this.Date = note.NOTE_DATE;
     this.Text = note.NOTE_TEXT;
     this.UpdatedBy = updatedBy;
     this.Parent = parent;
 }
Example #4
0
        public static string elementEmailSupportBody(ElementView element, IUser requestor)
        {
            string url = "http://" + MainFactory.getInstance() + "/Console/Dashboard/Element/" + element.ID;

            string email = "<html>";
            email += "<h3>A new element has been assigned to you.</h3><br /><table>";
            email += "<tr style='text-align: left'><th>Requested by: </th><td style='text-align: left'>" + requestor.EnglishName + "</td></tr>";
            email += "<tr style='text-align: left'><th>Parent Request Summary: </th><td style='text-align: left'>" + element.Parent.Summary + "</td></tr></table>";
            email += "<br><br>You can view the entire summary at <a href='" + url + "'>" + url + "</a>";
            email += "<br><br>Or view all your pending details in the <a href='http://" + MainFactory.getInstance() + "/Console" + "'>Dashboard</a>";
            email += "</html>";

            return email;
        }
Example #5
0
 public void NewElementViewTest()
 {
     ElementView elementView = new ElementView();
 }
Example #6
0
        /// <summary>
        /// Updates a element's property by creating a new element, 
        /// updating the parent and child pointers
        /// repoints the parent's child pointer to this
        /// repoints the children's parent pointer to this.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public ElementView updateElement(ElementView element, bool autoclose)
        {
            ElementView oldElement = this.requestList.Data.Where(x => x.ID == element.Parent.ID).FirstOrDefault().ElementList.Where(y => y.ID == element.ID).FirstOrDefault();

            if (!autoclose && oldElement.Status.ID == element.Status.ID && this.elementStatusList.Data.Where(x => x.ID == element.Status.ID).FirstOrDefault().Text.Equals("Complete"))
                throw new InvalidOperationException("The status is closed. You cannot update an element that is closed.");

            element.isNew = false;
            element.Status = this.elementStatusList.Data.Where(x => x.ID == element.Status.ID).FirstOrDefault();
            string status = element.Status.Text.ToLower();
            if (status.Equals("complete") || status.Equals("rejected")) {
                if (element.Resolution == null || element.Resolution.Length < 1)
                    throw new ArgumentException("You are closing this element. Please provide a resolution.");
                element.setClosed();
            }

            element.setLastUpdated();

            ElementView e = convertElement(this.svc.updateElement(element));

            e.Parent = oldElement.Parent;
            Parallel.ForEach(oldElement.Note, note => {
                note.Parent = e;
            });
            e.Note = oldElement.Note;

            // change the pointer in the requestList to point to this object
            foreach (RequestView rv in this.requestList.Data.ToList())
                foreach (ElementView ev in rv.ElementList.ToList())
                    if (ev.ID == element.ID) {
                        rv.ElementList.Remove(ev);
                        rv.ElementList.Add(e);
                        continue;
                    }

            HttpContext.Current.Application.Lock();
            HttpContext.Current.Application["Request"] = this.requestList;
            HttpContext.Current.Application.UnLock();
            return e;
        }
Example #7
0
        /// <summary>
        /// Saves a new element into the requestList Tree. \n
        /// Point to parent Request
        /// Add element to parent Request ElementList
        /// </summary>
        /// <param name="element">The new element to add</param>
        /// <returns>The updated element with the pointers updated</returns>
        public ElementView saveElement(ElementView element)
        {
            if (element.Summary == null || element.Summary.Length < 1)
                throw new ArgumentException("Summary is Required.");

            element.Status = this.elementStatusList.Data.Where(x => x.ID == element.Status.ID).FirstOrDefault();

            element.Status = this.elementStatusList.Data.Where(x => x.ID == element.Status.ID).FirstOrDefault();
            string status = element.Status.Text.ToLower();
            element.isNew = false;
            if (status.Equals("complete") || status.Equals("rejected")) {
                if (element.Resolution == null || element.Resolution.Length < 1)
                    throw new ArgumentException("You are closing this element. Please provide a resolution.");
                element.setClosed();
            }
            element.setLastUpdated();

            ElementView e = convertElement(this.svc.saveElement(element));
            RequestView r = getRequest(element.Parent.ID);
            e.Parent = r;
            r.ElementList.Add(e);

            HttpContext.Current.Application.Lock();
            HttpContext.Current.Application["Request"] = this.requestList;
            HttpContext.Current.Application.UnLock();
            return e;
        }
Example #8
0
 private ELEMENT convertElement(ElementView element)
 {
     return new ELEMENT {
         ASSIGNED_TO_ID = element.AssignedTo.EmployeeID,
         PARENT_REQUEST_ID = element.Parent.ID,
         ELEMENT_STATUS_ID = (byte)element.Status.ID,
         ASSIGNED_DATE = element.OpenDate,
         CLOSED_DATE = element.ClosedDate,
         LAST_UPDATED_DATE = element.LastUpdated,
         PERCENT_COMPLETE = (int)element.PercentComplete,
         HOURS = element.Hours,
         ELEMENT_SUMMARY = element.Summary,
         RESOLUTION = element.Resolution
     };
 }
Example #9
0
        public ELEMENT updateElement(ElementView element)
        {
            if (!element.isValid())
                throw new Exception("Element is not valid. Please send error.");

            ELEMENT updateElement = convertElement(element);
            updateElement.ELEMENT_ID = element.ID;

            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    var details = db.ELEMENTs.Where(x => x.ELEMENT_ID == element.ID).FirstOrDefault();

                    details.ASSIGNED_TO_ID = element.AssignedTo.EmployeeID;
                    details.ELEMENT_STATUS_ID = (byte)element.Status.ID;
                    details.PERCENT_COMPLETE = (int)element.PercentComplete;
                    details.HOURS = element.Hours;
                    details.RESOLUTION = element.Resolution;
                    details.CLOSED_DATE = element.ClosedDate;

                    db.SubmitChanges();

                    return details;
                }
            } catch (Exception se) {
                throw new Exception(se.Message);
            }
        }
Example #10
0
        public ELEMENT saveElement(ElementView element)
        {
            if (!element.isValid())
                throw new Exception("There is an issue with your element.");
            ELEMENT details = convertElement(element);

            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.ELEMENTs.InsertOnSubmit(details);
                    db.SubmitChanges();

                    return details;
                }
            } catch (Exception se) {
                throw new Exception("Unable to save new element due to " + se.Message);
            }
        }
Example #11
0
 public ActionResult updateElement(ElementView elementView)
 {
     ElementView element = null;
     if (elementView != null) {
         try {
             RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
             element = requestMgr.updateElement(elementView, false);
             TempData["error"] = "Update Successful";
             TempData["valid"] = true;
             return RedirectToAction("Element", "Console", new { id = element.ID });
         } catch (Exception e) {
             elementView.isNew = false;
             TempData["error"] = e.Message;
             TempData["valid"] = false;
             TempData["model"] = elementView;
             return RedirectToAction("Element", "Console", new { id = elementView.ID });
         }
     }
     return Dashboard(null, null);
 }