Пример #1
0
        public int DownloadSigntureDocumentFromServer(DocumentModel doc, int userId)
        {
            this.UpdateLeadStatus(userId, "Contract Received", -userId);
            var canDownload = DownloadSigntureWS(doc.ID, userId, doc.docNoOfSign.Value);

            if (!canDownload)
            {
                return -1;
            }
            return 0;
        }
Пример #2
0
        public ActionResult UploadDocument(DocumentViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                Session["debt_document_isn"] = -1;

                return RedirectToAction("Index");
            }

            var UserIP = string.Empty;
            UserIP = Request.ServerVariables["REMOTE_ADDR"];
            var document = new DocumentModel();

            document.Public = true;
            document.SignatureStatus = 0;
            document.MemberISN = this.MemberISN;
            document.DocName = viewModel.DocName;
            document.Desc = viewModel.Notes;
            document.SendIP = UserIP;
            document.UpdatedBy = -this.MemberISN;
            if (viewModel.SelectedCreditorID != null)
            {
                document.CreditorISN = viewModel.SelectedCreditorID.Value;
                document.CreditorName = viewModel.GetCreditorName(viewModel.SelectedCreditorID.Value, this.MemberISN);
            }

            var addedDate = DateTime.Now;

            var fullPath = string.Empty;

            //
            // get file uploaded
            if (viewModel.UploadedFile != null && viewModel.UploadedFile.ContentLength > 0)
            {
                document.FileName = viewModel.UploadedFile.FileName;
                document.FileSize = viewModel.UploadedFile.ContentLength;
            }

            var documentISN = _docBusiness.UploadDocument(document);

            //
            // save file if add document success
            #region save document isn to session
            Session["debt_document_isn"] = documentISN;

            if (documentISN > 0 && !string.IsNullOrEmpty(document.FileName))
            {

                var pathConfig = ConfigurationManager.AppSettings["UploadFolder"];
                if (string.IsNullOrEmpty(pathConfig))
                {
                    // pathConfig = "C:\\";                   
                    pathConfig = Environment.GetLogicalDrives()[0]; // expect C:\\
                }

                //
                // check path is exist
                // if not exist, create new folder

                // document template
                // yyyyMM\\Documents\\dd\\123
                var docPath = _docBusiness.GetDocumentPath(documentISN, addedDate);
                fullPath = Path.Combine(pathConfig, docPath);

                if (!Directory.Exists(fullPath))
                {
                    try
                    {
                        Directory.CreateDirectory(fullPath);

                        fullPath = Path.Combine(fullPath.TrimEnd('/', '\\'), document.FileName);

                        //
                        // save file if create folder success
                        try
                        {
                            viewModel.UploadedFile.SaveAs(fullPath);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(ex, "Cannot save image to {0}", fullPath);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex, "Cannot create directory");
                    }
                }
            }
            #endregion

            return RedirectToAction("Index");
        }
Пример #3
0
        public ActionResult Edit(DocumentViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                Session["debt_document_isn"] = -1;

                return RedirectToAction("Index");
            }

            var document = new DocumentModel();

            document.Public = true;
            document.ID = viewModel.DocumentISN;
            document.MemberISN = this.MemberISN;
            document.Desc = viewModel.Notes;

            document.DocName = viewModel.DocName;

            if (viewModel.SelectedCreditorID != null)
            {
                document.CreditorISN = viewModel.SelectedCreditorID.Value;
                document.CreditorName = viewModel.GetCreditorName(viewModel.SelectedCreditorID.Value, this.MemberISN);
            }

            document.AddedDate = viewModel.AddedDate;

            //
            // TODO
            // save file
            var fullPath = string.Empty;
            var canSave = false;

            //
            // save file
            #region save file
            if (viewModel.UploadedFile != null && viewModel.UploadedFile.ContentLength > 0)
            {
                document.FileName = viewModel.UploadedFile.FileName;
                document.FileSize = viewModel.UploadedFile.ContentLength;

                var pathConfig = ConfigurationManager.AppSettings["UploadFolder"];
                if (string.IsNullOrEmpty(pathConfig))
                {
                    pathConfig = Environment.GetLogicalDrives()[0]; // expect C:\\
                }

                //
                // check path is exist
                // if not exist, create new folder

                // var path = Server.MapPath("~/" + pathConfig);
                // var docPath = _docBusiness.GetDocumentPath(viewModel.DocumentISN, document.AddedDate);
                var docPath = _premierBusiness.GetDocumentPath(viewModel.DocumentISN, document.AddedDate);
                fullPath = Path.Combine(pathConfig, docPath);

                if (!Directory.Exists(fullPath))
                {
                    try
                    {
                        Directory.CreateDirectory(fullPath);
                        canSave = true;
                    }
                    catch (Exception ex)
                    {
                        canSave = false;
                        _logger.Error(ex.Message, "Cannot create directory {0}.", fullPath);
                    }
                }

                fullPath = Path.Combine(fullPath.TrimEnd('/', '\\'), document.FileName);
                canSave = true;
            }
            #endregion

            var success = _premierBusiness.EditDocument(document);

            Session["debt_document_edit"] = true;

            if (success > 0)
            {
                Session["debt_document_isn"] = document.ID;
                if (canSave)
                {
                    try
                    {
                        viewModel.UploadedFile.SaveAs(fullPath);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex, "Cannot save file");
                    }
                }
            }
            else
            {
                Session["debt_document_isn"] = -1;
            }

            return RedirectToAction("Index");
        }
Пример #4
0
 public int EditDocument(DocumentModel doc)
 {
     string sqlQuery = "update Document set MemberISN=@memberISN, docName=@name, docDesc=@desc, CreditorISN=@creditorISN , docFileName=@fileName, docSize=@fileSize where DocumentISN=@ISN";
     if (string.IsNullOrWhiteSpace(doc.FileName))
     {
         sqlQuery = "update Document set MemberISN=@memberISN, docName=@name, docDesc=@desc, CreditorISN=@creditorISN , docSize=@fileSize where DocumentISN=@ISN";
     }
     var query = _db.Sql(sqlQuery);
     query.WithParameters(new
     {
         fileName = doc.FileName,
         fileSize = doc.FileSize > 0 ? doc.FileSize : 0,
         memberISN = doc.MemberISN,
         name = doc.DocName,
         desc = doc.Desc,
         creditorISN = doc.CreditorISN,
         ISN = doc.ID
     });
     return query.AsNonQuery();
 }
Пример #5
0
 public int UpdateDocSignature(DocumentModel doc, string appendNotes = "")
 {
     var sproc = _db.StoredProcedure("xp_debtext_document_signature_upd").WithParameters(
         new
         {
             DocumentISN = doc.ID,
             docFileName = doc.FileName,
             docSignatureIP = doc.SignatureIP,
             docGUID = doc.DocGUID,
             AppendNotes = appendNotes,
             updatedBy = doc.MemberISN
         }
         );
     int result = sproc.AsScalar<int>();
     return result;
 }
Пример #6
0
 public int EditSignatureDocument(DocumentModel doc)
 {
     var query = _db.Sql("update Vw_DebtExt_Document set docFileName=@Filename, docSignatureIP=@SendIP where DocumentISN=@DocId").
         WithParameters(new
         {
             Filename = doc.FileName,
             DocId = doc.ID,
             SendId = doc.SendIP
         });
     return query.AsScalar<int>();
 }