public ActionResult SupprimerDocument(Guid idDocument)
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var signaturetransaction = FrDossierBL.GetSignatureTransaction(dossierVm.IdSubscriptionFile);
            var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var idDocumentModel = produit.IdDocumentModel;

            DocumentBL.RemoveDocument(idDocument);

            var document = FrDossierBL.GetDocument(idDocumentModel.GetValueOrDefault());
            var listdoc = DocumentBL.GetDocuments(signaturetransaction.idSignatureTransaction, ElectronicSafeDocumentBL.DocumentType.DOC);

            return PartialView("Documents", new DossierSouscriptionVm { Document = document, Documents = GetValidListOfPieces(listdoc), ProductDocuments = GetProductDocument(produit) });
        }
        public ActionResult ListingDocuments()
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            if (dossierVm == null) return RedirectToAction("Index");

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var idDocumentModel = produit.IdDocumentModel;

            var document = FrDossierBL.GetDocument(idDocumentModel.GetValueOrDefault());

            var signatureTransaction = FrDossierBL.GetSignatureTransaction(dossierVm.IdSubscriptionFile);

            if (!signatureTransaction.DocumentsInitialized)
            {
                //Génération documents par défaut.
                //var firmSDG = SessionManager.GetFirmInstitutionSession(); firmSDG.idFirmInstitution
                DocumentBL.GenerateDefaultDocuments(signatureTransaction.idSignatureTransaction, produit.IdFirmInstitution);
            }

            var listDocs = DocumentBL.GetDocuments(signatureTransaction.idSignatureTransaction, ElectronicSafeDocumentBL.DocumentType.DOC);



            return PartialView("Documents", new DossierSouscriptionVm { Document = document, Documents = GetValidListOfPieces(listDocs), ProductDocuments = GetProductDocument(produit) });
        }
        public ActionResult AjouterDocuments(String lstDocs)
        {

                var dossierVm = new DossierViewModel();
                SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
                var signaturetransaction = FrDossierBL.GetSignatureTransaction(dossierVm.IdSubscriptionFile);
                var produit = ProductBL.GetProductById(dossierVm.IdProduit);
                var idDocumentModel = produit.IdDocumentModel;

                string[] separators = { "-" };
                string[] splittedDocs = lstDocs.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                List<int> docCategories = new List<int>();
                foreach (var str in splittedDocs)
                {
                    docCategories.Add(Convert.ToInt32(str));
                }
                DocumentBL.AddDocuments(signaturetransaction.idSignatureTransaction, docCategories);

                var document = FrDossierBL.GetDocument(idDocumentModel.GetValueOrDefault());
                var listdoc = DocumentBL.GetDocuments(signaturetransaction.idSignatureTransaction, ElectronicSafeDocumentBL.DocumentType.DOC);
                return PartialView("Documents", new DossierSouscriptionVm { Document = document, Documents = GetValidListOfPieces(listdoc), ProductDocuments = GetProductDocument(produit) });
            
        }
