Пример #1
0
        public FileStreamResult Download(int nDocumentDetailsID, string GUID, string sDocumentName, string sFileType, int acid)
        {
            string directory  = ConfigurationManager.AppSettings["Document"];
            string sExtension = "";

            LoginUserDetails   objLoginUserDetails   = null;
            DocumentDetailsDTO objDocumentDetailsDTO = null;

            try
            {
                if (nDocumentDetailsID == 0)
                {
                    directory = Path.Combine(directory, "temp", GUID);
                    if (System.IO.File.Exists(directory))
                    {
                        return(File(new FileStream(directory, FileMode.Open), sFileType, sDocumentName));
                    }
                }
                else
                {
                    objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                    using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                    {
                        objDocumentDetailsDTO = objDocumentDetailsSL.GetDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, nDocumentDetailsID);

                        /*For user document, extensions are not stored in the file name, so that are to be explicitly concatenated */
                        if (objDocumentDetailsDTO.MapToTypeCodeId == ConstEnum.Code.UserDocument)
                        {
                            sExtension = objDocumentDetailsDTO.FileType;
                        }
                        directory = Path.Combine(directory, Common.Common.ConvertToString(objDocumentDetailsDTO.MapToTypeCodeId), Common.Common.ConvertToString(objDocumentDetailsDTO.MapToId), objDocumentDetailsDTO.GUID);
                        if (System.IO.File.Exists(directory))
                        {
                            return(File(new FileStream(directory, FileMode.Open), objDocumentDetailsDTO.FileType, objDocumentDetailsDTO.DocumentName + sExtension /*+ objDocumentDetailsDTO.FileType*/));
                        }
                    }
                }
            }
            finally
            {
                objLoginUserDetails   = null;
                objDocumentDetailsDTO = null;
            }

            return(null);
        }
Пример #2
0
        public ActionResult ShowUserConsent(int acid, int DocumentID)
        {
            DocumentDetailsSL   objDocumentDetailsSL   = null;
            EULAAcceptanceModel objEULAAcceptanceModel = new EULAAcceptanceModel();
            LoginUserDetails    objLoginUserDetails    = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);

            DocumentDetailsDTO objDocumentDetailsDTO = new DocumentDetailsDTO();

            try
            {
                objDocumentDetailsSL = new DocumentDetailsSL();

                //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);
                }

                //copy document details DTO into User policy document model
                objEULAAcceptanceModel.DocumentID         = objDocumentDetailsDTO.DocumentId;
                objEULAAcceptanceModel.DocumentName       = objDocumentDetailsDTO.DocumentName;
                objEULAAcceptanceModel.DocumentFileType   = objDocumentDetailsDTO.FileType;
                objEULAAcceptanceModel.DocumentPath       = objDocumentDetailsDTO.DocumentPath;
                objEULAAcceptanceModel.UserInfoID         = objLoginUserDetails.LoggedInUserID;
                objEULAAcceptanceModel.EULAAcceptanceFlag = false;

                ViewBag.UserAction = acid;

                return(View("~/Views/UserDetails/UserConsent.cshtml", objEULAAcceptanceModel));
            }
            catch (Exception ex)
            {
                string sErrMessage = Common.Common.getResource(ex.InnerException.Data[0].ToString());
                ModelState.AddModelError("Error", sErrMessage);
                return(View("~/Views/UserDetails/UserConsent.cshtml"));
            }
            finally
            {
                objDocumentDetailsSL   = null;
                objEULAAcceptanceModel = null;
                objLoginUserDetails    = null;
                objDocumentDetailsDTO  = null;
            }
        }
Пример #3
0
        public JsonResult DeleteDocumentDetails(int acid, int nDocumentDetailsID, string sGUID, int nMapToTypeCodeId = 0, int nMapToId = 0, int nPurposeCodeId = 0)
        {
            bool bReturn         = false;
            bool statusFlag      = false;
            var  ErrorDictionary = new Dictionary <string, string>();

            LoginUserDetails objLoginUserDetails = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);

                using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                {
                    bReturn = objDocumentDetailsSL.DeleteDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, nDocumentDetailsID, objLoginUserDetails.LoggedInUserID, nMapToTypeCodeId, nMapToId, nPurposeCodeId);
                    if (bReturn)
                    {
                        string   directory = ConfigurationManager.AppSettings["Document"];
                        FileInfo file      = new FileInfo(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), sGUID));
                        file.Delete();
                        statusFlag = true;
                        ErrorDictionary.Add("success", "Record deleted");
                    }
                }
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("error", sErrMessage);
            }
            finally
            {
                objLoginUserDetails = null;
            }

            return(Json(new
            {
                status = statusFlag,
                Message = ErrorDictionary
            }, "text/html"));
        }
