예제 #1
0
        public static void UpdateDocumentsStatus(Guid idTransaction, List<string> documentTypes, DocumentBL.Status status)
        {
            using (var db = new UpsilabEntities())
            {
                var docs = db.Document.Where(d => d.idSignatureTransaction == idTransaction 
                                    && documentTypes.Contains(d.DocumentType))
                        .ToList();

                //Update document status
                foreach (var doc in docs)
                {
                    doc.Status = status.ToString();
                }

                //Commit changes
                db.SaveChanges();

            }
        }
예제 #2
0
        public static void UpdateDocumentStatusById(Guid idDocument, DocumentBL.Status status)
        {
            using (var db = new UpsilabEntities())
            {
                var doc = db.Document.FirstOrDefault(d => d.idDocument == idDocument);

                if (doc != null)
                {
                    doc.Status = status.ToString();
                }

                //Commit changes
                db.SaveChanges();
            }
        }
        public static SignatureTransaction UpdateTransactionStatus(Guid pTransactionId, DocumentBL.Status pStatus, DateTime? dateUpdated = null)
        {
            string status = pStatus.ToString();
            var transaction = new SignatureTransaction();

            using (UpsilabEntities context = new UpsilabEntities())
            {
                context.Connection.Open();
                using (var dbContextTransaction = context.Connection.BeginTransaction())
                {
                    try
                    {
                        //1- Update Transaction status
                        transaction = context.SignatureTransaction.FirstOrDefault(x => x.idSignatureTransaction == pTransactionId);
                        transaction.Status = status;

                        //2- Update latest transaction status
                        var calculatedData = FirmInstitutionBL.GetCalculatedData(transaction.idFirmInstitution.Value);
                        if (calculatedData != null)
                        {
                            if (transaction.SignatureTransactionType == SignatureTransactionType.CONVENTION.ToString())
                            {
                                calculatedData.ConventionLatestStatus = status;
                                if (pStatus == DocumentBL.Status.Completed)
                                {
                                    calculatedData.ConventionDateUpdated = (dateUpdated == null) ? DateTime.Now : dateUpdated;
                                    calculatedData.HasDataInCoffre = true;
                                    calculatedData.AvenantLatestStatus = DocumentBL.Status.Created.ToString(); //activer le bouton "Avenant"
                                }
                            }
                            else if (transaction.SignatureTransactionType == SignatureTransactionType.AVENANT.ToString())
                            {
                                calculatedData.AvenantLatestStatus = status;
                                if (pStatus == DocumentBL.Status.Completed)
                                {
                                    calculatedData.AvenantDateUpdated = (dateUpdated == null) ? DateTime.Now : dateUpdated;
                                    calculatedData.HasDataInCoffre = true;
                                }
                            }

                            FirmInstitutionBL.SaveCalculatedData(calculatedData, context);
                        }

                        //If "InProgress", clear email de rappel ?
                        if (pStatus == DocumentBL.Status.InProgress)
                        {
                            transaction.DateSignaturesObjet = null;
                            transaction.DatesReminderEmail = null;
                        }


                        //Log transaction status
                        var documentStatus = DocumentStatusBL.GetByCode(status);

                        var signatureTransactionStatusLog = new SignatureTransactionStatusLog
                        {
                            DateCreated = DateTime.Now,
                            idDocumentStatus = documentStatus.idDocumentStatus,
                            idSignatureTransaction = pTransactionId
                        };

                        context.SignatureTransactionStatusLog.AddObject(signatureTransactionStatusLog);
                        context.SaveChanges();
                        //
                        //
                        //
                        dbContextTransaction.Commit();
                    }
                    catch (Exception e)
                    {
                        dbContextTransaction.Rollback();
                        Log.Log.AppendException(e);
                        throw new Exception("SavingError");
                    }
                }
            }

            return transaction;
        }
        public static Guid InsererDocument(Guid idTransaction, ElectronicSafeDocumentBL.DocumentType documentType, string name, string location, string designation, int pageCount = 0, DocumentBL.Status status = DocumentBL.Status.Created)
        {
            Guid id = Guid.NewGuid();
            var doc = new Upsilab.Data.Model.Document
            {
                idDocument = id,
                DateCreated = DateTime.Now,
                DocumentType = documentType.ToString().ToUpper().Trim(),
                Name = name,
                Location = location,
                Designation = designation,
                idSignatureTransaction = idTransaction,
				PageCount = pageCount,

                Status = status.ToString()
            };

            if (documentType == ElectronicSafeDocumentBL.DocumentType.AVENANT)
            {
                doc.Status = DocumentBL.Status.InProgress.ToString();
            }

            DocumentBL.AddDocument(doc);
            return id;
        }
