Beispiel #1
0
        public ResponseMessage Create(StaffFile entity)
        {
            ResponseMessage response = new ResponseMessage();

            _repository.Create(entity);

            return(response);
        }
        public ActionResult Assign(HttpPostedFileBase file, AssignViewModel model)
        {
            if (file == null)
            {
                ModelState.AddModelError(string.Empty, "Mohon upload file pendukung.");
                PrepareAssignSelectList();
                return(View(model));
            }

            Report report = new Report();

            report.Id           = model.Id;
            report.PPKId        = model.PPKId;
            report.StaffComment = model.StaffComment;
            _reportLogic.AssignReport(report);
            if (file.ContentLength > 0)
            {
                var fileName = Path.GetFileName(file.FileName);
                var filePath = model.Id + "_" + fileName;
                var path     = Path.Combine(Server.MapPath("~/Content/UploadStaff"), filePath);
                file.SaveAs(path);

                StaffFile staffFile = new StaffFile();
                staffFile.FileName = fileName;
                staffFile.ReportId = model.Id;

                _staffFileLogic.Create(staffFile);
            }

            try {
                var ppk = _ppkLogic.GetById(model.PPKId);

                if (ppk != null)
                {
                    if (ppk.PIC != null)
                    {
                        var msg = new MailMessage();
                        msg.To.Add(new MailAddress(ppk.PIC.Email));
                        msg.Subject = "LAPOR-BRANTAS New Disposition";
                        msg.Body    = model.StaffComment;
                        msg.From    = new MailAddress("*****@*****.**");

                        using (var client = new SmtpClient()
                        {
                            Host = "relay-hosting.secureserver.net", Port = 25, EnableSsl = false, UseDefaultCredentials = false
                        })
                        {
                            client.Send(msg);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index"));
        }
        //public ActionResult FolderDisplay(string folder)
        //{
        //    var folderList = new List<StaffFolder>();

        //    string path = ConfigurationManager.AppSettings["FileRepositoryPath"].ToString();
        //    path = Path.Combine(path, folder);
        //    GetFolderFiles(path, folder, folderList);
        //    ViewBag.FolderName = folder;

        //    return View(folderList);
        //}

        //public ActionResult FolderDisplayTree(string folder)
        //{
        //    string path = ConfigurationManager.AppSettings["FileRepositoryPath"].ToString();
        //    path = Path.Combine(path, folder);

        //    ViewBag.FolderName = folder;

        //    string user = User.Identity.Name;
        //    var list = DynamicFolderFile.GetFileFolderModel(path, folder, user);
        //    return View(list);
        //}

        private void GetFolderFiles(string path, string topFolder, List <StaffFolder> folderList)
        {
            //DirectoryInfo di = new DirectoryInfo(path);
            string staffFolder = topFolder;

            string[] parts  = path.Split(new string[] { "\\" }, StringSplitOptions.None);
            int      iStart = 100;

            for (int i = 3; i < parts.Length; i++)
            {
                if (parts[i] == topFolder)
                {
                    iStart = i;
                }
                if (i > iStart)
                {
                    staffFolder += "/" + parts[i];
                }
            }

            var sf = new StaffFolder(staffFolder);
            List <StaffFile> files = new List <StaffFile>();

            sf.Files = files;
            folderList.Add(sf);

            string fileFolder = staffFolder.Replace("/", "~");

            foreach (string f in Directory.GetFiles(path))
            {
                StaffFile file = new StaffFile(Path.GetFileName(f));
                file.FolderName = fileFolder;
                files.Add(file);
            }

            foreach (string d in Directory.GetDirectories(path))
            {
                GetFolderFiles(d, topFolder, folderList);
            }
        }
Beispiel #4
0
 public StaffFile Edit(StaffFile entity)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public void Create(StaffFile entity)
 {
     _db.StaffFiles.Add(entity);
     _db.SaveChanges();
 }
Beispiel #6
0
 public ResponseMessage Edit(StaffFile entity)
 {
     throw new NotImplementedException();
 }