Пример #4
0
        public void Generate(EULAAcceptanceModel objEULAAcceptanceModel, 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" },
                    { ".html", "text/html" },
                    { ".htm", "text/html" },
                };
                if (nDocumentId != 0)
                {
                    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;
            }
        }
Пример #5
0
        public JsonResult UploadDocument(Dictionary <int, List <DocumentDetailsModel> > dicDocumentDetailsModel, int acid, int buttonName, int index, string divclone)
        {
            var ErrorDictionary = new Dictionary <string, string>();

            String UploadStatusMsg  = "";
            int    UploadStatusCode = -1; //used to set upload status message - this is default return msg code

            LoginUserDetails   objLoginUserDetails   = null;
            DocumentDetailsDTO objDocumentDetailsDTO = null;

            List <DocumentDetailsModel> lstSaveDetailsModel = null;
            List <Object> lstobject = null;

            try
            {
                string        directory     = ConfigurationManager.AppSettings["Document"];
                string        rootDirectory = directory;
                DirectoryInfo di;

                objLoginUserDetails   = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                objDocumentDetailsDTO = new DocumentDetailsDTO();

                lstSaveDetailsModel = new List <DocumentDetailsModel>();
                lstobject           = new List <object>();
                bool   bFlag         = false; //flag used to
                bool   bReturnStatus = true;
                int    nMapToId      = 0;
                string newFileName   = string.Empty;

                //check dictionary which content document uploade details - if it is not empty
                if (dicDocumentDetailsModel.Count != 0 && dicDocumentDetailsModel.ContainsKey(buttonName))
                {
                    List <DocumentDetailsModel> lstDocumentDetailsModel = new List <DocumentDetailsModel>();
                    List <string> lstExtensions = new List <string>();
                    lstExtensions.Add("pdf");
                    lstExtensions.Add("xls");
                    lstExtensions.Add("xlsx");
                    lstExtensions.Add("doc");
                    lstExtensions.Add("docx");
                    lstExtensions.Add("png");
                    lstExtensions.Add("jpg");
                    lstExtensions.Add("jpeg");
                    //lstExtensions.Add("html");
                    //lstExtensions.Add("htm");
                    lstDocumentDetailsModel = dicDocumentDetailsModel[buttonName];

                    //process each document model
                    foreach (DocumentDetailsModel objDocumentDetailsModel in lstDocumentDetailsModel)
                    {
                        //Check file contains more than one dots
                        if (objDocumentDetailsModel.Document != null)
                        {
                            //check if actual file is uploaded by checking model document property
                            string extension = System.IO.Path.GetExtension(objDocumentDetailsModel.Document.FileName).ToLower();

                            if (extension != ".pdf" && acid == InsiderTrading.Common.ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_CONTINUOUS_DISCLOSURE_LETTER_SUBMISSION && objLoginUserDetails.CompanyName.ToUpper().Contains(InsiderTrading.Common.ConstEnum.CLIENT_DB_NAME_IGNORE_DATABASE))
                            {
                                UploadStatusCode = 5;
                            }
                            else if (extension != ".html" && extension != ".htm" && acid == InsiderTrading.Common.ConstEnum.UserActions.COMPANY_VIEW)
                            {
                                UploadStatusCode = 6;
                            }
                            else
                            {
                                if (lstExtensions.Contains(extension.Remove(0, 1)))
                                {
                                    extension   = System.IO.Path.GetExtension(objDocumentDetailsModel.Document.FileName).ToLower();
                                    newFileName = Guid.NewGuid() + extension;

                                    //check if document is uploaded for first time or updating existing document
                                    if (objDocumentDetailsModel.MapToId != 0)
                                    {
                                        //updating existing document record
                                        bFlag    = true;
                                        nMapToId = objDocumentDetailsModel.MapToId;
                                        lstSaveDetailsModel.Add(objDocumentDetailsModel);
                                    }
                                    Common.Common.CopyObjectPropertyByName(objDocumentDetailsModel, objDocumentDetailsDTO);
                                    objDocumentDetailsDTO.DocumentName = objDocumentDetailsModel.Document.FileName;
                                    objDocumentDetailsDTO.GUID         = newFileName;
                                    objDocumentDetailsDTO.DocumentPath = Path.Combine(directory, newFileName);
                                    objDocumentDetailsDTO.FileSize     = objDocumentDetailsModel.Document.ContentLength;
                                    objDocumentDetailsDTO.FileType     = extension;

                                    //get temp folder path
                                    directory = Path.Combine(directory, "temp");

                                    //if temp directory not exists then create temp folder
                                    if (!Directory.Exists(directory))
                                    {
                                        di = Directory.CreateDirectory(directory);
                                    }

                                    //check guid is set or document id set then remove temp folder file
                                    if ((objDocumentDetailsModel.DocumentId != 0 && objDocumentDetailsModel.DocumentId != null) || objDocumentDetailsModel.GUID != null)
                                    {
                                        //get file object and delete file
                                        FileInfo file = new FileInfo(Path.Combine(rootDirectory, "temp", objDocumentDetailsModel.GUID));
                                        file.Delete();
                                        //remove guid stored in session
                                        objLoginUserDetails.DocumentDetails.Remove(objDocumentDetailsModel.GUID);
                                    }
                                    //save file into temp folder with new name as guid
                                    objDocumentDetailsModel.Document.SaveAs(Path.Combine(directory, newFileName));

                                    //add uploaded file info into session variable
                                    objLoginUserDetails.DocumentDetails.Add(newFileName, objDocumentDetailsDTO);

                                    //save file information into user session
                                    Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails);

                                    string IsofficeInstalled = ConfigurationManager.AppSettings["IsOfficeInstalled"];
                                    ///This block is used to check whether office is installed on server
                                    if (IsofficeInstalled == "true")
                                    {
                                        if (extension == ".doc" || extension == ".docx")
                                        {
                                            Microsoft.Office.Interop.Word._Application _appWord = new Microsoft.Office.Interop.Word.Application();
                                            Microsoft.Office.Interop.Word.Document     doc      = null;
                                            string pathToWordFile = Path.Combine(directory, newFileName);
                                            bool   _hasMacroWord  = false;
                                            try
                                            {
                                                doc = _appWord.Documents.Open(pathToWordFile, Type.Missing, true);
                                                Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
                                                wordApplication.DisplayAlerts         = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
                                                wordApplication.ShowVisualBasicEditor = false;
                                                _hasMacroWord = doc.HasVBProject;
                                                if (_hasMacroWord)
                                                {
                                                    UploadStatusCode = 4;
                                                }
                                                else
                                                {
                                                    UploadStatusCode = 0;
                                                }
                                                doc.Close(Type.Missing, Type.Missing, Type.Missing);
                                                // _appWord.Application.Quit(); // optional
                                                _appWord.Quit();
                                                System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_appWord);
                                                _appWord = null;
                                                if (UploadStatusCode == 4)
                                                {
                                                    //get file object and delete file
                                                    FileInfo file = new FileInfo(Path.Combine(rootDirectory, "temp", newFileName));
                                                    file.Delete();
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                // optional: this Log function should be defined somewhere in your code                                     }
                                            }
                                            finally
                                            {
                                                if (_appWord != null)
                                                {
                                                    _appWord.Quit();
                                                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_appWord);
                                                }
                                            }
                                        }
                                        else if (extension == ".xls" || extension == ".xlsx")
                                        {
                                            Microsoft.Office.Interop.Excel._Application _appExcel = new Microsoft.Office.Interop.Excel.Application();
                                            Microsoft.Office.Interop.Excel.Workbook     _workbook = null;
                                            string pathToExcelFile = Path.Combine(directory, newFileName);
                                            bool   _hasMacro       = false;
                                            try
                                            {
                                                _workbook = _appExcel.Workbooks.Open(pathToExcelFile, Type.Missing, true);
                                                _hasMacro = _workbook.HasVBProject;
                                                if (_hasMacro)
                                                {
                                                    UploadStatusCode = 4;
                                                }
                                                else
                                                {
                                                    //lstobject.Add(dic); //set uploaded file into list to return
                                                    UploadStatusCode = 0;
                                                }
                                                _workbook.Close(false, Type.Missing, Type.Missing);
                                                _appExcel.Application.Quit();
                                                _appExcel.Quit();
                                                System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_appExcel);
                                                _appExcel = null;
                                                if (UploadStatusCode == 4)
                                                {
                                                    FileInfo file = new FileInfo(Path.Combine(rootDirectory, "temp", newFileName));
                                                    file.Delete();
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                // optional: this Log function should be defined somewhere in your code
                                            }
                                            finally
                                            {
                                                if (_appExcel != null)
                                                {
                                                    _appExcel.Quit();
                                                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_appExcel);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            UploadStatusCode = 0;     //set return msg code
                                        }
                                    }
                                    else
                                    {
                                        UploadStatusCode = 0;     //set return msg code
                                    }
                                    //block end


                                    if (UploadStatusCode != 4)
                                    {
                                        //set uploaded file information into dictionary to sent back as output
                                        Dictionary <string, string> dic = new Dictionary <string, string>();
                                        dic.Add("GUID", objDocumentDetailsDTO.GUID);
                                        dic.Add("DocumentID", objDocumentDetailsDTO.DocumentId.ToString());
                                        dic.Add("Index", objDocumentDetailsModel.Index.ToString());
                                        dic.Add("SubIndex", objDocumentDetailsModel.SubIndex.ToString());
                                        dic.Add("DocumentName", objDocumentDetailsDTO.DocumentName);
                                        dic.Add("FileType", objDocumentDetailsDTO.FileType);
                                        dic.Add("UserAction", acid.ToString());
                                        lstobject.Add(dic);     //set uploaded file into list to return
                                        UploadStatusCode = 0;   //set return msg code
                                    }
                                }
                                else
                                {
                                    UploadStatusCode = 3;     //set return msg code
                                }
                            }
                        }
                        else
                        {
                            //UploadStatusCode = 2; //set return msg code
                        }
                    }

                    //upload and update existing records
                    if (bFlag == true && UploadStatusCode != 4)
                    {
                        using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                        {
                            List <DocumentDetailsModel> retlistDocumentDetailsModel = new List <DocumentDetailsModel>();

                            FileInfo file = new FileInfo(Path.Combine(rootDirectory, "temp", newFileName));
                            file.Delete();
                            //as uploading file for already existing record which has MaptoId - upload/save record directly
                            retlistDocumentDetailsModel = objDocumentDetailsSL.SaveDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, lstSaveDetailsModel, buttonName, nMapToId, objLoginUserDetails.LoggedInUserID);

                            lstobject.Clear();

                            foreach (DocumentDetailsModel objDocModel in retlistDocumentDetailsModel)
                            {
                                //set uploaded file information into dictionary to sent back as output
                                Dictionary <string, string> dic = new Dictionary <string, string>();
                                dic.Add("GUID", objDocModel.GUID);
                                dic.Add("DocumentID", objDocModel.DocumentId.ToString());
                                dic.Add("Index", objDocModel.Index.ToString());
                                dic.Add("SubIndex", objDocModel.SubIndex.ToString());
                                dic.Add("DocumentName", objDocModel.DocumentName);
                                dic.Add("FileType", objDocModel.FileType);
                                dic.Add("UserAction", acid.ToString());

                                lstobject.Add(dic);   //set uploaded file into list to return

                                UploadStatusCode = 0; //set return msg code
                            }
                        }
                    }

                    lstExtensions = null;
                }
                else
                {
                    UploadStatusCode = 1; //set return msg code
                }

                switch (UploadStatusCode)
                {
                case 0:
                    UploadStatusMsg = "Document uploaded successfully";
                    break;

                case 1:
                    UploadStatusMsg = "Error occured while uploading file. Please try again";
                    bReturnStatus   = false;
                    break;

                case 2:
                    UploadStatusMsg = "File is not attached properly and thus not able to upload file. Please try again";
                    bReturnStatus   = false;
                    break;

                case 3:
                    UploadStatusMsg = "Only following file types can be uploaded: pdf,xls,xlsx,doc,docx,png,jpg,jpeg";
                    bReturnStatus   = false;
                    break;

                case 4:
                    UploadStatusMsg = "Uploaded file contains macros, please remove it and then upload";
                    bReturnStatus   = false;
                    break;

                case 5:
                    UploadStatusMsg = "Only pdf file can be uploaded";
                    bReturnStatus   = false;
                    break;

                case 6:
                    UploadStatusMsg = "Only html file can be uploaded";
                    bReturnStatus   = false;
                    break;

                default:
                    UploadStatusMsg = "Error occured while uploading file. Please try again";
                    bReturnStatus   = false;
                    break;
                }

                ErrorDictionary.Add("Document", UploadStatusMsg);

                return(Json(new
                {
                    status = bReturnStatus,
                    Message = ErrorDictionary,
                    obj = lstobject,
                    divclone = divclone
                }, "text/html"));
            }
            catch (Exception exp)
            {
                return(null);
            }
            finally
            {
                objLoginUserDetails   = null;
                objDocumentDetailsDTO = null;
                lstSaveDetailsModel   = null;
            }
        }
