C2017-003: Support SQL Server for storing of Referenced Object data

This commit is contained in:
Kathy Ruffing 2020-01-09 15:45:12 +00:00
parent de58331ffb
commit c44181bc3f
12 changed files with 1507 additions and 0 deletions

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="${USERPROFILE}/My Documents/VEPROMS/ErrorLog.txt"/>
<!--<param name="File" value="${APPDATA}/Volian/Proms2010/ErrorLog.txt" />-->
<!--<param name="File" value="${LOCALAPPDATA}/Temp/VEPROMS/ErrorLog.txt" />-->
<param name="AppendToFile" value="true"/>
<layout type="log4net.Layout.PatternLayout">
<!--<param name="Header" value="[Header]\r\n" />-->
<!--<param name="Footer" value="[Footer]\r\n" />-->
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="--&gt; %date [%thread] %-5level %logger (%property{log4net:HostName}) [%ndc] - %message%newline"/>
</layout>
</appender>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<threshold value="WARN"/>
<mapping>
<level value="DEBUG"/>
<eventLogEntryType value="Information"/>
</mapping>
<mapping>
<level value="INFO"/>
<eventLogEntryType value="Information"/>
</mapping>
<mapping>
<level value="WARN"/>
<eventLogEntryType value="Warning"/>
</mapping>
<mapping>
<level value="ERROR"/>
<eventLogEntryType value="Error"/>
</mapping>
<mapping>
<level value="FATAL"/>
<eventLogEntryType value="Error"/>
</mapping>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="---&gt; %d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="LogFileAppender"/>
<appender-ref ref="EventLogAppender"/>
</root>
<logger name="VEPROMS.CSLA.Library">
<level value="INFO"/>
</logger>
<logger name="Volian.Controls.Library">
<level value="INFO"/>
</logger>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RoAccessToSql
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RoAccessToSql(args));
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RoAccessToSql")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RoAccessToSql")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ff85e109-0a0d-4dbd-8181-21d877549e8b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace RoAccessToSql.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RoAccessToSql.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace RoAccessToSql.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,306 @@
namespace RoAccessToSql
{
partial class RoAccessToSql
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RoAccessToSql));
this.lblAccessPath = new System.Windows.Forms.Label();
this.tbAccessPath = new System.Windows.Forms.TextBox();
this.btnConvert = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.btnBrowse = new DevComponents.DotNetBar.ButtonX();
this.panelExStatus = new DevComponents.DotNetBar.PanelEx();
this.pBarDbs = new DevComponents.DotNetBar.Controls.ProgressBarX();
this.pBarROs = new DevComponents.DotNetBar.Controls.ProgressBarX();
this.lblConvertStatusROs = new DevComponents.DotNetBar.LabelX();
this.lblConvertStatusDB = new DevComponents.DotNetBar.LabelX();
this.lblSqlDbName = new System.Windows.Forms.Label();
this.tbSqlDbName = new System.Windows.Forms.TextBox();
this.btnTestConnect = new DevComponents.DotNetBar.ButtonX();
this.lblSqlServerName = new System.Windows.Forms.Label();
this.tbSqlServerName = new System.Windows.Forms.TextBox();
this.groupPanel1 = new DevComponents.DotNetBar.Controls.GroupPanel();
this.panelExStatus.SuspendLayout();
this.groupPanel1.SuspendLayout();
this.SuspendLayout();
//
// lblAccessPath
//
this.lblAccessPath.AutoSize = true;
this.lblAccessPath.Location = new System.Drawing.Point(31, 9);
this.lblAccessPath.Name = "lblAccessPath";
this.lblAccessPath.Size = new System.Drawing.Size(167, 17);
this.lblAccessPath.TabIndex = 0;
this.lblAccessPath.Text = "Path to Access Database";
//
// tbAccessPath
//
this.tbAccessPath.Location = new System.Drawing.Point(48, 40);
this.tbAccessPath.Name = "tbAccessPath";
this.tbAccessPath.Size = new System.Drawing.Size(630, 22);
this.tbAccessPath.TabIndex = 2;
this.tbAccessPath.Leave += new System.EventHandler(this.tbAccessPath_Leave);
//
// btnConvert
//
this.btnConvert.Location = new System.Drawing.Point(635, 148);
this.btnConvert.Name = "btnConvert";
this.btnConvert.Size = new System.Drawing.Size(72, 29);
this.btnConvert.TabIndex = 4;
this.btnConvert.Text = "Convert";
this.btnConvert.UseVisualStyleBackColor = true;
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
//
// btnExit
//
this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnExit.Location = new System.Drawing.Point(635, 201);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 29);
this.btnExit.TabIndex = 5;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnBrowse
//
this.btnBrowse.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnBrowse.BackColor = System.Drawing.Color.Transparent;
this.btnBrowse.Image = ((System.Drawing.Image)(resources.GetObject("btnBrowse.Image")));
this.btnBrowse.Location = new System.Drawing.Point(698, 40);
this.btnBrowse.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnBrowse.Name = "btnBrowse";
this.btnBrowse.Size = new System.Drawing.Size(21, 23);
this.btnBrowse.TabIndex = 40;
this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
//
// panelExStatus
//
this.panelExStatus.CanvasColor = System.Drawing.SystemColors.Control;
this.panelExStatus.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.panelExStatus.Controls.Add(this.pBarDbs);
this.panelExStatus.Controls.Add(this.pBarROs);
this.panelExStatus.Controls.Add(this.lblConvertStatusROs);
this.panelExStatus.Controls.Add(this.lblConvertStatusDB);
this.panelExStatus.DisabledBackColor = System.Drawing.Color.Empty;
this.panelExStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panelExStatus.Location = new System.Drawing.Point(0, 255);
this.panelExStatus.Name = "panelExStatus";
this.panelExStatus.Size = new System.Drawing.Size(771, 135);
this.panelExStatus.Style.Alignment = System.Drawing.StringAlignment.Center;
this.panelExStatus.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
this.panelExStatus.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
this.panelExStatus.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
this.panelExStatus.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.panelExStatus.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.panelExStatus.Style.GradientAngle = 90;
this.panelExStatus.TabIndex = 45;
//
// pBarDbs
//
//
//
//
this.pBarDbs.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.pBarDbs.Location = new System.Drawing.Point(34, 37);
this.pBarDbs.Name = "pBarDbs";
this.pBarDbs.Size = new System.Drawing.Size(656, 24);
this.pBarDbs.TabIndex = 4;
this.pBarDbs.TextVisible = true;
//
// pBarROs
//
//
//
//
this.pBarROs.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.pBarROs.Location = new System.Drawing.Point(34, 99);
this.pBarROs.Name = "pBarROs";
this.pBarROs.Size = new System.Drawing.Size(656, 24);
this.pBarROs.TabIndex = 3;
this.pBarROs.TextVisible = true;
//
// lblConvertStatusROs
//
//
//
//
this.lblConvertStatusROs.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.lblConvertStatusROs.Location = new System.Drawing.Point(14, 69);
this.lblConvertStatusROs.Name = "lblConvertStatusROs";
this.lblConvertStatusROs.Size = new System.Drawing.Size(128, 24);
this.lblConvertStatusROs.TabIndex = 2;
this.lblConvertStatusROs.Text = "Converting ROs:";
//
// lblConvertStatusDB
//
//
//
//
this.lblConvertStatusDB.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.lblConvertStatusDB.Location = new System.Drawing.Point(14, 3);
this.lblConvertStatusDB.Name = "lblConvertStatusDB";
this.lblConvertStatusDB.Size = new System.Drawing.Size(226, 24);
this.lblConvertStatusDB.TabIndex = 0;
this.lblConvertStatusDB.Text = "Converting Database:";
//
// lblSqlDbName
//
this.lblSqlDbName.AutoSize = true;
this.lblSqlDbName.BackColor = System.Drawing.Color.Transparent;
this.lblSqlDbName.Location = new System.Drawing.Point(14, 0);
this.lblSqlDbName.Name = "lblSqlDbName";
this.lblSqlDbName.Size = new System.Drawing.Size(134, 17);
this.lblSqlDbName.TabIndex = 1;
this.lblSqlDbName.Text = "Sql Database Name";
//
// tbSqlDbName
//
this.tbSqlDbName.Location = new System.Drawing.Point(31, 31);
this.tbSqlDbName.Name = "tbSqlDbName";
this.tbSqlDbName.Size = new System.Drawing.Size(309, 22);
this.tbSqlDbName.TabIndex = 3;
this.tbSqlDbName.Leave += new System.EventHandler(this.tbSqlDbName_Leave);
//
// btnTestConnect
//
this.btnTestConnect.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnTestConnect.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnTestConnect.Location = new System.Drawing.Point(380, 44);
this.btnTestConnect.Name = "btnTestConnect";
this.btnTestConnect.Size = new System.Drawing.Size(105, 51);
this.btnTestConnect.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnTestConnect.TabIndex = 39;
this.btnTestConnect.Text = "Test Connect";
this.btnTestConnect.Click += new System.EventHandler(this.btnTestConnect_Click);
//
// lblSqlServerName
//
this.lblSqlServerName.AutoSize = true;
this.lblSqlServerName.BackColor = System.Drawing.Color.Transparent;
this.lblSqlServerName.Location = new System.Drawing.Point(14, 69);
this.lblSqlServerName.Name = "lblSqlServerName";
this.lblSqlServerName.Size = new System.Drawing.Size(115, 17);
this.lblSqlServerName.TabIndex = 43;
this.lblSqlServerName.Text = "Sql Server Name";
//
// tbSqlServerName
//
this.tbSqlServerName.Location = new System.Drawing.Point(31, 100);
this.tbSqlServerName.Name = "tbSqlServerName";
this.tbSqlServerName.Size = new System.Drawing.Size(309, 22);
this.tbSqlServerName.TabIndex = 44;
this.tbSqlServerName.Leave += new System.EventHandler(this.tbSqlServerName_Leave);
//
// groupPanel1
//
this.groupPanel1.CanvasColor = System.Drawing.SystemColors.Control;
this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
this.groupPanel1.Controls.Add(this.lblSqlDbName);
this.groupPanel1.Controls.Add(this.tbSqlServerName);
this.groupPanel1.Controls.Add(this.btnTestConnect);
this.groupPanel1.Controls.Add(this.tbSqlDbName);
this.groupPanel1.Controls.Add(this.lblSqlServerName);
this.groupPanel1.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanel1.Location = new System.Drawing.Point(34, 84);
this.groupPanel1.Name = "groupPanel1";
this.groupPanel1.Size = new System.Drawing.Size(528, 160);
//
//
//
this.groupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
this.groupPanel1.Style.BackColorGradientAngle = 90;
this.groupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
this.groupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanel1.Style.BorderBottomWidth = 1;
this.groupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.groupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanel1.Style.BorderLeftWidth = 1;
this.groupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanel1.Style.BorderRightWidth = 1;
this.groupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanel1.Style.BorderTopWidth = 1;
this.groupPanel1.Style.CornerDiameter = 4;
this.groupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
this.groupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
this.groupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.groupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
//
//
//
this.groupPanel1.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.groupPanel1.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.groupPanel1.TabIndex = 56;
this.groupPanel1.Text = "SQL Connection";
//
// RoAccessToSql
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(771, 390);
this.Controls.Add(this.groupPanel1);
this.Controls.Add(this.panelExStatus);
this.Controls.Add(this.btnBrowse);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnConvert);
this.Controls.Add(this.tbAccessPath);
this.Controls.Add(this.lblAccessPath);
this.Name = "RoAccessToSql";
this.Text = "Ro Convert MSAccess To Sql";
this.panelExStatus.ResumeLayout(false);
this.groupPanel1.ResumeLayout(false);
this.groupPanel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblAccessPath;
private System.Windows.Forms.TextBox tbAccessPath;
private System.Windows.Forms.Button btnConvert;
private System.Windows.Forms.Button btnExit;
private DevComponents.DotNetBar.ButtonX btnBrowse;
private DevComponents.DotNetBar.PanelEx panelExStatus;
private DevComponents.DotNetBar.LabelX lblConvertStatusDB;
private System.Windows.Forms.Label lblSqlDbName;
private System.Windows.Forms.TextBox tbSqlDbName;
private DevComponents.DotNetBar.ButtonX btnTestConnect;
private System.Windows.Forms.Label lblSqlServerName;
private System.Windows.Forms.TextBox tbSqlServerName;
private DevComponents.DotNetBar.Controls.GroupPanel groupPanel1;
private DevComponents.DotNetBar.LabelX lblConvertStatusROs;
private DevComponents.DotNetBar.Controls.ProgressBarX pBarROs;
private DevComponents.DotNetBar.Controls.ProgressBarX pBarDbs;
}
}

