Beispiel #1
0
        protected void mergeLetter(int templateID)
        {
            string finalDocumentPath            = null;
            string clientFileName               = null;
            int    claimID                      = 0;
            ClientLetterTemplate letterTemplate = null;

            clientID = Core.SessionHelper.getClientId();

            claimID = Core.SessionHelper.getClaimID();

            try {
                letterTemplate = LetterTemplateManager.Get(templateID);

                finalDocumentPath = Core.MergeDocumentHelper.mergeLetterTemplate(clientID, letterTemplate, claimID);

                Core.MergeDocumentHelper.addLetterToDocumentList(claimID, finalDocumentPath, letterTemplate.Description);

                clientFileName = Core.SessionHelper.getClaimantName() + ".doc";
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);
            }

            if (!string.IsNullOrEmpty(finalDocumentPath) && !string.IsNullOrEmpty(clientFileName))
            {
                Core.ReportHelper.renderToBrowser(finalDocumentPath, clientFileName);

                Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
            }
        }
Beispiel #2
0
        //protected void addLetterToDocumentList(int claimID, string documentPath, string documentDescription) {
        //	string directoryPath = null;

        //	ClaimDocument claimDocument = new ClaimDocument();
        //	string destinationPath = null;

        //	if (!File.Exists(documentPath))
        //		return;

        //	string ext = System.IO.Path.GetExtension(documentPath);

        //	claimDocument.ClaimID = claimID;
        //	claimDocument.Description = documentDescription;
        //	claimDocument.DocumentName = Utilities.ReportHelper.sanatizeFileName(documentDescription) + ext;

        //	claimDocument.DocumentDate = DateTime.Now;

        //	claimDocument = ClaimDocumentManager.Save(claimDocument);

        //	if (claimDocument.ClaimDocumentID > 0) {
        //		directoryPath = string.Format("{0}/ClaimDocuments/{1}/{2}", appPath, claimID, claimDocument.ClaimDocumentID);

        //		if (!Directory.Exists(directoryPath))
        //			Directory.CreateDirectory(directoryPath);

        //		destinationPath = directoryPath + "/" + claimDocument.DocumentName;

        //		File.Copy(documentPath, destinationPath);
        //	}
        //}


        protected void gvLetter_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    templateID                   = 0;
            string finalDocumentPath            = null;
            string clientFileName               = null;
            ClientLetterTemplate letterTemplate = null;

            if (e.CommandName == "DoPrint")
            {
                templateID = Convert.ToInt32(e.CommandArgument);

                try {
                    letterTemplate = LetterTemplateManager.Get(templateID);

                    finalDocumentPath = Core.MergeDocumentHelper.mergeLetterTemplate(clientID, letterTemplate, this.claimID);

                    Core.MergeDocumentHelper.addLetterToDocumentList(this.claimID, finalDocumentPath, letterTemplate.Description);

                    clientFileName = SessionHelper.getClaimantName() + ".doc";
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }

                if (!string.IsNullOrEmpty(finalDocumentPath) && !string.IsNullOrEmpty(clientFileName))
                {
                    Core.ReportHelper.renderToBrowser(finalDocumentPath, clientFileName);
                }
            }
        }
        protected void gvLetterTemplate_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    clientID               = SessionHelper.getClientId();
            string clientTemplatePath     = null;
            string filePath               = null;
            int    templateID             = 0;
            ClientLetterTemplate template = null;

            string appPath = ConfigurationManager.AppSettings["appPath"].ToString();

            if (e.CommandName == "DoEdit")
            {
                pnlUpload.Visible = true;
                pnlGrid.Visible   = false;

                templateID = Convert.ToInt32(e.CommandArgument);
                template   = LetterTemplateManager.Get(templateID);

                if (template != null)
                {
                    hfID.Value = e.CommandArgument.ToString();

                    txtDescription.Text = template.Description;

                    lblFilename.Text = template.Path;
                }
            }
            else if (e.CommandName == "DoDelete")
            {
                templateID = Convert.ToInt32(e.CommandArgument);

                try {
                    template = LetterTemplateManager.Get(templateID);

                    LetterTemplateManager.Delete(templateID);

                    if (clientID > 0 && template != null)
                    {
                        clientTemplatePath = appPath + "/ClientLetterTemplates/" + clientID.ToString();

                        filePath = clientTemplatePath + "/" + templateID + "." + Path.GetExtension(template.Path);

                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }

            // refresh grdiview
            loadData();
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            int clientID = SessionHelper.getClientId();
            ClientLetterTemplate template = null;
            int templateID        = 0;
            int hidden_templateID = 0;

            Page.Validate("newTemplate");
            if (!Page.IsValid)
            {
                return;
            }

            // no client available
            if (clientID == 0)
            {
                return;
            }

            // this is non zero when in edit mode
            hidden_templateID = Convert.ToInt32(hfID.Value);

            if (fileUpload.HasFile && hidden_templateID == 0)
            {
                // new template being uploaded
                template             = new ClientLetterTemplate();
                template.ClientID    = clientID;
                template.Description = txtDescription.Text.Trim();
                template.Path        = fileUpload.FileName;

                // save template
                templateID = LetterTemplateManager.Save(template);

                if (templateID > 0)
                {
                    // upload letter template
                    uploadTemplate(clientID, templateID);
                }
            }
            else if (!fileUpload.HasFile && hidden_templateID > 0)
            {
                // update template description only, no upload file specified
                template = LetterTemplateManager.Get(hidden_templateID);
                if (template != null)
                {
                    template.Description = txtDescription.Text.Trim();
                    LetterTemplateManager.Save(template);
                }
            }
            else if (fileUpload.HasFile && hidden_templateID > 0)
            {
                // update template description and upload file
                template = LetterTemplateManager.Get(hidden_templateID);
                if (template != null)
                {
                    template.Description = txtDescription.Text.Trim();
                    template.Path        = fileUpload.FileName;
                    templateID           = LetterTemplateManager.Save(template);

                    // upload letter template
                    if (templateID > 0)
                    {
                        uploadTemplate(clientID, templateID);
                    }
                }
            }

            pnlGrid.Visible   = true;
            pnlUpload.Visible = false;

            hfID.Value = "0";

            // refresh grdiview
            loadData();
        }