Exemple #1
0
        public TakeDocModel.Folder Create(JObject jfolder)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                TakeDocModel.Folder folder = new TakeDocModel.Folder();

                Guid entityId       = new Guid(jfolder.Value <string>("entityId"));
                Guid userCreateData = new Guid(jfolder.Value <string>("userCreateId"));
                Guid ownerId        = new Guid(jfolder.Value <string>("ownerId"));
                Guid folderTypeId   = new Guid(jfolder.Value <string>("folderTypeId"));

                TakeDocModel.StatusFolder status  = daoStatusFolder.GetBy(x => x.StatusFolderReference == "OPEN" && x.EntityId == entityId).First();
                TakeDocModel.TypeDocument typeDoc = daoTypeDoc.GetBy(x => x.FolderTypeId == folderTypeId).First();

                folder.FolderLabel    = jfolder.Value <string>("title");
                folder.FolderTypeId   = folderTypeId;
                folder.FolderOwnerId  = ownerId;
                folder.FolderStatusId = status.StatusFolderId;

                folder.FolderDateStart = DateTimeOffset.Parse(jfolder.Value <string>("start"), System.Globalization.CultureInfo.InvariantCulture);
                folder.FolderDateEnd   = DateTimeOffset.Parse(jfolder.Value <string>("end"), System.Globalization.CultureInfo.InvariantCulture);

                daoFolder.Create(folder, userCreateData, entityId);
                servDocument.Create(ownerId, folder.EntityId, typeDoc.TypeDocumentId, folder.FolderLabel, folder.FolderId);
                transaction.Complete();
                return(folder);
            }
        }
Exemple #2
0
        public void CreateDocument()
        {
            TakeDocModel.Environnement.Init(System.Configuration.ConfigurationManager.AppSettings);
            TakeDocModel.TypeDocument typeDocument = daoTypeDocument.GetBy(x => x.TypeDocumentReference == "TEST-INTEGRATION-NO-VALIDATION").First();
            MyDocument = servDocument.Create(userId, entityId, typeDocument.TypeDocumentId, "Test intégration no validation");

            Assert.IsTrue(MyDocument.Status_Document.StatusDocumentReference.Equals(TakeDocModel.Status_Document.Create), "Statut du document CREATE");
            Assert.IsTrue(MyDocument.Version.Count() == 1);
            Assert.IsTrue(MyDocument.LastVersion.VersionMajor);
            Assert.IsTrue(MyDocument.LastVersion.VersionNumber == 0);
            Assert.AreEqual(MyDocument.UserCreateData, userId);
            Assert.AreEqual(MyDocument.EntityId, entityId);
            Assert.IsNotNull(MyDocument.DateCreateData);
            Assert.AreNotEqual(MyDocument.DateCreateData, System.DateTimeOffset.MinValue);
            Assert.IsFalse(MyDocument.EtatDeleteData);
            Assert.IsFalse(MyDocument.LastVersion.EtatDeleteData);
            Assert.IsTrue(MyDocument.Type_Document.TypeDocumentReference == "TEST-INTEGRATION-NO-VALIDATION");
            Assert.IsTrue(MyDocument.DocumentLabel == "Test intégration no validation");
            Assert.IsTrue(MyDocument.LastVersionMetadata.Count() == 2);
            Assert.IsTrue(MyDocument.LastVersionMetadata.Any(x => x.MetaDataName == "REFACTURABLE") == true);
            Assert.IsTrue(MyDocument.LastVersionMetadata.Any(x => x.MetaDataName == "MONTANT") == true);
            ICollection <TakeDocModel.DocumentStatusHisto> histos = servStatus.GetStatus(MyDocument);

            Assert.IsTrue(histos.Count() == 0, "no histo for the moment");
        }