Пример #6
0
        public JsonResult DeleteSingleDocumentDetails(int?nDocumentDetailsID, int nIndex, int nSubIndex, string GUID, int acid, int nMapToTypeCodeId = 0, int nMapToId = 0, int nPurposeCodeId = 0)
        {
            bool             bReturn             = false;
            bool             statusFlag          = false;
            bool             userType            = false;
            var              ErrorDictionary     = new Dictionary <string, string>();
            bool             removeMapToId       = true;
            LoginUserDetails objLoginUserDetails = null;
            Dictionary <string, DocumentDetailsDTO> dicDocumentDetailsDTO = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                //  DocumentDetailsDTO objDocumentDetailsDTO = new DocumentDetailsDTO();
                string directory = ConfigurationManager.AppSettings["Document"];
                if (nDocumentDetailsID != null && nDocumentDetailsID != 0)
                {
                    if (nMapToTypeCodeId == ConstEnum.Code.UserDocument)
                    {
                        userType = true;
                    }
                    if (acid == InsiderTrading.Common.ConstEnum.UserActions.COMPANY_VIEW)
                    {
                        removeMapToId = false;
                    }
                    using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                    {
                        bReturn = objDocumentDetailsSL.DeleteDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(nDocumentDetailsID), objLoginUserDetails.LoggedInUserID, nMapToTypeCodeId, nMapToId, Convert.ToInt32(nPurposeCodeId));
                        if (bReturn)
                        {
                            if (nMapToTypeCodeId != Common.ConstEnum.Code.TradingPolicy)
                            {
                                if (System.IO.File.Exists(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), GUID)))
                                {
                                    FileInfo file = new FileInfo(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), GUID));
                                    file.Delete();
                                }
                            }
                            statusFlag = true;
                            ErrorDictionary.Add("Document", "Record deleted");
                        }
                    }
                }
                else
                {
                    dicDocumentDetailsDTO = objLoginUserDetails.DocumentDetails;
                    if (dicDocumentDetailsDTO != null && dicDocumentDetailsDTO.Count > 0 && dicDocumentDetailsDTO.ContainsKey(GUID))
                    {
                        if (System.IO.File.Exists(Path.Combine(directory, "temp", GUID)))
                        {
                            FileInfo file = new FileInfo(Path.Combine(directory, "temp", GUID));
                            file.Delete();
                        }
                        objLoginUserDetails.DocumentDetails.Remove(GUID);
                        Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails);
                        statusFlag = true;
                        ErrorDictionary.Add("Document", "Record deleted");
                    }
                }
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("Document", sErrMessage);
            }
            finally
            {
                objLoginUserDetails   = null;
                dicDocumentDetailsDTO = null;
            }

            return(Json(new
            {
                status = statusFlag,
                Message = ErrorDictionary,
                Index = nIndex,
                SubIndex = nSubIndex,
                userType = userType,
                removeMapToId = removeMapToId
            }, "text/html"));
        }