View File

@ -0,0 +1,616 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;
using Volian.Base.Library;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
//RoAccessToSql is the program to be used to convert Referenced Object data that is stored in a Microsoft Access database to a sql database.
// Input to this program is:
// /acc=<pathname where romaster.mdb is stored>
// /sqldb=<name of sql database to use, this program appends a '_RO' to it>
// /server=<server name>
// for example: 'RoAccessSql /acc=D:\Backup2012\APP\RO /sqldb=VEPROMS_APP /server=.\sqlexpress_2012'
//
// Some things to note:
// 1) the database must exist in the server and must have the 'roall' table and stored procedures. It cannot have any data.
// 2) no ro images are stored. These will continue to be used as before
// 3) log4net is used for errors, it is stored in the same place as the Proms error log
// 4) The program can be run standalone, but if run from Proms, the database name, server and romaster.mdb path will be initialized based on the rodb selected
// 5) Data in sql is stored in only one table, 'roall'. It as a column for the table from which it came.
namespace RoAccessToSql
{
public partial class RoAccessToSql : Form
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _MSAccessPath = null;
public string MSAccessPath
{
get { return _MSAccessPath; }
set { _MSAccessPath = value; }
}
private string _SqlServerName = null;
public string SqlServerName
{
get { return _SqlServerName; }
set { _SqlServerName = value; }
}
private string _SqlDatabaseName = null;
public string SqlDatabaseName
{
get { return _SqlDatabaseName; }
set { _SqlDatabaseName = value; }
}
bool _Initializing = false;
public RoAccessToSql(string[] args)
{
_Initializing = true;
InitializeComponent();
foreach (string parm in args) // get access & sql database info from program arguments, or use defaults
{
if (parm.StartsWith("/acc="))
{
MSAccessPath = parm.Substring(5);
}
else if (parm.StartsWith("/sqldb="))
{
SqlDatabaseName = parm.Substring(7) + "_RO";
}
else if (parm.StartsWith("/server="))
{
SqlServerName = parm.Substring(8);
}
}
if (MSAccessPath != null && !(Directory.Exists(MSAccessPath)))
{
MessageBox.Show("Invalid MS Access path, cannot convert. Fix before running conversion");
if (MSAccessPath != null) tbAccessPath.Text = MSAccessPath;
}
else
tbAccessPath.Text = MSAccessPath;
if (SqlServerName == null)
{
SqlServerName = @".\sqlserver";
}
tbSqlServerName.Text = SqlServerName;
if (SqlDatabaseName == null)
{
SqlDatabaseName = "VEPROMS_RO";
}
if (UserInRoEditor()) this.Close();
tbSqlDbName.Text = SqlDatabaseName;
_TmpFileForConnectStr = Path.GetTempPath();
_TmpFileForConnectStr = _TmpFileForConnectStr + @"\PromsConnect.txt";
File.Delete(_TmpFileForConnectStr);
_Initializing = false;
}
private bool UserInRoEditor()
{
FileInfo fiown = null;
FileStream fsown = null;
// The following code was taken from the roeditor. It uses the 'RoEditor.own' file to assure that
// no one is in the roeditor. This file is located in the microsoft access database directory.
try
{
string filename = MSAccessPath + @"\RoEditor.own";
fiown = new FileInfo(filename);
try
{
// Try to delete the owner file. If another process has the file open, this delete will fail.
// If the file is closed, it will be deleted, and the user will be placed in the editor. The users
// name and the time when this session began will be placed in the owner file.
fiown.Delete();
}
catch (Exception ex)
{
fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
TextReader tr1 = new StreamReader(fsown);
string who1 = tr1.ReadToEnd();
MessageBox.Show(ex.Message + "\r\n\r\n" + who1, "RO Editor In Use", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
fsown = fiown.Open(FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
TextReader tr = new StreamReader(fsown);
string who = tr.ReadToEnd();
tr.Close();
if (who.Contains(Environment.UserName.ToUpper()))
{
return true;
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "fileinfo");
}
// Open the file just specified. Open it so that no-one else can use it
try
{
fsown = fiown.Open(FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
TextWriter tw = new StreamWriter(fsown);
tw.WriteLine("Current User: {0}, Date and Time Started: {1}", Environment.UserName.ToUpper(), DateTime.Now.ToString("MM/dd/yyyy @ hh:mm"));
tw.Flush();
}
catch (IOException ex)
{
fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
TextReader tr = new StreamReader(fsown);
string who = tr.ReadToEnd();
tr.Close();
if (!who.Contains(Environment.UserName.ToUpper()))
MessageBox.Show(who, "Another user is executing the RoEditor");
return true;
}
return false;
}
static string _ErrorLogFileName;
public static string ErrorLogFileName
{
get { return _ErrorLogFileName; }
set { _ErrorLogFileName = value; }
}
// make error log file name (uses same logic as proms error log)
static bool ChangeLogFileName(string AppenderName, string NewFilename)
{
log4net.Repository.ILoggerRepository RootRep;
RootRep = log4net.LogManager.GetRepository();
foreach (log4net.Appender.IAppender iApp in RootRep.GetAppenders())
{
if (iApp.Name.CompareTo(AppenderName) == 0
&& iApp is log4net.Appender.FileAppender)
{
log4net.Appender.FileAppender fApp = (log4net.Appender.FileAppender)iApp;
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
fApp.File = folderPath + @"\VEPROMS\" + (Volian.Base.Library.VlnSettings.GetCommand("prefix", "") + "_").TrimStart("_".ToCharArray()) + NewFilename;
ErrorLogFileName = fApp.File;
fApp.ActivateOptions();
return true;
}
}
return false;
}
// Browse to romaster.mdb (Microsoft access database)
private void btnBrowse_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
if (Directory.Exists(fbd.SelectedPath))
tbAccessPath.Text = fbd.SelectedPath;
else
MessageBox.Show("Path doesn't exist " + tbAccessPath.Text);
}
}
// Convert the data
private void btnConvert_Click(object sender, EventArgs e)
{
if (!Directory.Exists(tbAccessPath.Text))
{
MessageBox.Show("Invalid Path to Access Database", "Cannot convert data");
return;
}
bool canmigrate = TestConnection(false);
if (!canmigrate) return;
SetLogFileInfo();
this.Cursor = Cursors.WaitCursor;
MigrateData();
this.Cursor = Cursors.Default;
}
// Setup the log file, including the name and adding Session beginning info to the log file
private void SetLogFileInfo()
{
DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek));
ChangeLogFileName("LogFileAppender", SqlDatabaseName + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt");
_MyLog.InfoFormat("\r\nSession Beginning\r\n<===={0}[SQL:{1:yyMM.ddHH}]====== User: {2}/{3} Started {4} ===============>{5}"
, Application.ProductVersion, RevDate, DateTime.Now, Environment.UserDomainName, Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"), "");
}
private string _SqlConnectStr = null;
// Start the migration process, this method checks for valid connections and calls MigrateTables to actually migrate the data
private void MigrateData()
{
_SqlConnectStr = string.Format(@"Data Source={0};Initial Catalog={1};Integrated Security=True", SqlServerName, SqlDatabaseName);
using (SqlConnection sqlConnection = new SqlConnection(_SqlConnectStr))
{
try
{
sqlConnection.Open();
if (sqlConnection.State == ConnectionState.Open)
{
// now try to open access db:
string strDatabaseConnectionCommand = "Provider=Microsoft.Jet.OLEDB.4.0;Password=\"\";User ID=Admin;Data Source=" + MSAccessPath + "\\ROMaster.mdb;Mode=Share Deny None;Extended Properties=\"\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Database Password=\"\";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
using (OleDbConnection accessConnection = new OleDbConnection(strDatabaseConnectionCommand))
{
try
{
accessConnection.Open();
if (accessConnection.State == ConnectionState.Open)
{
MigrateTables(accessConnection, sqlConnection);
if (accessConnection.State == ConnectionState.Open) accessConnection.Close();
}
}
catch (OleDbException ex)
{
_MyLog.Error("Access Connection failed.", ex);
MessageBox.Show(ex.Message, "Access Connection failed.");
}
}
if (sqlConnection.State == ConnectionState.Open) sqlConnection.Close();
}
else
{
_MyLog.Error("SQL Connection is not open. Check connection string: " + tbSqlDbName.Text);
MessageBox.Show("Check connection string: " + tbSqlDbName.Text, "SQL Connection is not open.");
}
}
catch (SqlException ex)
{
_MyLog.Error("SQL Connection is not open. Check connection string: " + tbSqlDbName.Text);
MessageBox.Show(ex.Message, "Unknown error when migrating RO data from MS Access to SQL");
}
}
}
private void MigrateTables(OleDbConnection accessConnection, SqlConnection sqlConnection)
{
DateTime lastTimeDbs = DateTime.Now;
DateTime lastTimeRos = DateTime.Now;
List<string> allTables = new List<string>();
List<string> allTablesText = new List<string>();
// set up the Progress bars. The top one is for the tables and the bottom one tracks ros as migrated for the current table.
int maxCntRo = GetRecordCountForTable("ROMaster", accessConnection);
lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, 1, 0, 0, lastTimeDbs, false);
lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, false);
lastTimeDbs = ProgressBarUpdate(pBarDbs, "ROMaster Table", 0, 5, 0, 1, lastTimeDbs, false);
OleDbDataReader reader = null;
OleDbCommand command = new OleDbCommand("select * from ROMaster", accessConnection);
reader = command.ExecuteReader();
// Do access's romaster table first so that the list of other tables to process is found. While doing this, migrate this table's data.
int cntRo = 0;
int cntDb = 0;
int maxCntDb = 0;
while (reader.Read()) // reading from Access Database
{
string RecID = reader[0].ToString();
int RecType = int.Parse(reader[1].ToString());
string ParentID = reader[2].ToString();
string AccPageID = reader[3].ToString();
string ModDateTime = reader[4].ToString();
string Info = reader[5].ToString();
// Migrate the access record to sql
AddRecordToRoAll(sqlConnection, RecID, RecType, ParentID, AccPageID, ModDateTime, Info, "ROMASTER");
cntRo++;
lastTimeRos = ProgressBarUpdate(pBarROs, "ROMaster", 0, maxCntRo, cntRo, 1, lastTimeRos, true);
// store table names so that the progress bars can be managed. Table names are at end of rectype=1 info's field
if (RecType == 1)
{
int tabIndx = Info.LastIndexOf("\tRO");
string tname = Info.Substring(tabIndx);
allTables.Add(tname.Substring(1));
allTablesText.Add(Info.Substring(0, tabIndx));
maxCntDb++;
}
}
lastTimeRos = ProgressBarUpdate(pBarROs, "ROMaster", 0, maxCntRo, maxCntRo, 1, lastTimeRos, true);
lastTimeDbs = ProgressBarUpdate(pBarDbs, null, 0, maxCntDb, 0, 0, lastTimeDbs, false);
reader.Close();
reader = null;
// now migrate all the tables that were found
foreach (string tableName in allTables)
{
lastTimeRos = DateTime.Now;
cntRo = 0;
maxCntRo = GetRecordCountForTable(tableName, accessConnection);
lastTimeRos = DateTime.Now;
lastTimeRos = ProgressBarUpdate(pBarROs, null, 0, maxCntRo, 0, 0, lastTimeRos, true);
lastTimeDbs = ProgressBarUpdate(pBarDbs, allTablesText[cntDb], 0, maxCntDb, cntDb, 1, lastTimeDbs, false);
command = null;
command = new OleDbCommand("select * from " + tableName, accessConnection);
reader = command.ExecuteReader();
while (reader.Read()) // read all of the records from the current access table
{
string RecID = reader[0].ToString();
int RecType = int.Parse(reader[1].ToString());
string ParentID = reader[2].ToString();
string AccPageID = reader[3].ToString();
string ModDateTime = reader[4].ToString();
string Info = reader[5].ToString();
// Migrate to sql:
AddRecordToRoAll(sqlConnection, RecID, RecType, ParentID, AccPageID, ModDateTime, Info, tableName);
cntRo++;
lastTimeRos = ProgressBarUpdate(pBarROs, AccPageID, 0, maxCntRo, cntRo, 1, lastTimeRos, true);
}
cntDb++;
reader.Close();
reader = null;
lastTimeRos = ProgressBarUpdate(pBarROs, tableName, 0, maxCntRo, maxCntRo, 1, lastTimeRos, false);
}
lastTimeDbs = ProgressBarUpdate(pBarDbs, allTablesText[maxCntDb - 1], 0, maxCntDb, maxCntDb, 1, lastTimeDbs, false);
pBarDbs.Text = "Referenced Object Tables Migration Completed";
pBarROs.Text = "Referenced Objects Migration Completed";
btnConvert.Enabled = false;
// add a record to the access database so that proms/roeditor will know that the data has been converted.
UpdateAccessToFlagConverted(accessConnection);
// if called from proms, the database connection string must be stored in the rodb record. write the connection string
// out to a temporary file so the Proms can set this field in its database.
WriteSqlPathToTempFile();
}
private void UpdateAccessToFlagConverted(OleDbConnection accessConnection)
{
try
{
OleDbDataReader reader = null;
string dt = string.Format("{0:yyyyMMddHHmmss}", System.DateTime.Now);
string strInsert = "INSERT INTO ROMaster (RecID, RecType, ModDateTime, Info) ";
// note that '8' for rectype flags database converted:
strInsert = strInsert + " VALUES ('09999999', 8, '" + dt + "', '" + _SqlConnectStr + "');";
OleDbCommand command = new OleDbCommand(strInsert, accessConnection);
reader = command.ExecuteReader();
if (reader.Read()) return;
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error on insert to flag migration completed");
}
}
private string _TmpFileForConnectStr = null;
private void WriteSqlPathToTempFile()
{
System.IO.File.WriteAllText(_TmpFileForConnectStr, _SqlConnectStr);
}
// the following is used to update the progress bars, it finds how many records are in a table.
private int GetRecordCountForTable(string tableName, OleDbConnection accessConnection)
{
OleDbDataReader reader = null;
int retcnt = 100;
try
{
OleDbCommand command = new OleDbCommand("SELECT COUNT (RecID) as cnt FROM " + tableName, accessConnection);
reader = command.ExecuteReader();
if (reader.Read())
{
retcnt = reader.GetInt32(0);
}
reader.Close();
command.Dispose();
}
catch
{
}
return retcnt;
}
DateTime ProgressBarUpdate(DevComponents.DotNetBar.Controls.ProgressBarX pbi, string msg, int min, int max, int progress, int flag, DateTime lastUpdateDisplay, bool doTimeCheck)
{
if (flag == 0) // setup
pbi.Maximum = max;
else
{
if (doTimeCheck && lastUpdateDisplay != null && DateTime.Now.Subtract(lastUpdateDisplay).TotalSeconds < 0.25f) return lastUpdateDisplay;
if (progress == pbi.Maximum) pbi.Text = msg.Trim();
pbi.Value = progress;
pbi.Text = string.Format("Processing {0} ({1} of {2})", msg.Trim(), progress + 1, pbi.Maximum);
}
pbi.Refresh();
return DateTime.Now;
}
// Using the data as defined by the arguments, save the data to sql.
private void AddRecordToRoAll(SqlConnection sqlConnection, string RecID, int RecType, string ParentID, string AccPageID, string ModDateTime, string Info, string tableName)
{
try
{
SqlCommand command = new SqlCommand();
command.Connection = sqlConnection;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "insertAllRectypes";
command.Parameters.AddWithValue("@RecType", RecType);
if (AccPageID == null || AccPageID == "")
command.Parameters.AddWithValue("@AccPageID", string.Empty);
else
command.Parameters.AddWithValue("@AccPageID", AccPageID);
command.Parameters.AddWithValue("@ROTable", tableName);
command.Parameters.AddWithValue("@RecID", RecID);
command.Parameters.AddWithValue("@ParentID", ParentID);
command.Parameters.AddWithValue("@Info", Info);
command.Parameters.AddWithValue("@ModDateTime", ModDateTime);
using (SqlDataReader reader = command.ExecuteReader())
{
bool success = true;
}
command = null;
}
catch (Exception ex)
{
string msg = string.Format("Error when adding a record to the sql database for table {0} recid {1}", tableName, RecID);
_MyLog.Error(msg, ex);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
// the user selected the button to test the sql connection string
private void btnTestConnect_Click(object sender, EventArgs e)
{
TestConnection(true);
}
// the RevDate & RevDescription are found in a stored procedure, vesp_GetSQLCodeRevision, in the sql database. These get updated each
// time a revision is made to the sql database using ROFixes.sql script.
private static DateTime _RevDate = DateTime.MinValue;
public static DateTime RevDate
{
get { return _RevDate; }
set { _RevDate = value; }
}
private static string _RevDescription = "Unknown";
public static string RevDescription
{
get { return _RevDescription; }
set { _RevDescription = value; }
}
// This is called to test the sql connection, either from the button when pressed by user, or from the convert button, before
// the conversion is done. See below for what is checked
private bool TestConnection(bool notifyUser)
{
// The following conditions must be true in order to migrate the ro data to sql. Only the first condition can be
// tested in this executable since the roall database is interfaced to by the roeditor & the program that migrates the data.
// The migration program will make the 2-4 tests, put up a message box if it cannot migrate & will send a failure back
// to this program, PROMS.
// 1) (done in proms to enable the migrate button) the rodb record's connection string must be 'cstring' (it is the connection string if data was migrated)
// 2) the roall database must exist when using the rodb record's connection string and this database must have the stored procedures
// 3) roall must be empty
// 4) the database must be the correct version
bool success = false;
bool dbsuc = false;
try
{
string conStr = string.Format(@"Data Source={0};Initial Catalog={1};Integrated Security=True", SqlServerName, SqlDatabaseName);
using (SqlConnection connection = new SqlConnection(conStr))
{
try
{
connection.Open();
if (connection.State == ConnectionState.Open)
{
// now see if there is an roall table
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "(SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ROALL]') AND type in (N'U'))";
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
int count = reader.GetInt32(0);
if (count < 1)
{
MessageBox.Show("The database exists but does not have the required 'ROALL' table. Contact your DBA", "Invalid database");
dbsuc = false;
}
else
dbsuc = true;
}
}
success = dbsuc;
if (success)
{
// now see if there are stored procedures:
command = null; // reset command
command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "(SELECT count(*) FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByROTable]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)";
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
int count = reader.GetInt32(0);
if (count < 1)
{
MessageBox.Show("The database exists but does not have the necessary stored procedures. Contact your DBA", "Invalid database");
dbsuc = false;
}
else
dbsuc = true;
}
}
success = dbsuc;
}
if (success)
{
// now test that the roall table is empty:
command = null; // reset command
command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "SELECT count(*) FROM roall";
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
int count = reader.GetInt32(0);
if (count > 0)
{
MessageBox.Show("The database already has data, cannot migrate additional data into it. Contact your DBA", "Invalid contents in database");
dbsuc = false;
}
else
dbsuc = true;
}
}
success = dbsuc;
}
if (success)
{
// now test that the database version is ok
command = null; // reset command
command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "vesp_GetSQLCodeRevision";
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
_RevDate = reader.GetDateTime(0);
_RevDescription = reader.GetString(1);
dbsuc = true;
}
else
dbsuc = false;
}
success = dbsuc;
}
}
else
{
if (notifyUser) MessageBox.Show("Connection failed.", "Connection Failed");
}
}
catch (SqlException ex)
{
if (notifyUser) MessageBox.Show("Connection failed: " + ex, "Connection Failed");
}
}
}
catch (Exception ex)
{
if (notifyUser) MessageBox.Show("Connection failed: " + ex, "Connection Failed");
}
if (notifyUser && success) MessageBox.Show("You have been successfully connected to the database!", "Connection Succeeded");
return success;
}
private void tbSqlDbName_Leave(object sender, EventArgs e)
{
if (_Initializing) return;
SqlDatabaseName = tbSqlDbName.Text;
}
private void tbSqlServerName_Leave(object sender, EventArgs e)
{
if (_Initializing) return;
SqlServerName = tbSqlServerName.Text;
}
private void tbAccessPath_Leave(object sender, EventArgs e)
{
if (_Initializing) return;
MSAccessPath = tbAccessPath.Text;
}
}
}

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1EC96BDA-01E7-4153-A95D-6A4A36FA278E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RoAccessToSql</RootNamespace>
<AssemblyName>RoAccessToSql</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\VEPROMS User Interface\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="DevComponents.DotNetBar2, Version=14.0.0.11, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04, processorArchitecture=MSIL" />
<Reference Include="log4net">
<HintPath>..\DataLoader\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Volian.Base.Library">
<HintPath>..\Volian.Base.Library\bin\Debug\Volian.Base.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="RoAccessToSql.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RoAccessToSql.Designer.cs">
<DependentUpon>RoAccessToSql.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RoAccessToSql.resx">
<DependentUpon>RoAccessToSql.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnBrowse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsDAAALAwFJjozSAAACeUlE
QVQ4T6WSWUiUURiG/4suurJIjUIwskQsEAMjqosQpUVNKbdCSRPKrQVDMddmXEedGdcpFXNGnUYdrSzF
sEIoFInQcqHE1CwoKsXUUMnt6XfEye0munjgnO+c9+HjO0cA/osNi2tJLdA6SXN13MwoI12lJ06uiV8+
W3d5IwIjVXiGKvwX11djSs2TRFlUito7ILIAoVab7SvCWhqrZYq1omXC4gpPe4Ur8AjNMQjo69IwPVZj
4PeojtlhNfoyBXXalKSNBJ5hSjxCcnELzkeoKVcyNVq5Kjz/rZDZnggqSzOoKEpDXZBEcU4id+Sx5Mui
RcdfmVClyWLqh8YYXhDD9MVCT/CGrBPcK5Hx62uxMdxUm2XgiT6Tep2MhxVp6NXJ6IqllKlucTc3niJl
LKqsGINMqChOY+JTnqHtwRYJdZVK5gelMJSymo9ibSAOeiPhXTid1T5cD3IvF9SqZMb7M+CznEdVCtqe
ypcurWz9bQC0ezHX6sr0M0c+lNtx5cKJcVGwXyjJlfDzvZSh1gTqdHIWBiTQHbIU7AwSg+eYa3Nnuvk4
E41HGak9gDTUmvPOZjmGGRQqExjpiuG+NouOl2InvRGi4BJ0+LPw6gwzL04x2XSM0ToHvlfZ0p66FT9X
KxxsTGwMAlVmLN3NiTzQZkJ/IrwR233tzUyLG5PPHRmrP8Sw3o4vmr30yE2RBO/Bfp9Fg/EV8tKjqSnL
oOdxGO3ZgpE2+SaaZZtpSNpCdbw56mgLbt/YhZ/L7oVD9pYuRkF2ShTZksukxwQSd813cbJc9HHm7MnD
OB2x46CdNbZWFljuNGP7NhN2mJqIuRX/YOXm30H4A70P0TsBWkcYAAAAAElFTkSuQmCC
</value>
</data>
</root>