// GET: AutoApproval public ActionResult AutoApproval() { ViewBag.ProcessNo = _FileTransMainService.All().Select(x => x.FileTransID).LastOrDefault() + 1; ViewBag.ActID = LoadDropDown.LoadAllActions(_actionListService); ViewBag.ActionBy = LoadDropDown.LoadPrepApprvBy(); ViewBag.MarkTo = LoadDropDown.LoadPrepApprvBy(); // ViewBag.ActionBy = LoadDropDown.LoadPrepApprvBy(_employeeService, "MemberLoan", "Action By"); // ViewBag.MarkTo = LoadDropDown.LoadPrepApprvBy(_employeeService, "MemberLoan", "Mark To"); return(View()); }
public ActionResult GetAllItem() { //FileMainInfo.UserID = Convert.ToInt32(Session["UserID"].ToString()); var uservalid = Convert.ToInt32(Session["UserID"].ToString()); var FileInfo = _fileMainService.All().ToList().Where(x => x.UserID == uservalid || (x.UpdUserID == uservalid)); var FileInfoAll = _fileMainService.All(); //var FileTransNo = _fileMainService.All().Where(x => x.UserID == uservalid).Select(x => x.FileNo).FirstOrDefault(); //var FileTransInfo = _fileTransMainService.All().Where(x => x.FileID == FileTransNo).Select(x=>x.MarkToID); if (uservalid != null) { List <FileInfos> fInfos = new List <FileInfos>(); //if (FileInfo!=null) //{ foreach (var item in FileInfo) { FileInfos fInfo = new FileInfos(); fInfo.FileNo = item.FileNo; fInfo.FileRef = item.FileRef; fInfo.FileSub = item.FileSub; var openuser = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.UserID).FirstOrDefault(); var openuserstaff = _newStaffService.All().Where(x => x.StaffId == openuser).Select(x => x.StaffName).FirstOrDefault(); fInfo.UserName = openuserstaff; var openuserstaffid = _newStaffService.All().Where(x => x.StaffId == openuser).Select(x => x.StaffId).FirstOrDefault(); fInfo.UserId = openuserstaffid; var updateUserId = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.UpdUserID).FirstOrDefault(); // fInfo.UpdateName = _newStaffService.All().Where(x => x.StaffId == updateUserId).Select(x => x.StaffName).FirstOrDefault(); // var approvedCheck = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.VersionNo).LastOrDefault(); //var Check = item.VersionNo; var MainId = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.MainID).FirstOrDefault(); var Checkid = _fileTransMainService.All().Where(x => x.MainID == MainId).Select(x => x.ActionID).LastOrDefault(); var Check = _actionListService.All().Where(x => x.ActID == Checkid).Select(x => x.ActDesc).FirstOrDefault(); fInfo.approved = _actionListService.All().Where(x => x.ActDesc == Check).Select(x => x.ActID).LastOrDefault(); fInfo.Status = Convert.ToString(Check); if (Check == "New") { fInfo.Status = "New"; } //DateTime CurrDate = DateTime.UtcNow; //fInfo.days = (int)(CurrDate.Subtract((DateTime)fInfo.CreateDate)).Days; fInfo.CreateDate = item.CreateDate.ToString("yyyy-MM-dd"); fInfo.UpdateUser = updateUserId.ToString(); fInfo.LoginUser = (Session["UserID"].ToString()); if (fInfo.UserId == Convert.ToInt64(fInfo.LoginUser) && fInfo.approved == 2) { fInfo.Status = "Processing....."; } fInfos.Add(fInfo); } if (uservalid == 1002) { List <FileInfos> fInfosTr = new List <FileInfos>(); foreach (var item in FileInfoAll) { FileInfos fInfoAll = new FileInfos(); fInfoAll.FileNo = item.FileNo; fInfoAll.FileRef = item.FileRef; fInfoAll.FileSub = item.FileSub; var openuser = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.UserID).FirstOrDefault(); var openuserstaff = _newStaffService.All().Where(x => x.StaffId == openuser).Select(x => x.StaffName).FirstOrDefault(); fInfoAll.UserName = openuserstaff; fInfoAll.CreateDate = item.CreateDate.ToString("yyyy-MM-dd"); fInfoAll.Status = item.VersionNo; var updateUserId = _fileMainService.All().Where(x => x.FileNo == item.FileNo).Select(x => x.UpdUserID).FirstOrDefault(); fInfoAll.UpdateName = _newStaffService.All().Where(x => x.StaffId == updateUserId).Select(x => x.StaffName).FirstOrDefault(); fInfosTr.Add(fInfoAll); return(Json(new { data = fInfoAll }, JsonRequestBehavior.AllowGet)); } } return(Json(new { data = fInfos }, JsonRequestBehavior.AllowGet)); } else { return(null); } }
public ActionResult SaveFileProcessAction() { //foreach (HttpPostedFileBase f in Request.Files) //{ //} HttpFileCollectionBase PhotoFile = Request.Files; var fMain = Request.Form["fMain"]; var obj1 = JObject.Parse(fMain); var fileBelongstoUser = _fileMainService.All().Where(x => x.FileNo == (string)obj1["fMain"]["FileID"]).Select(x => x.UserID).FirstOrDefault(); try { using (var transaction = new TransactionScope()) { var fileNoCheck = _fileMainService.All().Where(x => x.FileNo == (string)obj1["fMain"]["FileID"]).FirstOrDefault(); //FileMain FileMainInfo = new FileMain(); if (fileNoCheck != null) { var VersionNo = EncryptionDecryption.DH_PEncode(_actionListService.All().Where(x => x.ActID == (int)obj1["fMain"]["Action"]).Select(x => x.ActDesc).LastOrDefault()); var UpdUserID = (int)obj1["fMain"]["MarkTo"]; if (UpdUserID == 0) { fileNoCheck.UpdUserID = EncryptionDecryption.DH_PEncodeInt(fileBelongstoUser); //Convert.ToInt32(Session["UserID"]); } else { fileNoCheck.UpdUserID = EncryptionDecryption.DH_PEncodeInt((int)obj1["fMain"]["MarkTo"]); } fileNoCheck.VersionNo = EncryptionDecryption.DH_PEncode(VersionNo); _fileMainService.Update(fileNoCheck); _fileMainService.Save(); } var user = Convert.ToInt32(Session["UserID"]); FileTransMain FileTransMainInfo = new FileTransMain(); FileTransMainInfo.MainID = EncryptionDecryption.DH_PEncodeInt(_fileMainService.All().Where(x => x.FileNo == (string)obj1["fMain"]["FileID"]).Select(x => x.MainID).FirstOrDefault()); FileTransMainInfo.ActionNum = EncryptionDecryption.DH_PEncode(_actionListService.All().Where(x => x.ActID == (int)obj1["fMain"]["Action"]).Select(x => x.ActDesc).LastOrDefault()); //FileTransMainInfo.EntryDate = (DateTime)obj1["fMain"]["Date"]; FileTransMainInfo.MarkToID = EncryptionDecryption.DH_PEncodeInt((int)obj1["fMain"]["MarkTo"]); //FileTransMainInfo.MarkToID = _newStaffService.All().Where(x => x.StaffId ==user).Select(x => x.ReportingId).FirstOrDefault(); if (FileTransMainInfo.MarkToID == 0) { FileTransMainInfo.MarkToID = fileBelongstoUser; } FileTransMainInfo.EntryDate = DateTime.Now; FileTransMainInfo.ActionID = EncryptionDecryption.DH_PEncodeInt((int)obj1["fMain"]["Action"]); FileTransMainInfo.AttachNum = EncryptionDecryption.DH_PEncode(Convert.ToString(PhotoFile.Count)); // var action = _fileTransMainService.All().Where(x => x.MainID ==(int)obj1["fMain"]["FileID"]).Select(x => x.ActionNum).LastOrDefault(); var FileTransNum = Convert.ToInt16(_fileTransMainService.All().Where(x => x.MainID == FileTransMainInfo.MainID).Select(x => x.FileTransNum).LastOrDefault()); FileTransMainInfo.FileTransNum = EncryptionDecryption.DH_PEncode((FileTransNum + 1).ToString()); // FileTransMainInfo.FileTransID = 1; FileTransMainInfo.ActionByID = EncryptionDecryption.DH_PEncodeInt(Convert.ToInt32(Session["UserID"].ToString())); FileTransMainInfo.SignDate = DateTime.Now; FileTransMainInfo.TransDate = DateTime.Now; FileTransMainInfo.Note = EncryptionDecryption.DH_PEncode((string)obj1["fMain"]["Note"]); _fileTransMainService.Add(FileTransMainInfo); _fileTransMainService.Save(); transaction.Complete(); } } catch (Exception ex) { return(Json("0", JsonRequestBehavior.AllowGet)); } var MainIdCheck = _fileMainService.All().Where(x => x.FileNo == (string)obj1["fMain"]["FileID"]).Select(x => x.MainID).LastOrDefault(); string fileName = ""; string NewPhotoID = ""; //string ImgPrefix = ""; string ext = ""; string PhotoPath = ""; string PhysicalPhPath = ""; string DBPhotoPath = ""; try { if (PhotoFile != null) { for (int i = 0; i < PhotoFile.Count; i++) { string fileId = Guid.NewGuid().ToString().Replace("-", ""); HttpPostedFileBase file = PhotoFile[i]; fileName = Path.GetFileName(file.FileName); //ImgPrefix = file.ContentType; //"Photo";//file.ContentType;// int fSize = file.ContentLength; //var path = Path.Combine(Server.MapPath("~/Uploads/Photo/"), MemberCode, fileId); ext = System.IO.Path.GetExtension(fileName); if (ext.ToLower().Contains("txt") || ext.ToLower().Contains("gif") || ext.ToLower().Contains("jpg") || ext.ToLower().Contains("jpeg") || ext.ToLower().Contains("png") || ext.ToLower().Contains(".xls") || ext.ToLower().Contains(".docx") || ext.ToLower().Contains(".xlsx") || ext.ToLower().Contains(".pdf")) { NewPhotoID = fileId + ext; PhotoPath = ConfigurationManager.AppSettings["PhotoPath"]; PhysicalPhPath = Path.Combine(Server.MapPath(PhotoPath), NewPhotoID); //var path = Path.Combine(Server.MapPath("~/Images/Photo"), fileName); file.SaveAs(PhysicalPhPath); DBPhotoPath = PhotoPath + "\\" + NewPhotoID; } var FileTransMain = new FileTransDetail { AttachFileName = fileName, FileType = ext, Size = fSize, FileSourcePath = PhysicalPhPath, FileTransID = _fileTransMainService.All().Where(x => x.MainID == MainIdCheck).Select(x => x.FileTransID).LastOrDefault(), }; _fileTransDetailService.Add(FileTransMain); _fileTransDetailService.Save(); } } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json("0", JsonRequestBehavior.AllowGet)); } }