Exemple #1
0
        [HttpPost] //add Breakedown to database
        public ActionResult AddIssueBreakedown(issue_occurrence issueModel)
        {
            var    time         = DateTime.Now;
            string current_time = time.ToString("yyyy-MM-dd HH:mm:ss");//get today to string variable

            using (issue_management_systemEntities1 db = new issue_management_systemEntities1())
            {
                if (ModelState.IsValid)
                {
                    int userID   = (int)Session["userID"];
                    var lineInfo = db.line_supervisor.Where(x => x.supervisor_emp_id == userID).FirstOrDefault();

                    issueModel.line_line_id              = lineInfo.line_line_id;
                    issueModel.issue_satus               = "1";
                    issueModel.issue_issue_ID            = 1; //Issue id is 1 for Machine Brakedown
                    issueModel.responsible_person_emp_id = 5; //get specific employee
                    var date = DateTime.ParseExact(current_time, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                    issueModel.date_time = date;
                    issueModel.location  = (string)Session["location"];
                    db.issue_occurrence.Add(issueModel);
                    db.SaveChanges();
                    if (issueModel.issue_occurrence_id > 0)
                    {
                        var    line        = db.lines.Where(x => x.line_id == lineInfo.line_line_id).FirstOrDefault();
                        string msg         = line.line_name + " line IT/SoftWare issue has been occurred at " + date + ". Special Note of Line supervisor - " + issueModel.description;
                        var    displayInfo = db.displays.Where(x => x.line_id == lineInfo.line_line_id).FirstOrDefault();
                        com.lightON("1", displayInfo.raspberry_ip_address);//turn on the Light
                        sendCD(lineInfo.line_line_id, 1, msg, "Machine Brakedown has been occurred");
                    }
                    ModelState.Clear();
                }
            }
            return(RedirectToAction("selectIssue", "Supervisor"));
        }
Exemple #2
0
        [HttpPost]//solovedIssueMethod
        public JsonResult SolvedIssue(int?issueId, int?issueOccourId)
        {
            //update Issueststus as 0
            issue_management_systemEntities1 db = new issue_management_systemEntities1();
            var issueoccourInfo = db.issue_occurrence.Where(x => x.issue_occurrence_id == issueOccourId).FirstOrDefault();

            issueoccourInfo.issue_satus = "0";
            db.SaveChanges();

            int userID   = (int)Session["userID"];
            var lineInfo = db.line_supervisor.Where(x => x.supervisor_emp_id == userID).FirstOrDefault();

            var line_id = lineInfo.line_line_id;

            //get the list of Issuueoccurrence table
            List <issue_occurrence> issue = db.issue_occurrence.ToList();
            int count = 0;

            foreach (var item in issue)
            {        //check issue id == to clicked issueid
                if (item.issue_issue_ID == issueId && item.line_line_id == line_id)
                {
                    //if any status is there under selected issueid and line id cout will up
                    if (item.issue_satus == "1")
                    {
                        count++;
                    }
                }
            }
            if (count == 0)      // if cout ==0 light will off
            {
                var displayInfo = db.displays.Where(x => x.line_id == line_id).FirstOrDefault();
                //com.lightOFF(issueId.ToString(), displayInfo.raspberry_ip_address);
            }
            return(Json(true));
        }