public ActionResult Next(UsersPolicyDocumentModel objUsersPolicyDocumentModel, int acid) { bool bReturn = false; UserPolicyDocumentEventLogModel objUserPolicyDocumentEventLogModel = new UserPolicyDocumentEventLogModel(); UserPolicyDocumentEventLogDTO objUserPolicyDocumentEventLogDTO = new UserPolicyDocumentEventLogDTO(); InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); try { objUserPolicyDocumentEventLogModel.EventCodeId = ConstEnum.Code.PolicyDocumentViewd; objUserPolicyDocumentEventLogModel.MapToTypeCodeId = ConstEnum.Code.PolicyDocument; objUserPolicyDocumentEventLogModel.MapToId = objUsersPolicyDocumentModel.PolicyDocumentId; Common.Common.CopyObjectPropertyByName(objUserPolicyDocumentEventLogModel, objUserPolicyDocumentEventLogDTO); bReturn = objInsiderInitialDisclosureSL.SaveEvent(objLoginUserDetails.CompanyDBConnectionString, objUserPolicyDocumentEventLogDTO, objLoginUserDetails.LoggedInUserID); return(RedirectToAction("Index", "InsiderInitialDisclosure", new { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_INITIAL_DISCLOSURE }).Success("Policy is viewed.")); } catch { return(View()); } finally { objUserPolicyDocumentEventLogModel = null; objUserPolicyDocumentEventLogDTO = null; objInsiderInitialDisclosureSL = null; objLoginUserDetails = null; } }
public ActionResult Accept(UsersPolicyDocumentModel objUsersPolicyDocumentModel, int acid) { bool bReturn = false; UserPolicyDocumentEventLogModel objUserPolicyDocumentEventLogModel = new UserPolicyDocumentEventLogModel(); UserPolicyDocumentEventLogDTO objUserPolicyDocumentEventLogDTO = new UserPolicyDocumentEventLogDTO(); InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); InsiderInitialDisclosureDTO objInsiderInitialDisclosureDTO = null; try { objUserPolicyDocumentEventLogModel.EventCodeId = ConstEnum.Code.PolicyDocumentAgreed; objUserPolicyDocumentEventLogModel.MapToTypeCodeId = ConstEnum.Code.PolicyDocument; objUserPolicyDocumentEventLogModel.MapToId = objUsersPolicyDocumentModel.PolicyDocumentId; Common.Common.CopyObjectPropertyByName(objUserPolicyDocumentEventLogModel, objUserPolicyDocumentEventLogDTO); bReturn = objInsiderInitialDisclosureSL.SaveEvent(objLoginUserDetails.CompanyDBConnectionString, objUserPolicyDocumentEventLogDTO, objLoginUserDetails.LoggedInUserID); if (bReturn) { objInsiderInitialDisclosureDTO = objInsiderInitialDisclosureSL.GetInitialDisclosureDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID).FirstOrDefault(); } if (objInsiderInitialDisclosureDTO.EventDate != null) { return(RedirectToAction("List", "InsiderInitialDisclosure", new { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_POLICY_DOCUMENT_LIST }).Success(InsiderTrading.Common.Common.getResource("dis_grd_17452")));//"Policy is accepted."); } else { return(RedirectToAction("Index", "InsiderInitialDisclosure", new { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_INITIAL_DISCLOSURE, ReqModuleId = objUsersPolicyDocumentModel.RequiredModuleID }).Success(InsiderTrading.Common.Common.getResource("dis_grd_17452")));//"Policy is accepted."); } } catch { return(View()); } finally { objUserPolicyDocumentEventLogModel = null; objUserPolicyDocumentEventLogDTO = null; objInsiderInitialDisclosureSL = null; objLoginUserDetails = null; } }
public ActionResult DisplayHardCopy(int acid, int DocumentID, string DocumentPath, int TransactionMasterId, int DisclosureTypeId, string CalledFrom) { UsersPolicyDocumentModel objUsersPolicyDocumentModel = new UsersPolicyDocumentModel(); UsersPolicyDocumentDTO objUsersPolicyDocumentDTO = new UsersPolicyDocumentDTO(); InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL(); try { objUsersPolicyDocumentModel.PolicyDocumentPath = DocumentPath; objUsersPolicyDocumentModel.DocumentId = DocumentID; ViewBag.TransactionMasterId = TransactionMasterId; ViewBag.DisclosureTypeId = DisclosureTypeId; Common.Common.CopyObjectPropertyByName(objUsersPolicyDocumentDTO, objUsersPolicyDocumentModel); if (objUsersPolicyDocumentModel.DocumentViewAgreeFlag == true) { ViewBag.ViewAgreeFlag = true; ViewBag.ViewFlag = false; } else if (objUsersPolicyDocumentModel.DocumentViewFlag == true) { ViewBag.ViewAgreeFlag = false; ViewBag.ViewFlag = true; } ViewBag.CalledFrom = CalledFrom; return(View("ViewDocument", objUsersPolicyDocumentModel)); } catch { return(View("ViewDocument")); } finally { objUsersPolicyDocumentModel = null; objInsiderInitialDisclosureSL = null; } }
public ActionResult PartialViewDocument(UsersPolicyDocumentModel objUsersPolicyDocumentModel, int acid) { return(PartialView(objUsersPolicyDocumentModel)); }
public void Generate(UsersPolicyDocumentModel objUsersPolicyDocumentModel, int acid, int nDocumentId = 0) { String mimeType = "application/unknown"; DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL(); DocumentDetailsDTO objDocumentDetailsDTO = new DocumentDetailsDTO(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); System.IO.FileInfo fFile = null; try { Dictionary <String, String> mtypes = new Dictionary <string, string>() { { ".pdf", "application/pdf" }, { ".png", "application/png" }, { ".jpeg", "application/jpeg" }, { ".jpg", "application/jpeg" }, { ".txt", "text/plain" }, { ".xls", "application/vnd.ms-excel" }, { ".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet " }, { ".doc", "application/msword" }, { ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, }; if (nDocumentId == 0) { objDocumentDetailsDTO = objDocumentDetailsSL.GetDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, objUsersPolicyDocumentModel.DocumentId); } else { objDocumentDetailsDTO = objDocumentDetailsSL.GetDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, nDocumentId); } fFile = new System.IO.FileInfo(objDocumentDetailsDTO.DocumentPath); Response.Clear(); // ContentDisposition Value and Parameter are used. // Meaning of Value [inline] : Displayed automatically // Meaning of Parameter [filename] : Name to be used when creating file ContentDisposition contentDisposition = new ContentDisposition { FileName = objDocumentDetailsDTO.DocumentName, Inline = true }; Response.AppendHeader("Content-Disposition", contentDisposition.ToString()); String filetype = fFile.Extension.ToLower(); if (mtypes.Keys.Contains <String>(filetype)) { mimeType = mtypes[filetype]; } Response.ContentType = mimeType; Response.WriteFile(fFile.FullName); Response.End(); //NOTE - ADDED ABOVE CODE TO HANDLE DIFFERENT FILE TYPE ////Response.AddHeader("Content-Length", fFile.Length.ToString()); //if (fFile.Extension.ToLower() == ".pdf") //{ // Response.ContentType = "application/pdf"; // Response.WriteFile(fFile.FullName); // Response.End(); //} //else if (fFile.Extension.ToLower() == ".xls" || fFile.Extension.ToLower() == ".xlsx") //{ // Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; // Response.WriteFile(fFile.FullName); // Response.End(); //} //else if (fFile.Extension.ToLower() == ".png" || fFile.Extension.ToLower() == ".jpg") //{ // Response.ContentType = "image/png"; // Response.WriteFile(fFile.FullName); // Response.End(); //} //else if (fFile.Extension.ToLower() == ".docx" || fFile.Extension.ToLower() == ".doc") //{ // Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; // Response.WriteFile(fFile.FullName); // Response.End(); // //NOTE - Following code is commented because to make functionality similar to other file types // //START COMMENT ===> // //Microsoft.Office.Interop.Word.Application objWordApp = new Microsoft.Office.Interop.Word.Application(); // //object objWordFile = objUsersPolicyDocumentModel.PolicyDocumentPath; // //object objNull = System.Reflection.Missing.Value; // //Microsoft.Office.Interop.Word.Document WordDoc = objWordApp.Documents.Open( // //ref objWordFile, ref objNull, ref objNull, // //ref objNull, ref objNull, ref objNull, // //ref objNull, ref objNull, ref objNull, // //ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull); // //WordDoc.ActiveWindow.Selection.WholeStory(); // //WordDoc.ActiveWindow.Selection.Copy(); // //string strWordText = WordDoc.Content.Text; // //WordDoc.Close(ref objNull, ref objNull, ref objNull); // //objWordApp.Quit(ref objNull, ref objNull, ref objNull); // //Response.Write(strWordText); // //END COMMENT <=== //} //else if (fFile.Extension.ToLower() == ".txt") //{ // Response.ContentType = "application/text"; // Response.WriteFile(fFile.FullName); // Response.End(); //} //byte[] bytes = System.IO.File.ReadAllBytes(objUsersPolicyDocumentModel.PolicyDocumentPath); //return File(bytes, "application/pdf"); } catch (Exception exp) { @ViewBag.ErrorMsg = exp.Message; //throw exp; } finally { objDocumentDetailsSL = null; objDocumentDetailsDTO = null; objLoginUserDetails = null; fFile = null; } }
public ActionResult DisplayPolicy(int acid, int PolicyDocumentID, int DocumentID, string CalledFrom, bool CalledFromHardCopy = false, int year = 0, int Period = 0, string frm = "", bool IsFromDashboard = false, int nUserInfoId = 0, string DiscType = "", int RequiredModuleID = 0) { DocumentDetailsSL objDocumentDetailsSL = null; List <DocumentDetailsDTO> objDocumentDetailsDTOList = null; string FAQMenuURL = string.Empty; string[] MenuURLParts = null; string PID = string.Empty; string ID = string.Empty; List <InsiderTradingDAL.MenuMasterDTO> menuList = new List <MenuMasterDTO>(); ViewBag.RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOwnSecurity; menuList = (List <InsiderTradingDAL.MenuMasterDTO>)TempData["MenuList"]; if (CalledFrom == "ViewAgree_OS") { ViewBag.RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOtherSecurity; } else { ViewBag.RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOwnSecurity; } //Get the MenuURL of FAQ if (CalledFrom.ToUpper().Contains("FAQ") && IsFromDashboard) { foreach (InsiderTradingDAL.MenuMasterDTO item in menuList) { if (!String.IsNullOrEmpty(item.MenuURL) && item.MenuURL.Contains("FAQ")) { FAQMenuURL = item.MenuURL; } } if (!String.IsNullOrEmpty(FAQMenuURL)) { MenuURLParts = FAQMenuURL.Split('&'); } if (MenuURLParts.Length > 0) { for (int i = 0; i <= MenuURLParts.Length - 1; i++) { if (MenuURLParts[i].ToUpper().Contains("DOCUMENTID")) { if (MenuURLParts[i].ToUpper().Contains('=')) { if (MenuURLParts[i].ToUpper().Contains("POLICY")) { PID = MenuURLParts[i].Split('=')[1]; } else { ID = MenuURLParts[i].Split('=')[1]; } } } } PolicyDocumentID = Convert.ToInt32(PID); DocumentID = Convert.ToInt32(ID); } } Boolean isShowDownloadDocumentMsg = true; //flag used to show message to download file bool IsCalledFromReport = false; // flag used to show this page is show from Report page link bool HardCopyFileNotUploaded = false; UsersPolicyDocumentModel objUsersPolicyDocumentModel = new UsersPolicyDocumentModel(); UsersPolicyDocumentDTO objUsersPolicyDocumentDTO = new UsersPolicyDocumentDTO(); InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); int PurposeCodeId = 0; if (Convert.ToString(objLoginUserDetails.DateOfBecomingInsider).Equals("") && objLoginUserDetails.UserTypeCodeId.Equals(InsiderTrading.Common.ConstEnum.Code.EmployeeType) && (PolicyDocumentID == InsiderTrading.Common.ConstEnum.Code.FAQInsiderPolicyDocumentID || PolicyDocumentID == InsiderTrading.Common.ConstEnum.Code.FAQEmployeePolicyDocumentID)) { PolicyDocumentID = InsiderTrading.Common.ConstEnum.Code.FAQInsiderPolicyDocumentID; DocumentID = InsiderTrading.Common.ConstEnum.Code.FAQDocumentID; } DocumentDetailsDTO objDocumentDetailsDTO = new DocumentDetailsDTO(); UserPolicyDocumentEventLogDTO objUserPolicyDocumentEventLogDTO = null; try { if (DiscType == "OS") { RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOtherSecurity; } else { RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOwnSecurity; } objDocumentDetailsSL = new DocumentDetailsSL(); objUsersPolicyDocumentModel.PolicyDocumentId = PolicyDocumentID; //in case of hard copy display this value is MapToId objUsersPolicyDocumentModel.DocumentId = DocumentID; objUsersPolicyDocumentModel.CalledFrom = CalledFrom; objUsersPolicyDocumentModel.RequiredModuleID = RequiredModuleID; if (!CalledFromHardCopy && !Common.Common.CheckUserTypeAccess(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.Code.PolicyDocument, Convert.ToInt64(PolicyDocumentID), objLoginUserDetails.LoggedInUserID)) { return(RedirectToAction("Unauthorised", "Home")); } //check if to show policy document details or hard copy file and get details accourdingly if (CalledFromHardCopy) { //get hard copy document details //check if document has uploaded or not -- by checking document id - in case of not uploaded document id is "0" if (DocumentID > 0) { objDocumentDetailsDTO = objDocumentDetailsSL.GetDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, DocumentID); } else { HardCopyFileNotUploaded = true; } //copy document details DTO into User policy document model objUsersPolicyDocumentModel.DocumentId = objDocumentDetailsDTO.DocumentId; objUsersPolicyDocumentModel.PolicyDocumentName = objDocumentDetailsDTO.DocumentName; objUsersPolicyDocumentModel.PolicyDocumentFileType = objDocumentDetailsDTO.FileType; objUsersPolicyDocumentModel.CalledFrom = CalledFrom; objUsersPolicyDocumentModel.DocumentViewFlag = false; objUsersPolicyDocumentModel.DocumentViewAgreeFlag = false; } else { objUsersPolicyDocumentDTO = objInsiderInitialDisclosureSL.GetDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, PolicyDocumentID, DocumentID); objUsersPolicyDocumentDTO.DocumentId = DocumentID; Common.Common.CopyObjectPropertyByName(objUsersPolicyDocumentDTO, objUsersPolicyDocumentModel); } if (objUsersPolicyDocumentModel.DocumentViewAgreeFlag == true) { ViewBag.ViewAgreeFlag = true; ViewBag.ViewFlag = false; } else if (objUsersPolicyDocumentModel.DocumentViewFlag == true) { ViewBag.ViewAgreeFlag = false; ViewBag.ViewFlag = true; } ViewBag.CalledFrom = CalledFrom; ViewBag.Company = objLoginUserDetails.CompanyName; ViewBag.PDID = PolicyDocumentID; ViewBag.Year = year; ViewBag.Period = Period; ViewBag.nUserInfoId = nUserInfoId; int DocMapToTypeCodeId = 0; //get document details - document id - to set and show document to user if (DiscType == "OS") { DocMapToTypeCodeId = (CalledFromHardCopy) ? ConstEnum.Code.DisclosureTransactionforOS : ConstEnum.Code.PolicyDocument; } else { DocMapToTypeCodeId = (CalledFromHardCopy) ? ConstEnum.Code.DisclosureTransaction : ConstEnum.Code.PolicyDocument; } //get details if document is uploaded by checking document id if (DocumentID > 0) { PurposeCodeId = (CalledFrom == "DisclosureDocuments") ? ConstEnum.Code.TransactionDetailsUpload : 0; objDocumentDetailsDTOList = objDocumentDetailsSL.GetDocumentList(objLoginUserDetails.CompanyDBConnectionString, DocMapToTypeCodeId, PolicyDocumentID, PurposeCodeId); ViewBag.DocumentId = objDocumentDetailsDTOList[0].DocumentId; ViewBag.GUID = objDocumentDetailsDTOList[0].GUID; ViewBag.DocumentName = objDocumentDetailsDTOList[0].DocumentName; ViewBag.FileType = objDocumentDetailsDTOList[0].FileType; //check for following file type and set flag to false so message to download file will not be appear if (objDocumentDetailsDTOList[0].FileType == ".pdf") { isShowDownloadDocumentMsg = false; } } //set flag to show download document message ViewBag.ShowDownloadDocumentMsg = isShowDownloadDocumentMsg; //check if in session "BackURL" is set or not -- this URL is set from report contoller //if url is set then set flag true in viewbag for URL from Report page and reset backurl to empty if (objLoginUserDetails.BackURL != null && objLoginUserDetails.BackURL != "") { IsCalledFromReport = true; ViewBag.ReturnUrl = objLoginUserDetails.BackURL; objLoginUserDetails.BackURL = ""; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); } ViewBag.IsCalledFromReport = IsCalledFromReport; ViewBag.CalledFromHardCopy = CalledFromHardCopy; ViewBag.HardCopyFileNotUploaded = HardCopyFileNotUploaded; ViewBag.frm = frm; ViewBag.UserAction = acid; // check from where document is displayed -- if policy document is displayed to user which are view only and whoes status is view only // then add event to viewed for user if (CalledFrom != null && (CalledFrom.ToLower() == "view" || CalledFrom.ToLower() == "viewagreelist")) { //check is document show is view only document if (objUsersPolicyDocumentModel.DocumentViewAgreeFlag != true && objUsersPolicyDocumentModel.DocumentViewFlag == true) { objUserPolicyDocumentEventLogDTO = new UserPolicyDocumentEventLogDTO(); objUserPolicyDocumentEventLogDTO.EventCodeId = ConstEnum.Code.PolicyDocumentViewd; objUserPolicyDocumentEventLogDTO.MapToTypeCodeId = ConstEnum.Code.PolicyDocument; objUserPolicyDocumentEventLogDTO.MapToId = objUsersPolicyDocumentModel.PolicyDocumentId; // save policy document viewed event objInsiderInitialDisclosureSL.SaveEvent(objLoginUserDetails.CompanyDBConnectionString, objUserPolicyDocumentEventLogDTO, objLoginUserDetails.LoggedInUserID); } } return(View("~/Views/InsiderInitialDisclosure/ViewDocument.cshtml", objUsersPolicyDocumentModel)); } catch (Exception ex) { string sErrMessage = Common.Common.getResource(ex.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); return(View("~/Views/InsiderInitialDisclosure/ViewDocument.cshtml")); } finally { objDocumentDetailsSL = null; objDocumentDetailsDTOList = null; objUsersPolicyDocumentModel = null; objUsersPolicyDocumentDTO = null; objInsiderInitialDisclosureSL = null; objLoginUserDetails = null; objDocumentDetailsDTO = null; objUserPolicyDocumentEventLogDTO = null; } }