예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DocumentId,Time,Operation")] DocumentLog documentLog)
        {
            if (id != documentLog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(documentLog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DocumentLogExists(documentLog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DocumentId"] = new SelectList(_context.Document, "Id", "Id", documentLog.DocumentId);
            return(View(documentLog));
        }
        public async Task <IActionResult> Create([Bind("Id,DocumentName,File")] Document document)
        {
            if (ModelState.IsValid)
            {
                UploadDocument(document);

                document.Modified = DateTime.Now;

                var publisher = (from pub in _context.Publisher
                                 where User.Identity.Name.Equals(pub.Email)
                                 select pub).FirstOrDefault();

                document.PublisherId = publisher.Id;


                _context.Add(document);


                await _context.SaveChangesAsync();

                DocumentLog log = new DocumentLog();
                log.DocumentId = document.Id;
                log.Operation  = Operation.CREATED;
                log.Time       = DateTime.Now;
                _context.Add(log);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PublisherId"] = new SelectList(_context.Set <Publisher>(), "Id", "Id", document.PublisherId);
            return(View(document));
        }
예제 #3
0
 public int CreateOrUpdateDocumentLog(DocumentLog data)
 {
     using (var db = new LogistoDb())
     {
         // TODO:
         var id = Convert.ToInt32(db.InsertWithIdentity(data));
         return(id);
     }
 }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,DocumentId,Time,Operation")] DocumentLog documentLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(documentLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DocumentId"] = new SelectList(_context.Document, "Id", "Id", documentLog.DocumentId);
            return(View(documentLog));
        }
예제 #5
0
 private void OpenEfolderDocument()
 {
     try
     {
         eFolderDialog e           = new eFolderDialog(Session.DefaultInstance.LoanDataMgr, Session.DefaultInstance);
         GridView      gvDocuments = (GridView)e.Controls.Find("gvDocuments", true)[0]; if (gvDocuments != null)
         {
             DocumentLog document = (DocumentLog)gvDocuments.Items.FirstOrDefault(x => ((DocumentLog)x.Tag).Title.Equals(DocumentName)).Tag;
             DocumentDetailsDialog.ShowInstance(Session.DefaultInstance.LoanDataMgr, document);
         }
     }
     catch (Exception ex)
     {
         Logger.HandleError(ex, nameof(OpenEfolderDocument), (object)null);
     }
 }
예제 #6
0
 private void SelectDocument(string DocumentName)
 {
     try
     {
         GridView gvDocuments = (GridView)FormWrapper.OpenForms.FirstOrDefault(x => x.Name.Equals("eFolderDialog")).Controls.Find("gvDocuments", true)[0];
         if (gvDocuments != null)
         {
             DocumentLog document = (DocumentLog)gvDocuments.Items.FirstOrDefault(x => ((DocumentLog)x.Tag).Title.Equals(DocumentName)).Tag;
             DocumentDetailsDialog.ShowInstance(EncompassHelper.LoanDataManager, document);
         }
     }
     catch (Exception ex)
     {
         Logger.HandleError(ex, nameof(OpeneFolderDocument));
     }
 }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var document = await _context.Document.FindAsync(id);

            _context.Document.Remove(document);

            DocumentLog log = new DocumentLog();

            log.DocumentId = document.Id;
            log.Operation  = Operation.DELETED;
            log.Time       = DateTime.Now;
            _context.Add(log);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #8
0
        public List <DocumentLog> GetOwnershipHistory(Guid documentID, string documentTypeCode)
        {
            List <DocumentLog> ownershipHistoryList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetDocumentOwnershipHistory]";
                        cmd.Parameters.Add("@DocumentID", SqlDbType.UniqueIdentifier).Value  = documentID;
                        cmd.Parameters.Add("@DocumentTypeCode", SqlDbType.NVarChar, 5).Value = documentTypeCode;
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                ownershipHistoryList = new List <DocumentLog>();
                                while (sdr.Read())
                                {
                                    DocumentLog ownershipHistory = new DocumentLog();
                                    {
                                        ownershipHistory.Date          = (sdr["Date"].ToString() != "" ? DateTime.Parse(sdr["Date"].ToString()) : ownershipHistory.Date);
                                        ownershipHistory.DateFormatted = (sdr["Date"].ToString() != "" ? DateTime.Parse(sdr["Date"].ToString()).ToString(_settings.DateFormat) : ownershipHistory.DateFormatted);
                                        ownershipHistory.Type          = (sdr["Type"].ToString() != "" ? sdr["Type"].ToString() : ownershipHistory.Type);
                                        ownershipHistory.Remarks       = (sdr["Remarks"].ToString() != "" ? sdr["Remarks"].ToString() : ownershipHistory.Remarks == null?"-":ownershipHistory.Remarks);
                                    }
                                    ownershipHistoryList.Add(ownershipHistory);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(ownershipHistoryList);
        }
        public void CheckDocumentProcessedSuccessfully()
        {
            //Для документов с DocumentSendLogs.Id > 15374942 все должно работать по новому,

            var log = new DocumentLog();

            log.DeliveredId       = 15374943;
            log.FileDelivered     = null;
            log.DocumentDelivered = null;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(false));

            log.FileDelivered     = false;
            log.DocumentDelivered = null;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(false));

            log.FileDelivered     = false;
            log.DocumentDelivered = false;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(false));

            log.FileDelivered     = true;
            log.DocumentDelivered = false;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(true));

            log.FileDelivered     = false;
            log.DocumentDelivered = true;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(true));


            //для старых документов - они всегда должно помечатся как ProcessedSuccessfully и отдавать RequestTime сразу

            log.DeliveredId       = 1;
            log.FileDelivered     = null;
            log.DocumentDelivered = null;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(true));

            log.FileDelivered     = false;
            log.DocumentDelivered = false;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(true));

            log.FileDelivered     = false;
            log.DocumentDelivered = true;
            Assert.That(log.DocumentProcessedSuccessfully(), Is.EqualTo(true));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,DocumentName,DocumentUrl,File")] Document document)
        {
            if (id != document.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var publisher = (from pub in _context.Publisher
                                     where User.Identity.Name.Equals(pub.Email)
                                     select pub).FirstOrDefault();

                    document.PublisherId = publisher.Id;

                    document.Modified = DateTime.Now;
                    _context.Update(document);

                    DocumentLog log = new DocumentLog();
                    log.DocumentId = document.Id;
                    log.Operation  = Operation.UPDATED;
                    log.Time       = DateTime.Now;
                    _context.Add(log);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DocumentExists(document.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PublisherId"] = new SelectList(_context.Set <Publisher>(), "Id", "Id", document.PublisherId);
            return(View(document));
        }
예제 #11
0
 public DocumentLog InsertTakeOwnership(DocumentLog documentLog)
 {
     try
     {
         DocumentLog documentLogOut = _takeOwnershipRepository.InsertTakeOwnership(documentLog);
         bool        sendsuccess    = false;
         string      mailBody       = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/TakeOwnershipAcknowledgement.html"));
         MailMessage _mail          = new MailMessage();
         string      link           = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
         _mail.Body = mailBody.Replace("$DocumentOwner$", documentLogOut.OldUserName).Replace("$Document$", "Enquiry").Replace("$DocumentNo$", documentLogOut.DocumentNo).Replace("$DocumentDate$", documentLog.DateFormatted).Replace("$NewDocumentOwner$", documentLog.NewDocumentOwner).Replace("$Reason$", documentLog.Remarks).Replace("$Logo$", link);
         _mail.To.Add(documentLogOut.OldUserEmail);
         _mail.Subject    = "Document Ownership Change";
         _mail.IsBodyHtml = true;
         sendsuccess      = _mailBusiness.MailMessageSend(_mail);
         return(documentLogOut);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
        private bool UpdateEntitiesOnUpload(Client currentClient, Document entity, String pathFile, Boolean isImage, IDocumentLogRepository repoLog)
        {
            FileInfo f = new FileInfo(pathFile);

            repoLog.includes.Add("ResourceConfig");
            DocumentLog logEntity = repoLog.GetDocumentLogById(currentClient.Id);

            entity.SizeDocument        = f.Length;
            entity.Url                 = pathFile.Replace(WebApiApplication.UPLOAD_FOLDER_ROOT, string.Empty);
            entity.DateUpload          = DateTime.Now;
            logEntity.CurrentSize     += DocumentUtils.GetAllDocumentsSize(f.Length, pathFile, isImage);
            logEntity.DateModification = DateTime.Now;
            if (!((DocumentValidation)validation).CheckSizeUpload(validationDictionnary, logEntity))
            {
                return(false);
            }
            repo.Update(entity);
            repo.Save();
            repoLog.Update(logEntity);
            repoLog.Save();
            return(true);
        }
예제 #13
0
        public DocumentLog InsertTakeOwnership(DocumentLog documentLog)
        {
            SqlParameter outputStatus, outputCode, emailID, oldUserName, documentID, newDocumentOwner = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[InsertTakeOwnership]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@DocumentNo", SqlDbType.VarChar).Value      = documentLog.DocumentNo;
                        cmd.Parameters.Add("@Type", SqlDbType.VarChar).Value            = documentLog.Type;
                        cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value           = documentLog.PSASysCommon.CreatedDate;
                        cmd.Parameters.Add("@Remarks", SqlDbType.VarChar).Value         = documentLog.Remarks;
                        cmd.Parameters.Add("@DocumentType", SqlDbType.VarChar).Value    = documentLog.DocType;
                        cmd.Parameters.Add("@LoginName", SqlDbType.NVarChar, 250).Value = documentLog.PSASysCommon.CreatedBy;
                        cmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar, 250).Value = documentLog.PSASysCommon.CreatedBy;
                        cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value    = documentLog.PSASysCommon.CreatedDate;
                        cmd.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar, 250).Value = documentLog.PSASysCommon.UpdatedBy;
                        cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value    = documentLog.PSASysCommon.UpdatedDate;
                        outputStatus           = cmd.Parameters.Add("@Status", SqlDbType.SmallInt);
                        outputStatus.Direction = ParameterDirection.Output;
                        outputCode             = cmd.Parameters.Add("@CodeOut", SqlDbType.Int);
                        outputCode.Direction   = ParameterDirection.Output;
                        oldUserName            = cmd.Parameters.Add("@oldUserName", SqlDbType.NVarChar, 250);
                        oldUserName.Direction  = ParameterDirection.Output;
                        emailID                    = cmd.Parameters.Add("@EmailID", SqlDbType.NVarChar, 250);
                        emailID.Direction          = ParameterDirection.Output;
                        documentID                 = cmd.Parameters.Add("@DocumentID", SqlDbType.UniqueIdentifier);
                        documentID.Direction       = ParameterDirection.Output;
                        newDocumentOwner           = cmd.Parameters.Add("@NewDocumentOwner", SqlDbType.NVarChar, 250);
                        newDocumentOwner.Direction = ParameterDirection.Output;
                        cmd.ExecuteNonQuery();
                    }
                }
                switch (outputStatus.Value.ToString())
                {
                case "0":
                    throw new Exception(_appConstant.InsertFailure);

                case "1":
                    documentLog.Code             = int.Parse(outputCode.Value.ToString());
                    documentLog.OldUserName      = oldUserName.Value.ToString();
                    documentLog.OldUserEmail     = emailID.Value.ToString();
                    documentLog.DateFormatted    = DateTime.Parse(documentLog.PSASysCommon.CreatedDate.ToString()).ToString("dd-MMM-yyyy hh:mm tt");
                    documentLog.DocumentID       = Guid.Parse(documentID.Value.ToString());
                    documentLog.NewDocumentOwner = newDocumentOwner.Value.ToString();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(documentLog);
        }
예제 #14
0
        public async Task <IHttpActionResult> Get()
        {
            DocumentLog docLog = await DocumentLogRepository.GetDocumentLogByIdAsync(currentClient.Id);

            return(Ok(docLog));
        }
예제 #15
0
 public bool CheckSizeUpload(System.Web.Http.ModelBinding.ModelStateDictionary validationDictionary, DocumentLog log)
 {
     if (log == null)
     {
         validationDictionary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <Document>(), "DocumentLog"), GenericError.FORBIDDEN_RESOURCE_OR_DOES_NO_EXIST);
     }
     else if (log.CurrentSize > log.ResourceConfig.LimitBase)
     {
         validationDictionary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <Document>(), "LimitBase"), GenericError.UPLOAD_LIMIT);
     }
     return(validationDictionary.IsValid);
 }
 public DocumentLog InsertRevise(DocumentLog _documentLogObj)
 {
     //    PaymentDetailsXMl(_documentLogObj);
     return(_supplierPaymentsRepository.InsertRevise(_documentLogObj));
 }