Ejemplo n.º 1
0
        private void btnRand_Click(object sender, EventArgs e)
        {
            PostString ps = new PostString();

            ps.rand((int)editRandDigits.Value);
            editPostStr.Text = ps.toString();
        }
Ejemplo n.º 2
0
        private void editPostStr_TextChanged(object sender, EventArgs e)
        {
            if (speed_ == 0)
            {
                return;
            }
            PostString ps = new PostString();

            ps.load(editPostStr.Text);
            decimal dist    = ps.distance();
            decimal elapSec = dist / speed_;
            decimal elapMin = elapSec / 60;
            decimal elapHor = elapMin / 60;
            decimal elapDay = elapHor / 24;

            elapHor         %= 24;
            elapMin         %= 60;
            elapSec         %= 60;
            labelExpect.Text = string.Format("{0}天{1}小时{2}分{3}秒", (int)elapDay, (int)elapHor, (int)elapMin, (int)elapSec);
        }
Ejemplo n.º 3
0
        private void btnSpeed_Click(object sender, EventArgs e)
        {
            Stopwatch  sw  = new Stopwatch();
            string     hs  = GetHash.hash("test", editSalt1.Text);
            PostString ps  = new PostString();
            decimal    cnt = 0;

            sw.Start();
            while (true)
            {
                string hs2 = GetHash.hash(hs + ps.toString(), editSalt2.Text);
                cnt++;
                if (sw.ElapsedMilliseconds > 3000)
                {
                    sw.Stop();
                    break;
                }
            }

            speed_          = cnt / (sw.ElapsedMilliseconds / 1000);
            labelSpeed.Text = string.Format("{0} h/s", speed_);
            editPostStr_TextChanged(null, null);
        }
Ejemplo n.º 4
0
        public ActionResult Create(Project collection, string Prange, FormCollection form)
        {
            try
            {
                int Priority = 1;
                int.TryParse(Prange, out Priority);
                string CheckDate = form["hdnChk"].ToString();
                string UserID    = form["User"].ToString();
                //validate :
                if (collection.Project1 == "")
                {
                    ModelState.AddModelError(string.Empty, "Please enter all the fileds below");
                    if (Session["ProjectToEdit"] == null)
                    {
                        ViewBag.SubmitValue = "Add";
                    }
                    else
                    {
                        ViewBag.SubmitValue = "Update";
                    }
                    collection.User_info = UserList();
                    collection.Priority  = Priority;
                    ViewData["project"]  = collection;
                    ViewData["oList"]    = (List <Project>)Session["ProjectList"];
                    return(View("ProjectView"));
                }
                if (CheckDate == "true")
                {
                    if (collection.Start_Date < DateTime.Now || collection.Start_Date == null || collection.End_date <= DateTime.Now.Date || collection.End_date == null)
                    {
                        ModelState.AddModelError(string.Empty, "Please enter Correct start and end date");
                        if (Session["ProjectToEdit"] == null)
                        {
                            ViewBag.SubmitValue = "Add";
                        }
                        else
                        {
                            ViewBag.SubmitValue = "Update";
                        }
                        collection.User_info = UserList();
                        collection.Priority  = Priority;
                        ViewData["project"]  = collection;
                        ViewData["oList"]    = (List <Project>)Session["ProjectList"];
                        return(View("ProjectView"));
                    }
                }


                string PostString;
                collection.Priority = Priority;

                if (Session["ProjectToEdit"] == null)
                {
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(Baseurl);

                        //HTTP POST
                        var postTask = client.PostAsJsonAsync <Project>("PostProject", collection);
                        postTask.Wait();

                        var result = postTask.Result;
                        PostString = result.StatusCode.ToString();
                        if (PostString.Contains("InternalServerError") == true)
                        {
                            PostString = "OK";
                        }
                    }
                    //update the same in the User table
                    AddUserProject(collection, UserID);
                }
                else
                {
                    //update
                    Project ProjectToSave = new Project();
                    ProjectToSave = (Project)Session["ProjectToEdit"];
                    //Clear the session
                    Session["ProjectToEdit"] = null;
                    ProjectToSave.Project1   = collection.Project1;
                    ProjectToSave.Start_Date = collection.Start_Date;
                    ProjectToSave.End_date   = collection.End_date;
                    ProjectToSave.Priority   = Priority;
                    ProjectToSave.User_info  = null;//this will not add any extra row in the User table.
                    ProjectToSave.Tasks      = null;

                    oUser(UserID, ProjectToSave.Project_ID);
                    //Call the Put Method

                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(Baseurl);

                        //HTTP POST
                        var postTask = client.PutAsJsonAsync <Project>("PutProject", ProjectToSave);
                        postTask.Wait();

                        var result = postTask.Result;
                        PostString = result.StatusCode.ToString();
                        if (PostString.Contains("NoConte") == true)
                        {
                            PostString = "OK";
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Create(Task collection, FormCollection form)
        {
            string PostString;

            try
            {
                int    Priority = 1;
                string Prange   = form["Prange"].ToString();
                int.TryParse(Prange, out Priority);
                string CheckParentTkt = form["hdnChk"].ToString();

                string ProjectVal = form["ProjectDDL"].ToString();

                //validate the Input
                //Parent task
                if (collection.Task1 == null || collection.Task1 == "")
                {
                    ModelState.AddModelError("ERROR", "Please add Task name");
                    return(RedirectToAction("Create"));
                }
                if (CheckParentTkt == "false")
                {
                    if (collection.Start_Date == null || collection.Start_Date < DateTime.Today || collection.End_date == null || collection.End_date < DateTime.Today.AddDays(1))
                    {
                        ModelState.AddModelError("ERROR", "Please enter all the subtask data and data should be valid.");
                        return(RedirectToAction("Create"));
                    }
                }



                if (CheckParentTkt == "true")//Parent Ticket
                {
                    ParentTask Ptask = new ParentTask();
                    Ptask.Parent_Task = collection.Task1;
                    //add the parent task , then call the userInfo table to update the Task ID based on the project ID
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(Baseurl);

                        //HTTP POST
                        var postTask = client.PostAsJsonAsync <ParentTask>("PostParentTask", Ptask);
                        postTask.Wait();

                        var result = postTask.Result;
                        PostString = result.StatusCode.ToString();
                        if (PostString.Contains("InternalServerError") == true)
                        {
                            PostString = "OK";
                        }
                        ViewBag.Message = "Parent task added sucessfully";
                    }
                    UpdateUserTableforTask(ProjectVal, Ptask);
                }
                else//subtask
                {
                    string UserID        = form["User"].ToString();
                    string ParentTaskval = form["taskName"].ToString();

                    int ProjectID;
                    int PtaskID;

                    int.TryParse(ProjectVal, out ProjectID);
                    int.TryParse(ParentTaskval, out PtaskID);

                    collection.Parent_ID  = PtaskID;
                    collection.Project_ID = ProjectID;
                    collection.Status     = "Active";
                    collection.Priority   = Priority;
                    //call insert method
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(Baseurl);

                        //HTTP POST
                        var postTask = client.PostAsJsonAsync <Task>("PostTask", collection);
                        postTask.Wait();

                        var result = postTask.Result;
                        PostString = result.StatusCode.ToString();
                        if (PostString.Contains("InternalServerError") == true)
                        {
                            PostString = "OK";
                        }
                        ViewBag.Message = "Subtask added sucessfully";
                    }
                }

                return(RedirectToAction("Create"));
            }
            catch
            {
                ModelState.AddModelError("ERROR", "Error in Add task");
                return(View("Create"));
            }
        }