示例#1
0
        public ActionResult Create(ProfileDTO profile)
        {
            bool success = false;

            var handler = Request.Params["handler"];

            if (Const.IsNullOrEmpty(profile.Project_Code))
            {
                var result = new { errors = "B003", message = "项目编码不能为空。" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

            var uploadFile = Request.Files["UploadFile"];

            string filepath = ConfigurationManager.AppSettings["Repository"];
            filepath += profile.Project_Code + @"\";
            filepath += profile.Project_Stage + @"\";
            filepath += profile.Project_Subject + @"\";

            Const.Direcotry(filepath);

            string barcode = BarcodeService.Create();
            string filename = barcode + "@" + Const.GetSimpleFileName(uploadFile.FileName);
            filepath += filename;

            try
            {
                uploadFile.SaveAs(filepath);

                var extension = Const.GetExtension(filepath);
                if (extension.ToLower() == ".dwg")
                {
                    // 转换PDF文件
                    var pdfFileName = Const.RemoveExtension(filepath) + ".pdf";
                    DwgDirectXManager.Instance.ConvertToPDF(new InputOutputParam()
                    {
                        dwgFileName = filepath,
                        pdfFileName = pdfFileName
                    });
                }

                profile.Barcode = barcode;
                profile.File_Name = filename;
                profile.Created_Date = DateTime.Now;
                profile.Plotter = User.Identity.Name;

                ProfileService.Save(profile);
                success = true;
            }
            catch
            {
                System.IO.File.Delete(filepath);
            }

            return Json(new { success = success }, "text/html");
        }
示例#2
0
        public ProfileDTO Save(ProfileDTO entity)
        {
            if (GetProfile(entity.Barcode) == null)
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    data.ProfileDTO.InsertOnSubmit(entity);
                    data.SubmitChanges();
                }
            }

            return entity;
        }
 partial void DeleteProfileDTO(ProfileDTO instance);
 partial void UpdateProfileDTO(ProfileDTO instance);
 partial void InsertProfileDTO(ProfileDTO instance);