Exemple #3
0
        public TakeDocModel.TypeDocument Add(string label, Guid entityId, Guid userId)
        {
            string        normalized    = label.Normalize(NormalizationForm.FormD);
            StringBuilder resultBuilder = new StringBuilder();

            foreach (var character in normalized)
            {
                System.Globalization.UnicodeCategory category = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(character);
                if (category == System.Globalization.UnicodeCategory.LowercaseLetter ||
                    category == System.Globalization.UnicodeCategory.UppercaseLetter ||
                    category == System.Globalization.UnicodeCategory.SpaceSeparator)
                {
                    resultBuilder.Append(character);
                }
            }
            string reference = System.Text.RegularExpressions.Regex.Replace(resultBuilder.ToString(), @"\s+", "-");

            TakeDocModel.TypeDocument toAdd = new TakeDocModel.TypeDocument();
            toAdd.TypeDocumentId        = System.Guid.NewGuid();
            toAdd.TypeDocumentLabel     = label;
            toAdd.TypeDocumentReference = reference.ToUpper();
            toAdd.TypeDocumentPageNeed  = false;
            toAdd.UserCreateData        = userId;
            toAdd.DateCreateData        = System.DateTimeOffset.UtcNow;
            toAdd.EntityId                   = entityId;
            toAdd.EtatDeleteData             = false;
            toAdd.TypeDocumentWorkflowTypeId = daoWorkflowType.GetBy(x => x.WorkflowTypeReference == "NO").First().WorkflowTypeId;
            return(daoTypeDocument.Add(toAdd));
        }
