コード例 #1
0
        public JsonResult Create(int?id, FormCollection collection)
        {
            if (id == null || collection["name"] == null)
            {
                return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet));
            }
            var a = collection["weight"];
            int i = 0;

            int.TryParse(a, out i);
            Nullable <int> result = new Nullable <int>(i);

            problem newProblem = new problem {
                name = collection["name"], description = collection["description"], weight = result, inputDescription = collection["inputdescription"], outputDescription = collection["outputdescription"], sampleInput = collection["sampleinput"], sampleOutput = collection["sampleoutput"]
            };

            db.problem.Add(newProblem);
            db.SaveChanges();
            problems newConnection = new problems {
                problemId = db.problem.Max(x => x.id), assignmentId = Convert.ToInt32(id)
            };

            db.problems.Add(newConnection);
            db.SaveChanges();
            int prblmId = db.problem.Max(x => x.id);

            return(Json(new { status = "SuccessAdd", problemId = prblmId }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult GetProblemAsJSON(int?id)
        {
            int     prbId = Convert.ToInt32(id);
            problem prb   = problmService.GetProblemById(prbId);

            return(Json(new { name = prb.name, description = prb.description, weight = prb.weight, sampleinput = prb.sampleInput, sampleoutput = prb.sampleOutput }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
ファイル: qc.aspx.cs プロジェクト: zyhzx123e/TA
    protected void submit_prob_btn_Click(object sender, EventArgs e)
    {
        //Response.Redirect("http://www.google.com");

        if (validateAddingNewProblem() == false)
        {
            msg.Text = "The problem was not added, please fill up all details";
        }
        else
        {
            problem prob = new problem();
            prob.venue       = venueTxt.Text;
            prob.location_id = int.Parse(newProblemLocation.SelectedValue);
            prob.description = newProblemDescription.Text;
            prob.shift       = shiftsList.SelectedValue;
            prob.date        = DateTime.Now.ToString("yyy-MM-dd");
            prob.type        = 'q';
            prob.status      = 'p';
            prob.added_by    = int.Parse(Session["id"].ToString());

            RoundingFunctions.addNewProblem(prob);

            msg.Text = "The problem has been added, thank you";
            emptyPopUpFrom();
        }
    }
コード例 #4
0
ファイル: RoundingFunctions.cs プロジェクト: zyhzx123e/TA
    public static problem getProblem(int problemID)
    {
        problem       prob   = new problem();
        db_connection db_obj = new db_connection();

        db_obj.open();

        string       query   = "SELECT * FROM problem WHERE problem_id=@problem_id";
        MySqlCommand command = new MySqlCommand(query, db_obj.connection);

        command.Parameters.AddWithValue("@problem_id", problemID);
        MySqlDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            prob.id          = int.Parse(reader["problem_id"].ToString());
            prob.venue       = reader["venue"].ToString();
            prob.pc          = reader["pc"].ToString();
            prob.description = reader["description"].ToString();
            prob.location_id = int.Parse(reader["location_id"].ToString());
            prob.shift       = reader["shift"].ToString();
            prob.date        = reader["date"].ToString();
            prob.status      = char.Parse(reader["status"].ToString());
            prob.type        = char.Parse(reader["type"].ToString());
            prob.added_by    = int.Parse(reader["added_by"].ToString());
        }

        db_obj.close();

        return(prob);
    }
コード例 #5
0
ファイル: problemController.cs プロジェクト: Haute998/WalkTd
 private string StrWhere(problem condition)
 {
     string where = string.Empty;
     if (!string.IsNullOrWhiteSpace(condition.keyword))
     {
         where += string.Format(" and (problem like '%{0}%' )", condition.keyword);
     }
     return(where);
 }
コード例 #6
0
        public ActionResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            problem problem = db.problem.Find(id);

            db.problem.Remove(problem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #7
0
ファイル: problemController.cs プロジェクト: Haute998/WalkTd
        private ActionResult GetPages(problem condition, string where)
        {
            PageJsonModel <B_problem> page = new PageJsonModel <B_problem>();

            page.pageIndex = condition.pageIndex;
            page.pageSize  = condition.pageSize;
            page.strForm   = @" B_problem";
            page.strSelect = " * ";
            page.strWhere  = where;
            page.strOrder  = "ID";
            page.LoadList();
            return(Json(page.pageResponse, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public void MaidCreateProblem(ProblemModel model)
        {
            if (Request.Headers.TryGetValues("Token", out var values))
            {
                var token      = values.First();
                var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token));
                var maid       = _service.GetActiveMaidById(tokenModel.Id);
                if (Equals(maid, null))
                {
                    ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found");
                }

                var contract = _service.GetCurrentParentContractByApartmentId(model.ApartmentId);
                if (Equals(contract, null))
                {
                    ExceptionContent(HttpStatusCode.InternalServerError, "err_apartment_not_contract");
                }

                var problem = new problem
                {
                    created_date = ConvertDatetime.GetCurrentUnixTimeStamp(),
                    issue_id     = model.IssueId,
                    description  = model.Description,
                    problem_id   = 0,
                    status       = 0,
                    summary      = model.Summary,
                    type         = (int)ProblemType.Maid,
                    is_calendar  = false,
                    apartment_id = model.ApartmentId,
                    employee_id  = maid.employee_id,
                    contract_id  = contract.contract_id
                };
                _service.SaveProblem(problem);

                int idx       = 0;
                var listImage = new List <problem_image>();
                foreach (var item in model.ListImage)
                {
                    var img = new problem_image
                    {
                        problem_id = problem.problem_id,
                        img        = _service.SaveImage("~/Upload/problem/",
                                                        "problem_" + ConvertDatetime.GetCurrentUnixTimeStamp() + "_" + idx + ".png",
                                                        item.Img_Base64)
                    };
                    listImage.Add(img);
                    idx++;
                }
                _service.SaveListProblemImage(listImage);
            }
        }
コード例 #9
0
        private void Solve_Click(object sender, EventArgs e)
        {
            state first = new state(3);

            string[,] k = new string[3, 3];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Point pt = new Point(100 * j + 50, 100 * i + 50);
                    k[i, j] = ((Button)firststate.GetChildAtPoint(pt)).Text;
                }
            }
            first.setk(k);
            state goal = new state(3);

            string[,] g = new string[3, 3];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Point pt = new Point(100 * j + 50, 100 * i + 50);
                    g[i, j] = ((Button)Goalstate.GetChildAtPoint(pt)).Text;
                }
            }
            goal.setk(g);
            p = new problem(first, goal, 3);
            if (p.whichset(first.getk()) != p.whichset(goal.getk()))
            {
                MessageBox.Show("the sets didnt match");
            }
            else
            {
                AStar AS = new AStar(p);
                try
                {
                    state[] solution = AS.AS();
                    MessageBox.Show("I found the solution now i will show it : ");
                    foreach (state s in solution)
                    {
                        showstate(s);
                        this.Refresh();
                        Thread.Sleep(1000);
                    }
                }
                catch (OutOfMemoryException)
                {
                    MessageBox.Show("SYSTEM IS OUT OF MEMORY");
                }
            }
        }
コード例 #10
0
    protected void populateProblemDetails(problem prob)
    {
        string ta_name = commonMethods.getTAName(prob.added_by);


        id_lbl.Text       = prob.id.ToString();
        pc_lbl.Text       = prob.pc;
        location_lbl.Text = commonMethods.getLocationName(prob.location_id);
        venue_lbl.Text    = prob.venue;
        desc_lbl.Text     = prob.description;
        added_lbl.Text    = DateTime.Parse(prob.date).ToString("yyy-MM-dd") + " " + prob.shift;

        //by whom
        by_whom_lbl.Text = ta_name;
        type_lbl.Text    = RoundingFunctions.getTypeName(prob.type);
    }
コード例 #11
0
        public JsonResult DeleteProblem(string id)
        {
            if (id == null)
            {
                return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet));
            }
            int prbId = Convert.ToInt32(id);

            problem         prob  = db.problem.Find(prbId);
            problems        prob2 = problmService.GetConnectionById(prbId);
            int             aId   = prob2.id; //because errors
            problems        probs = db.problems.Find(aId);
            List <testcase> cases = problmService.getTestCasesOfProblem(prbId);

            foreach (var item in cases)
            {
                db.testcaseOutput.RemoveRange(db.testcaseOutput.Where(b => b.testcaseId == item.id));
            }
            foreach (var item in cases)
            {
                int      bId = item.id;
                testcase tst = db.testcase.Find(bId);
                db.testcase.Remove(tst);
            }
            db.testcases.RemoveRange(db.testcases.Where(b => b.problemId == prbId));

            List <clarification> clars = clarificationService.getClarificationsOfProblem(prbId);

            foreach (var item in clars)
            {
                db.clarificationAnswer.RemoveRange(db.clarificationAnswer.Where(b => b.clarificationId == item.id));
            }
            foreach (var item in clars)
            {
                int           cId = item.id;
                clarification clr = db.clarification.Find(cId);
                db.clarification.Remove(clr);
            }
            db.clarifications.RemoveRange(db.clarifications.Where(b => b.problemId == prbId));

            db.problem.Remove(prob);
            db.problems.Remove(probs);
            db.SaveChanges();

            return(Json(new { status = "successRemove" }, JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            problem problem = db.problem.Find(id);

            if (problem == null)
            {
                return(HttpNotFound());
            }
            account user   = accountHelper.getCurrentUser(Session["User"].ToString());
            int     userId = user.id;

            ViewBag.userName  = user.name;
            ViewBag.imagePath = user.imagePath;
            return(View(problem));
        }
コード例 #13
0
        public static problemVM ToViewModel(this problem problem, IEnumerable <istab> probcod_istab)
        {
            if (problem == null)
            {
                return(null);
            }

            problemVM p = new problemVM
            {
                id       = problem.id,
                date     = problem.date,
                name     = problem.name,
                probcod  = probcod_istab.Where(pc => pc.id == problem.probcod) != null?probcod_istab.Where(pc => pc.id == problem.probcod).First().typcod : "",
                probdesc = problem.probdesc,
                problem  = problem,
                chgdat   = problem.chgdat,
                state    = problem.id < 0 ? 1 : 0
            };

            return(p);
        }
コード例 #14
0
        public ActionResult EditProblem(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            problem problem = problmService.GetProblemById(id);

            if (problem == null)
            {
                return(HttpNotFound());
            }
            account user   = accountHelper.getCurrentUser(Session["User"].ToString());
            int     userId = user.id;

            ViewBag.userName  = user.name;
            ViewBag.imagePath = user.imagePath;
            EditProblemViewModel info = new EditProblemViewModel {
                prob = problem, cases = problmService.getTestCasesOfProblem(id)
            };

            return(View(info));
        }
コード例 #15
0
ファイル: RoundingFunctions.cs プロジェクト: zyhzx123e/TA
    public static void addNewProblem(problem prob)
    {
        db_connection db_obj = new db_connection();

        db_obj.open();

        string       query = "INSERT INTO problem (venue, pc, description, location_id, shift, date, status, type, added_by) VALUES (@venue, @pc, @description, @location_id, @shift, @date, @status, @type, @added_by)";
        MySqlCommand cmd   = new MySqlCommand(query, db_obj.connection);

        cmd.Parameters.AddWithValue("@venue", prob.venue);
        cmd.Parameters.AddWithValue("@pc", prob.pc);
        cmd.Parameters.AddWithValue("@description", prob.description);
        cmd.Parameters.AddWithValue("@location_id", prob.location_id);
        cmd.Parameters.AddWithValue("@shift", prob.shift);
        cmd.Parameters.AddWithValue("@date", prob.date);
        cmd.Parameters.AddWithValue("@status", prob.status);
        cmd.Parameters.AddWithValue("@type", prob.type);
        cmd.Parameters.AddWithValue("@added_by", prob.added_by);

        cmd.ExecuteNonQuery();

        db_obj.close();
    }
コード例 #16
0
ファイル: RoundingFunctions.cs プロジェクト: zyhzx123e/TA
    public static List <problem> getProblems(int locationID, char type)
    {
        List <problem> problemsList = new List <problem>();

        db_connection db_obj = new db_connection();

        db_obj.open();

        string       query   = "SELECT * FROM problem WHERE location_id=@location AND type=@type AND status = 'p'";
        MySqlCommand command = new MySqlCommand(query, db_obj.connection);

        command.Parameters.AddWithValue("@type", type);
        command.Parameters.AddWithValue("@location", locationID);

        MySqlDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            problem prob = new problem();
            prob.id          = int.Parse(reader["problem_id"].ToString());
            prob.venue       = reader["venue"].ToString();
            prob.pc          = reader["pc"].ToString();
            prob.description = reader["description"].ToString();
            prob.location_id = int.Parse(reader["location_id"].ToString());
            prob.shift       = reader["shift"].ToString();
            prob.date        = reader["date"].ToString();
            prob.status      = char.Parse(reader["status"].ToString());
            prob.type        = char.Parse(reader["type"].ToString());
            prob.added_by    = int.Parse(reader["added_by"].ToString());

            problemsList.Add(prob);
        }
        db_obj.close();

        return(problemsList);
    }
コード例 #17
0
 public void AddToproblems(problem problem)
 {
     base.AddObject("problems", problem);
 }
コード例 #18
0
 public static problem Createproblem(int ID)
 {
     problem problem = new problem();
     problem.id = ID;
     return problem;
 }
コード例 #19
0
ファイル: problemController.cs プロジェクト: Haute998/WalkTd
 public ActionResult GetPage1(problem condition)
 {
     string where = StrWhere(condition);
     where       += " and lag='e'";
     return(GetPages(condition, where));
 }
コード例 #20
0
 public void SaveProblem(problem problem)
 {
     ProblemRepository.Save(problem);
 }
コード例 #21
0
A wide variety of machine learning methods have been applied to this problem, including Hidden Markov Models (Bikel et al. 1997), Maximum Entropy methods (Borthwick et al. 1998, Chieu and Ng 2002), Decision Trees (Sekine et al. 1998), Conditional Random Fields (McCallum and Li 2003), Class-based Language Model (Sun et al. 2002), Agent-based Approach (Ye et al. 2002) and Support Vector Machines.