diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRServer.Model.csproj b/BRServer.Model/BRServer.Model.csproj
index 282cd2c..4b6463d 100644
--- a/BRServer.Model/BRServer.Model.csproj
+++ b/BRServer.Model/BRServer.Model.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRServer.Model.csproj b/BRServer.Model/BRServer.Model.csproj
index 282cd2c..4b6463d 100644
--- a/BRServer.Model/BRServer.Model.csproj
+++ b/BRServer.Model/BRServer.Model.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.dll b/BRServer.Model/obj/Debug/BRServer.Model.dll
index 973712c..a5ad8db 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.dll
+++ b/BRServer.Model/obj/Debug/BRServer.Model.dll
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRServer.Model.csproj b/BRServer.Model/BRServer.Model.csproj
index 282cd2c..4b6463d 100644
--- a/BRServer.Model/BRServer.Model.csproj
+++ b/BRServer.Model/BRServer.Model.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.dll b/BRServer.Model/obj/Debug/BRServer.Model.dll
index 973712c..a5ad8db 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.dll
+++ b/BRServer.Model/obj/Debug/BRServer.Model.dll
Binary files differ
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.pdb b/BRServer.Model/obj/Debug/BRServer.Model.pdb
index dcf82a9..7eddac9 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.pdb
+++ b/BRServer.Model/obj/Debug/BRServer.Model.pdb
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRServer.Model.csproj b/BRServer.Model/BRServer.Model.csproj
index 282cd2c..4b6463d 100644
--- a/BRServer.Model/BRServer.Model.csproj
+++ b/BRServer.Model/BRServer.Model.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.dll b/BRServer.Model/obj/Debug/BRServer.Model.dll
index 973712c..a5ad8db 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.dll
+++ b/BRServer.Model/obj/Debug/BRServer.Model.dll
Binary files differ
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.pdb b/BRServer.Model/obj/Debug/BRServer.Model.pdb
index dcf82a9..7eddac9 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.pdb
+++ b/BRServer.Model/obj/Debug/BRServer.Model.pdb
Binary files differ
diff --git a/BRServer.suo b/BRServer.suo
index 72bf124..a70401f 100644
--- a/BRServer.suo
+++ b/BRServer.suo
Binary files differ
diff --git a/BRServer.BLL/Alarm.cs b/BRServer.BLL/Alarm.cs
new file mode 100644
index 0000000..31c6bfc
--- /dev/null
+++ b/BRServer.BLL/Alarm.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class Alarm
+ {
+ private static Alarm alarm;
+
+ private Alarm()
+ {
+ }
+
+ public static Alarm getInstance()
+ {
+ if (alarm == null)
+ {
+ alarm = new Alarm();
+ }
+ return alarm;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.Alarm alarm)
+ {
+ if (alarm == null || alarm.MESSAGE == null || alarm.MESSAGE == "")
+ {
+ return;
+ }
+
+ IAlarm dal = DALFactory.Alarm.Create();
+ dal.insert(alarm);
+ }
+
+ ///**
+ // *sequeceName:需要更新的序列名称
+ // *key:主键字段名称
+ // *tableName:表名称
+ // */
+ //public void updateSequence(String sequeceName)
+ //{
+ // IBRCJ dal = DALFactory.BR.Create();
+ // dal.updateSequence(sequeceName);
+ //}
+
+ }
+}
diff --git a/BRServer.BLL/BRCJ.cs b/BRServer.BLL/BRCJ.cs
new file mode 100644
index 0000000..c90b49e
--- /dev/null
+++ b/BRServer.BLL/BRCJ.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BRServer.IDAL;
+
+namespace BRServer.BLL
+{
+ public class BRCJ
+ {
+ private static BRCJ br;
+
+ private BRCJ()
+ {
+ }
+
+ public static BRCJ getInstance()
+ {
+ if (br == null)
+ {
+ br = new BRCJ();
+ }
+ return br;
+ }
+
+ ///
+ /// A method to insert a new Adapter
+ ///
+ /// An adapter entity with information about the new adapter
+ public void insert(Model.BRCJ cj)
+ {
+ if (cj == null || (cj.SEDIMENTATION == 0.0 && cj.TEMPERATURE == 0.0))
+ {
+ return;
+ }
+
+ IBRCJ dal = DALFactory.BRCJ.Create();
+ dal.insert(cj);
+ }
+ }
+}
diff --git a/BRServer.BLL/BRServer.BLL.csproj b/BRServer.BLL/BRServer.BLL.csproj
index 3d489f9..c8b2a14 100644
--- a/BRServer.BLL/BRServer.BLL.csproj
+++ b/BRServer.BLL/BRServer.BLL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
index 64bafec..b7f9bce 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.dll b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
index 273337f..4123df3 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.dll
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.dll
Binary files differ
diff --git a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
index ac68f3f..3737785 100644
--- a/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
+++ b/BRServer.BLL/obj/Debug/BRServer.BLL.pdb
Binary files differ
diff --git a/BRServer.DAL/Alarm.cs b/BRServer.DAL/Alarm.cs
new file mode 100644
index 0000000..c9ad5ca
--- /dev/null
+++ b/BRServer.DAL/Alarm.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class Alarm : IDAL.IAlarm
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_ALARM";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_MESSAGE = "MESSAGE";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_MESSAGE = "@MESSAGE";
+
+ private const string SQL_INSERT_ALARM = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_MESSAGE + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_MESSAGE + ")";
+
+
+ public void insert(Model.Alarm alarm)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(alarm.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, alarm);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_ALARM, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_MESSAGE, MySqlDbType.VarChar,255)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.Alarm alarm)
+ {
+ parms[0].Value = alarm.DEVCODE;
+
+ if (null != alarm.LOGTIME)
+ {
+ parms[1].Value = alarm.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != alarm.MESSAGE)
+ {
+ parms[2].Value = alarm.MESSAGE;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRCJ.cs b/BRServer.DAL/BRCJ.cs
new file mode 100644
index 0000000..7326b2a
--- /dev/null
+++ b/BRServer.DAL/BRCJ.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data.MySqlClient;
+
+namespace BRServer.DAL
+{
+ public class BRCJ : IDAL.IBRCJ
+ {
+ public static readonly string ConnectionStringOrderDistributedTransaction =
+ System.Configuration.ConfigurationManager.AppSettings["MySqlConnString"];
+
+ // Static constants
+ private const string TABLE_NAME = "BRCJ_DATA";
+
+ private const string COLUMN_DEVCODE = "DEVCODE";
+ private const string COLUMN_LOGTIME = "LOGTIME";
+ private const string COLUMN_CELL = "CELL";
+ private const string COLUMN_VALUE = "SEDIMENTATION";
+ private const string COLUMN_VALUE2 = "TEMPERATURE";
+ private const string COLUMN_UPTIME = "UPTIME";
+
+ private const string PARM_DEVCODE = "@DEVCODE";
+ private const string PARM_LOGTIME = "@LOGTIME";
+ private const string PARM_CELL = "@CELL";
+ private const string PARM_VALUE = "@SEDIMENTATION";
+ private const string PARM_VALUE2 = "@TEMPERATURE";
+ private const string PARM_UPTIME = "@UPTIME";
+
+ private const string SQL_INSERT_CJ = "INSERT INTO " + TABLE_NAME
+ + " (" + COLUMN_DEVCODE + ","
+ + " " + COLUMN_LOGTIME + ","
+ + " " + COLUMN_CELL + ","
+ + " " + COLUMN_VALUE + ","
+ + " " + COLUMN_VALUE2 + ","
+ + " " + COLUMN_UPTIME + ")"
+ + " VALUES "
+ + " (" + PARM_DEVCODE + ","
+ + " " + PARM_LOGTIME + ","
+ + " " + PARM_CELL + ","
+ + " " + PARM_VALUE + ","
+ + " " + PARM_VALUE2 + ","
+ + " " + PARM_UPTIME + ")";
+
+
+ public void insert(Model.BRCJ cj)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ if (string.IsNullOrEmpty(cj.DEVCODE))
+ {
+ throw new Exception("设备ID为空!");
+ }
+
+ MySqlParameter[] parms = GetAdapterParameters();
+ SetAdapterParameters(parms, cj);
+
+ MySqlCommand cmd = new MySqlCommand(SQL_INSERT_CJ, conn);
+ foreach (MySqlParameter pram in parms)
+ cmd.Parameters.Add(pram);
+ cmd.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+ /**
+ *sequeceName:需要更新的序列名称
+ *key:主键字段名称
+ *tableName:表名称
+ */
+ public void updateSequence(String sequeceName)
+ {
+ MySqlTransaction tran = null;
+ using (MySqlConnection conn = new MySqlConnection(ConnectionStringOrderDistributedTransaction))
+ {
+ try
+ {
+ conn.Open();
+ tran = conn.BeginTransaction();
+
+ String SQL_DROP_SEQUENCE = "ALTER TABLE " + TABLE_NAME +" DROP "+ sequeceName;
+ MySqlCommand cmd1 = new MySqlCommand(SQL_DROP_SEQUENCE, conn);
+ cmd1.ExecuteNonQuery();
+
+ String SQL_ADD_SEQUENC = "ALTER TABLE " + TABLE_NAME + " ADD " + sequeceName +
+ " INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (" + sequeceName + ")";
+
+ MySqlCommand cmd2 = new MySqlCommand(SQL_ADD_SEQUENC, conn);
+ cmd2.ExecuteNonQuery();
+
+ tran.Commit();
+ }
+ catch (Exception e)
+ {
+ if (null != tran)
+ {
+ tran.Rollback();
+ }
+ throw (e);
+ }
+ }
+ }
+
+
+ ///
+ /// An internal function to get the database parameters
+ ///
+ /// Parameter array
+ private static MySqlParameter[] GetAdapterParameters()
+ {
+ MySqlParameter[] parms = null;//OracleHelperParameterCache.GetCachedParameterSet(SQL_INSERT_WS, "INSERT:UPDATE");
+
+ if (parms == null)
+ {
+ parms = new MySqlParameter[]{
+ new MySqlParameter(PARM_DEVCODE, MySqlDbType.VarChar, 255),
+ new MySqlParameter(PARM_LOGTIME, MySqlDbType.DateTime),
+ new MySqlParameter(PARM_CELL, MySqlDbType.VarChar,255),
+ new MySqlParameter(PARM_VALUE, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_VALUE2, MySqlDbType.Float,20),
+ new MySqlParameter(PARM_UPTIME, MySqlDbType.DateTime)
+ };
+ }
+
+ return parms;
+ }
+
+
+ ///
+ /// An internal function to bind values parameters for insert
+ ///
+ /// Database parameters
+ /// Values to bind to parameters
+ private void SetAdapterParameters(MySqlParameter[] parms, Model.BRCJ cj)
+ {
+ parms[0].Value = cj.DEVCODE;
+
+ if (null != cj.LOGTIME)
+ {
+ parms[1].Value = cj.LOGTIME;
+ }
+ else
+ {
+ parms[1].Value = DBNull.Value;
+ }
+
+ if (null != cj.CELL)
+ {
+ parms[2].Value = cj.CELL;
+ }
+ else
+ {
+ parms[2].Value = DBNull.Value;
+ }
+
+ if (null != cj.SEDIMENTATION)
+ {
+ parms[3].Value = cj.SEDIMENTATION;
+ }
+ else
+ {
+ parms[3].Value = DBNull.Value;
+ }
+
+ if (null != cj.TEMPERATURE)
+ {
+ parms[4].Value = cj.TEMPERATURE;
+ }
+ else
+ {
+ parms[4].Value = DBNull.Value;
+ }
+
+ if (null != cj.UPTIME)
+ {
+ parms[5].Value = cj.UPTIME;
+ }
+ else
+ {
+ parms[5].Value = DBNull.Value;
+ }
+ }
+ }
+}
diff --git a/BRServer.DAL/BRServer.DAL.csproj b/BRServer.DAL/BRServer.DAL.csproj
index aa29460..3580c8e 100644
--- a/BRServer.DAL/BRServer.DAL.csproj
+++ b/BRServer.DAL/BRServer.DAL.csproj
@@ -45,7 +45,8 @@
-
+
+
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
index 4a9e055..9c6f3ca 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.dll b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
index 59819df..b4d9f97 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.dll
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.dll
Binary files differ
diff --git a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
index f5a2f12..3c487bc 100644
--- a/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
+++ b/BRServer.DAL/obj/Debug/BRServer.DAL.pdb
Binary files differ
diff --git a/BRServer.DALFactory/Alarm.cs b/BRServer.DALFactory/Alarm.cs
new file mode 100644
index 0000000..9fe1f50
--- /dev/null
+++ b/BRServer.DALFactory/Alarm.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class Alarm
+ {
+ public static BRServer.IDAL.IAlarm Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".Alarm";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IAlarm)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRCJ.cs b/BRServer.DALFactory/BRCJ.cs
new file mode 100644
index 0000000..56bfa0f
--- /dev/null
+++ b/BRServer.DALFactory/BRCJ.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace BRServer.DALFactory
+{
+ public class BRCJ
+ {
+ public static BRServer.IDAL.IBRCJ Create()
+ {
+ // Look up the DAL implementation we should be using
+ string path = System.Configuration.ConfigurationManager.AppSettings["mysqlDAL"];
+ string className = path + ".BRCJ";
+
+ // Using the evidence given in the config file load the appropriate assembly and class
+ return (BRServer.IDAL.IBRCJ)Assembly.Load(path).CreateInstance(className);
+ }
+ }
+}
diff --git a/BRServer.DALFactory/BRServer.DALFactory.csproj b/BRServer.DALFactory/BRServer.DALFactory.csproj
index 3799033..0a82d65 100644
--- a/BRServer.DALFactory/BRServer.DALFactory.csproj
+++ b/BRServer.DALFactory/BRServer.DALFactory.csproj
@@ -41,7 +41,8 @@
-
+
+
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
index 716d0c1..1fb7c62 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
index b32b907..f2b0556 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.dll
Binary files differ
diff --git a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
index d3f668a..f610993 100644
--- a/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
+++ b/BRServer.DALFactory/obj/Debug/BRServer.DALFactory.pdb
Binary files differ
diff --git a/BRServer.IDAL/BRServer.IDAL.csproj b/BRServer.IDAL/BRServer.IDAL.csproj
index 4ff7d1b..129f852 100644
--- a/BRServer.IDAL/BRServer.IDAL.csproj
+++ b/BRServer.IDAL/BRServer.IDAL.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.IDAL/IAlarm.cs b/BRServer.IDAL/IAlarm.cs
new file mode 100644
index 0000000..72dffcc
--- /dev/null
+++ b/BRServer.IDAL/IAlarm.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IBRCJ
+ {
+ void insert(Model.BRCJ cj);
+ void updateSequence(String sequeceName);
+ //int queryCountByDevAndUpTime(String devCode, DateTime upTime);
+
+ //float getLastData(Model.BRKKJ tempInfo);
+ }
+}
diff --git a/BRServer.IDAL/IBRCJ.cs b/BRServer.IDAL/IBRCJ.cs
new file mode 100644
index 0000000..b187d2e
--- /dev/null
+++ b/BRServer.IDAL/IBRCJ.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+
+namespace BRServer.IDAL
+{
+ public interface IAlarm
+ {
+ void insert(Model.Alarm alarm);
+ //void updateSequence(String sequeceName);
+ }
+}
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
index 77a9cd8..2846259 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
index 095ed2b..f669ec3 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.dll
Binary files differ
diff --git a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
index f13b477..a892aa5 100644
--- a/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
+++ b/BRServer.IDAL/obj/Debug/BRServer.IDAL.pdb
Binary files differ
diff --git a/BRServer.Model/Alarm.cs b/BRServer.Model/Alarm.cs
new file mode 100644
index 0000000..477c734
--- /dev/null
+++ b/BRServer.Model/Alarm.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class Alarm
+ {
+ private long dbId;
+ private string devCode;
+ private string message;
+ private DateTime logTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public string MESSAGE
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRCJ.cs b/BRServer.Model/BRCJ.cs
new file mode 100644
index 0000000..8f1f519
--- /dev/null
+++ b/BRServer.Model/BRCJ.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BRServer.Model
+{
+ public class BRCJ
+ {
+ private long dbId;
+ private string devCode;
+ private DateTime logTime;
+ private int cell;
+ private float sedimentation;
+ private float temperature;
+ private DateTime upTime;
+
+ public long DBID
+ {
+ get { return dbId; }
+ set { dbId = value; }
+ }
+
+ public string DEVCODE
+ {
+ get { return devCode; }
+ set { devCode = value; }
+ }
+
+ public DateTime LOGTIME
+ {
+ get { return logTime; }
+ set { logTime = value; }
+ }
+
+ public int CELL
+ {
+ get { return cell; }
+ set { cell = value; }
+ }
+
+ public float SEDIMENTATION
+ {
+ get { return sedimentation; }
+ set { sedimentation = value; }
+ }
+
+ public float TEMPERATURE
+ {
+ get { return temperature; }
+ set { temperature = value; }
+ }
+
+ public DateTime UPTIME
+ {
+ get { return upTime; }
+ set { upTime = value; }
+ }
+ }
+}
diff --git a/BRServer.Model/BRServer.Model.csproj b/BRServer.Model/BRServer.Model.csproj
index 282cd2c..4b6463d 100644
--- a/BRServer.Model/BRServer.Model.csproj
+++ b/BRServer.Model/BRServer.Model.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.dll b/BRServer.Model/obj/Debug/BRServer.Model.dll
index 973712c..a5ad8db 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.dll
+++ b/BRServer.Model/obj/Debug/BRServer.Model.dll
Binary files differ
diff --git a/BRServer.Model/obj/Debug/BRServer.Model.pdb b/BRServer.Model/obj/Debug/BRServer.Model.pdb
index dcf82a9..7eddac9 100644
--- a/BRServer.Model/obj/Debug/BRServer.Model.pdb
+++ b/BRServer.Model/obj/Debug/BRServer.Model.pdb
Binary files differ
diff --git a/BRServer.suo b/BRServer.suo
index 72bf124..a70401f 100644
--- a/BRServer.suo
+++ b/BRServer.suo
Binary files differ
diff --git a/BRServer/BRCJTagHandler.cs b/BRServer/BRCJTagHandler.cs
new file mode 100644
index 0000000..c2935ec
--- /dev/null
+++ b/BRServer/BRCJTagHandler.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+namespace BRServer
+{
+ public class BRCJTagHandler:TagHandler
+ {
+ public override void resolve(Tag tag,CasicSession session)
+ {
+ //TODO LIST:解析数据,保存数据
+ UploadTag BRTag = tag as UploadTag;
+ Interval = BRTag.CollectInter;
+ CollecTime = BRTag.CollectTime;
+ int len = BRTag.Len;
+ String dataValue = BRTag.DataValue;
+
+ DataList = new List