public static List <YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView> GetPhysicianClientDistributions(int physicianClientId) { List <YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView> result = new List <YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView>(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); MongoCollection physicianClientDistributionCollection = server.Database.GetCollection <BsonDocument>("PhysicianClientDistribution"); MongoCursor physicianClientDistributionCursor = physicianClientDistributionCollection.FindAs <BsonDocument>(Query.EQ("PhysicianClientID", BsonValue.Create(physicianClientId))); foreach (BsonDocument physicianClientDistributionDocument in physicianClientDistributionCursor) { BsonDocument physicianClientDocument = physicianClientCollection.FindOneAs <BsonDocument>(Query.EQ("PhysicianClientId", physicianClientDistributionDocument.GetValue("DistributionID"))); BsonDocument clientDocument = clientCollection.FindOneAs <BsonDocument>(Query.EQ("ClientId", physicianClientDocument.GetValue("ClientId"))); BsonDocument physicianDocument = physicianCollection.FindOneAs <BsonDocument>(Query.EQ("PhysicianId", physicianClientDocument.GetValue("PhysicianId"))); YellowstonePathology.Business.Client.Model.PhysicianClientDistribution physicianClientDistribution = (YellowstonePathology.Business.Client.Model.PhysicianClientDistribution)Mongo.BSONObjectBuilder.Build(physicianClientDistributionDocument, typeof(YellowstonePathology.Business.Client.Model.PhysicianClientDistribution)); YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView physicianClientDistributionView = new YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView(physicianClientDistribution); physicianClientDistributionView.ClientId = clientDocument.GetValue("ClientId").AsInt32; physicianClientDistributionView.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName")); physicianClientDistributionView.DistributionType = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("DistributionType")); physicianClientDistributionView.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianClientDistributionView.PhysicianName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("DisplayName")); result.Add(physicianClientDistributionView); } return(result); }
public static YellowstonePathology.Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByClientId(int clientId) { Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); BsonDocument clientDocument = clientCollection.FindOneAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); List <BsonValue> physicianIdList = new List <BsonValue>(); foreach (BsonDocument physicianClientDocument in physicianClientCursor) { physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId")); } MongoCursor physicianCursor = physicianCollection.FindAs <BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument); result.Add(physicianClientDistribution); } return(result); }
public static Domain.PhysicianCollection GetPhysiciansByName(string firstName, string lastName) { YellowstonePathology.Business.Domain.PhysicianCollection result = new YellowstonePathology.Business.Domain.PhysicianCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Physician"); MongoCursor cursor = null; if (string.IsNullOrEmpty(firstName) == false) { cursor = collection.FindAs <BsonDocument>(Query.And(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i")), Query.Matches("FirstName", BsonRegularExpression.Create("^" + firstName + ".*", "i")))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); } else { cursor = collection.FindAs <BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); } foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Domain.Physician physician = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician); result.Add(physician); } return(result); }
public static void ExtendCytologyDocuments() { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>("PanelSetOrder"); SqlCommand cmdPSO = new SqlCommand(); cmdPSO.CommandText = "Select * from tblPanelSetOrder pso join tblPanelSetOrderCytology psoc on pso.ReportNo = psoc.ReportNo"; cmdPSO.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmdPSO.Connection = cn; using (SqlDataReader dr = cmdPSO.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonPSO = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); bsonPSO.Add("ExtendedFrom", "PanelSetOrderCytology"); bsonPSO.Add("HasBeenExtended", true); string reportNo = bsonPSO.GetValue("ReportNo").AsString; WritePODocument(reportNo, bsonPSO); mongoCollection.Save(bsonPSO); } } } }
public static List <YellowstonePathology.Business.Test.PanelSetOrderView> GetCasesToSchedule() { List <YellowstonePathology.Business.Test.PanelSetOrderView> result = new List <Test.PanelSetOrderView>(); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("AccessionOrder"); MongoCursor cursor = collection.FindAs <BsonDocument>(Query.ElemMatch("PanelSetOrderCollection", Query.And(Query.EQ("Final", BsonValue.Create(true)), Query.EQ("ScheduledPublishTime", BsonNull.Value), Query.EQ("Published", BsonValue.Create(false))))); foreach (BsonDocument accessionOrders in cursor) { BsonArray panelSetOrders = accessionOrders.GetValue("PanelSetOrderCollection").AsBsonArray; foreach (BsonDocument panelSetOrderDocument in panelSetOrders) { if (panelSetOrderDocument.GetValue("Final").AsBoolean == true && panelSetOrderDocument.GetValue("Published").AsBoolean == false && panelSetOrderDocument.GetValue("ScheduledPublishTime").IsBsonNull) { YellowstonePathology.Business.Test.PanelSetOrderView panelSetOrderView = (YellowstonePathology.Business.Test.PanelSetOrderView)Mongo.BSONObjectBuilder.Build(panelSetOrderDocument, typeof(YellowstonePathology.Business.Test.PanelSetOrderView)); result.Add(panelSetOrderView); } } } return(result); }
public static void ExtendDocuments(Transfer transfer) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(transfer.BaseTableName.Substring(3)); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from " + transfer.BaseTableName + " btn join " + transfer.TableName + " dtn on btn." + transfer.PrimaryKeyName + " = dtn." + transfer.PrimaryKeyName; cmd.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); bsonDocument.Add("ExtendedFrom", transfer.TableName); bsonDocument.Add("HasBeenExtended", true); mongoCollection.Save(bsonDocument); } } } }
private static List <YellowstonePathology.Business.Test.PanelSetOrderView> GetCasesWithQualifyingScheduledDistributionTime(BsonValue currentDate) { List <YellowstonePathology.Business.Test.PanelSetOrderView> result = new List <Test.PanelSetOrderView>(); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("AccessionOrder"); MongoCursor accessionOrderCursor = collection.FindAs <BsonDocument>(Query.ElemMatch("PanelSetOrderCollection", Query.And(Query.EQ("Final", BsonValue.Create(true)), Query.LTE("TestOrderReportDistributionCollection.ScheduledDistributionTime", currentDate)))); foreach (BsonDocument accessionOrderDocument in accessionOrderCursor) { BsonArray panelSetOrders = accessionOrderDocument.GetValue("PanelSetOrderCollection").AsBsonArray; foreach (BsonDocument panelSetOrderDocument in panelSetOrders) { if (panelSetOrderDocument.GetValue("Final").AsBoolean == true) { BsonArray testOrderReportDistributions = panelSetOrderDocument.GetValue("TestOrderReportDistributionCollection").AsBsonArray; foreach (BsonDocument testOrderReportDistributionDocument in testOrderReportDistributions) { if (testOrderReportDistributionDocument.GetValue("ScheduledDistributionTime").IsBsonNull == false && testOrderReportDistributionDocument.GetValue("ScheduledDistributionTime") <= currentDate) { YellowstonePathology.Business.Test.PanelSetOrderView panelSetOrderView = (YellowstonePathology.Business.Test.PanelSetOrderView)Mongo.BSONObjectBuilder.Build(panelSetOrderDocument, typeof(YellowstonePathology.Business.Test.PanelSetOrderView)); result.Add(panelSetOrderView); } } } } } return(result); }
public static void BuildIndexes(string tableName, string collectionName, string databaseName) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(collectionName); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT col.name " + "FROM sys.indexes ind " + "INNER JOIN sys.index_columns ic ON ind.object_id = ic.object_id and ind.index_id = ic.index_id " + "INNER JOIN sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id " + "INNER JOIN sys.tables t ON ind.object_id = t.object_id " + "WHERE t.Name = '" + tableName + "'"; cmd.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { mongoCollection.CreateIndex(dr.GetString(0)); } } } }
public static void TransferTableToMongo(string tableName, string databaseName, string collectionName, System.ComponentModel.BackgroundWorker backgroundWorker) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from " + tableName; cmd.CommandType = CommandType.Text; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(collectionName); using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; int transferredRowCount = 1; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); mongoCollection.Insert(bsonDocument); if (transferredRowCount > 100 && transferredRowCount % 1000 == 0) { backgroundWorker.ReportProgress(0, "Transfering " + tableName + ", " + transferredRowCount.ToString() + " rows transferred."); } transferredRowCount += 1; } } } }
public static void Synchronize(string tableName, string databaseName, string collectionName) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from " + tableName + " where [TimeStamp] > " + "(SELECT convert(int, ep.value) " + "FROM sys.extended_properties AS ep " + "INNER JOIN sys.tables AS t ON ep.major_id = t.object_id " + "INNER JOIN sys.columns AS c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id " + "WHERE class = 1 and t.Name = '" + tableName + "' and c.Name = 'TimeStamp' and ep.Name = 'TransferDBTS')"; cmd.CommandType = CommandType.Text; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); BsonObjectId bsonObjectId = (BsonObjectId)bsonDocument.GetValue("_id"); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(collectionName); mongoCollection.Update(Query.EQ("_id", bsonObjectId), Update.Replace(bsonDocument), UpdateFlags.Upsert); } } } }
public static View.ClientPhysicianView GetClientPhysicianViewByClientId(int clientId) { YellowstonePathology.Business.View.ClientPhysicianView result = new YellowstonePathology.Business.View.ClientPhysicianView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); BsonDocument clientBsonDocument = clientCollection.FindOneAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(clientBsonDocument, result); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); List <BsonValue> physicianIdList = new List <BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { physicianIdList.Add(bsonDocument.GetValue("PhysicianId")); } MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician"); MongoCursor physicianCursor = physicianCollection.FindAs <BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("FirstName")); foreach (BsonDocument bsonDocument in physicianCursor) { YellowstonePathology.Business.Domain.Physician physician = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician); result.Physicians.Add(physician); } return(result); }
public static Domain.ClientCollection GetClientsByPhysicianId(int physicianId) { Domain.ClientCollection result = new Domain.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); List <BsonValue> clientIdList = new List <BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { clientIdList.Add(bsonDocument.GetValue("ClientId").AsInt32); } MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs <BsonDocument>(Query.In("ClientId", clientIdList)); foreach (BsonDocument bsonDocument in clientCursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); result.Add(client); } return(result); }
public static void AddAllSQLTables(YellowstonePathology.Business.Mongo.TransferCollection transferCollection) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT Table_Name, Column_Name " + "FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE " + "WHERE OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1 " + "AND table_name like 'tbl%'"; cmd.CommandType = CommandType.Text; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename); using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { YellowstonePathology.Business.Mongo.Transfer transfer = new Transfer(); transfer.ObjectId = BsonObjectId.GenerateNewId().ToString(); transfer.TableName = dr.GetString(0); transfer.PrimaryKeyName = dr.GetString(1); transferCollection.Add(transfer); } } } }
public static View.PhysicianClientView GetPhysicianClientView(int physicianId) { View.PhysicianClientView physicianClientView = new View.PhysicianClientView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician"); BsonDocument physicianDocument = physicianCollection.FindOneAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(physicianDocument, physicianClientView); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianClientView.PhysicianId))); List <BsonValue> clientIdList = new List <BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { clientIdList.Add(bsonDocument.GetValue("ClientId")); } MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs <BsonDocument>(Query.In("ClientId", clientIdList)); foreach (BsonDocument bsonDocument in clientCursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); physicianClientView.Clients.Add(client); } return(physicianClientView); }
public static Flow.FlowLogList GetByAccessionMonth(DateTime date) { YellowstonePathology.Business.Flow.FlowLogList result = new YellowstonePathology.Business.Flow.FlowLogList(); List<BsonValue> values = new List<BsonValue>(); values.Add(BsonValue.Create(19)); values.Add(BsonValue.Create(143)); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection<BsonDocument>("AccessionOrder"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.And(Query.GTE("AccessionDate", BsonValue.Create(date)), Query.LT("AccessionDate", BsonValue.Create(date.AddMonths(1))), Query.ElemMatch("PanelSetOrderCollection", Query.And(Query.EQ("CaseType", BsonValue.Create("Flow Cytometry")), Query.NotIn("PanelSetId", values))))) .SetSortOrder(SortBy.Descending("AccessionDate", "PanelSetOrderCollection.ReportNo")); foreach (BsonDocument bsonDocument in cursor) { foreach (BsonDocument panelSetDocument in bsonDocument.GetValue("PanelSetOrderCollection").AsBsonArray) { int panelSetId = panelSetDocument.GetValue("PanelSetId").AsInt32; if (panelSetDocument.GetValue("CaseType").AsString == "Flow Cytometry" && panelSetId != 19 && panelSetId != 143) { YellowstonePathology.Business.Flow.FlowLogListItem flowLogListItem = BuildFlowLog(bsonDocument, panelSetDocument); result.Add(flowLogListItem); break; } } } return result; }
public static long GetExtendedDocumentCount(Transfer transfer) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename); MongoCollection collection = server.Database.GetCollection <BsonDocument>(transfer.TableName); long count = collection.Count(Query.And(Query.EQ("HasBeenExtended", true), Query.EQ("ExtendedFrom", transfer.TableName))); return(count); }
public static YellowstonePathology.Business.Test.AccessionOrder GetAccessionOrderByMasterAccessionNo(string masterAccessionNo) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>("AccessionOrder"); BsonDocument bsonDocument = mongoCollection.FindOneAs <BsonDocument>(Query.EQ("MasterAccessionNo", BsonValue.Create(masterAccessionNo))); YellowstonePathology.Business.Test.AccessionOrder accessionOrder = (YellowstonePathology.Business.Test.AccessionOrder)YellowstonePathology.Business.Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Test.AccessionOrder)); return(accessionOrder); }
public static YellowstonePathology.Business.Test.AccessionOrderView GetAccessionOrderView(string masterAccessionNo) { YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("AccessionOrder"); BsonDocument bsonDocument = collection.FindOneAs <BsonDocument>(Query.EQ("MasterAccessionNo", BsonValue.Create(masterAccessionNo))); YellowstonePathology.Business.Test.AccessionOrderView result = (YellowstonePathology.Business.Test.AccessionOrderView)Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Test.AccessionOrderView)); return(result); }
public static Test.AccessionOrder GetAccessionOrderByReportNo(string reportNo) { YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("AccessionOrder"); BsonDocument bsonDocument = collection.FindOneAs <BsonDocument>(Query.EQ("PanelSetOrderCollection.ReportNo", BsonValue.Create(reportNo))); YellowstonePathology.Business.Test.AccessionOrder result = (YellowstonePathology.Business.Test.AccessionOrder)Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Test.AccessionOrder)); return(result); }
public static YellowstonePathology.Business.Client.Model.Client GetClientByClientId(int clientId) { YellowstonePathology.Business.Client.Model.Client result = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Client"); BsonDocument bsonDocument = collection.FindOneAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, result); return result; }
public static YellowstonePathology.Business.Client.Model.Client GetClientByClientId(int clientId) { YellowstonePathology.Business.Client.Model.Client result = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Client"); BsonDocument bsonDocument = collection.FindOneAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, result); return(result); }
public static Domain.Physician GetPhysicianByNpi(string npi) { YellowstonePathology.Business.Domain.Physician result = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Physician"); BsonDocument bsonDocument = collection.FindOneAs <BsonDocument>(Query.EQ("Npi", BsonValue.Create(npi))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, result); return(result); }
public static long GetMongoDocumentCount(string collectionName, string databaseName) { long result = 0; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(collectionName); result = mongoCollection.Count(); return(result); }
public static int GetMongoIndexCount(string collectionName, string databaseName) { int result = 0; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(collectionName); GetIndexesResult getIndexesResult = mongoCollection.GetIndexes(); result = getIndexesResult.Count; return(result); }
public static void DeletePSOIHCollections() { List <string> psoihList = GetPSOInheritedCollectionNames(); foreach (string s in psoihList) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection <BsonDocument>(s); mongoCollection.Drop(); } }
public static YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection GetPhysicianClientNameCollection(string clientName, string physicianName) { YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection result = new YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs <BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))).SetSortOrder(SortBy.Ascending("ClientName")); string physicianClientId = string.Empty; long count = clientCursor.Count(); foreach (BsonDocument clientDocument in clientCursor) { BsonValue clientId = clientDocument.GetValue("ClientId"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("ClientId", clientId)); List <BsonValue> physicianIdList = new List <BsonValue>(); foreach (BsonDocument physicianClientDocument in physicianClientCursor) { physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId")); } MongoCursor physicianCursor = physicianCollection.FindAs <BsonDocument>(Query.And(Query.In("PhysicianId", physicianIdList), Query.Matches("LastName", BsonRegularExpression.Create("^" + physicianName + ".*", "i")))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { foreach (BsonDocument physicianClientDocument in physicianClientCursor) { if (physicianClientDocument.GetValue("PhysicianId").Equals(physicianDocument.GetValue("PhysicianId")) && physicianClientDocument.GetValue("ClientId").Equals(clientId)) { physicianClientId = Mongo.ValueHelper.GetStringValue(physicianClientDocument.GetValue("PhysicianClientId")); break; } } YellowstonePathology.Business.Client.Model.PhysicianClientName physicianClientName = new YellowstonePathology.Business.Client.Model.PhysicianClientName(); physicianClientName.ClientId = clientId.AsInt32; physicianClientName.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName")); physicianClientName.Fax = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax")); physicianClientName.FirstName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("FirstName")); physicianClientName.LastName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("LastName")); physicianClientName.PhysicianClientId = physicianClientId; physicianClientName.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianClientName.Telephone = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Telephone")); result.Add(physicianClientName); } } return(result); }
public static void DropMongoCollection(string tableName) { YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.SQLTransferDatabasename); MongoCollection transferCollection = transferServer.Database.GetCollection <BsonDocument>(tableName); transferCollection.Drop(); YellowstonePathology.Business.Mongo.Server lisServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection lisCollection = lisServer.Database.GetCollection <BsonDocument>(tableName.Substring(3)); lisCollection.Drop(); }
public static YellowstonePathology.Business.Client.Model.ClientCollection GetClientsByClientName(string clientName) { YellowstonePathology.Business.Client.Model.ClientCollection result = new YellowstonePathology.Business.Client.Model.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor cursor = collection.FindAs <BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Client.Model.Client client = (YellowstonePathology.Business.Client.Model.Client)YellowstonePathology.Business.Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Client.Model.Client)); result.Add(client); } return(result); }
public static View.ClientSearchView GetClientSearchViewByClientName(string clientName) { YellowstonePathology.Business.View.ClientSearchView result = new YellowstonePathology.Business.View.ClientSearchView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor cursor = collection.FindAs <BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))).SetSortOrder(SortBy.Ascending("ClientName")); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.View.ClientSearchViewItem clientSearchViewItem = new YellowstonePathology.Business.View.ClientSearchViewItem(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, clientSearchViewItem); result.Add(clientSearchViewItem); } return(result); }
public static YellowstonePathology.Business.Typing.TypingShortcutCollection GetTypingShortcutCollectionByUser(int userId) { YellowstonePathology.Business.Typing.TypingShortcutCollection result = new Typing.TypingShortcutCollection(); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("TypingShortcut"); MongoCursor cursor = collection.FindAs <BsonDocument>(Query.EQ("UserId", BsonValue.Create(userId))).SetSortOrder(SortBy.Ascending("Shortcut")); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Typing.TypingShortcut typingShortcut = new YellowstonePathology.Business.Typing.TypingShortcut(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, typingShortcut); result.Add(typingShortcut); } return(result); }
public static YellowstonePathology.Business.NeogenomicsResultCollection GetNeogenomicsResultCollection() { YellowstonePathology.Business.NeogenomicsResultCollection result = new YellowstonePathology.Business.NeogenomicsResultCollection(); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("NeogenomicsResult"); MongoCursor cursor = collection.FindAllAs <BsonDocument>().SetSortOrder(SortBy.Descending("DateResultReceived")); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.NeogenomicsResult neogenomicsResult = new YellowstonePathology.Business.NeogenomicsResult(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, neogenomicsResult); result.Add(neogenomicsResult); } return(result); }
public static YellowstonePathology.Business.Client.Model.ClientGroupCollection GetClientGroupCollection() { YellowstonePathology.Business.Client.Model.ClientGroupCollection result = new Client.Model.ClientGroupCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("ClientGroup"); MongoCursor cursor = collection.FindAllAs<BsonDocument>(); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Client.Model.ClientGroup clientGroup = new Client.Model.ClientGroup(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, clientGroup); result.Add(clientGroup); } return result; }
public static YellowstonePathology.Business.Client.Model.ClientCollection GetAllClients() { YellowstonePathology.Business.Client.Model.ClientCollection result = new YellowstonePathology.Business.Client.Model.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection <BsonDocument>("Client"); MongoCursor cursor = collection.FindAllAs <BsonDocument>(); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); result.Add(client); } return(result); }
public static View.ClientLocationViewCollection GetClientLocationViewByClientName(string clientName) { YellowstonePathology.Business.View.ClientLocationViewCollection result = new View.ClientLocationViewCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))); foreach (BsonDocument bsonDocument in cursor) { BsonArray locations = bsonDocument.GetValue("ClientLocationCollection").AsBsonArray; foreach (BsonDocument location in locations) { YellowstonePathology.Business.View.ClientLocationView clientLocationView = new View.ClientLocationView(bsonDocument.GetValue("ClientId").AsInt32, location.GetValue("ClientLocationId").AsInt32, Mongo.ValueHelper.GetStringValue(bsonDocument.GetValue("ClientName")), Mongo.ValueHelper.GetStringValue(location.GetValue("Location"))); result.Add(clientLocationView); } } return result; }
public static Flow.FlowLogList GetByLeukemiaNotFinal() { YellowstonePathology.Business.Flow.FlowLogList result = new YellowstonePathology.Business.Flow.FlowLogList(); YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = transferServer.Database.GetCollection<BsonDocument>("AccessionOrder"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.ElemMatch("PanelSetOrderCollection", Query.And(Query.EQ("PanelSetId", BsonValue.Create(20)), Query.EQ("Final", BsonValue.Create(false))))) .SetSortOrder(SortBy.Descending("AccessionDate", "PanelSetOrderCollection.ReportNo")); foreach (BsonDocument bsonDocument in cursor) { foreach (BsonDocument panelSetDocument in bsonDocument.GetValue("PanelSetOrderCollection").AsBsonArray) { if (panelSetDocument.GetValue("PanelSetId").AsInt32 == 20) { YellowstonePathology.Business.Flow.FlowLogListItem flowLogListItem = BuildFlowLog(bsonDocument, panelSetDocument); result.Add(flowLogListItem); } } } return result; }
public static long GetExtendedDocumentCount(Transfer transfer) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename); MongoCollection collection = server.Database.GetCollection<BsonDocument>(transfer.TableName); long count = collection.Count(Query.And(Query.EQ("HasBeenExtended", true), Query.EQ("ExtendedFrom", transfer.TableName))); return count; }
public static View.PhysicianClientView GetPhysicianClientView(int physicianId) { View.PhysicianClientView physicianClientView = new View.PhysicianClientView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); BsonDocument physicianDocument = physicianCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(physicianDocument, physicianClientView); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianClientView.PhysicianId))); List<BsonValue> clientIdList = new List<BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { clientIdList.Add(bsonDocument.GetValue("ClientId")); } MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)); foreach (BsonDocument bsonDocument in clientCursor) { YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, client); physicianClientView.Clients.Add(client); } return physicianClientView; }
public static Business.Client.Model.PhysicianClientDistributionList GetPhysicianClientDistributionByPhysicianFirstLastName(string firstName, string lastName) { Business.Client.Model.PhysicianClientDistributionList result = new Client.Model.PhysicianClientDistributionList(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.And(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i")), Query.Matches("FirstName", BsonRegularExpression.Create("^" + firstName + ".*", "i")))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", physicianDocument.GetValue("PhysicianId"))); List<BsonValue> clientIdList = new List<BsonValue>(); foreach (BsonDocument physicianClientDocument in physicianClientCursor) { clientIdList.Add(physicianClientDocument.GetValue("ClientId")); } MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)).SetSortOrder(SortBy.Ascending("ClientName")); foreach (BsonDocument clientDocument in clientCursor) { YellowstonePathology.Business.Client.Model.PhysicianClientDistributionListItem physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument); result.Add(physicianClientDistribution); } } return result; }
public static View.ClientSearchView GetClientSearchViewByClientName(string clientName) { YellowstonePathology.Business.View.ClientSearchView result = new YellowstonePathology.Business.View.ClientSearchView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))).SetSortOrder(SortBy.Ascending("ClientName")); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.View.ClientSearchViewItem clientSearchViewItem = new YellowstonePathology.Business.View.ClientSearchViewItem(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, clientSearchViewItem); result.Add(clientSearchViewItem); } return result; }
public static YellowstonePathology.Business.Test.AccessionOrder GetAccessionOrderByMasterAccessionNo(string masterAccessionNo) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>("AccessionOrder"); BsonDocument bsonDocument = mongoCollection.FindOneAs<BsonDocument>(Query.EQ("MasterAccessionNo", BsonValue.Create(masterAccessionNo))); YellowstonePathology.Business.Test.AccessionOrder accessionOrder = (YellowstonePathology.Business.Test.AccessionOrder)YellowstonePathology.Business.Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Test.AccessionOrder)); return accessionOrder; }
public static Domain.PhysicianCollection GetPhysiciansByClientId(int clientId) { Domain.PhysicianCollection result = new Domain.PhysicianCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); List<BsonValue> physicianIdList = new List<BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { physicianIdList.Add(bsonDocument.GetValue("PhysicianId")); } MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.In("PhysicianId", physicianIdList)); foreach (BsonDocument bsonDocument in physicianCursor) { Domain.Physician physician = new Domain.Physician(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician); result.Add(physician); } return result; }
public static YellowstonePathology.Business.Client.Model.ClientCollection GetClientsByClientName(string clientName) { YellowstonePathology.Business.Client.Model.ClientCollection result = new YellowstonePathology.Business.Client.Model.ClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Client.Model.Client client = (YellowstonePathology.Business.Client.Model.Client)YellowstonePathology.Business.Mongo.BSONObjectBuilder.Build(bsonDocument, typeof(YellowstonePathology.Business.Client.Model.Client)); result.Add(client); } return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianClientCollection GetPhysicianClientListByClientId(int clientId) { YellowstonePathology.Business.Client.Model.PhysicianClientCollection result = new Client.Model.PhysicianClientCollection(); BsonValue bsonClientId = BsonValue.Create(clientId); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); BsonDocument clientDocument = clientCollection.FindOneAs<BsonDocument>(Query.EQ("ClientId", bsonClientId)); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", bsonClientId)); List<BsonValue> physicianIdList = new List<BsonValue>(); foreach (BsonDocument physicianClientDocument in physicianClientCursor) { physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId")); } MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); BsonValue bsonPhysicianClientId = null; foreach (BsonDocument physicianDocument in physicianCursor) { foreach (BsonDocument physicianClientDocument in physicianClientCursor) { if (physicianClientDocument.GetValue("PhysicianId").Equals(physicianDocument.GetValue("PhysicianId"))) { bsonPhysicianClientId = physicianClientDocument.GetValue("PhysicianClientId"); break; } } YellowstonePathology.Business.Client.Model.PhysicianClient physicianClient = BuildPhysicianClient(clientDocument, physicianDocument, bsonPhysicianClientId); result.Add(physicianClient); } return result; }
public static Domain.Physician GetPhysicianByPhysicianId(int physicianId) { YellowstonePathology.Business.Domain.Physician result = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Physician"); BsonDocument bsonDocument = collection.FindOneAs<BsonDocument>(Query.EQ("PhysicianId", BsonValue.Create(physicianId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, result); return result; }
public static void ExtendDocuments(Transfer transfer) { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(transfer.BaseTableName.Substring(3)); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from " + transfer.BaseTableName + " btn join " + transfer.TableName + " dtn on btn." + transfer.PrimaryKeyName + " = dtn." + transfer.PrimaryKeyName; cmd.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); bsonDocument.Add("ExtendedFrom", transfer.TableName); bsonDocument.Add("HasBeenExtended", true); mongoCollection.Save(bsonDocument); } } } }
public static List<YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView> GetPhysicianClientDistributions(int physicianClientId) { List<YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView> result = new List<YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView>(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCollection physicianClientDistributionCollection = server.Database.GetCollection<BsonDocument>("PhysicianClientDistribution"); MongoCursor physicianClientDistributionCursor = physicianClientDistributionCollection.FindAs<BsonDocument>(Query.EQ("PhysicianClientID", BsonValue.Create(physicianClientId))); foreach(BsonDocument physicianClientDistributionDocument in physicianClientDistributionCursor) { BsonDocument physicianClientDocument = physicianClientCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianClientId", physicianClientDistributionDocument.GetValue("DistributionID"))); BsonDocument clientDocument = clientCollection.FindOneAs<BsonDocument>(Query.EQ("ClientId", physicianClientDocument.GetValue("ClientId"))); BsonDocument physicianDocument = physicianCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianId", physicianClientDocument.GetValue("PhysicianId"))); YellowstonePathology.Business.Client.Model.PhysicianClientDistribution physicianClientDistribution = (YellowstonePathology.Business.Client.Model.PhysicianClientDistribution)Mongo.BSONObjectBuilder.Build(physicianClientDistributionDocument, typeof(YellowstonePathology.Business.Client.Model.PhysicianClientDistribution)); YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView physicianClientDistributionView = new YellowstonePathology.Business.Client.Model.PhysicianClientDistributionView(physicianClientDistribution); physicianClientDistributionView.ClientId = clientDocument.GetValue("ClientId").AsInt32; physicianClientDistributionView.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName")); physicianClientDistributionView.DistributionType = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("DistributionType")); physicianClientDistributionView.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianClientDistributionView.PhysicianName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("DisplayName")); result.Add(physicianClientDistributionView); } return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianClientCollection GetPhysicianClientListByPhysicianLastName(string physicianLastName) { YellowstonePathology.Business.Client.Model.PhysicianClientCollection result = new Client.Model.PhysicianClientCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + physicianLastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { BsonValue physicianId = physicianDocument.GetValue("PhysicianId"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", physicianId)); List<BsonValue> clientIdList = new List<BsonValue>(); foreach(BsonDocument physicianClientDocument in physicianClientCursor) { clientIdList.Add(physicianClientDocument.GetValue("ClientId")); } MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)).SetSortOrder(SortBy.Ascending("ClientName")); foreach (BsonDocument clientDocument in clientCursor) { BsonValue physicianClientId = null; foreach(BsonDocument physicianClientDocument in physicianClientCursor) { if(physicianClientDocument.GetValue("ClientId").Equals(clientDocument.GetValue("ClientId"))) { physicianClientId = physicianClientDocument.GetValue("PhysicianClientId"); break; } } YellowstonePathology.Business.Client.Model.PhysicianClient physicianClient = BuildPhysicianClient(clientDocument, physicianDocument, physicianClientId); result.Add(physicianClient); } } return result; }
public static long GetMongoDocumentCount(string collectionName, string databaseName) { long result = 0; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(collectionName); result = mongoCollection.Count(); return result; }
public static void ExtendCytologyDocuments() { YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>("PanelSetOrder"); SqlCommand cmdPSO = new SqlCommand(); cmdPSO.CommandText = "Select * from tblPanelSetOrder pso join tblPanelSetOrderCytology psoc on pso.ReportNo = psoc.ReportNo"; cmdPSO.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmdPSO.Connection = cn; using (SqlDataReader dr = cmdPSO.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonPSO = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); bsonPSO.Add("ExtendedFrom", "PanelSetOrderCytology"); bsonPSO.Add("HasBeenExtended", true); string reportNo = bsonPSO.GetValue("ReportNo").AsString; WritePODocument(reportNo, bsonPSO); mongoCollection.Save(bsonPSO); } } } }
public static YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection GetPhysicianClientNameCollection(string clientName, string physicianName) { YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection result = new YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.Matches("ClientName", BsonRegularExpression.Create("^" + clientName + ".*", "i"))).SetSortOrder(SortBy.Ascending("ClientName")); string physicianClientId = string.Empty; long count = clientCursor.Count(); foreach (BsonDocument clientDocument in clientCursor) { BsonValue clientId = clientDocument.GetValue("ClientId"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", clientId)); List<BsonValue> physicianIdList = new List<BsonValue>(); foreach (BsonDocument physicianClientDocument in physicianClientCursor) { physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId")); } MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.And(Query.In("PhysicianId", physicianIdList), Query.Matches("LastName", BsonRegularExpression.Create("^" + physicianName + ".*", "i")))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { foreach (BsonDocument physicianClientDocument in physicianClientCursor) { if (physicianClientDocument.GetValue("PhysicianId").Equals(physicianDocument.GetValue("PhysicianId")) && physicianClientDocument.GetValue("ClientId").Equals(clientId)) { physicianClientId = Mongo.ValueHelper.GetStringValue(physicianClientDocument.GetValue("PhysicianClientId")); break; } } YellowstonePathology.Business.Client.Model.PhysicianClientName physicianClientName = new YellowstonePathology.Business.Client.Model.PhysicianClientName(); physicianClientName.ClientId = clientId.AsInt32; physicianClientName.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName")); physicianClientName.Fax = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax")); physicianClientName.FirstName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("FirstName")); physicianClientName.LastName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("LastName")); physicianClientName.PhysicianClientId = physicianClientId; physicianClientName.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianClientName.Telephone = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Telephone")); result.Add(physicianClientName); } } return result; }
public static int GetMongoIndexCount(string collectionName, string databaseName) { int result = 0; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(collectionName); GetIndexesResult getIndexesResult = mongoCollection.GetIndexes(); result = getIndexesResult.Count; return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection GetPhysicianClientNameCollection(string physicianClientId) { YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection result = new YellowstonePathology.Business.Client.Model.PhysicianClientNameCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); BsonDocument pcDocument = physicianClientCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianClientId", physicianClientId)); BsonValue physicianId = pcDocument.GetValue("PhysicianId"); BsonDocument physicianDocument = physicianCollection.FindOneAs<BsonDocument>(Query.EQ("PhysicianId", physicianId)); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", physicianId)); List<BsonValue> clientIdList = new List<BsonValue>(); foreach(BsonDocument physicianClientDocument in physicianClientCursor) { clientIdList.Add(physicianClientDocument.GetValue("ClientId")); } MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)).SetSortOrder(SortBy.Ascending("ClientName")); foreach(BsonDocument clientDocument in clientCursor) { foreach (BsonDocument physicianClientDocument in physicianClientCursor) { if (physicianClientDocument.GetValue("ClientId").Equals(clientDocument.GetValue("ClientId"))) { physicianClientId = Mongo.ValueHelper.GetStringValue(physicianClientDocument.GetValue("PhysicianClientId")); break; } } YellowstonePathology.Business.Client.Model.PhysicianClientName physicianClientName = new YellowstonePathology.Business.Client.Model.PhysicianClientName(); physicianClientName.ClientId = clientDocument.GetValue("ClientId").AsInt32; physicianClientName.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName")); physicianClientName.Fax = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax")); physicianClientName.FirstName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("FirstName")); physicianClientName.LastName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("LastName")); physicianClientName.PhysicianClientId = physicianClientId; physicianClientName.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianClientName.Telephone = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Telephone")); result.Add(physicianClientName); } return result; }
public static Business.ReportDistribution.Model.ReportDistributionLogEntryCollection GetReportDistributionLogEntryCollectionGTETime(DateTime startTime) { Business.ReportDistribution.Model.ReportDistributionLogEntryCollection result = new ReportDistribution.Model.ReportDistributionLogEntryCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("ReportDistributionLogEntry"); BsonDateTime bsonStartDate = BsonDateTime.Create(startTime); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.GTE("Date", bsonStartDate.ToUniversalTime())); foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.ReportDistribution.Model.ReportDistributionLogEntry reportDistributionLogEntry = new ReportDistribution.Model.ReportDistributionLogEntry(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, reportDistributionLogEntry); result.Add(reportDistributionLogEntry); } return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianNameViewCollection GetPhysicianNameViewCollectionByPhysicianLastName(string physicianLastName) { YellowstonePathology.Business.Client.Model.PhysicianNameViewCollection result = new YellowstonePathology.Business.Client.Model.PhysicianNameViewCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCursor cursor = collection.FindAs<BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + physicianLastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("FirstName")); foreach (BsonDocument physicianDocument in cursor) { BsonDocument clientDocument = clientCollection.FindOneAs<BsonDocument>(Query.EQ("ClientId", physicianDocument.GetValue("HomeBaseClientId"))); YellowstonePathology.Business.Client.Model.PhysicianNameView physicianNameView = new YellowstonePathology.Business.Client.Model.PhysicianNameView(); physicianNameView.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32; physicianNameView.FirstName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("FirstName")); physicianNameView.LastName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("LastName")); physicianNameView.HomeBaseFax = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax")); physicianNameView.HomeBasePhone = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Telephone")); result.Add(physicianNameView); } return result; }
public static TransferCollection GetTransferCollection() { TransferCollection result = new TransferCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Transfer"); MongoCursor cursor = collection.FindAllAs(typeof(BsonDocument)).SetSortOrder(SortBy.Ascending("TableName")); foreach (BsonDocument bsonDocument in cursor) { Transfer transfer = new Transfer(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, transfer); result.Add(transfer); } return result; }
public static Domain.PhysicianCollection GetPhysiciansByName(string firstName, string lastName) { YellowstonePathology.Business.Domain.PhysicianCollection result = new YellowstonePathology.Business.Domain.PhysicianCollection(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection collection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCursor cursor = null; if (string.IsNullOrEmpty(firstName) == false) { cursor = collection.FindAs<BsonDocument>(Query.And(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i")), Query.Matches("FirstName", BsonRegularExpression.Create("^" + firstName + ".*", "i")))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); } else { cursor = collection.FindAs<BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); } foreach (BsonDocument bsonDocument in cursor) { YellowstonePathology.Business.Domain.Physician physician = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician); result.Add(physician); } return result; }
public static void Synchronize(string tableName, string databaseName, string collectionName) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from " + tableName + " where [TimeStamp] > " + "(SELECT convert(int, ep.value) " + "FROM sys.extended_properties AS ep " + "INNER JOIN sys.tables AS t ON ep.major_id = t.object_id " + "INNER JOIN sys.columns AS c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id " + "WHERE class = 1 and t.Name = '" + tableName + "' and c.Name = 'TimeStamp' and ep.Name = 'TransferDBTS')"; cmd.CommandType = CommandType.Text; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); BsonObjectId bsonObjectId = (BsonObjectId)bsonDocument.GetValue("_id"); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(collectionName); mongoCollection.Update(Query.EQ("_id", bsonObjectId), Update.Replace(bsonDocument), UpdateFlags.Upsert); } } } }
public static View.ClientPhysicianView GetClientPhysicianViewByClientId(int clientId) { YellowstonePathology.Business.View.ClientPhysicianView result = new YellowstonePathology.Business.View.ClientPhysicianView(); YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName); MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client"); BsonDocument clientBsonDocument = clientCollection.FindOneAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(clientBsonDocument, result); MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId))); List<BsonValue> physicianIdList = new List<BsonValue>(); foreach (BsonDocument bsonDocument in physicianClientCursor) { physicianIdList.Add(bsonDocument.GetValue("PhysicianId")); } MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician"); MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("FirstName")); foreach (BsonDocument bsonDocument in physicianCursor) { YellowstonePathology.Business.Domain.Physician physician = new YellowstonePathology.Business.Domain.Physician(); YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician); result.Physicians.Add(physician); } return result; }
public static void TransferTableToMongo(string tableName, string databaseName, string collectionName, System.ComponentModel.BackgroundWorker backgroundWorker) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from " + tableName; cmd.CommandType = CommandType.Text; YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(databaseName); MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(collectionName); using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; int transferredRowCount = 1; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr); mongoCollection.Insert(bsonDocument); if (transferredRowCount > 100 && transferredRowCount % 1000 == 0) { backgroundWorker.ReportProgress(0, "Transfering " + tableName + ", " + transferredRowCount.ToString() + " rows transferred."); } transferredRowCount += 1; } } } }