private void BuildTestOrderReportDistributionLog(YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder, XElement panelSetOrderElement)
 {
     List<XElement> testOrderReportDistributionLogElements = (from item in panelSetOrderElement.Elements("TestOrderReportDistributionLogCollection")
                                                               select item).ToList<XElement>();
     foreach (XElement testOrderReportDistributionLogElement in testOrderReportDistributionLogElements.Elements("TestOrderReportDistributionLog"))
     {
         YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog();
         YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(testOrderReportDistributionLogElement, testOrderReportDistributionLog);
         xmlPropertyWriter.Write();
         panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);
     }
 }
        private void PublishNext()
        {
            List <YellowstonePathology.Business.Test.PanelSetOrderView> caseList = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetNextCasesToPublish();

            int maxProcessCount = 2;

            if (caseList.Count >= 10)
            {
                maxProcessCount = 10;
            }

            int processCount = 0;

            foreach (YellowstonePathology.Business.Test.PanelSetOrderView view in caseList)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(view.MasterAccessionNo, this);
                YellowstonePathology.Business.Test.PanelSetOrder  panelSetOrder  = accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(view.ReportNo);

                if (panelSetOrder.PanelSetId == 116)
                {
                    this.HandleWHP(accessionOrder, panelSetOrder);
                }

                YellowstonePathology.Business.PanelSet.Model.PanelSetCollection panelSetCollection = YellowstonePathology.Business.PanelSet.Model.PanelSetCollection.GetAll();
                YellowstonePathology.Business.PanelSet.Model.PanelSet           panelSet           = panelSetCollection.GetPanelSet(panelSetOrder.PanelSetId);

                YellowstonePathology.Business.Interface.ICaseDocument caseDocument  = YellowstonePathology.Business.Document.DocumentFactory.GetDocument(accessionOrder, panelSetOrder, Business.Document.ReportSaveModeEnum.Normal);
                YellowstonePathology.Business.OrderIdParser           orderIdParser = new YellowstonePathology.Business.OrderIdParser(panelSetOrder.ReportNo);

                if (panelSetOrder.HoldDistribution == false)
                {
                    if (this.TryDelete(panelSetOrder, caseDocument, orderIdParser) == true)
                    {
                        if (this.TryPublish(caseDocument, accessionOrder, panelSetOrder) == true)
                        {
                            if (panelSetOrder.Distribute == true)
                            {
                                foreach (YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistribution testOrderReportDistribution in panelSetOrder.TestOrderReportDistributionCollection)
                                {
                                    if (testOrderReportDistribution.Distributed == false)
                                    {
                                        YellowstonePathology.Business.ReportDistribution.Model.DistributionResult distributionResult = this.Distribute(testOrderReportDistribution, accessionOrder, panelSetOrder);
                                        if (distributionResult.IsComplete == true)
                                        {
                                            testOrderReportDistribution.TimeOfLastDistribution    = DateTime.Now;
                                            testOrderReportDistribution.ScheduledDistributionTime = null;
                                            testOrderReportDistribution.Distributed = true;

                                            string testOrderReportDistributionLogId = Guid.NewGuid().ToString();
                                            string objectId = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
                                            YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog(testOrderReportDistributionLogId, objectId);
                                            testOrderReportDistributionLog.FromTestOrderReportDistribution(testOrderReportDistribution);
                                            testOrderReportDistributionLog.TimeDistributed = DateTime.Now;
                                            panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("INFO", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                                                                 testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, "TestOrderReportDistribution Distributed");
                                        }
                                        else
                                        {
                                            testOrderReportDistribution.ScheduledDistributionTime = DateTime.Now.AddMinutes(30);
                                            testOrderReportDistribution.Rescheduled        = true;
                                            testOrderReportDistribution.RescheduledMessage = distributionResult.Message;

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("ERROR", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                                                                 testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, distributionResult.Message);

                                            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**", System.Windows.Forms.SystemInformation.UserName, distributionResult.Message);
                                            System.Net.Mail.SmtpClient  client  = new System.Net.Mail.SmtpClient("10.1.2.111");

                                            Uri uri = new Uri("http://tempuri.org/");
                                            System.Net.ICredentials      credentials = System.Net.CredentialCache.DefaultCredentials;
                                            System.Net.NetworkCredential credential  = credentials.GetCredential(uri, "Basic");

                                            client.Credentials = credential;
                                            client.Send(message);
                                        }
                                    }
                                }
                            }

                            panelSetOrder.Published            = true;
                            panelSetOrder.TimeLastPublished    = DateTime.Now;
                            panelSetOrder.ScheduledPublishTime = null;

                            Business.Persistence.DocumentGateway.Instance.Save();
                        }
                    }

                    processCount += 1;
                    if (processCount == maxProcessCount)
                    {
                        break;
                    }
                }
            }

            YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this);
        }
        private void PublishNext()
        {
            List<YellowstonePathology.Business.Test.PanelSetOrderView> caseList = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetNextCasesToPublish();

            int maxProcessCount = 2;
            if (caseList.Count >= 10) maxProcessCount = 10;

            int processCount = 0;

            foreach (YellowstonePathology.Business.Test.PanelSetOrderView view in caseList)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(view.MasterAccessionNo, this);
                YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder = accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(view.ReportNo);

                YellowstonePathology.Business.PanelSet.Model.PanelSetCollection panelSetCollection = YellowstonePathology.Business.PanelSet.Model.PanelSetCollection.GetAll();
                YellowstonePathology.Business.PanelSet.Model.PanelSet panelSet = panelSetCollection.GetPanelSet(panelSetOrder.PanelSetId);

                YellowstonePathology.Business.Interface.ICaseDocument caseDocument = YellowstonePathology.Business.Document.DocumentFactory.GetDocument(accessionOrder, panelSetOrder, Business.Document.ReportSaveModeEnum.Normal);
                YellowstonePathology.Business.OrderIdParser orderIdParser = new YellowstonePathology.Business.OrderIdParser(panelSetOrder.ReportNo);

                if (panelSetOrder.HoldDistribution == false)
                {
                    if (this.TryDelete(panelSetOrder, caseDocument, orderIdParser) == true)
                    {
                        if (this.TryPublish(caseDocument, accessionOrder, panelSetOrder) == true)
                        {
                            if (panelSetOrder.Distribute == true)
                            {
                                foreach (YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistribution testOrderReportDistribution in panelSetOrder.TestOrderReportDistributionCollection)
                                {
                                    if (testOrderReportDistribution.Distributed == false)
                                    {
                                        YellowstonePathology.Business.ReportDistribution.Model.DistributionResult distributionResult = this.Distribute(testOrderReportDistribution, accessionOrder, panelSetOrder);
                                        if (distributionResult.IsComplete == true)
                                        {
                                            testOrderReportDistribution.TimeOfLastDistribution = DateTime.Now;
                                            testOrderReportDistribution.ScheduledDistributionTime = null;
                                            testOrderReportDistribution.Distributed = true;

                                            string testOrderReportDistributionLogId = Guid.NewGuid().ToString();
                                            string objectId = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
                                            YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog(testOrderReportDistributionLogId, objectId);
                                            testOrderReportDistributionLog.FromTestOrderReportDistribution(testOrderReportDistribution);
                                            testOrderReportDistributionLog.TimeDistributed = DateTime.Now;
                                            panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("INFO", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, "TestOrderReportDistribution Distributed");
                                        }
                                        else
                                        {
                                            testOrderReportDistribution.ScheduledDistributionTime = DateTime.Now.AddMinutes(30);
                                            testOrderReportDistribution.Rescheduled = true;
                                            testOrderReportDistribution.RescheduledMessage = distributionResult.Message;

                                            this.m_ReportDistributionLogEntryCollection.AddEntry("ERROR", "Publish Next", testOrderReportDistribution.DistributionType, panelSetOrder.ReportNo, panelSetOrder.MasterAccessionNo,
                                                testOrderReportDistribution.PhysicianName, testOrderReportDistribution.ClientName, distributionResult.Message);

                                            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**", System.Windows.Forms.SystemInformation.UserName, distributionResult.Message);
                                            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");

                                            Uri uri = new Uri("http://tempuri.org/");
                                            System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials;
                                            System.Net.NetworkCredential credential = credentials.GetCredential(uri, "Basic");

                                            client.Credentials = credential;
                                            client.Send(message);
                                        }
                                    }
                                }
                            }

                            this.HandleNotificationEmail(panelSetOrder);

                            panelSetOrder.Published = true;
                            panelSetOrder.TimeLastPublished = DateTime.Now;
                            panelSetOrder.ScheduledPublishTime = null;

                            Business.Persistence.DocumentGateway.Instance.Save();
                        }
                    }

                    processCount += 1;
                    if (processCount == maxProcessCount) break;
                }
            }

            YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this);
        }
