Exemplo n.º 1
0
        public Document Pull(DocumentId documentId, DocumentBuilder documentBuilder)
        {
            Document document = null;

            if (this.KeyTypeExists(documentId) == true)
            {
                if (this.WriterTypeExistsOtherThanThis(documentId) == true)
                {
                    Document otherDocument = this.GetWriterTypeOtherThanThis(documentId);
                    this.PushOne(otherDocument, documentId.Writer);
                }

                document = this.Get(documentId);
                if (document.Writers.Exists(p => p == documentId.Writer) == false)
                {
                    document.Writers.Add(documentId.Writer);
                }

                if (document.Value is YellowstonePathology.Business.Test.AccessionOrder)
                {
                    YellowstonePathology.Business.Test.AccessionOrder ao = (YellowstonePathology.Business.Test.AccessionOrder)document.Value;
                    if (ao.AccessionLock.IsLockAquiredByMe == true)
                    {
                        document.Submit();
                    }
                    else
                    {
                        if (document.IsDirty() == true)
                        {
                            throw new Exception("Lock is not aquired and data is dirty.");
                        }
                        else
                        {
                            documentBuilder.Refresh(document.Value);
                            document.Refresh();
                            this.HandleAccessionLock(document);
                        }
                    }
                }
            }
            else if (this.WriterTypeExists(documentId) == true)
            {
                Document outgoingDocument = this.WriterTypeGet(documentId);
                this.PushOne(outgoingDocument, documentId.Writer);

                object value = documentBuilder.BuildNew();
                documentId.Value = value;
                document         = new DocumentUpdate(documentId);
                this.HandleAccessionLock(document);
                this.m_Documents.Add(document);
            }
            else
            {
                object value = documentBuilder.BuildNew();
                documentId.Value = value;

                document = new DocumentUpdate(documentId);
                this.m_Documents.Add(document);

                this.HandleAccessionLock(document);
            }

            return(document);
        }
Exemplo n.º 2
0
        public Document Pull(DocumentId documentId, DocumentBuilder documentBuilder)
        {
            Document document = null;

            if (this.KeyTypeExists(documentId) == true)
            {
                if (this.WriterTypeExistsOtherThanThis(documentId) == true)
                {
                    Document otherDocument = this.GetWriterTypeOtherThanThis(documentId);
                    this.PushOne(otherDocument, documentId.Writer);
                }

                document = this.Get(documentId);
                if (document.Writers.Exists(p => p == documentId.Writer) == false)
                {
                    document.Writers.Add(documentId.Writer);
                }

                if (document.Value is YellowstonePathology.Business.Test.AccessionOrder)
                {
                    //Save even if the lock is not aquired.
                    if (document.IsDirty() == true)
                    {
                        document.Submit();
                    }
                    else
                    {
                        documentBuilder.Refresh(document.Value);
                        document.ResetClone();

                        Business.Test.AccessionOrder accessionOrder = (Business.Test.AccessionOrder)document.Value;
                        document.IsLockAquiredByMe = accessionOrder.IsLockAquiredByMe;
                    }
                }
                else
                {
                    if (document.IsDirty() == true)
                    {
                        document.Submit();
                    }
                    else
                    {
                        documentBuilder.Refresh(document.Value);
                        document.ResetClone();
                    }
                }
            }
            else if (this.WriterTypeExists(documentId) == true)
            {
                Document outgoingDocument = this.WriterTypeGet(documentId);
                this.PushOne(outgoingDocument, documentId.Writer);

                if (documentId.ValueWasPassedIn == true)
                {
                    document = new DocumentUpdate(documentId);
                    this.m_Documents.Add(document);
                }
                else
                {
                    object value = documentBuilder.BuildNew();
                    documentId.Value = value;
                    document         = new DocumentUpdate(documentId);
                    this.m_Documents.Add(document);
                }
            }
            else
            {
                if (documentId.ValueWasPassedIn == true)
                {
                    documentBuilder.Refresh(documentId.Value);
                }
                else
                {
                    object value = documentBuilder.BuildNew();
                    documentId.Value = value;
                }

                document = new DocumentUpdate(documentId);
                this.m_Documents.Add(document);

                if (document.Value is YellowstonePathology.Business.Test.AccessionOrder)
                {
                    Business.Test.AccessionOrder accessionOrder = (Business.Test.AccessionOrder)document.Value;
                    document.IsLockAquiredByMe = accessionOrder.IsLockAquiredByMe;
                }
            }

            return(document);
        }