Пример #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;
        }
Пример #3
0
 partial void DeleteProfileDTO(ProfileDTO instance);
Пример #4
0
 partial void UpdateProfileDTO(ProfileDTO instance);
Пример #5
0
 partial void InsertProfileDTO(ProfileDTO instance);