Exemplo n.º 4
0
        private void BuildTestOrderReportDistributionLog(YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder, XElement panelSetOrderElement)
        {
            List<XElement> testOrderReportDistributionLogElements = (from item in panelSetOrderElement.Elements("TestOrderReportDistributionLogCollection")
                                                                      select item).ToList<XElement>();

            panelSetOrder.TestOrderReportDistributionLogCollection.RemoveDeleted(testOrderReportDistributionLogElements.Elements("TestOrderReportDistributionLog"));
            foreach (XElement testOrderReportDistributionLogElement in testOrderReportDistributionLogElements.Elements("TestOrderReportDistributionLog"))
            {
                string testOrderReportDistributionLogId = testOrderReportDistributionLogElement.Element("TestOrderReportDistributionLogId").Value;
                YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = null;
                if (panelSetOrder.TestOrderReportDistributionLogCollection.Exists(testOrderReportDistributionLogId) == true)
                {
                    testOrderReportDistributionLog = panelSetOrder.TestOrderReportDistributionLogCollection.Get(testOrderReportDistributionLogId);
                }
                else
                {
                    testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog();
                    panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);
                }

                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(testOrderReportDistributionLogElement, testOrderReportDistributionLog);
                xmlPropertyWriter.Write();
            }
        }
Exemplo n.º 5
0
        private void BuildTestOrderReportDistributionLog(YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder, XElement panelSetOrderElement)
        {
            List <XElement> testOrderReportDistributionLogElements = (from item in panelSetOrderElement.Elements("TestOrderReportDistributionLogCollection")
                                                                      select item).ToList <XElement>();

            foreach (XElement testOrderReportDistributionLogElement in testOrderReportDistributionLogElements.Elements("TestOrderReportDistributionLog"))
            {
                YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog testOrderReportDistributionLog = new YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionLog();
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(testOrderReportDistributionLogElement, testOrderReportDistributionLog);
                xmlPropertyWriter.Write();
                panelSetOrder.TestOrderReportDistributionLogCollection.Add(testOrderReportDistributionLog);
            }
        }