Пример #7
0
        public JsonResult SaveDocumentDetails(int nMapToTypeCodeId, int nMapToId, string sDocName, string sDocDescription, int acid, string GUID, int nDocumentDetailsID = 0)
        {
            bool statusFlag      = false;
            var  ErrorDictionary = new Dictionary <string, string>();

            LoginUserDetails            objLoginUserDetails     = null;
            DocumentDetailsDTO          objDocumentDetailsDTO   = null;
            List <DocumentDetailsModel> lstDocumentDetailsModel = null;
            DocumentDetailsModel        objDocumentDetailsModel = null;

            try
            {
                if (GUID == null || GUID == "")
                {
                    string sErrMessage = "Please Upload Document";
                    ErrorDictionary.Add("Document", sErrMessage);
                }
                else
                {
                    objLoginUserDetails   = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                    objDocumentDetailsDTO = new DocumentDetailsDTO();

                    lstDocumentDetailsModel = new List <DocumentDetailsModel>();

                    objDocumentDetailsModel = new DocumentDetailsModel();

                    objDocumentDetailsModel.MapToTypeCodeId = nMapToTypeCodeId;
                    objDocumentDetailsModel.MapToId         = nMapToId;
                    objDocumentDetailsModel.DocumentId      = nDocumentDetailsID;
                    objDocumentDetailsModel.GUID            = GUID;
                    objDocumentDetailsModel.DocumentName    = sDocName;
                    objDocumentDetailsModel.Description     = sDocDescription;
                    lstDocumentDetailsModel.Add(objDocumentDetailsModel);

                    using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                    {
                        lstDocumentDetailsModel = objDocumentDetailsSL.SaveDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, lstDocumentDetailsModel, nMapToTypeCodeId, nMapToId, objLoginUserDetails.LoggedInUserID);

                        if (lstDocumentDetailsModel.Count > 0)
                        {
                            statusFlag = true;
                        }
                    }
                }
                return(Json(new
                {
                    status = statusFlag,
                    Message = ErrorDictionary
                }, "text/html"));
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                objLoginUserDetails     = null;
                objDocumentDetailsDTO   = null;
                lstDocumentDetailsModel = null;
                objDocumentDetailsModel = null;
            }
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
        public ActionResult SaveImportedRecordsProc(int acid, MassUploadModel objMassUploadModel, Dictionary <int, List <DocumentDetailsModel> > dicPolicyDocumentsUploadFileList, int massuploadid)
        {
            LoginUserDetails objLoginUserDetails   = null;
            string           sCurrentCompanyDBName = "";
            string           sConnectionString     = "";
            CompanyDTO       objCompanyToMassUpload;

            Dictionary <string, DocumentDetailsDTO> objDocumentDetailsdDTO = new Dictionary <string, DocumentDetailsDTO>();
            string sFilePath     = "";
            string sFileName     = "";
            string sErrorMessage = "";
            //objDocumentDetailsdDTO.
            string directory = ConfigurationManager.AppSettings["Document"];
            Dictionary <string, List <MassUploadResponseDTO> > objSheetWiseError = new Dictionary <string, List <MassUploadResponseDTO> >();
            Dictionary <string, string> objInvalidSheetColumnError = new Dictionary <string, string>();
            MassUploadDTO objSelectedMassUploadDTO = new MassUploadDTO();

            string sErrorFileGuid           = "";
            bool   bErrorExistInExcelSheets = false;
            bool   bCheckifExcelIsvalid     = false;
            int    nSavedMassUploadLogId    = 0;

            try
            {
                objLoginUserDetails    = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)InsiderTrading.Common.ConstEnum.SessionValue.UserDetails);
                objDocumentDetailsdDTO = objLoginUserDetails.DocumentDetails;
                sCurrentCompanyDBName  = objLoginUserDetails.CompanyName;
                sConnectionString      = objLoginUserDetails.CompanyDBConnectionString;

                using (var objCompaniesSL = new CompaniesSL())
                {
                    objCompanyToMassUpload = objCompaniesSL.getSingleCompanies(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName);
                }
                sConnectionString = objCompanyToMassUpload.CompanyConnectionStringWithTimeout(5000);
                ViewBag.acid      = acid;
                if (dicPolicyDocumentsUploadFileList.ContainsKey(InsiderTrading.Common.ConstEnum.Code.MassUpload) && dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload].Count > 0)
                {
                    if (dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload].Count > 0)
                    {
                        using (var objMassUploadSL = new MassUploadSL())
                        {
                            objSelectedMassUploadDTO = objMassUploadSL.GetSingleMassUploadDetails(sConnectionString, massuploadid);
                        }
                        string sUploadedFileOriginalName = dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload][0].DocumentName;
                        sUploadedFileOriginalName = sUploadedFileOriginalName.Substring(0, sUploadedFileOriginalName.IndexOf("."));
                        if (objSelectedMassUploadDTO.TemplateFileName != sUploadedFileOriginalName)
                        {
                            sErrorMessage            = "The selected file name does not match with the Template to be used for \"" + objSelectedMassUploadDTO.MassUploadName + "\". Please select correct file and try again.";
                            TempData["ErrorMessage"] = sErrorMessage;
                            TempData["IsError"]      = "1";
                            return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid }));
                        }

                        sFileName = dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload][0].GUID;
                    }
                    sFilePath = directory + "temp/" + sFileName;
                }

                if (sFileName == null || sFileName == "" || sFilePath == "")
                {
                    sErrorMessage            = "File not selected.";
                    TempData["ErrorMessage"] = sErrorMessage;
                    TempData["IsError"]      = "1";
                    return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid }));
                }
                using (var objParameterisedMassUploadSL = new MassUploadSL(massuploadid, sConnectionString, sCurrentCompanyDBName))
                {
                    //objMassUploadSL = new InsiderTradingMassUpload.MassUploadSL(massuploadid, sConnectionString, sCurrentCompanyDBName);
                    //Add entry in the Log table and generate the MapToId (i.e. the log table id) for the document to be saved.
                    objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, 0, massuploadid, InsiderTrading.Common.ConstEnum.Code.MassUploadStarted, null, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                    //Save the document and add entry in the Document table
                    List <DocumentDetailsModel> objSavedDocumentDetialsModelList = new List <DocumentDetailsModel>();
                    using (var objDocumentDetailsSL = new DocumentDetailsSL())
                    {
                        objSavedDocumentDetialsModelList = objDocumentDetailsSL.SaveDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload], Convert.ToInt32(InsiderTrading.Common.ConstEnum.Code.MassUpload), nSavedMassUploadLogId, objLoginUserDetails.LoggedInUserID);
                    }

                    objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, InsiderTrading.Common.ConstEnum.Code.MassUploadStarted, objSavedDocumentDetialsModelList[0].DocumentId, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                    objParameterisedMassUploadSL.SetUploadedfileGUID(objSavedDocumentDetialsModelList[0].GUID);
                    sFilePath = objSavedDocumentDetialsModelList[0].DocumentPath;
                    objParameterisedMassUploadSL.SetExcelFilePath(sFilePath);
                    objParameterisedMassUploadSL.SetEncryptionSaltValue(Common.ConstEnum.User_Password_Encryption_Key);

                    objParameterisedMassUploadSL.ExecuteMassUploadCall();

                    bCheckifExcelIsvalid = objParameterisedMassUploadSL.IsExcelValid();

                    if (!bCheckifExcelIsvalid)
                    {
                        //Check if there are errors in the excel sheet before processing it for mass upload insert.
                        //If all the data from the excel is valid then only let user impoert the excel file.
                        bErrorExistInExcelSheets = objParameterisedMassUploadSL.CheckIfErrorExistInExcelSheets();
                        Dictionary <string, List <MassUploadExcelSheetErrors> > objAllSheetColumnWiseErrorList = objParameterisedMassUploadSL.GetExcelSheetWiseErrors();

                        if (bErrorExistInExcelSheets)
                        {
                            TempData["AllSheetErrors"]        = objAllSheetColumnWiseErrorList;
                            TempData["AllSheetErrorsPresent"] = bErrorExistInExcelSheets;
                            sErrorFileGuid = objParameterisedMassUploadSL.WriteErrorsToExcel(ConfigurationManager.AppSettings["ExportDocument"], ConfigurationManager.AppSettings["Document"]);
                            //Update the error log file name in log table
                            objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, sErrorFileGuid + ".xlsx", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                            TempData["ErrorFileGuid"]  = sErrorFileGuid;
                            TempData["SuccessMessage"] = "Successfully Imported the Excel";
                        }
                    }
                    else
                    {
                        sErrorMessage = "Uploaded excel is not valid. Please use the provided template for corresponding mass upload and try again.";
                        objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, "", sErrorMessage, objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                    }
                }
            }
            catch (Exception exp)
            {
                sErrorMessage = exp.Message;
                if (exp.Source == "Microsoft JET Database Engine")
                {
                    sErrorMessage = "Uploaded excel is not valid. Please use the provided template for corresponding mass upload and try again.";
                }
                using (var objMassUploadSL = new MassUploadSL())
                {
                    objMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, "", sErrorMessage, objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                }
            }
            finally
            {
                //objLoginUserDetails = null;
                objCompanyToMassUpload     = null;;
                objDocumentDetailsdDTO     = null;
                objSheetWiseError          = null;
                objInvalidSheetColumnError = null;
                objSelectedMassUploadDTO   = null;
            }
            //TempData is equivalent to ViewBag, but TempData is used when sending the data during redirection
            if ((sErrorMessage != null && sErrorMessage != "") || bErrorExistInExcelSheets)
            {
                TempData["ErrorMessage"] = sErrorMessage;
                TempData["IsError"]      = "1";
            }
            else
            {
                TempData["SuccessMessage"] = "Successfully Imported the Excel";
                TempData["IsError"]        = "0";
                using (var objMassUploadSL = new MassUploadSL())
                {
                    objMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadCompleted, null, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId);
                }
            }
            objMassUploadModel.MassUploadFile = Common.Common.GenerateDocumentList(Common.ConstEnum.Code.MassUpload, 0, 0, null, 0);
            return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid }));
        }
