Пример #1
0
        public ActionResult ManageResume(HttpPostedFileBase cv)
        {
            int    sess     = Convert.ToInt32(Session["js_id"].ToString());
            string filename = null;

            if (cv != null)
            {
                try
                {
                    string ext = Path.GetExtension(cv.FileName);
                    filename = Guid.NewGuid().ToString() + ext;
                    string path1 = Path.Combine(Server.MapPath("~/Content/Files"), filename);
                    cv.SaveAs(path1);
                    tbl_cv cv_save = db.tbl_cv.Where(a => a.jobseeker_id == sess).FirstOrDefault();
                    if (cv_save == null)
                    {
                        tbl_cv cvnext = new tbl_cv();
                        cvnext.jobseeker_id = sess;
                        cvnext.file_loc     = filename;
                        cvnext.updated_at   = DateTime.Now;
                        db.tbl_cv.Add(cvnext);
                    }
                    else
                    {
                        cv_save.file_loc   = filename;
                        cv_save.updated_at = DateTime.Now;
                    }
                    if (db.SaveChanges() > 0)
                    {
                        StringBuilder text = new StringBuilder();
                        Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
                        object miss     = System.Reflection.Missing.Value;
                        object path     = @"E:\College_project\myCareer_files\myCareer\myCareer\Content\Files\" + filename;
                        object readOnly = true;
                        Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
                        docs.Activate();
                        for (int i = 0; i < docs.Paragraphs.Count; i++)
                        {
                            text.Append(" \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString());
                        }
                        string final = Regex.Replace(text.ToString(), @"\r\n?|\n", "<br/>");
                        cv_save.cv = final;
                        db.SaveChanges();
                        return(View());
                    }
                    else
                    {
                        return(View());
                    }
                }
                catch (Exception ex)
                {
                    ex.StackTrace.ToString();
                }
            }

            return(View());
        }
Пример #2
0
        public JsonResult updateCv(string val)
        {
            int    sess    = Convert.ToInt32(Session["js_id"].ToString());
            tbl_cv cv_save = db.tbl_cv.Where(a => a.jobseeker_id == sess).FirstOrDefault();

            cv_save.updated_at = DateTime.Now;
            cv_save.cv         = val;
            if (db.SaveChanges() > 0)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }