Example #1
0
        public ActionResult fileUp()
        {
            #region
            var file = Request.Files["Filedata"];
            //var userID = Request.QueryString["u"];
            var foldName = Request.QueryString["foldName"].ToString();


            if (file != null)
            {
                imgUpload imgUpLoad = new imgUpload();//上传图片的类
                var       reUrl     = imgUpLoad.picUpLoad(file, foldName);
                //return new ContentResult() { Content = serverPath.imageURL + reUrl, ContentType = "text/plain", ContentEncoding = System.Text.Encoding.UTF8 };
                return(new ContentResult()
                {
                    Content = reUrl, ContentType = "text/plain", ContentEncoding = System.Text.Encoding.UTF8
                });
            }
            else
            {
                return(new ContentResult()
                {
                    Content = "0", ContentType = "text/plain", ContentEncoding = System.Text.Encoding.UTF8
                });
            }
            #endregion
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Mail,Password,GoogleToken,TodoTitle,PersonId")] Todo todo)
        {
            if (id != todo.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var       key     = _appOptions.Value.AccountKey;
                    var       name    = _appOptions.Value.AccountName;
                    imgUpload img     = new imgUpload();
                    string    imgPath = img.ImgUpload(Request.HttpContext, name, key);
                    _context.Update(todo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TodoExists(todo.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(todo));
        }
Example #3
0
        public async Task <IActionResult> MainForm()
        {
            if (ModelState.IsValid)
            {
                int userID = int.Parse(TempData["userID"].ToString());
                var todo   = await _context.Todo.SingleOrDefaultAsync(m => m.ID == userID);

                try
                {
                    //顔画像のパス取得
                    var       key     = _appOptions.Value.AccountKey;
                    var       name    = _appOptions.Value.AccountName;
                    imgUpload img     = new imgUpload();
                    string    imgPath = img.ImgUpload(Request.HttpContext, name, key);

                    //名前でPERSON作成+画像をPERSONへ追加
                    var       subscriptionKey = _faceApiOptions.Value.Subscriptionkey;
                    var       groupName       = _faceApiOptions.Value.GroupName;
                    AddPerson face            = new AddPerson();
                    string    personId        = face.addPerson(subscriptionKey, groupName, todo.Name, imgPath);
                    todo.PersonId = personId;
                    _context.Update(todo);
                    await _context.SaveChangesAsync();

                    if (todo.PersonId != null)
                    {
                        ViewBag.imgRegister = "画像のアップが完了しています。OK";
                    }
                    else
                    {
                        ViewBag.imgNoRegister = "画像のアップが未完了です!";
                    }
                    ViewBag.name       = "ログイン中:" + todo.Name;
                    TempData["userID"] = userID;
                    return(View("mainForm"));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TodoExists(todo.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(View());
        }
Example #4
0
        public ActionResult fileUpOfPro()
        {
            #region
            HttpPostedFileBase file = Request.Files["imgFile"];
            var foldName            = Request.QueryString["foldName"].ToString();

            Hashtable hash = new Hashtable();
            if (file != null)
            {
                imgUpload imgUpLoad = new imgUpload();//上传图片的类
                var       reUrl     = imgUpLoad.picUpLoad(file, foldName);
                hash["error"] = 0;
                hash["url"]   = reUrl;
                return(Json(hash, "text/html;charset=UTF-8"));
            }
            else
            {
                hash["error"]   = 1;
                hash["message"] = "请选择文件";
                return(Json(hash));
            }
            #endregion
        }
Example #5
0
        public ActionResult StuRegister(HCHEv2.Models.stuRegist.StuRegistInfo model)
        {
            ViewBag.AddResult = false;
            string upPhotePath = "";

            if (ModelState.IsValid)
            {
                try
                {
                    var file = Request.Files["Sphoto"];

                    #region 图片上传和验证
                    if (file != null)
                    {
                        imgUpload imgUpLoad = new imgUpload();//上传图片的类
                        upPhotePath = imgUpLoad.picUpLoad(file, "BmStuPic");
                    }
                    else
                    {
                        ModelState.AddModelError("noPhoto", "请上传1寸免冠照片");
                        return(View(model));
                    }
                    if (upPhotePath == "0" || upPhotePath == "1")
                    {
                        string errorMsg = "";
                        switch (upPhotePath)
                        {
                        case "0":
                            errorMsg = "图片格式错误,请重新上传";
                            break;

                        case "1":
                            errorMsg = "图片大小超出1M,请重新上传";
                            break;
                        }
                        ModelState.AddModelError("noPhoto", errorMsg);
                        return(View(model));
                    }

                    #endregion


                    #region 保存报名学生
                    var student = new HC.Data.Models.StudentInfo()
                    {
                        FatherPhone  = model.FatherPhone,
                        major        = model.major,
                        MotherPhone  = model.MotherPhone,
                        ReceiveName  = model.ReceiveName,
                        ReceivePhone = model.ReceivePhone,
                        registerNo   = model.registerNo,
                        RegisterTime = DateTime.Now,
                        Scategory    = model.Scategory,
                        SchoolName   = model.SchoolName,
                        SeflPhone    = model.SeflPhone,
                        SelfCardNo   = model.SelfCardNo,
                        SendAddress  = model.SendAddress,
                        Sex          = model.Sex,
                        Sfrom        = model.Sfrom,
                        Sphoto       = upPhotePath,
                        StudentName  = model.StudentName,
                        Stype        = model.Stype,
                        TelNum       = model.TelNum,
                        ZipCode      = model.ZipCode
                    };


                    #region 重复校验
                    if (_iEnrolsysService.isExsit(student))
                    {
                        ModelState.AddModelError("noPhoto", "您的信息已存在,请勿重复提交!");
                        return(View(model));
                    }
                    #endregion


                    _iEnrolsysService.AddStudentInfo(student);
                    #endregion

                    ViewBag.AddResult = true;
                }
                catch
                {
                }
                return(View());
            }
            else
            {
                return(View(model));
            }
        }