Пример #10
0
        public ActionResult Save(InsiderTrading.Models.NSEGroupDocumentMappingModel objNSEGroupDocumentModel, Dictionary <int, List <DocumentDetailsModel> > dicPolicyDocumentsUploadFileList, int GroupId)
        {
            ModelState.Remove("KEY");
            ModelState.Add("KEY", new ModelState());
            ModelState.Clear();
            var StockExchangeDateSubmission = Request.Form["SubmissionFromDate"];
            LoginUserDetails            objLoginUserDetails  = null;
            DocumentDetailsSL           objDocumentDetailsSL = new DocumentDetailsSL();
            List <DocumentDetailsModel> UploadFileDocumentDetailsModelList = null;
            NSEGroupDocumentMappingDTO  objNSEGroupDocDTO     = new NSEGroupDocumentMappingDTO();
            NSEGroupDetailsDTO          objNSEGroupDetailsDTO = new NSEGroupDetailsDTO();
            NSEGroupDTO objNSEGroupDTO = new NSEGroupDTO();

            objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
            DateTime?date = null;

            using (NSEGroupSL ObjNSEGroupSL = new NSEGroupSL())
            {
                List <NSEGroupDTO> lstDate = ObjNSEGroupSL.Get_Group_Date(objLoginUserDetails.CompanyDBConnectionString, GroupId);
                foreach (var submitdate in lstDate)
                {
                    date = submitdate.DownloadedDate;
                }
            }
            if (StockExchangeDateSubmission == "")
            {
                ModelState.AddModelError("DateOfSubmissionToNSE", Common.Common.getResource("nse_lbl_50535"));
            }
            else
            {
                objNSEGroupDTO.SubmissionDate = Convert.ToDateTime(StockExchangeDateSubmission);
                if (objNSEGroupDTO.SubmissionDate > Common.Common.GetCurrentDate(objLoginUserDetails.CompanyDBConnectionString))
                {
                    ModelState.AddModelError("DateOfSubmissionToNSE", Common.Common.getResource("nse_lbl_50534"));
                }
                if (Convert.ToDateTime(date).Date > objNSEGroupDTO.SubmissionDate)
                {
                    ModelState.AddModelError("DateOfSubmissionToNSE", Common.Common.getResource("nse_lbl_50536"));
                }
            }
            if (ModelState.IsValid)
            {
                if (dicPolicyDocumentsUploadFileList.Count > 0) // file is uploaded and data found for file upload
                {
                    UploadFileDocumentDetailsModelList = dicPolicyDocumentsUploadFileList[ConstEnum.Code.UploadNseDocument];
                }
                List <DocumentDetailsModel> objSavedDocumentDetialsModelList = objDocumentDetailsSL.SaveDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, UploadFileDocumentDetailsModelList, ConstEnum.Code.UploadNseDocument, GroupId, objLoginUserDetails.LoggedInUserID, objLoginUserDetails.CompanyName);
                DocumentDetailsDTO          objDocumentDetailsDTO            = null;
                objDocumentDetailsDTO = new DocumentDetailsDTO();
                using (NSEGroupSL objNSEGroupSL = new NSEGroupSL())
                {
                    if (UploadFileDocumentDetailsModelList != null)
                    {
                        foreach (var fleGUID in UploadFileDocumentDetailsModelList)
                        {
                            objNSEGroupDetailsDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID;
                            objNSEGroupDetailsDTO.GroupId        = GroupId;
                            List <NSEGroupDetailsDTO> GrouplistDetails = objNSEGroupSL.Save_NSEGroup_Details(objLoginUserDetails.CompanyDBConnectionString, objNSEGroupDetailsDTO);
                            foreach (var nseuserId in GrouplistDetails)
                            {
                                objNSEGroupDocDTO.NSEGroupDetailsId = nseuserId.NSEGroupDetailsId;
                                objNSEGroupDetailsDTO.GroupId       = Convert.ToInt32(GroupId);
                                bool bReturnDoc = objNSEGroupSL.Save_New_NSEDocument(objLoginUserDetails.CompanyDBConnectionString, objNSEGroupDocDTO, fleGUID.GUID);
                            }
                        }
                    }
                    objNSEGroupDTO.GroupId        = GroupId;
                    objNSEGroupDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID;
                    objNSEGroupDTO.StatusCodeId   = 508007;
                    bool bReturn = objNSEGroupSL.Update_NSEGroup(objLoginUserDetails.CompanyDBConnectionString, objNSEGroupDTO);
                }
                TradingTransactionMasterDTO objTradingTransactionMasterDTO = null;
                using (TradingTransactionSL objTradingTransactionSL = new TradingTransactionSL())
                {
                    using (NSEGroupSL objNSEGroupSL = new NSEGroupSL())
                    {
                        List <NSEGroupDetailsDTO> grpTransIdList = objNSEGroupSL.Get_Group_TransactionId(objLoginUserDetails.CompanyDBConnectionString, GroupId);
                        foreach (var TransId in grpTransIdList)
                        {
                            objTradingTransactionMasterDTO = new TradingTransactionMasterDTO();
                            objTradingTransactionMasterDTO.TransactionMasterId        = TransId.transId;
                            objTradingTransactionMasterDTO.TransactionStatusCodeId    = ConstEnum.Code.DisclosureStatusForHardCopySubmittedByCO;
                            objTradingTransactionMasterDTO.HardCopyByCOSubmissionDate = Convert.ToDateTime(StockExchangeDateSubmission);
                            objTradingTransactionMasterDTO = objTradingTransactionSL.GetTradingTransactionMasterCreate(objLoginUserDetails.CompanyDBConnectionString, objTradingTransactionMasterDTO, objLoginUserDetails.LoggedInUserID, out nDisclosureCompletedFlag);
                        }
                    }
                }
                return(RedirectToAction("Index", "NSEDownload", new { acid = ConstEnum.UserActions.NSEDownload }));
            }
            else
            {
                ViewBag.groupId      = GroupId;
                ViewBag.DownloadDate = date;
                ViewBag.UserAction   = Common.ConstEnum.UserActions.NSEDownload;
                objNSEGroupDocumentModel.NSEGroupDocumentFile = Common.Common.GenerateDocumentList(ConstEnum.Code.UploadNseDocument, 0, 0, null, 0, false, 0, ConstEnum.FileUploadControlCount.NSEUploadFile);
                return(View("NSEUploadDoc", objNSEGroupDocumentModel));
            }
        }