Пример #1
0
        public void DeleteDocument(object o, object writer)
        {
            DocumentId documentId = new DocumentId(o, writer);
            this.m_Documents.Remove(documentId);

            DocumentDelete documentDelete = new DocumentDelete(documentId);
            documentDelete.Submit();
        }
Пример #2
0
        public Document(DocumentId documentId)
        {
            if (documentId.Value == null) throw new Exception("Can't create a new document without a value.");

            this.m_Value = documentId.Value;
            this.m_Writers = new List<object>();
            this.m_Type = documentId.Type;
            this.m_Key = documentId.Key;
            this.m_Writers.Add(documentId.Writer);
            this.m_IsGlobal = documentId.IsGlobal;
            this.SetHasLock();
        }
Пример #3
0
        public Document Get(DocumentId documentId)
        {
            Document result = null;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName
                    && document.Key.ToString() == documentId.Key.ToString())
                {
                    result = document;
                    break;
                }
            }

            return result;
        }
Пример #4
0
        public Document(DocumentId documentId)
        {
            if (documentId.Value == null) throw new Exception("Can't create a new document without a value.");

            this.m_Value = documentId.Value;
            this.m_Writers = new List<object>();
            this.m_Type = documentId.Type;
            this.m_Key = documentId.Key;
            this.m_Writers.Add(documentId.Writer);
            this.m_IsGlobal = documentId.IsGlobal;

            if (this.m_Value is YellowstonePathology.Business.Test.AccessionOrder)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = (YellowstonePathology.Business.Test.AccessionOrder)this.m_Value;
                this.m_IsLockAquiredByMe = accessionOrder.IsLockAquiredByMe;
            }
        }
Пример #5
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;
        }
Пример #6
0
        public void PullTypingShortcut(YellowstonePathology.Business.Typing.TypingShortcut typingShortcut, object writer)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * From tblTypingShortcut where ObjectId = @ObjectId";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@ObjectId", SqlDbType.VarChar).Value = typingShortcut.ObjectId;
            GenericDocumentBuilder builder = new GenericDocumentBuilder(cmd, typeof(YellowstonePathology.Business.Typing.TypingShortcut));

            DocumentId documentId = new DocumentId(typingShortcut, writer);
            Document document = this.m_Stack.Pull(documentId, builder);
        }
Пример #7
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;
        }
Пример #8
0
        private bool WriterTypeExistsOtherThanThis(DocumentId documentId)
        {
            bool result = false;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName &&
                    document.Writers.Exists(p => p == documentId.Writer))
                {
                    if(document.Key.ToString() != documentId.Key.ToString())
                    {
                        result = true;
                        break;
                    }
                }
            }

            return result;
        }
Пример #9
0
        public YellowstonePathology.Business.Test.AccessionOrder PullAccessionOrder(string masterAccessionNo, object writer)
        {
            lock(locker)
            {
                AODocumentBuilder documentBuilder = new AODocumentBuilder(masterAccessionNo, true);
                DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Test.AccessionOrder), writer, masterAccessionNo);
                Document document = this.m_Stack.Pull(documentId, documentBuilder);

                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = (YellowstonePathology.Business.Test.AccessionOrder)document.Value;
                return accessionOrder;
            }
        }
Пример #10
0
        public bool TypeKeyLockExists(DocumentId documentId)
        {
            bool result = false;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName
                    && document.Key.ToString() == documentId.Key.ToString()
                    && documentId.LockAquired == true)
                {
                    result = true;
                    break;
                }
            }

            return result;
        }
Пример #11
0
        private Document GetWriterTypeOtherThanThis(DocumentId documentId)
        {
            Document result = null;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName &&
                    document.Writers.Exists(p => p == documentId.Writer))
                {
                    if (document.Key.ToString() != documentId.Key.ToString())
                    {
                        result = document;
                        break;
                    }
                }
            }

            return result;
        }
Пример #12
0
 public YellowstonePathology.Business.Domain.Physician PullPhysician(int physicianId, object writer)
 {
     lock (locker)
     {
         ProviderDocumentBuilder documentBuilder = new ProviderDocumentBuilder(physicianId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Domain.Physician), writer, physicianId);
         Document document = this.m_Stack.Pull(documentId, documentBuilder);
         return (YellowstonePathology.Business.Domain.Physician)document.Value;
     }
 }
