Esempio n. 1
0
        public ActionResult DownloadFormBOS(int acid, int MapToTypeCodeId = 0, int nTransactionMasterId = 0, string DisplayCode = "")
        {
            LoginUserDetails           objLoginUserDetails           = null;
            InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL();
            FormBDetails_OSDTO         objFormBDetails_OSDTO         = null;

            try
            {
                objLoginUserDetails   = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails);
                objFormBDetails_OSDTO = objInsiderInitialDisclosureSL.GetFormBDetails_OS(objLoginUserDetails.CompanyDBConnectionString, Common.ConstEnum.Code.DisclosureTransactionforOS, Convert.ToInt32(nTransactionMasterId));


                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.AppendHeader("content-disposition", "attachment;filename=" + DisplayCode + ".pdf");
                Response.Flush();
                Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
                Response.Buffer = true;

                // objFormEDetailsDTO = new FormEDetailsDTO();
                //  objFormEDetailsDTO.GeneratedFormContents = "<html><body>1.1.1	Description: Admin shall have the facility to set the configuration of trade details submission for insiders/employees in initial and period end disclosures.</body></html>";
                string LetterHTMLContent = objFormBDetails_OSDTO.GeneratedFormContents;
                System.Text.RegularExpressions.Regex rReplaceScript = new System.Text.RegularExpressions.Regex(@"<br>");
                LetterHTMLContent = rReplaceScript.Replace(LetterHTMLContent, "<br />");


                using (var ms = new MemoryStream())
                {
                    using (var doc = new Document(PageSize.A4, 30f, 30f, 30f, 30f))
                    {
                        using (var writer = PdfWriter.GetInstance(doc, Response.OutputStream))
                        {
                            doc.Open();
                            doc.NewPage();

                            using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(LetterHTMLContent)))
                            {
                                using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(LetterHTMLContent)))
                                {
                                    iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss);
                                }
                            }

                            doc.Close();
                        }

                        Response.Write(doc);
                        Response.End();
                    }
                }
                return(null);
            }
            catch (Exception exp)
            {
                ModelState.AddModelError("Warning", Common.Common.GetErrorMessage(exp));
                return(View("OtherSecuritiesIndex"));
            }
        }
Esempio n. 2
0
        public FormBDetails_OSDTO GetFormBOSDetails(string i_sConnectionString, int i_nMapToTypeCodeId, int i_nMapToId)
        {
            FormBDetails_OSDTO res = null;

            string sErrCode = string.Empty;

            #region Paramters
            int               out_nReturnValue;
            int               out_nSQLErrCode;
            string            out_sSQLErrMessage;
            PetaPoco.Database db = null;
            #endregion Paramters
            try
            {
                var nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
                nReturnValue.Direction = System.Data.ParameterDirection.Output;
                //  nReturnValue.Value = 0;
                var nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
                nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
                nSQLErrCode.Value     = 0;
                var sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.VarChar);
                sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
                sSQLErrMessage.Value     = "";
                sSQLErrMessage.Size      = 500;
                //  db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient");

                using (db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        res = db.Query <FormBDetails_OSDTO>("exec st_tra_GetGeneratedFormBDetails_OS @inp_iMapToTypeCodeId,@inp_iMapToId,@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                            new
                        {
                            @inp_iMapToTypeCodeId = i_nMapToTypeCodeId,
                            @inp_iMapToId         = i_nMapToId,
                            out_nReturnValue      = nReturnValue,
                            out_nSQLErrCode       = nSQLErrCode,
                            out_sSQLErrMessage    = sSQLErrMessage
                        }).FirstOrDefault <FormBDetails_OSDTO>();

                        if (Convert.ToInt32(nReturnValue.Value) != 0)
                        {
                            Exception e = new Exception();
                            out_nReturnValue = Convert.ToInt32(nReturnValue.Value);
                            string sReturnValue = sLookUpPrefix + out_nReturnValue;
                            e.Data[0] = sReturnValue;
                            if (nSQLErrCode.Value != System.DBNull.Value)
                            {
                                out_nSQLErrCode = Convert.ToInt32(nSQLErrCode.Value);
                                e.Data[1]       = out_nSQLErrCode;
                            }
                            if (sSQLErrMessage.Value != System.DBNull.Value)
                            {
                                out_sSQLErrMessage = Convert.ToString(sSQLErrMessage.Value);
                                e.Data[2]          = out_sSQLErrMessage;
                            }

                            Exception ex = new Exception(db.LastSQL.ToString(), e);
                            throw ex;
                        }
                        else
                        {
                            scope.Complete();
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return(res);
        }