예제 #5
0
        /*private static Action<List<FirmInstitution>, Dictionary<Guid, FirmInstitution>> addDictionnary = (x, y) =>
        {
            foreach (var cgp in x)
            {
                if (!y.ContainsKey(cgp.idFirmInstitution))
                    y.Add(cgp.idFirmInstitution, cgp);
            }
        };*/

        public static List<CgpVM> AdvancedSearch(Guid idFirmSdg, DocumentBL.Status conventionstatus, DocumentBL.Status avenantstatus, bool includedocincomplet, bool includedocexpired)
        {
            using (UpsilabEntities context = new UpsilabEntities())
            {
                var dict = new Dictionary<Guid, FirmInstitution>();
                Action<List<FirmInstitution>, Dictionary<Guid, FirmInstitution>> addDictionnary = (x, y) =>
                {
                    foreach (var cgp in x)
                    {
                        if (!y.ContainsKey(cgp.idFirmInstitution))
                            y.Add(cgp.idFirmInstitution, cgp);
                    }
                };
                //
                //
                //
                if ((int)conventionstatus > 0)
                {
                    var firms = SearchListCGPByConventionStatut(idFirmSdg, conventionstatus, context);
                    addDictionnary(firms, dict);
                }

                if ((int)avenantstatus > 0)
                {
                    var firms = SearchListCGPByAvenantStatut(idFirmSdg, avenantstatus, context);
                    addDictionnary(firms, dict);
                }
                if (includedocexpired || includedocincomplet)
                {
                    Func<Data.Model.Document, bool> predicat =
                        x => x.SignatureTransaction.SignatureTransactionType == "CONVENTION" &&
                      x.SignatureTransaction.idFirmInstitution != null &&
                      x.DocumentType == "DOC" &&
                            //x.DocumentCategory.IsMandatory &&
                      x.SignatureTransaction.FirmInstitution.FirmInstitutionParent == idFirmSdg &&
                      (!x.SignatureTransaction.FirmInstitution.isDelete.HasValue || !x.SignatureTransaction.FirmInstitution.isDelete.Value);


                    var docs = context.Document.Where(predicat).GroupBy(x => new { x.IdDocumentCategory, x.SignatureTransaction.idFirmInstitution }).Select(y => y.OrderByDescending(a => a.DateCreated).FirstOrDefault());

                    if (includedocincomplet)
                    {
                        var firms = docs.Where(x => string.IsNullOrEmpty(x.Location) && x.DocumentCategory.IsMandatory).Select(y => y.SignatureTransaction.FirmInstitution).ToList();
                        addDictionnary(firms, dict);
                    }

                    if (includedocexpired)
                    {
                        //var firms = SearchCGPDocumentExpire(idFirmSdg, context);
                        var firms = docs.Where(x => x.DateExpiration < DateTime.Now).Select(y => y.SignatureTransaction.FirmInstitution).ToList();
                        addDictionnary(firms, dict);
                    }
                }
                Business.Log.Log.LogOnDB(string.Join(",", dict.Values.Select(x => x.idFirmInstitution).ToArray()));

                //return GetListCgpByFirms(dict.Values.ToList(), context);

                var listCgpVm = new List<CgpVM>();
                foreach (var firm in dict.Values)
                {
                    var firmadviser = firm.FirmInstitutionAdviser1.FirstOrDefault(x => (!x.IsDeleted.HasValue || !x.IsDeleted.Value)
                                                                && (x.IsDefaultSignatory.HasValue && x.IsDefaultSignatory.Value));

                    var user = firmadviser != null ? firmadviser.User : null;
                    var calc = firm.FirmInstitutionCalculatedData.FirstOrDefault();

                    listCgpVm.Add(new CgpVM
                            {
                                IdFirmInstitution = firm.idFirmInstitution,
                                FirmInstitutionName = firm.FirmInstitutionName,

                                UserFirstName = user == null ? string.Empty : user.UserFirstName,
                                UserName = user == null ? string.Empty : user.UserName,
                                UserEmail = user == null ? string.Empty : user.UserEmail,
                                UserMobilePhone = user == null ? string.Empty : user.UserMobilePhone,

                                ConventionStatus = calc == null ? "" : calc.ConventionLatestStatus,
                                ConventionDateUpdated = calc == null ? null : calc.ConventionDateUpdated,

                                AvenantStatus = calc != null ? "" : calc.AvenantLatestStatus,
                                AvenantDateUpdated = calc != null ? null : calc.AvenantDateUpdated,

                                HasDocInCoffreFort = calc != null ? null : calc.HasDataInCoffre,

                                OriasNumber = firm.OriasNumber
                            });
                }
                return listCgpVm;
            }
        }
예제 #6
0
        private static List<FirmInstitution> SearchListCGPByAvenantStatut(Guid idFirmSDG, DocumentBL.Status statut, UpsilabEntities context)
        {
            var _status = statut.ToString().ToLower();
            var calcdata = context.FirmInstitutionCalculatedData.Where(
                  x => x.FirmInstitution.FirmInstitutionParent == idFirmSDG &&
                  (!x.FirmInstitution.isDelete.HasValue || !x.FirmInstitution.isDelete.Value) &&
                  x.AvenantLatestStatus.ToLower() == _status);

            return calcdata.Count() == 0 ? new List<FirmInstitution>() : calcdata.Select(x => x.FirmInstitution).ToList();
        }