Пример #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);
            }
        }
Пример #2
0
        public ICollection <object> GetJsonByPeriod(ICollection <JObject> agendas, DateTimeOffset start, DateTimeOffset end)
        {
            ICollection <Guid> agendaIds = new List <Guid>();

            foreach (JObject agenda in agendas)
            {
                agendaIds.Add(new Guid(agenda.Value <string>("id")));
            }

            ICollection <TakeDocModel.Entity>       entitys = daoEntity.GetAll();
            ICollection <TakeDocModel.FolderType>   types   = daoFolderType.GetAll();
            ICollection <TakeDocModel.StatusFolder> status  = daoStatusFolder.GetAll();

            ICollection <TakeDocModel.Folder> folders = this.GetByPeriod(agendaIds, start, end);
            IList <object> items = new List <object>();

            foreach (TakeDocModel.Folder folder in folders)
            {
                TakeDocModel.Entity       entity  = entitys.First(x => x.EntityId == folder.EntityId);
                TakeDocModel.FolderType   ctype   = types.First(x => x.FolderTypeId == folder.FolderTypeId);
                TakeDocModel.StatusFolder cstatus = status.First(x => x.StatusFolderId == folder.FolderStatusId);

                string color = string.Empty;
                ICollection <JObject> currentAgenda = agendas.Where(x => new Guid(x.Value <string>("id")) == folder.FolderOwnerId).ToList();
                if (currentAgenda.Count() > 0)
                {
                    color = currentAgenda.First().Value <string>("color");
                }
                var json = new
                {
                    id                      = folder.FolderId,
                    folderId                = folder.FolderId,
                    folderTypeLabel         = ctype.FolderTypeLabel,
                    title                   = folder.FolderLabel,
                    detail                  = folder.FolderDetail,
                    status                  = cstatus.StatusFolderLabel,
                    statusReference         = cstatus.StatusFolderReference,
                    start                   = folder.FolderDateStart,
                    end                     = folder.FolderDateEnd,
                    allDay                  = false,
                    entityId                = folder.EntityId,
                    entityLabel             = entity.EntityLabel,
                    ownerId                 = folder.FolderOwnerId,
                    folderTypeId            = folder.FolderTypeId,
                    readOnly                = false,
                    color                   = color,
                    documentId              = folder.Document.First().DocumentId,
                    documentVersionId       = folder.Document.First().DocumentCurrentVersionId,
                    documentReference       = folder.Document.First().DocumentReference,
                    typeDocumentId          = folder.Document.First().DocumentTypeId,
                    documentStatutReference = folder.Document.First().Status_Document.StatusDocumentReference
                };
                items.Add(json);
            }

            return(items);
        }
Пример #3
0
        protected void SetStatus(TakeDocModel.Document document, string status, Guid userId)
        {
            servStatus.SetStatus(document, status, userId, true);
            if (document.DocumentFolderId != null && document.DocumentFolderId != System.Guid.Empty)
            {
                TakeDocModel.StatusFolder stFolder = null;
                if (status == TakeDocModel.Status_Document.Approve || status == TakeDocModel.Status_Document.Archive)
                {
                    stFolder = daoStFolder.GetBy(x => x.EntityId == document.EntityId && x.StatusFolderReference == "CLOSE").First();
                }
                else if (status == TakeDocModel.Status_Document.Create)
                {
                    stFolder = daoStFolder.GetBy(x => x.EntityId == document.EntityId && x.StatusFolderReference == "OPEN").First();
                }
                else if (status == TakeDocModel.Status_Document.Complete || status == TakeDocModel.Status_Document.Incomplete ||
                         status == TakeDocModel.Status_Document.Refuse || status == TakeDocModel.Status_Document.ToValidate)
                {
                    stFolder = daoStFolder.GetBy(x => x.EntityId == document.EntityId && x.StatusFolderReference == "INPROGRESS").First();
                }

                this.context.UpdateFolderStatus(document.DocumentFolderId, document.EntityId, stFolder.StatusFolderId);
            }
        }