Пример #13
0
 public YellowstonePathology.Business.Specimen.Model.SpecimenOrder PullSpecimenOrderByContainerId(string containerId, object writer)
 {
     lock (locker)
     {
         SpecimenOrderDocumentBuilder specimenOrderDocumentBuilder = new SpecimenOrderDocumentBuilder();
         specimenOrderDocumentBuilder.SetSqlByContainerId(containerId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Specimen.Model.SpecimenOrder), writer, containerId);
         Document document = this.m_Stack.Pull(documentId, specimenOrderDocumentBuilder);
         return (YellowstonePathology.Business.Specimen.Model.SpecimenOrder)document.Value;
     }
 }
Пример #14
0
        public YellowstonePathology.Business.Client.Model.ClientSupplyOrder PullClientSupplyOrder(string clientSupplyOrderId, object writer)
        {
            lock (locker)
            {
                ClientSupplyOrderDocumentBuilder builder = new ClientSupplyOrderDocumentBuilder(clientSupplyOrderId);

                DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Client.Model.ClientSupplyOrder), writer, clientSupplyOrderId);
                Document document = this.m_Stack.Pull(documentId, builder);
                return (YellowstonePathology.Business.Client.Model.ClientSupplyOrder)document.Value;
            }
        }
Пример #15
0
 public YellowstonePathology.Business.MaterialTracking.Model.MaterialTrackingBatch PullMaterialTrackingBatch(string materialTrackingBatchId, object writer)
 {
     lock (locker)
     {
         MaterialTrackingBatchDocumentBuilder builder = new MaterialTrackingBatchDocumentBuilder(materialTrackingBatchId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.MaterialTracking.Model.MaterialTrackingBatch), writer, materialTrackingBatchId);
         Document document = this.m_Stack.Pull(documentId, builder);
         return (YellowstonePathology.Business.MaterialTracking.Model.MaterialTrackingBatch)document.Value;
     }
 }
Пример #16
0
        public YellowstonePathology.Business.ClientOrder.Model.ClientOrder PullClientOrderByExternalOrderId(string clientOrderId, object writer)
        {
            lock (locker)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "gwGetClientOrderByExternalOrderId";
                SqlParameter clientOrderIdParameter = new SqlParameter("@ExternalOrderId", SqlDbType.VarChar, 100);
                clientOrderIdParameter.Value = clientOrderId;
                cmd.Parameters.Add(clientOrderIdParameter);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                ClientOrderDocumentBuilder builder = new ClientOrderDocumentBuilder(cmd);

                DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.User.UserPreference), writer, clientOrderId);
                Document document = this.m_Stack.Pull(documentId, builder);

                return (YellowstonePathology.Business.ClientOrder.Model.ClientOrder)document.Value;
            }
        }
Пример #17
0
 public YellowstonePathology.Business.Client.Model.Client PullClient(int clientId, object writer)
 {
     lock (locker)
     {
         ClientDocumentBuilder documentBuilder = new ClientDocumentBuilder(clientId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Client.Model.Client), writer, clientId);
         Document document = this.m_Stack.Pull(documentId, documentBuilder);
         return (YellowstonePathology.Business.Client.Model.Client)document.Value;
     }
 }
Пример #18
0
 public YellowstonePathology.Business.Test.AliquotOrder PullAliquotOrder(string aliquotOrderId, object writer)
 {
     lock (locker)
     {
         AliquotOrderDocumentBuilder aliquotOrderDocumentBuilder = new AliquotOrderDocumentBuilder(aliquotOrderId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Task.Model.TaskOrder), writer, aliquotOrderId);
         Document document = this.m_Stack.Pull(documentId, aliquotOrderDocumentBuilder);
         return (YellowstonePathology.Business.Test.AliquotOrder)document.Value;
     }
 }
Пример #19
0
 public void Push(object o, object writer)
 {
     DocumentId documentId = new DocumentId(o, writer);
     if (this.KeyTypeExists(documentId) == true)
     {
         Document document = this.Get(documentId);
         this.PushOne(document, writer);
     }
     else
     {
         throw new Exception("You are trying to push an object that is not on the stack.");
     }
 }
Пример #20
0
 public YellowstonePathology.Business.Task.Model.TaskOrder PullTaskOrder(string taskOrderId, object writer)
 {
     lock (locker)
     {
         TaskOrderDocumentBuilder taskOrderDocumentBuilder = new TaskOrderDocumentBuilder(taskOrderId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Task.Model.TaskOrder), writer, taskOrderId);
         Document document = this.m_Stack.Pull(documentId, taskOrderDocumentBuilder);
         return (YellowstonePathology.Business.Task.Model.TaskOrder)document.Value;
     }
 }