Exemplo n.º 4
0
        private static void INITIALISER_DOSSIER_MEDIA()
        {
            if (DossierViewModel.GetAll().Count == 0)
            {
                DossierViewModel dossier = new DossierViewModel();
                dossier.Nom    = "Divx_1";
                dossier.Chemin = @"\\SRVTBR\Divx_1";
                dossier.save();

                dossier        = new DossierViewModel();
                dossier.Nom    = "Divx_2";
                dossier.Chemin = @"\\SRVTBR\Divx_2";
                dossier.save();

                dossier        = new DossierViewModel();
                dossier.Nom    = "Photo_1";
                dossier.Chemin = @"\\SRVTBR\Photos";
                dossier.save();

                dossier        = new DossierViewModel();
                dossier.Nom    = "Musiques";
                dossier.Chemin = @"\\SRVTBR\Musiques";
                dossier.save();
            }

            if (MediaViewModel.GetAll().Count == 0)
            {
                MediaViewModel media = new MediaViewModel();
                media.Nom           = "28 jours plus tard";
                media.RelativeURL   = @"~\28 jours plus tard\28 semaines plus tard.avi";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Divx_1").ID_Dossier;
                media.save();

                media               = new MediaViewModel();
                media.Nom           = "Massacre à la tronçonneuse 1";
                media.RelativeURL   = @"~\Massacre à la tronçonneuse\Massacre à la tronçonneuse [2003].avi";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Divx_2").ID_Dossier;
                media.save();

                media               = new MediaViewModel();
                media.Nom           = "Massacre à la tronçonneuse 2";
                media.RelativeURL   = @"~\Massacre à la tronçonneuse\Massacre à la tronçonneuse 2 [1986].avi";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Divx_2").ID_Dossier;
                media.save();

                media               = new MediaViewModel();
                media.Nom           = "Dexter 1";
                media.RelativeURL   = @"~\Dexter\Photo (1).jpg";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Photos").ID_Dossier;
                media.save();

                media               = new MediaViewModel();
                media.Nom           = "Dexter 2";
                media.RelativeURL   = @"~\Dexter\Photo (2).jpg";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Photos").ID_Dossier;
                media.save();

                media               = new MediaViewModel();
                media.Nom           = "Mylene1";
                media.RelativeURL   = @"~\Mylène Farmer\Avant que l'ombre\04 Q.I..mp3";
                media.FK_ID_Dossier = DossierViewModel.GetAll().First(d => d.Chemin == @"\\SRVTBR\Musiques").ID_Dossier;
                media.save();
            }
        }
        public ActionResult ConvertBulletinToPdf(string id)
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var firmCGP = dossierVm.FirmInstitutionCgp;

            FirmInstitution firmSDG = SessionManager.GetFirmInstitutionSession(); 
            
            int pageCount = 0;
            //byte[] byteFile = null;

            //Current document ?
            Guid idDocumentModel = Guid.Empty;
            Guid.TryParse(id, out idDocumentModel);

            if (idDocumentModel != null)
            {
               var product = DocumentModelBL.GetProductFromIdDocumentModel(idDocumentModel);
               var destinationPath = string.Empty; //force download
               var url = HostingEnvironment.ApplicationPhysicalPath + "/Content/images/logos/";
               pageCount = DocumentModelBL.ConvertHtmlSringBdsProductToPdf(product.Name, idDocumentModel, destinationPath, SessionManager.GetUserSession().idUser, firmCGP, Guid.Empty, true, url);
            }

            if (pageCount == 0)
            {
                return RedirectToAction("Index", "FrProduit");
            }
            else
            {
                /*this.Response.Clear();
                this.Response.ContentType = "tapplication/pdf";
                this.Response.AddHeader("content-disposition", "attachment;filename=" + "BulletinDeSouscription.pdf");
                this.Response.BinaryWrite(byteFile);
                this.Response.End();
                this.Response.Flush();
                this.Response.Close();*/
                return new EmptyResult();
            }

        }
        public ActionResult ConvertBulletinToPdf()
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var firmCGP = dossierVm.FirmInstitutionCgp;

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            if (produit.IdDocumentModel != null)
            {                
                var destinationPath = string.Empty; //force download
                //
                var url = HostingEnvironment.ApplicationPhysicalPath + "/Content/images/logos/";
                var pageCount = DocumentModelBL.ConvertHtmlSringBdsDossierToPdf(produit, destinationPath, SessionManager.GetUserSession().idUser, firmCGP, dossierVm.IdDocument, true, url);
            }

            return new EmptyResult();

        }
        public ActionResult SaveDossier(Guid produitId)
        {
            var productModel = ProductBL.GetProductById(produitId);
            
            var sfViewModel = new Upsilab.Web.ExtranetUser.Models.Provider.SubscriptionFileViewModel();
            sfViewModel.IdProduct = produitId;
            sfViewModel.IdUserCreator = SessionManager.GetUserSession().idUser;

            try 
	        {	        
		        var transactionId = Guid.NewGuid();
                #region "Création transaction"
                var transactionModel = new SignatureTransactionModel()
	            {
	                IdSignatureTransaction = transactionId,
                    IdUser = SessionManager.GetUserSession().idUser,
                    DateCreated = DateTime.Now,
                    Status = SignatureTransactionBL.Status.InProgress.ToString(),
                    DateSignatureObjetList = new List<DateSignatureObjet>()
                    {
                        new DateSignatureObjet(){ Role = SignatoryBL.Roles.CGP.ToString()}
                    }
	            };
                SignatureTransactionBL.InsertSignatureTransaction(transactionModel.ToEntity());
                #endregion

                #region "Création subcriptionFile"

	            sfViewModel.IdTransactionSignatory = transactionId;
                int subscriptionFileId = FrDossierBL.AddSubscriptionFile(sfViewModel.ToEntity());
                #endregion

                #region "Création document"
                if (subscriptionFileId > 0)
                {
                    sfViewModel.DossierNumber = subscriptionFileId.ToString();
                } 
	            var docId = Guid.NewGuid();
	            var doc = new Document()
	            {
                    idDocument = docId,
                    idSignatureTransaction = transactionId,
                    IdDocumentModel = productModel.IdDocumentModel,
                    DocumentType = Upsilab.Business.Document.ElectronicSafeDocumentBL.DocumentType.SF.ToString(),
                    Name = string.Format("Bulletin de souscription pour le dossier n°{0}", sfViewModel.DossierNumber),
                    DateCreated = DateTime.Now,
                    Status = DocumentBL.Status.InProgress.ToString(),
	            };
	            DocumentBL.AddDocument(doc);
                #endregion

                #region "Ajouter dans la session"

	            if (subscriptionFileId > 0)
	            {
	                var dossierViewModel = new DossierViewModel()
	                {
	                    IdSubscriptionFile = subscriptionFileId,
	                    IdDocument = docId,
                        IdProduit = produitId
	                };
	                SessionManager.Set(KEY_DOSSIER, dossierViewModel);
	            }

	            #endregion
                	           
                return RedirectToAction("Open");
	        }
	        catch (Exception ex)
	        {
		        Log.AppendException(ex);
	        }
            return RedirectToAction("Index");
        }
 public JsonResult GetDocumentCompleteStatus() 
 {
     var dossierVm = new DossierViewModel();
     var success = false;
     var complete = false;
     SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
     if(dossierVm.IdSubscriptionFile != null) 
     {
         complete = FrDossierBL.GetDocumentCompletion(dossierVm.IdSubscriptionFile);
         success = true;
     }
     return Json(new { success = success, complete = complete }, JsonRequestBehavior.AllowGet);
 }
        public JsonResult UpdataIdCustomerProspect(Guid idCustomer, bool coTitulaire = false) 
        {
            var bSuccess = false;

            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            if (dossierVm != null && idCustomer != Guid.Empty)
            {
                try
                {
                    var idSubscriptionFile = dossierVm.IdSubscriptionFile;
                    FrDossierBL.UpdataIdCustomerProspect(idSubscriptionFile, idCustomer, coTitulaire);
                    bSuccess = true;
                }
                catch (Exception e) { }
            }
            return Json(new { success = bSuccess,  }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Open()
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var languageData = PageLanguageHelper.GetLanguageContent("User", "FrDossier");

            if (dossierVm == null) return RedirectToAction("Index");

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var idDocumentModel = produit.IdDocumentModel;

            //TODO : est ce qu'on ne peut faire en une seule requete les 6 requetes suivantes ??
            var document = FrDossierBL.GetDocument(idDocumentModel.GetValueOrDefault());
            var sections = FrDossierBL.GetSections(idDocumentModel.GetValueOrDefault(), dossierVm.IdSubscriptionFile);
            var status = FrDossierBL.GetStatusById(dossierVm.IdSubscriptionFile);
            var subscriptionFile = FrDossierBL.GetInfoLiteById(dossierVm.IdSubscriptionFile);
            var subFileWithCgp = FrDossierBL.GetSubscriptionFileModelLiteWidthCgp(dossierVm.IdSubscriptionFile);

            //ajout frimCgp pour PDF
            dossierVm.FirmInstitutionCgp = subscriptionFile.FirmInstitution;
            SessionManager.Set<DossierViewModel>(KEY_DOSSIER, dossierVm);

            var docIsComplete = FrDossierBL.GetDocumentCompletion(dossierVm.IdSubscriptionFile);
            var countries = CustomEnumBL.GetCountries(1);
            ViewData["Countries"] = (countries != null) ? (from item in countries select item.Text).ToList() : new List<string>();

            var dossierSouscriptionVm = new DossierSouscriptionVm
            {
                Document = document,
                Sections = sections.ToList(),
                ProductModel = produit,
                SubscriptionVm = subscriptionFile,
                Status = status,
                IsCompleteDocument = docIsComplete,
                PageTitle = languageData.GetContent("dossiersouscription"),
            };

            //Le comportement de la page est different pour un FOURNISSEUR et CGP connecté
            var currentUser = SessionManager.GetUserSession();
            
            if (currentUser.IsProvider())
            {
                //Fournisseur (admin ou simple utilisateur)
                dossierSouscriptionVm.PageSubTitle = string.Format("{0} / N° : {1}", dossierSouscriptionVm.ProductModel.Name, dossierVm.IdSubscriptionFile.ToString("D8"));
                dossierSouscriptionVm.IsReadOnly  = true;
                dossierSouscriptionVm.IsProvider = true;
        }
            else
            { 
                //CGP (distributeur)
                dossierSouscriptionVm.PageSubTitle = string.Format("{0} / {1}", dossierSouscriptionVm.ProductModel.FirmInstitution.FirmInstitutionName, dossierSouscriptionVm.ProductModel.Name);
                dossierSouscriptionVm.IsReadOnly = false;
                dossierSouscriptionVm.IsProvider = false;
            }

            return View("DossierSouscription", dossierSouscriptionVm);
        }
        public JsonResult UpdateData(string name, string value, int idSection)
        {
            var currentUser = SessionManager.GetUserSession();
            var dossierVm = new DossierViewModel();
            
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            
            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            var idDocument = dossierVm.IdDocument;

            FieldValuesBL.Save(produit.IdFirmInstitution, produit.IdDocumentModel.GetValueOrDefault(), idDocument, null, name, value);

            return Json(new { success = true }, JsonRequestBehavior.AllowGet);
        }
        public PartialViewResult OpenPrintPopup()
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            //TODO : multilingue
            var productDocs = new List<DocumentVM>()
	        {
                new DocumentVM() { DocumentTypeCode = ElectronicSafeDocumentBL.DocumentType.SF.ToString(), UrlDocument = "BulletinDeSouscription.pdf", Label = "Bulletin de Souscription", IdProduct  = produit.IdProduct},
                new DocumentVM() { DocumentTypeCode = ElectronicSafeDocumentBL.DocumentType.DICI.ToString(), UrlDocument = produit.DICIFilename, Label = produit.DICILabel , IdProduct  = produit.IdProduct },
                new DocumentVM() { DocumentTypeCode = ElectronicSafeDocumentBL.DocumentType.BROC.ToString(), UrlDocument = produit.BrochureFilename, Label = produit.BrochureLabel , IdProduct  = produit.IdProduct},
	        };

            return PartialView("GrilleDocument", new DossierSouscriptionVm { ProductDocuments = productDocs });
        }
        public ActionResult SendDocumentToCoffre()
        {
            var error = string.Empty;

            try
            {
                var dossierVm = new DossierViewModel();
                SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

                var signatureTransaction = FrDossierBL.GetSignatureTransaction(dossierVm.IdSubscriptionFile);

                this.SaveSignedDocumentToCoffreFort(signatureTransaction.idSignatureTransaction, dossierVm.IdSubscriptionFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            
            if (!string.IsNullOrEmpty(error))
            {
                TempData["CoffreFortError"] = error;
            }

            return RedirectToAction("BackFromCoffreFort");
        }
 public JsonResult UpdateCompletion(int idSection, bool complete)
 {
     var success = true;
     var msg = "";
     try 
     {
         var dossierVm = new DossierViewModel();
         SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
         DocumentSectionBL.UpdateCompletion(dossierVm.IdSubscriptionFile, idSection, complete);
     }
     catch(Exception e) 
     {
         success = false;
         msg = e.Message;
     }
     return Json(new { success = success, msg = msg }, JsonRequestBehavior.AllowGet);
 }
        public ActionResult DocumentFileUpload() //string idDocument, HttpPostedFileBase uploadFile
        {
            HttpPostedFileBase uploadFile = Request.Files[0];
            var idDocument = Request.Form[0];

            //string id = Request.["idDocument"];
            Guid idDoc = Guid.Empty;
            Guid.TryParse(idDocument, out idDoc);

            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            var signaturetransaction = FrDossierBL.GetSignatureTransaction(dossierVm.IdSubscriptionFile);
            var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var idDocumentModel = produit.IdDocumentModel;


            var document = FrDossierBL.GetDocument(idDocumentModel.GetValueOrDefault());

            List<Document> listdoc = new List<Document>();
            string error = string.Empty;
            try
            {
                if (uploadFile.ContentLength > 0)
                {
                    //var currentCGP = GetFirm();
                    Document objDoc = DocumentBL.GetDocumentById(idDoc);
                    string documentPath = string.Empty; //FileManager.BuildDocumentPath(produit.Name, produit.IdFirmInstitution, ElectronicSafeDocumentBL.DocumentType.DOC.ToString());
  
                    var fullPath = ElectronicSafeDocumentBL.BuildSubscriptionFileDocumentsPath(dossierVm.IdSubscriptionFile, true, out documentPath);
                    
                    string fileName = ElectronicSafeDocumentBL.BuildDocumentName(FileManager.GetCorrectFileName(objDoc.Label), objDoc.idSignatureTransaction, uploadFile.FileName);
                    string filePath = Path.Combine(fullPath, fileName);
                    
                    //// 1- Sauvegarde dans le repertoire
                    uploadFile.SaveAs(filePath);

                    //// 2- Mise à jour du document en base
                    //if (!string.IsNullOrEmpty(dateExpiration))
                    //{
                    //objDoc.DateExpiration = dateExp;
                    //}
                    objDoc.Location = documentPath;
                    objDoc.Name = fileName;
                    DocumentBL.UpdateDocument(objDoc);

                }
                listdoc = DocumentBL.GetDocuments(signaturetransaction.idSignatureTransaction, ElectronicSafeDocumentBL.DocumentType.DOC);
            }
            catch (Exception ex)
            {
                Business.Log.Log.AppendException(ex);
                error = ex.Message;
            }
            return PartialView("GrillePieces", new DossierSouscriptionVm { Document = document, Documents = listdoc });
        }
        public JsonResult GetNameKeys(int idSection)
        {
            var dossierVm = new DossierViewModel();

            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            if (dossierVm == null) return Json(new { success = false }, JsonRequestBehavior.AllowGet);

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            var fields = DocumentSectionBL.GetFieldsBySection(produit.IdDocumentModel.GetValueOrDefault(), idSection);

            var list = new List<SignFieldsModel>();

            foreach (var item in fields)
            {
                if (item.Type == String.Empty || item.Type == null) item.Type = "textfield";
                list.Add(item);
            }

            return Json(new { success = true, namekeys = list }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult DownloadDocument(string documentType)
        {
            if (documentType == ElectronicSafeDocumentBL.DocumentType.SF.ToString())
            {
                //Bulletin de souscription
                return RedirectToAction("ConvertBulletinToPdf");
            }
            else
            {
                //Brochure ou fiche DICI
                var dossierVm = new DossierViewModel();
                SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
                var produit = ProductBL.GetProductById(dossierVm.IdProduit);
                string fileName = (documentType == ElectronicSafeDocumentBL.DocumentType.BROC.ToString() ? produit.BrochureFilename : produit.DICIFilename);

                var fullPath = ElectronicSafeDocumentBL.BuildProviderDocumentPath(produit.FirmInstitution.FirmInstitutionName, produit.IdFirmInstitution, documentType.ToDocumentTypeEnum(), true);
                var fileToDownload = string.Format("{0}\\{1}", fullPath, fileName);
                Log.LogOnDB(string.Format("file 1  - type_{1}: {0}", fileToDownload, documentType));
                if (!System.IO.File.Exists(fileToDownload))
                {
                    fileToDownload = fileToDownload.SendFournisseurSourceFilePathUploadsToUser();
                    Log.LogOnDB(string.Format("file to user  - type_{1}: {0}", fileToDownload, documentType));
                }

                if (!System.IO.File.Exists(fileToDownload))
                {
                    fileToDownload = fileToDownload.SendUserSourceFilePathUploadsToFournisseur();
                    Log.LogOnDB(string.Format("file to fournisseur  - type_{1}: {0}", fileToDownload, documentType));
                }

                if (System.IO.File.Exists(fileToDownload))
                {
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + Path.GetFileName(fileToDownload) + "\"");
                    Response.TransmitFile(fileToDownload);
                    Response.End();
                    return new EmptyResult();
                }
            }

            return RedirectToAction("Open", "FrDossier");
        }
        public JsonResult getFieldsValues(int idSection)
        {
            var dossierVm = new DossierViewModel();
            
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            if (dossierVm == null) return Json(new { success = false }, JsonRequestBehavior.AllowGet);
            
            var produit = ProductBL.GetProductById(dossierVm.IdProduit);

            var idDocument = dossierVm.IdDocument;

            var values = FieldValuesBL.GetAllValues( produit.IdDocumentModel.GetValueOrDefault(), idDocument, idSection);
            
            return Json(new { success = true, values = values }, JsonRequestBehavior.AllowGet);
        }       
        public ActionResult EditDossier(int idSubscriptionfile)
        {
            var sf = FrDossierBL.GetInfoForSessionById(idSubscriptionfile);
            if (sf.IdSubscriptionFile > 0)
            {
                var dossierViewModel = new DossierViewModel()
                {
                    IdSubscriptionFile = sf.IdSubscriptionFile,
                    IdDocument = sf.User.IdDocument.Value,
                    IdProduit = sf.Product.IdProduct,                    
                };

                SessionManager.Set(KEY_DOSSIER, dossierViewModel);
            }
            return RedirectToAction("Open");
        }
        public JsonResult GetDocumentSection(int idSection)
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);
            if (dossierVm == null) return Json(new { success = false }, JsonRequestBehavior.AllowGet);

            var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var idDocument = dossierVm.IdDocument;

            var html = DocumentSectionBL.GetHtml(idSection);
            var section = DocumentSectionBL.Get(idSection);
            var nameKeys = DocumentSectionBL.GetFieldsBySection(produit.IdDocumentModel.GetValueOrDefault(), idSection);
            var listKeys = new List<SignFieldsModel>();
            foreach (var item in nameKeys)
            {
                if (item.Type == String.Empty || item.Type == null) item.Type = "textfield";
                listKeys.Add(item);
            }
            //var values = FieldValuesBL.GetAllValues(produit.IdDocumentModel.GetValueOrDefault(), idDocument, idSection);
            var values = FieldValuesBL.GetAllValues(produit.IdDocumentModel.GetValueOrDefault(), idDocument);

            return Json(new { success = false, html = html, section = section, fieldValues = values, nameKeys = listKeys}, JsonRequestBehavior.AllowGet);
        }
        public PartialViewResult OpenCoffreFort()
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            //TODO : check dossierVm null

            DocumentType documentType = DocumentTypeBL.GetDocumentTypeByCode(ElectronicSafeDocumentBL.DocumentType.SF.ToString());

            /* SF */
            var sub = FrDossierBL.GetInfoLiteById(dossierVm.IdSubscriptionFile);

            /* */
            Document doc = DocumentBL.GetDocumentByIdSignatureTransaction(sub.IdSignatureTransaction, ElectronicSafeDocumentBL.DocumentType.SF.ToString());

            var coffreFortViewModel = new CoffreFortViewModel()
            {
                IdSubscriptionFile = dossierVm.IdSubscriptionFile,
                IdDocumentType = documentType.idDocumentType,
                DateSignatureCGP = DateTime.Now.ToShortDateString(),
                DateSignatureTitulaire1 = DateTime.Now.ToShortDateString(),
                DateSignatureTitulaire2 = DateTime.Now.ToShortDateString(),
                Document = doc
            };

            return PartialView("UploadDocumentPopup", coffreFortViewModel);

        }
        public ActionResult ObligationsDate(string idsubs,string iscgplab,string iscgprc, string iscustreclab)
        {
            var dossierVm = new DossierViewModel();
            SessionManager.Get<DossierViewModel>(KEY_DOSSIER, out dossierVm);

            if (dossierVm == null) return RedirectToAction("Index");

            int subscritionfileid = 0;
            if (!string.IsNullOrEmpty(idsubs) && Convert.ToInt32(idsubs) > 0)
            {
                Int32.TryParse(idsubs, out subscritionfileid);
            }
            else
            {
                subscritionfileid = dossierVm.IdSubscriptionFile;
            }

            /*var produit = ProductBL.GetProductById(dossierVm.IdProduit);
            var productModel = new ProductModel();
            productModel = ProductBL.GetProductObligationById(produit.IdProduct);*/
            //var subscriptionFileVm = new Upsilab.Data.Model.Provider.SubscriptionFileViewModel();
            var subscriptionFileVm = FrDossierBL.GetInfoLiteById(subscritionfileid);

            subscriptionFileVm.DocumentRC = DocumentBL.GetDocumentByIdSignatureTransaction(subscriptionFileVm.IdSignatureTransaction,
                                                               ElectronicSafeDocumentBL.DocumentType.RC.ToString());
            subscriptionFileVm.DocumentLAB = DocumentBL.GetDocumentByIdSignatureTransaction(subscriptionFileVm.IdSignatureTransaction,
                                                               ElectronicSafeDocumentBL.DocumentType.LAB.ToString());

            subscriptionFileVm.isCgpLAB = Convert.ToBoolean(iscgplab);
            subscriptionFileVm.isCgpRC = Convert.ToBoolean(iscgprc);
            subscriptionFileVm.isCustomHaveLicRecLab = Convert.ToBoolean(iscustreclab);
            //subscriptionFileVm.isCustomRC = Convert.ToBoolean(iscustrc);

            //return PartialView("ObligationsReglementaires", productModel);
            return PartialView("ObligationsReglementaires", subscriptionFileVm);
        }
 public Dossier()
 {
     InitializeComponent();
     BindingContext = new DossierViewModel();
 }
        public ActionResult UpdateDatesObligationReglementaires(string jsondata)
        {
            try
            {
                var dossierVm = new DossierViewModel();
                SessionManager.Get<DossierViewModel>("DossierSessionKey", out dossierVm);

                if (dossierVm == null) return Json(new { retour = "ko", msg = "" }, JsonRequestBehavior.AllowGet);

                int idSubscriptionFile = dossierVm.IdSubscriptionFile;
                if (idSubscriptionFile > 0)
                    FrDossierBL.UpdateSubscriptionFileDatesReportLab(idSubscriptionFile, jsondata);
                return Json(new { retour = "ok", msg = string.Empty }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                return Json(new { retour = "ko", msg = e.Message }, JsonRequestBehavior.AllowGet);
            }
        }