Exemple #4
0
        public HttpResponseMessage Update(Guid userId, [FromBody] string value)
        {
            TakeDocService.Document.Interface.ITypeDocumentService servTypeDocument = Utility.MyUnityHelper.UnityHelper.Resolve <TakeDocService.Document.Interface.ITypeDocumentService>();
            try
            {
                Newtonsoft.Json.Linq.JObject data = Newtonsoft.Json.Linq.JObject.Parse(value);
                Guid typeDocumentId            = new Guid(data.Value <string>("id"));
                Guid entityId                  = new Guid(data.Value <string>("entityId"));
                TakeDocModel.TypeDocument type = servTypeDocument.GetBy(x => x.TypeDocumentId == typeDocumentId && x.EntityId == entityId).First();
                type.TypeDocumentLabel    = data.Value <string>("label");
                type.TypeDocumentPageNeed = data.Value <bool>("pageNeed");
                bool deleted = data.Value <bool>("deleted");
                if (type.EtatDeleteData != deleted)
                {
                    type.EtatDeleteData = deleted;
                    type.UserDeleteData = userId;
                    type.DateDeleteData = System.DateTimeOffset.UtcNow;
                }
                type.TypeDocumentWorkflowTypeId = new Guid(data.Value <string>("workflowTypeId"));

                servTypeDocument.Update(type, userId);

                return(Request.CreateResponse());
            }
            catch (Exception ex)
            {
                TakeDocService.LoggerService.CreateError(ex.Message);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #5
0
 public void Delete(Guid typeDocumentId, Guid userId, Guid entityId)
 {
     TakeDocModel.TypeDocument current = daoTypeDocument.GetBy(x => x.TypeDocumentId == typeDocumentId && x.EntityId == entityId).First();
     current.EtatDeleteData = true;
     current.DateDeleteData = System.DateTimeOffset.UtcNow;
     current.UserDeleteData = userId;
     daoTypeDocument.Update(current);
 }
Exemple #6
0
        public void CreateDocumentTest()
        {
            TakeDocModel.Environnement.Init(System.Configuration.ConfigurationManager.AppSettings);
            TakeDocModel.TypeDocument typeDocument = daoTypeDocument.GetBy(x => x.TypeDocumentReference == "NOTE_FRAIS").First();
            MyDocument = servDocument.Create(userId, entityId, typeDocument.TypeDocumentId, "Test creation document");

            string base64image = servImage.ToBase64String(TakeDocModel.Environnement.JpegTestFile1);

            servDocument.AddPage(userId, entityId, MyDocument.DocumentId, base64image, "jpeg", 90);
        }
Exemple #7
0
 public HttpResponseMessage Update(string label, Guid userId, Guid entityId)
 {
     TakeDocService.Document.Interface.ITypeDocumentService servTypeDocument = Utility.MyUnityHelper.UnityHelper.Resolve <TakeDocService.Document.Interface.ITypeDocumentService>();
     try
     {
         TakeDocModel.TypeDocument back = servTypeDocument.Add(label, entityId, userId);
         return(Request.CreateResponse(back.TypeDocumentId));
     }
     catch (Exception ex)
     {
         TakeDocService.LoggerService.CreateError(ex.Message);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Exemple #8
0
        public void Update(Newtonsoft.Json.Linq.JArray pages, Guid userId, TakeDocModel.Version version, Guid entityId)
        {
            TakeDocModel.TypeDocument typeDoc = daoTypeDocument.GetBy(x => x.TypeDocumentId == version.Document.DocumentTypeId).First();

            if (typeDoc.TypeDocumentPageNeed)
            {
                int nb = pages.Where(obj => obj.Value <string>("pageNumber") != "-1").Count();
                if (nb == 0)
                {
                    throw new Exception("Une photographie est obligatoire.");
                }
            }

            foreach (Newtonsoft.Json.Linq.JObject page in pages.OrderBy(obj => obj["pageNumber"]))
            {
                Guid id = Guid.Empty;
                try
                {
                    id = new Guid(page.Value <string>("id"));
                }
                catch (Exception ex)
                {
                    id = Guid.Empty;
                }

                int    rotation   = page.Value <int>("rotation");
                int    pageNumber = page.Value <int>("pageNumber");
                string action     = page.Value <string>("action");
                if (string.IsNullOrEmpty(action) == false)
                {
                    bool delete = action.ToUpper().Equals("DELETE");
                    bool add    = action.ToUpper().Equals("ADD");
                    bool update = action.ToUpper().Equals("UPDATE");
                    if (delete && id != Guid.Empty)
                    {
                        this.Update(id, rotation, pageNumber, delete, userId, entityId);
                    }
                    else if (add)
                    {
                        string extension = page.Value <string>("base64Image").Split(';')[0].Replace("data:image/", string.Empty);
                        this.Add(userId, entityId, version.VersionId, page.Value <string>("base64Image"), extension, rotation, pageNumber);
                    }
                    else if (update && id != Guid.Empty)
                    {
                        this.Update(id, rotation, pageNumber, delete, userId, entityId);
                    }
                }
            }
        }
Exemple #9
0
        public void CreateDocument()
        {
            TakeDocModel.Environnement.Init(System.Configuration.ConfigurationManager.AppSettings);
            TakeDocModel.TypeDocument typeDocument = daoTypeDocument.GetBy(x => x.TypeDocumentReference == "NOTE_FRAIS").First();
            MyDocument = servDocument.Create(userId, entityId, typeDocument.TypeDocumentId, "Test creation document");

            Assert.IsTrue(MyDocument.Status_Document.StatusDocumentReference.Equals(TakeDocModel.Status_Document.Create), "Statut du document CREATE");
            Assert.IsTrue(MyDocument.Version.Count() == 1);
            Assert.IsTrue(MyDocument.LastVersion.VersionMajor);
            Assert.IsTrue(MyDocument.LastVersion.VersionNumber == 0);
            Assert.AreEqual(MyDocument.UserCreateData, userId);
            Assert.AreEqual(MyDocument.EntityId, entityId);
            Assert.IsNotNull(MyDocument.DateCreateData);
            Assert.AreNotEqual(MyDocument.DateCreateData, System.DateTimeOffset.MinValue);
            Assert.IsFalse(MyDocument.EtatDeleteData);
            Assert.IsFalse(MyDocument.LastVersion.EtatDeleteData);
            Assert.IsTrue(MyDocument.Type_Document.TypeDocumentReference == "NOTE_FRAIS");
            Assert.IsTrue(MyDocument.DocumentLabel == "Test creation document");
            Assert.IsTrue(MyDocument.LastVersionMetadata.Count() > 2);
        }
Exemple #10
0
 public void Update(TakeDocModel.TypeDocument typeDocument, Guid userId)
 {
     typeDocument.DateUpdateData = System.DateTime.UtcNow;
     typeDocument.UserUpdateData = userId;
     daoTypeDocument.Update(typeDocument);
 }