internal DBSiteSettingsEx( string dbConnectionString, ILoggerFactory loggerFactory) { logFactory = loggerFactory; connectionString = dbConnectionString; // possibly will change this later to have SqlCeProviderFactory/DbProviderFactory injected AdoHelper = new SqlCeHelper(SqlCeProviderFactory.Instance); }
internal void Delete(Entity entity) { SqlStatement sql = new SqlStatement(); // delete... StringBuilder builder = new StringBuilder(); builder.Append("delete from "); builder.Append(this.EntityType.NativeName); builder.Append(" where "); AppendSelectConstraint(builder, sql, entity); // run... sql.CommandText = builder.ToString(); // run... SqlCeHelper db = new SqlCeHelper(); db.EnsureTableExists(entity.EntityType); db.ExecuteNonQuery(sql); }
public DbSetup( cloudscribe.DbHelpers.SqlCe.SqlCeConnectionStringResolver connectionStringResolver, ILoggerFactory loggerFactory, IVersionProviderFactory versionProviderFactory) { if (connectionStringResolver == null) { throw new ArgumentNullException(nameof(connectionStringResolver)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (versionProviderFactory == null) { throw new ArgumentNullException(nameof(versionProviderFactory)); } versionProviders = versionProviderFactory; logFactory = loggerFactory; log = loggerFactory.CreateLogger(typeof(DbSetup).FullName); connectionString = connectionStringResolver.Resolve(); sqlCeFilePath = connectionStringResolver.SqlCeFilePath; // possibly will change this later to have SqlCeProviderFactory/DbProviderFactory injected AdoHelper = new SqlCeHelper(SqlCeProviderFactory.Instance); }
internal void Update(Entity entity) { SqlStatement sql = new SqlStatement(); // create... StringBuilder builder = new StringBuilder(); builder.Append("update "); builder.Append(this.EntityType.NativeName); builder.Append(" set "); bool first = true; foreach (EntityField field in this.EntityType.Fields) { if (entity.IsModified(field)) { if (first) first = false; else builder.Append(", "); builder.Append(field.NativeName); builder.Append("=@"); // value... object value = entity.GetValue(field); builder.Append(sql.AddParameter(value).Name); } } builder.Append(" where "); this.AppendSelectConstraint(builder, sql, entity); // run... sql.CommandText = builder.ToString(); // run... SqlCeHelper db = new SqlCeHelper(); db.EnsureTableExists(entity.EntityType); db.ExecuteNonQuery(sql); }
internal void Insert(Entity entity) { SqlStatement sql = new SqlStatement(); // create... StringBuilder builder = new StringBuilder(); builder.Append("insert into "); builder.Append(this.EntityType.NativeName); builder.Append(" ("); bool first = true; foreach (EntityField field in this.EntityType.Fields) { if (entity.IsModified(field)) { if (first) first = false; else builder.Append(", "); builder.Append(field.NativeName); } } builder.Append(") values ("); first = true; foreach (EntityField field in this.EntityType.Fields) { if (entity.IsModified(field)) { if (first) first = false; else builder.Append(", "); // param... object value = entity.GetValue(field); SqlStatementParameter param = sql.AddParameter(value); builder.Append("@"); builder.Append(param.Name); } } builder.Append(")"); // run... sql.CommandText = builder.ToString(); // run... SqlCeHelper db = new SqlCeHelper(); db.EnsureTableExists(entity.EntityType); db.ExecuteNonQuery(sql); }
internal static void DeleteAll() { SqlCeHelper db = new SqlCeHelper(); // ensure... EntityType et = EntityType.GetEntityType(typeof(Bookmark)); db.EnsureTableExists(et); // delete... db.ExecuteNonQuery(new SqlStatement("delete from " + et.NativeName)); }
private void GetLatest() { Debug.WriteLine("Getting latest..."); BookmarksService service = new BookmarksService(); service.GetAll((Action<List<Bookmark>>)delegate(List<Bookmark> bookmarks) { // ensure... SqlCeHelper db = new SqlCeHelper(); db.EnsureTableExists(EntityType.GetEntityType(typeof(Bookmark))); // delete first... Bookmark.DeleteAll(); // go through and save them... foreach (Bookmark fromServer in bookmarks) { // we need to clone it as the ones that come from the server will have an id set. we // need to junk this id... Bookmark newBookmark = new Bookmark(); newBookmark.Ordinal = fromServer.Ordinal; newBookmark.Name = fromServer.Name; newBookmark.Url = fromServer.Url; // set the local only stuff... newBookmark.IsLocalModified = false; newBookmark.IsLocalDeleted = false; // save... newBookmark.SaveChanges(); } // signal that we've finished... this.Callback(); }, this.Failed); }
/// <summary> /// Finds the image. /// </summary> /// <param name="addin">The addin.</param> /// <param name="affectedClass">The affected class.</param> /// <param name="connection">The connection.</param> /// <param name="ds">The ds.</param> /// <param name="response">The response.</param> /// <returns></returns> public static DicomCommandStatusType FindImage(FindAddIn addin, string affectedClass, string connection, DicomDataSet ds, DicomDataSet response) { string filter = string.Empty; string temp; SqlCeDataReader reader; filter = "s.StudyInstanceUID = '" + ds.GetValue <string>(DicomTag.StudyInstanceUID, string.Empty) + "'"; filter += " AND SeriesInstanceUID = '" + ds.GetValue <string>(DicomTag.SeriesInstanceUID, string.Empty) + "'"; temp = ds.GetValue <string>(DicomTag.PatientID, string.Empty); if (affectedClass == DicomUidType.PatientRootQueryFind && temp.Length > 0) { filter += " AND p.PatientID = '" + temp + "'"; } List <string> instances = ds.GetValue <List <string> >(DicomTag.SOPInstanceUID, new List <string>()); foreach (string instance in instances) { filter += " AND SOPInstanceUID ='" + instance + "'"; } temp = ds.GetValue <string>(DicomTag.InstanceNumber, string.Empty); if (temp.Length > 0) { filter += " AND InstanceNumber = " + temp.ToString(); } filter = "SELECT p.PatientId,Name,Images.* FROM Images JOIN Studies s ON s.StudyInstanceUid = images.StudyInstanceUid JOIN Patients p ON p.PatientId = s.PatientId WHERE " + filter; reader = SqlCeHelper.ExecuteReader(connection, filter); while (reader.Read()) { response.InsertElementAndSetValue(DicomTag.SOPInstanceUID, reader["SOPInstanceUID"]); if (affectedClass == DicomUidType.PatientRootQueryFind) { response.InsertElementAndSetValue(DicomTag.PatientID, ds.GetValue <string>(DicomTag.PatientID, string.Empty)); } if (reader["ImageNumber"] != null && reader["ImageNumber"].ToString().Length > 0) { response.InsertElementAndSetValue(DicomTag.InstanceNumber, reader["ImageNumber"]); } if (addin.OnMatchFound(response)) { reader.Close(); return(DicomCommandStatusType.Cancel); } else if (addin.Cancel) { if (addin.BreakType == BreakType.Cancel) { return(DicomCommandStatusType.Cancel); } else { return(DicomCommandStatusType.Failure); } } //response.Clear(); } return(DicomCommandStatusType.Success); }
/// <summary> /// Moves the images. /// </summary> /// <param name="addin">The addin.</param> /// <param name="level">The level.</param> /// <param name="affectedClass">The affected class.</param> /// <param name="connection">The connection.</param> /// <param name="ds">The ds.</param> /// <returns></returns> internal static DicomCommandStatusType MoveImages(MoveAddIn addin, string level, string affectedClass, string connection, DicomDataSet ds) { string filter = string.Empty; string countFilter = string.Empty; string queryFilter = string.Empty; string sTemp = string.Empty; object count = null; SqlCeDataReader reader; MoveDataSetEventArgs move = new MoveDataSetEventArgs(); if (affectedClass == DicomUidType.PatientRootQueryMove || affectedClass == DicomUidType.PatientRootQueryGet) { filter += " AND "; filter += AddParen("p.PatientID = '" + ds.GetValue <string>(DicomTag.PatientID, string.Empty) + "'"); } if (level == "STUDY" || level == "SERIES" || level == "IMAGE") { filter += " AND "; if (level == "STUDY") { filter += AddParen("s.StudyInstanceUID = '" + ds.GetValue <string>(DicomTag.StudyInstanceUID, string.Empty) + "'"); } else { List <string> instances = ds.GetValue <List <string> >(DicomTag.StudyInstanceUID, new List <string>()); sTemp = string.Empty; foreach (string instance in instances) { sTemp += "s.StudyInstanceUID ='" + instance + "'"; if (instances.IndexOf(instance) < instances.Count - 1) { sTemp += " AND "; } } filter += AddParen(sTemp); } } if (level == "SERIES" || level == "IMAGE") { filter += " AND "; if (level != "SERIES") { filter += AddParen("r.SeriesInstanceUID = '" + ds.GetValue <string>(DicomTag.SeriesInstanceUID, string.Empty) + "'"); } else { List <string> instances = ds.GetValue <List <string> >(DicomTag.SeriesInstanceUID, new List <string>()); sTemp = string.Empty; foreach (string instance in instances) { sTemp += "r.SeriesInstanceUID ='" + instance + "'"; if (instances.IndexOf(instance) < instances.Count - 1) { sTemp += " AND "; } } filter += AddParen(sTemp); } } if (level == "IMAGE") { List <string> instances = ds.GetValue <List <string> >(DicomTag.SOPInstanceUID, new List <string>()); if (instances.Count > 0) { filter += " AND "; } sTemp = string.Empty; foreach (string instance in instances) { sTemp += "i.SOPInstanceUID ='" + instance + "'"; if (instances.IndexOf(instance) < instances.Count - 1) { sTemp += " AND "; } } filter += AddParen(sTemp); } //countFilter = "SELECT COUNT(*) FROM IMAGES WHERE " + filter; //filter = "SELECT * FROM IMAGES WHERE " + filter; countFilter = "SELECT COUNT(*) " + "FROM Patients p, Studies s, Series r, Images i " + "WHERE (p.PatientID = s.PatientID) AND (s.StudyInstanceUID = r.StudyInstanceUID) AND (r.SeriesInstanceUID = i.SeriesInstanceUID) " + filter; queryFilter = "SELECT i.* " + "FROM Patients p, Studies s, Series r, Images i " + "WHERE (p.PatientID = s.PatientID) AND (s.StudyInstanceUID = r.StudyInstanceUID) AND (r.SeriesInstanceUID = i.SeriesInstanceUID) " + filter; count = SqlCeHelper.ExecuteScalar(connection, countFilter); if (count == null || Convert.ToInt32(count) == 0) { return(DicomCommandStatusType.Success); } move.Remaining = Convert.ToInt32(count); reader = SqlCeHelper.ExecuteReader(connection, queryFilter); while (reader.Read()) { try { DicomCommandStatusType status; using (DicomDataSet dicom = new DicomDataSet()) { dicom.Load(reader["ReferencedFile"].ToString(), DicomDataSetLoadFlags.LoadAndClose); //move.StoreFileName = reader["ReferencedFile"].ToString(); move.StoreDataSet = dicom; move.Remaining--; status = addin.OnMoveDataSet(move); if (status != DicomCommandStatusType.Success || addin.Cancel) { reader.Close(); if (addin.Cancel) { if (addin.BreakType == BreakType.Cancel) { status = DicomCommandStatusType.Cancel; } else { status = DicomCommandStatusType.Failure; } } return(status); } } } catch { } } return(DicomCommandStatusType.Success); }
public static DicomCommandStatusType FindPatient(FindAddIn addin, string connection, DicomDataSet ds, DicomDataSet response) { string filter = string.Empty; string patientID = ds.GetValue <string>(DicomTag.PatientID, string.Empty); string patientName = ds.GetValue <string>(DicomTag.PatientName, string.Empty); SqlCeDataReader reader = null; if (patientID.Length > 0) { filter = CheckForWildcards("PatientID LIKE '" + patientID + "'"); } if (patientName.Length > 0) { if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("Name LIKE '" + patientName + "'"); } if (string.IsNullOrEmpty(filter)) { filter = "SELECT * FROM Patients"; } else { filter = "SELECT * FROM Patients WHERE " + filter; } reader = SqlCeHelper.ExecuteReader(connection, filter); while (reader.Read()) { response.InsertElementAndSetValue(DicomTag.PatientID, reader["PatientID"]); if (reader["Name"] != null) { response.InsertElementAndSetValue(DicomTag.PatientName, reader["Name"]); } if (reader["BirthDate"] != null) { response.InsertElementAndSetValue(DicomTag.PatientBirthDate, reader["BirthDate"]); } if (reader["Sex"] != null) { response.InsertElementAndSetValue(DicomTag.PatientSex, reader["Sex"]); } if (reader["EthnicGroup"] != null) { response.InsertElementAndSetValue(DicomTag.EthnicGroup, reader["EthnicGroup"]); } if (reader["Comments"] != null) { response.InsertElementAndSetValue(DicomTag.PatientComments, reader["Comments"]); } if (addin.OnMatchFound(response)) { reader.Close(); return(DicomCommandStatusType.Cancel); } else if (addin.Cancel) { if (addin.BreakType == BreakType.Cancel) { return(DicomCommandStatusType.Cancel); } else { return(DicomCommandStatusType.Failure); } } //response.Clear(); } return(DicomCommandStatusType.Success); }
/// <summary> /// Finds the study. /// </summary> /// <param name="addin">The addin.</param> /// <param name="connection">The connection.</param> /// <param name="ds">The ds.</param> /// <param name="response">The response.</param> /// <returns></returns> public static DicomCommandStatusType FindStudy(FindAddIn addin, string connection, DicomDataSet ds, DicomDataSet response) { string filter = string.Empty; string temp; SqlCeDataReader reader; temp = ds.GetValue <string>(DicomTag.PatientID, string.Empty); if (temp.Length > 0) { filter = CheckForWildcards("Studies.PatientId = '" + temp + "'"); } temp = ds.GetValue <string>(DicomTag.PatientName, string.Empty); if (temp.Length > 0) { if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("Name LIKE '" + temp + "'"); } List <string> instances = ds.GetValue <List <string> >(DicomTag.StudyInstanceUID, new List <string>()); foreach (string instance in instances) { if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("StudyInstanceUid = '" + instance + "'"); } DicomDateRangeValue[] d = ExtensionMethods.GetDateRange(ds, DicomTag.StudyDate); DicomTimeRangeValue[] t = ExtensionMethods.GetTimeRange(ds, DicomTag.StudyTime); int dCount = (d == null ? 0 : d.Length); int tCount = (t == null ? 0 : t.Length); int maxEntries = Math.Max(dCount, tCount); for (int i = 0; i < maxEntries; i++) { DateTime startDate = new DateTime(1900, 1, 1, 0, 0, 0); DateTime endDate = new DateTime(3000, 12, 31, 23, 59, 59); DateTime startTime = DateTime.MinValue; DateTime endTime = DateTime.MaxValue; string sStartDateTime = string.Empty; string sEndDateTime = string.Empty; // Get the start date and end date if (i < dCount) { // start date if ((d[i].Type == DicomRangeType.Lower) || (d[i].Type == DicomRangeType.Both)) { startDate = new DateTime(d[i].Date1.Year, d[i].Date1.Month, d[i].Date1.Day, 0, 0, 0); } // end date if (d[i].Type == DicomRangeType.Upper) { endDate = new DateTime(d[i].Date1.Year, d[i].Date1.Month, d[i].Date1.Day, 23, 59, 59); } else if (d[i].Type == DicomRangeType.Both) { endDate = new DateTime(d[i].Date2.Year, d[i].Date2.Month, d[i].Date2.Day, 23, 59, 59); } } // Get the start time and end time if (i < tCount) { // start date if ((t[i].Type == DicomRangeType.Lower) || (t[i].Type == DicomRangeType.Both)) { startTime = new DateTime(1, 1, 1, t[i].Time1.Hours, t[i].Time1.Minutes, t[i].Time1.Seconds); } // end date if (t[i].Type == DicomRangeType.Upper) { endTime = new DateTime(1, 1, 1, t[i].Time1.Hours, t[i].Time1.Minutes, t[i].Time1.Seconds); } else if (t[i].Type == DicomRangeType.Both) { endTime = new DateTime(1, 1, 1, t[i].Time2.Hours, t[i].Time2.Minutes, t[i].Time2.Seconds); } } string sAdd = string.Format("( (StudyDate >= '{0}') and (StudyDate <= '{1}'))", startDate, endDate); string sTimeFormatString = "AND ((CONVERT(nvarchar,StudyDate,108) BETWEEN '{0}' AND '{1}'))"; filter += sAdd; sAdd = string.Format(sTimeFormatString, startTime.ToString("HH:mm:ss"), endTime.ToString("HH:mm:ss")); filter += sAdd; } temp = ds.GetValue <string>(DicomTag.AccessionNumber, string.Empty); if (temp.Length > 0) { if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("AccessionNumber = '" + temp + "'"); } temp = ds.GetValue <string>(DicomTag.StudyID, string.Empty); if (temp.Length > 0) { if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("StudyId LIKE '" + temp + "'"); } temp = ds.GetValue <string>(DicomTag.ReferringPhysicianName, string.Empty); if (temp.Length > 0) { temp = temp.Replace("*", "%"); if (filter.Length > 0) { filter += " AND "; } filter += CheckForWildcards("ReferDrName LIKE '" + temp + "'"); } temp = FindElementModalitiesInStudy(ds); if (temp.Length > 0) { if (filter.Length > 0) { filter += " AND "; } filter += temp; } if (string.IsNullOrEmpty(filter)) { filter = "SELECT p.PatientId,Name,Studies.* FROM Studies JOIN Patients p ON p.PatientId = Studies.PatientId"; } else { filter = "SELECT p.PatientId,Name,Studies.* FROM Studies JOIN Patients p ON p.PatientId = Studies.PatientId WHERE " + filter; } reader = SqlCeHelper.ExecuteReader(connection, filter); while (reader.Read()) { response.InsertElementAndSetValue(DicomTag.StudyInstanceUID, reader["StudyInstanceUID"]); if (reader["StudyDate"] != System.DBNull.Value) { DateTime date = DateTime.Parse(reader["StudyDate"].ToString()); response.InsertElementAndSetValue(DicomTag.StudyDate, date.ToShortDateString()); response.InsertElementAndSetValue(DicomTag.StudyTime, date.ToShortTimeString()); } if (reader["AccessionNumber"] != null) { response.InsertElementAndSetValue(DicomTag.AccessionNumber, reader["AccessionNumber"]); } if (reader["StudyId"] != null) { response.InsertElementAndSetValue(DicomTag.StudyID, reader["StudyId"]); } if (reader["PatientID"] != null) { response.InsertElementAndSetValue(DicomTag.PatientID, reader["PatientId"]); } if (reader["Name"] != null) { response.InsertElementAndSetValue(DicomTag.PatientName, reader["Name"]); } if (reader["ReferDrName"] != null) { response.InsertElementAndSetValue(DicomTag.ReferringPhysicianName, reader["ReferDrName"]); } if (reader["StudyDescription"] != null) { response.InsertElementAndSetValue(DicomTag.StudyDescription, reader["StudyDescription"]); } try { string sql = string.Format("SELECT Count(*) FROM Series WHERE StudyInstanceUid = '{0}'", reader["StudyInstanceUID"]); response.InsertElementAndSetValue(DicomTag.NumberOfStudyRelatedSeries, (int)SqlCeHelper.ExecuteScalar(connection, sql)); sql = string.Format("SELECT Count(*) FROM Images WHERE StudyInstanceUid = '{0}'", reader["StudyInstanceUID"]); response.InsertElementAndSetValue(DicomTag.NumberOfStudyRelatedInstances, (int)SqlCeHelper.ExecuteScalar(connection, sql)); } catch { } if (addin.OnMatchFound(response)) { reader.Close(); return(DicomCommandStatusType.Cancel); } else if (addin.Cancel) { if (addin.BreakType == BreakType.Cancel) { return(DicomCommandStatusType.Cancel); } else { return(DicomCommandStatusType.Failure); } } //response.Clear(); } return(DicomCommandStatusType.Success); }
private static DicomCommandStatusType AddImage(DateTime receive, string sopInstance, string StudyInstanceUid, string SeriesInstanceUid, string ConnectionString, string AETitle, DicomDataSet dataset, string ImageDirectory) { if (string.IsNullOrEmpty(sopInstance)) { throw new ArgumentException("Missing dicom tag", "SOP Instance UID"); } _newImage = false; if (!RecordExists(ConnectionString, "Images", "SOPInstanceUID = '" + sopInstance + "'")) { string fileName = ImageDirectory + sopInstance + ".dcm"; SqlCeResultSet rs = SqlCeHelper.ExecuteResultSet(ConnectionString, "Images"); SqlCeUpdatableRecord image = rs.CreateRecord(); image.SetValue(0, sopInstance); image.SetValue(1, SeriesInstanceUid); image.SetValue(2, StudyInstanceUid); if (HasValue(dataset, DicomTag.InstanceNumber)) { image.SetValue(3, dataset.GetValue <int>(DicomTag.InstanceNumber, 0)); } image.SetValue(4, fileName); image.SetValue(5, dataset.GetValue <string>(DicomTag.TransferSyntaxUID, DicomUidType.ImplicitVRLittleEndian)); image.SetValue(6, dataset.GetValue <string>(DicomTag.SOPClassUID, string.Empty)); image.SetValue(7, dataset.GetValue <string>(DicomTag.StationName, string.Empty)); image.SetValue(8, GetDateString(DateTime.Now, DateTime.Now)); image.SetValue(9, AETitle); rs.Insert(image); rs.Close(); _newImage = true; // // store the file // if (!Directory.Exists(ImageDirectory)) { Directory.CreateDirectory(ImageDirectory); } bool saved = true; try { dataset.Save(fileName, DicomDataSetSaveFlags.MetaHeaderPresent); } catch (Exception) { saved = false; } if (!saved) { return(DicomCommandStatusType.Failure); } } else { return(DicomCommandStatusType.DuplicateInstance); } return(DicomCommandStatusType.Success); }
public static void DeleteAllTableItems(string ConnectionString, string sTable) { string sQuery = string.Format(sQueryDeleteAllTableItems, sTable); SqlCeHelper.ExecuteNonQuery(ConnectionString, sQuery); }
public static void DeleteTableItem(string ConnectionString, string sTable, string sUniqueId, string sValue) { string sQuery = string.Format(sQueryDeleteTableItem, sTable, sUniqueId, sValue); SqlCeHelper.ExecuteNonQuery(ConnectionString, sQuery); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var bw = new BackgroundWorker(); bw.DoWork += bw_DoWork; bw.RunWorkerCompleted += (s, ea) => { Version.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version + " " + ea.Result.ToString(); }; bw.RunWorkerAsync(); Background = VsThemes.GetWindowBackground(); Version.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version; txtStatus.Text = "SQL Server Compact 4.0 in GAC - "; try { var version = new SqlCeHelper4().IsV40Installed(); if (version != null) { txtStatus.Text += string.Format("Yes - {0}\n", version); } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "SQL Server Compact 4.0 DbProvider - "; try { System.Data.Common.DbProviderFactories.GetFactory(SqlCeToolbox.Resources.SqlCompact40InvariantName); txtStatus.Text += "Yes\n"; } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "\nSQL Server Compact 4.0 DDEX provider - "; try { if (DataConnectionHelper.DdexProviderIsInstalled(new Guid(SqlCeToolbox.Resources.SqlCompact40Provider))) { txtStatus.Text += "Yes\n"; } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "SQL Server Compact 4.0 Simple DDEX provider - "; try { if (DataConnectionHelper.DdexProviderIsInstalled(new Guid(SqlCeToolbox.Resources.SqlCompact40PrivateProvider))) { txtStatus.Text += "Yes\n"; } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "\n\nSQL Server Compact 3.5 in GAC - "; try { var version = new SqlCeHelper().IsV35Installed(); if (version != null) { txtStatus.Text += string.Format("Yes - {0}\n", version); } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "SQL Server Compact 3.5 DbProvider - "; try { System.Data.Common.DbProviderFactories.GetFactory(SqlCeToolbox.Resources.SqlCompact35InvariantName); txtStatus.Text += "Yes\n"; } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "\nSQL Server Compact 3.5 DDEX provider - "; try { if (DataConnectionHelper.DdexProviderIsInstalled(new Guid(SqlCeToolbox.Resources.SqlCompact35Provider))) { txtStatus.Text += "Yes\n"; } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } txtStatus.Text += "\n\nSync Framework 2.1 SqlCe 3.5 provider - "; if (DataConnectionHelper.IsSyncFx21Installed()) { txtStatus.Text += "Yes\n"; } else { txtStatus.Text += "No\n"; } txtStatus.Text += $"\n\nSQLite ADO.NET Provider used: {Helpers.RepositoryHelper.SqliteEngineVersion}\n"; txtStatus.Text += "SQLite EF6 DbProvider in GAC - "; try { if (DataConnectionHelper.IsSqLiteDbProviderInstalled()) { txtStatus.Text += "Yes\n"; } else { txtStatus.Text += "No\n"; } } catch { txtStatus.Text += "No\n"; } }
private void TestConnection(bool showMessage) { try { if (createDb) { if (!System.IO.File.Exists(dataSourceTextBox.Text)) { var engineHelper = new SqlCeHelper(); engineHelper.CreateDatabase(_connectionString); } } using (var repository = new DBRepository(_connectionString)) { if (showMessage) { System.Windows.MessageBox.Show("Connection OK!"); } else { this.DialogResult = true; } } } catch (Exception ex) { System.Windows.MessageBox.Show(DataConnectionHelper.ShowErrors(ex)); } }
/// <summary> /// Finds the series. /// </summary> /// <param name="addin">The addin.</param> /// <param name="affectedClass">The affected class.</param> /// <param name="connection">The connection.</param> /// <param name="ds">The ds.</param> /// <param name="response">The response.</param> /// <returns></returns> public static DicomCommandStatusType FindSeries(FindAddIn addin, string affectedClass, string connection, DicomDataSet ds, DicomDataSet response) { string filter = string.Empty; string temp; SqlCeDataReader reader; filter = "s.StudyInstanceUID = '" + ds.GetValue <string>(DicomTag.StudyInstanceUID, string.Empty) + "'"; temp = ds.GetValue <string>(DicomTag.PatientID, string.Empty); if (affectedClass == DicomUidType.PatientRootQueryFind && temp.Length > 0) { filter += " AND p.PatientID = '" + temp + "'"; } temp = ds.GetValue <string>(DicomTag.SeriesInstanceUID, string.Empty); if (temp.Length > 0) { filter += " AND SeriesInstanceUID='" + temp + "'"; } temp = ds.GetValue <string>(DicomTag.Modality, string.Empty); if (temp.Length > 0) { filter += " AND Modality LIKE '" + temp + "'"; } temp = ds.GetValue <string>(DicomTag.SeriesNumber, string.Empty); if (temp.Length > 0) { filter += " AND SeriesNumber = " + temp; } filter = "SELECT p.PatientId,Name,Series.* FROM Series JOIN Studies s ON s.StudyInstanceUid = Series.StudyInstanceUid JOIN Patients p ON p.PatientId = s.PatientId WHERE " + filter; reader = SqlCeHelper.ExecuteReader(connection, filter); while (reader.Read()) { response.InsertElementAndSetValue(DicomTag.SeriesInstanceUID, reader["SeriesInstanceUID"]); if (reader["Modality"] != null) { response.InsertElementAndSetValue(DicomTag.Modality, reader["Modality"]); } if (reader["SeriesNumber"] != null && IsInteger(reader["SeriesNumber"].ToString())) { response.InsertElementAndSetValue(DicomTag.SeriesNumber, reader["SeriesNumber"]); } if (reader["SeriesDate"] != null && reader["SeriesDate"].ToString().Length > 0) { DateTime date = DateTime.Parse(reader["SeriesDate"].ToString()); response.InsertElementAndSetValue(DicomTag.SeriesDate, date.ToShortDateString()); response.InsertElementAndSetValue(DicomTag.SeriesTime, date.ToShortTimeString()); } if (reader["SeriesDesscription"] != null) { response.InsertElementAndSetValue(DicomTag.SeriesDescription, reader["SeriesDesscription"].ToString()); } if (reader["StudyInstanceUID"] != null) { response.InsertElementAndSetValue(DicomTag.StudyInstanceUID, reader["StudyInstanceUID"].ToString()); } try { string sql = string.Format("SELECT Count(*) FROM Images WHERE SeriesInstanceUID = '{0}'", reader["SeriesInstanceUID"]); response.InsertElementAndSetValue(DicomTag.NumberOfSeriesRelatedInstances, (int)SqlCeHelper.ExecuteScalar(connection, sql)); } catch { } if (addin.OnMatchFound(response)) { reader.Close(); return(DicomCommandStatusType.Cancel); } else if (addin.Cancel) { if (addin.BreakType == BreakType.Cancel) { return(DicomCommandStatusType.Cancel); } else { return(DicomCommandStatusType.Failure); } } //response.Clear(); } return(DicomCommandStatusType.Success); }
internal static string ShowErrors(Exception ex) { #if V35 ISqlCeHelper sqlCeHelper = new SqlCeHelper(); #else ISqlCeHelper sqlCeHelper = new SqlCeHelper4(); #endif Monitor.TrackException(ex); return sqlCeHelper.FormatError(ex); }