Пример #21
0
        public void ReleaseLock(YellowstonePathology.Business.Test.AccessionOrder accessionOrder, object writer)
        {
            DocumentId documentId = new DocumentId(accessionOrder, writer);
            Document document = this.Get(documentId);

            if (document != null)
            {
                if (accessionOrder.IsLockAquiredByMe == true)
                {
                    accessionOrder.ReleaseLock();
                    document.IsLockAquiredByMe = false;
                }
                document.Submit();
            }
            else
            {
                throw new Exception("You are trying to release the lock on a document that is not in the stack.");
            }
        }
Пример #22
0
 public DocumentInsert(DocumentId documentId)
     : base(documentId)
 {
 }
Пример #23
0
        public Document WriterTypeGet(DocumentId documentId)
        {
            Document result = null;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName &&
                    document.Writers.Exists(p => p == documentId.Writer))
                {
                    result = document;
                    break;
                }
            }

            return result;
        }
Пример #24
0
        public void PullTaskOrder(YellowstonePathology.Business.Task.Model.TaskOrder taskOrder, object writer)
        {
            SqlCommand cmd = new SqlCommand(" select tsk.*,  ( select tskd.* from tblTaskOrderDetail tskd where tskd.TaskOrderId = tsk.TaskOrderId " +
                "for xml Path('TaskOrderDetail'), type) [TaskOrderDetailCollection] " +
                "from tblTaskOrder tsk where tsk.TaskOrderId = @TaskOrderId  for xml Path('TaskOrder')");
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@TaskOrderId", SqlDbType.VarChar).Value = taskOrder.TaskOrderId;

            TaskOrderDocumentBuilder taskOrderDocumentBuilder = new TaskOrderDocumentBuilder(cmd);
            DocumentId documentId = new DocumentId(taskOrder, writer);
            Document document = this.m_Stack.Pull(documentId, taskOrderDocumentBuilder);
        }
Пример #25
0
        private bool TypeExists(DocumentId documentId)
        {
            bool result = false;

            foreach (Document document in this.m_Documents)
            {
                if (document.Type.FullName == documentId.Type.FullName)
                {
                    result = true;
                    break;
                }
            }

            return result;
        }
Пример #26
0
 public DocumentDelete(DocumentId documentId)
     : base(documentId)
 {
 }
Пример #27
0
 public YellowstonePathology.Business.Typing.TypingShortcut PullTypingShortcut(string objectId, object writer)
 {
     lock (locker)
     {
         SqlCommand cmd = new SqlCommand();
         TypingShortcutDocumentBuilder builder = new TypingShortcutDocumentBuilder(objectId);
         DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.Typing.TypingShortcut), writer, objectId);
         Document document = this.m_Stack.Pull(documentId, builder);
         return (YellowstonePathology.Business.Typing.TypingShortcut)document.Value;
     }
 }
Пример #28
0
 public DocumentUpdate(DocumentId documentId)
     : base(documentId)
 {
     ObjectCloner objectCloner = new ObjectCloner();
     this.m_Clone = objectCloner.Clone(this.m_Value);
 }
Пример #29
0
        public void InsertDocument(object o, object writer)
        {
            DocumentId documentId = new DocumentId(o, writer);

            DocumentInsert documentInsert = new DocumentInsert(documentId);
            documentInsert.SetLock();
            documentInsert.Submit();

            DocumentUpdate documentUpdate = new DocumentUpdate(documentId);
            this.m_Documents.Add(documentUpdate);
        }
Пример #30
0
        public YellowstonePathology.Business.User.UserPreference PullUserPreference(object writer)
        {
            lock (locker)
            {
                string hostName = Environment.MachineName;
                SqlCommand cmd = new SqlCommand("Select * from tblUserPreference where HostName = @HostName");
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.Add("@HostName", System.Data.SqlDbType.VarChar).Value = hostName;
                GenericDocumentBuilder builder = new GenericDocumentBuilder(cmd, typeof(YellowstonePathology.Business.User.UserPreference));

                DocumentId documentId = new DocumentId(typeof(YellowstonePathology.Business.User.UserPreference), writer, hostName);
                documentId.IsGlobal = true;
                Document document = this.m_Stack.Pull(documentId, builder);

                return (YellowstonePathology.Business.User.UserPreference)document.Value;
            }
        }