예제 #1
0
파일: VNPTLogs.cs 프로젝트: vumi846/TestPj
 public void Write(IRepository repository, EAction action, string content)
 {
     repository.Add(new AD_LOG()
     {
         ID          = Guid.NewGuid(),
         ServiceName = VNPTHelper.GetServiceName(),
         UserName    = VNPTHelper.GetUserName(),
         ActionRec   = (int)action,
         CreateAt    = DateTime.Now,
         Data        = content
     });
 }
예제 #2
0
파일: VNPTLogs.cs 프로젝트: vumi846/TestPj
        public Guid Write(IRepository repository, string content)
        {
            var id = Guid.NewGuid();

            repository.Add(new AD_LOG()
            {
                ID          = id,
                ServiceName = VNPTHelper.GetServiceName(),
                UserName    = VNPTHelper.GetUserName(),
                CreateAt    = DateTime.Now,
                Data        = content
            });

            //repository.UnitOfWork.SaveChanges();
            return(id);
        }
예제 #3
0
        public static string SaveBase64ToImage(string base64String, string pathSaveImage)
        {
            var server       = HttpContext.Current.Server;
            var folderBanner = $"{VNPTConfigs.DirRootUpload}/{pathSaveImage}";
            //server.MapPath(String.Concat("~", "/", pathSaveImage));
            string imageNm = String.Concat("IMG", DateTime.Now.ToString(Constants.LBM_FORMAT_SAVE_NAME_FILE), ".jpeg");

            if (!string.IsNullOrEmpty(base64String))
            {
                Image image = VNPTHelper.Base64ToImage(base64String);
                if (image != null)
                {
                    bool exists = System.IO.Directory.Exists(folderBanner);
                    if (!exists)
                    {
                        System.IO.Directory.CreateDirectory(folderBanner);
                    }
                    string fullPath = String.Concat(folderBanner, imageNm);
                    image.Save(fullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
                    FileInfo file = new FileInfo(fullPath);
                    if (file.Exists == true)
                    {
                        if (file.Length > Constants.LBM_MAX_SIZE_IMAGE)
                        {
                            return(EStatusFile.OverWeight.ToString());
                        }
                    }

                    return(imageNm);
                }
                else
                {
                    return(EStatusFile.Base64Incorrect.ToString());
                }
            }
            else
            {
                return(null);
            }
        }