Ejemplo n.º 1
0
        /// <summary>
        /// Method to retrieve orders information
        /// </summary>
        /// <returns>All orders</returns>
        public List <OrderInfo> GetOrders()
        {
            List <OrderInfo> orders = new List <OrderInfo>();

            try {
                //Execute a query to read the orders
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_ORDER_GETORDERS, null)) {
                    while (rdr.Read())
                    {
                        OrderInfo order = new OrderInfo();
                        order.LscID      = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        order.TargetID   = ComUtility.DBNullInt32Handler(rdr["TargetID"]);
                        order.TargetType = ComUtility.DBNullNodeTypeHandler(rdr["TargetType"]);
                        order.OrderType  = ComUtility.DBNullActTypeHandler(rdr["OrderType"]);
                        order.RelValue1  = ComUtility.DBNullStringHandler(rdr["RelValue1"]);
                        order.RelValue2  = ComUtility.DBNullStringHandler(rdr["RelValue2"]);
                        order.RelValue3  = ComUtility.DBNullStringHandler(rdr["RelValue3"]);
                        order.RelValue4  = ComUtility.DBNullStringHandler(rdr["RelValue4"]);
                        order.RelValue5  = ComUtility.DBNullStringHandler(rdr["RelValue5"]);
                        order.UpdateTime = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);

                        orders.Add(order);
                    }
                }

                return(orders);
            } catch {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the reservations
        /// </summary>
        public void UpdateReservations(IEnumerable <string> ids, bool isSended)
        {
            using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction)) {
                conn.Open();
                SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);

                try {
                    SqlParameter[] parms = { new SqlParameter("@Id",       SqlDbType.VarChar, 100),
                                             new SqlParameter("@IsSended", SqlDbType.Bit) };

                    foreach (var id in ids)
                    {
                        parms[0].Value = ComUtility.DBNullString2Checker(id);
                        parms[1].Value = isSended;

                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_SELECT_LSC_UPDATERESERVATION, parms);
                    }
                    trans.Commit();
                } catch {
                    trans.Rollback();
                    throw;
                } finally {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to get the specified node
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="nodeId">nodeId</param>
        /// <param name="nodeType">nodeType</param>
        /// <returns>node information</returns>
        public NodeInfo GetNode(int lscId, int nodeId, EnmNodeType nodeType)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID",    SqlDbType.Int),
                                         new SqlParameter("@NodeID",   SqlDbType.Int),
                                         new SqlParameter("@NodeType", SqlDbType.Int) };
                parms[0].Value = lscId;
                parms[1].Value = nodeId;
                parms[2].Value = (int)nodeType;

                NodeInfo node = null;
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_NODE_GETNODE, parms)) {
                    if (rdr.Read())
                    {
                        node            = new NodeInfo();
                        node.LscID      = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        node.NodeID     = ComUtility.DBNullInt32Handler(rdr["NodeID"]);
                        node.NodeType   = ComUtility.DBNullNodeTypeHandler(rdr["NodeType"]);
                        node.Value      = ComUtility.DBNullFloatHandler(rdr["Value"]);
                        node.Status     = ComUtility.DBNullStateHandler(rdr["Status"]);
                        node.DateTime   = ComUtility.DBNullDateTimeHandler(rdr["DateTime"]);
                        node.UpdateTime = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);
                    }
                }

                return(node);
            } catch {
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Syn Alarms
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="connectionString">connectionString</param>
        /// <returns>Alarms</returns>
        public List <AlarmInfo> SynAlarms(int lscId, string connectionString)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID",  SqlDbType.Int),
                                         new SqlParameter("@AIType", SqlDbType.Int),
                                         new SqlParameter("@DIType", SqlDbType.Int) };
                parms[0].Value = lscId;
                parms[1].Value = (int)EnmNodeType.Aic;
                parms[2].Value = (int)EnmNodeType.Dic;

                List <AlarmInfo> alarms = new List <AlarmInfo>();
                SqlHelper.TestConnection(connectionString);
                using (DataTable dt = SqlHelper.ExecuteTable(connectionString, CommandType.Text, SqlText.SQL_SELECT_ALARM_SYNALARMS, parms)) {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            AlarmInfo alarm = new AlarmInfo();
                            alarm.LscID          = ComUtility.DBNullInt32Handler(dr["LscID"]);
                            alarm.SerialNO       = ComUtility.DBNullInt32Handler(dr["SerialNO"]);
                            alarm.Area1Name      = ComUtility.DBNullStringHandler(dr["Area1Name"]);
                            alarm.Area2Name      = ComUtility.DBNullStringHandler(dr["Area2Name"]);
                            alarm.Area3Name      = ComUtility.DBNullStringHandler(dr["Area3Name"]);
                            alarm.Area4Name      = ComUtility.DBNullStringHandler(dr["Area4Name"]);
                            alarm.StaName        = ComUtility.DBNullStringHandler(dr["StaName"]);
                            alarm.DevName        = ComUtility.DBNullStringHandler(dr["DevName"]);
                            alarm.DevDesc        = ComUtility.DBNullStringHandler(dr["DevDesc"]);
                            alarm.NodeID         = ComUtility.DBNullInt32Handler(dr["NodeID"]);
                            alarm.NodeType       = ComUtility.DBNullNodeTypeHandler(dr["NodeType"]);
                            alarm.NodeName       = ComUtility.DBNullStringHandler(dr["NodeName"]);
                            alarm.AlarmID        = ComUtility.DBNullInt32Handler(dr["AlarmID"]);
                            alarm.AlarmValue     = ComUtility.DBNullFloatHandler(dr["AlarmValue"]);
                            alarm.AlarmLevel     = ComUtility.DBNullAlarmLevelHandler(dr["AlarmLevel"]);
                            alarm.AlarmStatus    = ComUtility.DBNullAlarmStatusHandler(dr["AlarmStatus"]);
                            alarm.AlarmDesc      = ComUtility.DBNullStringHandler(dr["AlarmDesc"]);
                            alarm.AuxAlarmDesc   = ComUtility.DBNullStringHandler(dr["AuxAlarmDesc"]);
                            alarm.StartTime      = ComUtility.DBNullDateTimeHandler(dr["StartTime"]);
                            alarm.EndTime        = ComUtility.DBNullDateTimeHandler(dr["EndTime"]);
                            alarm.ConfirmName    = ComUtility.DBNullStringHandler(dr["ConfirmName"]);
                            alarm.ConfirmMarking = ComUtility.DBNullConfirmMarkingHandler(dr["ConfirmMarking"]);
                            alarm.ConfirmTime    = ComUtility.DBNullDateTimeHandler(dr["ConfirmTime"]);
                            alarm.AuxSet         = ComUtility.DBNullStringHandler(dr["AuxSet"]);
                            alarm.TaskID         = ComUtility.DBNullStringHandler(dr["TaskID"]);
                            alarm.ProjName       = ComUtility.DBNullStringHandler(dr["ProjName"]);
                            alarm.TurnCount      = ComUtility.DBNullInt32Handler(dr["TurnCount"]);
                            alarm.UpdateTime     = ComUtility.DBNullDateTimeHandler(dr["UpdateTime"]);

                            alarms.Add(alarm);
                        }

                        SqlHelper.ExecuteBulkCopy(SqlHelper.ConnectionStringLocalTransaction, SqlText.TN_Alarm, dt);
                    }
                }

                return(alarms);
            } catch {
                throw;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Syn Trend Alarms
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="connectionString">connectionString</param>
        /// <returns>Trend Alarms</returns>
        public List <TrendAlarmInfo> SynTrendAlarms(int lscId, string connectionString)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int) };
            parms[0].Value = lscId;

            var alarms = new List <TrendAlarmInfo>();

            SqlHelper.TestConnection(connectionString);
            using (var dt = SqlHelper.ExecuteTable(connectionString, CommandType.Text, SqlText.SQL_SELECT_ALARM_SYNTRENDALARMS, parms)) {
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        var alarm = new TrendAlarmInfo();
                        alarm.LscID                 = ComUtility.DBNullInt32Handler(dr["LscID"]);
                        alarm.Area1Name             = ComUtility.DBNullStringHandler(dr["Area1Name"]);
                        alarm.Area2Name             = ComUtility.DBNullStringHandler(dr["Area2Name"]);
                        alarm.Area3Name             = ComUtility.DBNullStringHandler(dr["Area3Name"]);
                        alarm.Area4Name             = String.Empty;
                        alarm.StaName               = ComUtility.DBNullStringHandler(dr["StaName"]);
                        alarm.DevName               = ComUtility.DBNullStringHandler(dr["DevName"]);
                        alarm.NodeID                = ComUtility.DBNullInt32Handler(dr["NodeID"]);
                        alarm.NodeType              = EnmNodeType.Aic;
                        alarm.NodeName              = ComUtility.DBNullStringHandler(dr["NodeName"]);
                        alarm.AlarmType             = ComUtility.DBNullStringHandler(dr["AlarmType"]);
                        alarm.AlarmStatus           = ComUtility.DBNullInt32Handler(dr["AlarmStatus"]);
                        alarm.AlarmLevel            = ComUtility.DBNullInt32Handler(dr["AlarmLevel"]);
                        alarm.StartValue            = ComUtility.DBNullFloatHandler(dr["StartValue"]);
                        alarm.AlarmValue            = ComUtility.DBNullFloatHandler(dr["AlarmValue"]);
                        alarm.DiffValue             = ComUtility.DBNullFloatHandler(dr["DiffValue"]);
                        alarm.StartTime             = ComUtility.DBNullDateTimeHandler(dr["StartTime"]);
                        alarm.AlarmTime             = ComUtility.DBNullDateTimeHandler(dr["AlarmTime"]);
                        alarm.EventTime             = ComUtility.DBNullDateTimeHandler(dr["EventTime"]);
                        alarm.ConfirmName           = ComUtility.DBNullStringHandler(dr["ConfirmName"]);
                        alarm.ConfirmTime           = ComUtility.DBNullDateTimeHandler(dr["ConfirmTime"]);
                        alarm.EndName               = ComUtility.DBNullStringHandler(dr["EndName"]);
                        alarm.EndTime               = ComUtility.DBNullDateTimeHandler(dr["EndTime"]);
                        alarm.StartIsAddAlarmList   = ComUtility.DBNullBooleanHandler(dr["StartIsAddAlarmList"]);
                        alarm.EndIsAddAlarmList     = ComUtility.DBNullBooleanHandler(dr["EndIsAddAlarmList"]);
                        alarm.ConfirmIsAddAlarmList = ComUtility.DBNullBooleanHandler(dr["ConfirmIsAddAlarmList"]);
                        alarms.Add(alarm);
                    }

                    SqlHelper.ExecuteBulkCopy(SqlHelper.ConnectionStringLocalTransaction, SqlText.TN_TrendAlarm, dt);
                }
            }

            return(alarms);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method to get lsc information
        /// </summary>
        /// <returns>lsc information</returns>
        public LscInfo GetLsc(int lscId)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int) };
                parms[0].Value = lscId;

                LscInfo lsc = null;
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_LSC_GETLSC, parms)) {
                    if (rdr.Read())
                    {
                        lsc               = new LscInfo();
                        lsc.LscID         = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        lsc.LscName       = ComUtility.DBNullStringHandler(rdr["LscName"]);
                        lsc.LscIP         = ComUtility.DBNullStringHandler(rdr["LscIP"]);
                        lsc.LscPort       = ComUtility.DBNullInt32Handler(rdr["LscPort"]);
                        lsc.LscUID        = ComUtility.DBNullStringHandler(rdr["LscUID"]);
                        lsc.LscPwd        = ComUtility.DBNullStringHandler(rdr["LscPwd"]);
                        lsc.BeatInterval  = ComUtility.DBNullInt32Handler(rdr["BeatInterval"]);
                        lsc.BeatDelay     = ComUtility.DBNullInt32Handler(rdr["BeatDelay"]);
                        lsc.DBServer      = ComUtility.DBNullStringHandler(rdr["DBServer"]);
                        lsc.DBPort        = ComUtility.DBNullInt32Handler(rdr["DBPort"]);
                        lsc.DBName        = ComUtility.DBNullStringHandler(rdr["DBName"]);
                        lsc.DBUID         = ComUtility.DBNullStringHandler(rdr["DBUID"]);
                        lsc.DBPwd         = ComUtility.DBNullStringHandler(rdr["DBPwd"]);
                        lsc.HisDBServer   = ComUtility.DBNullStringHandler(rdr["HisDBServer"]);
                        lsc.HisDBPort     = ComUtility.DBNullInt32Handler(rdr["HisDBPort"]);
                        lsc.HisDBName     = ComUtility.DBNullStringHandler(rdr["HisDBName"]);
                        lsc.HisDBUID      = ComUtility.DBNullStringHandler(rdr["HisDBUID"]);
                        lsc.HisDBPwd      = ComUtility.DBNullStringHandler(rdr["HisDBPwd"]);
                        lsc.Connected     = ComUtility.DBNullBooleanHandler(rdr["Connected"]);
                        lsc.ChangeTime    = ComUtility.DBNullDateTimeHandler(rdr["ChangedTime"]);
                        lsc.MaxNodeModify = null;
                        lsc.MaxChangeLog  = null;
                        lsc.Enabled       = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    }
                }

                return(lsc);
            } catch {
                throw;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Method to get all lscs information
        /// </summary>
        /// <returns>all lscs information</returns>
        public List <LscInfo> GetLscs()
        {
            try {
                List <LscInfo> lscList = new List <LscInfo>();
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_LSC_GETLSCS, null)) {
                    while (rdr.Read())
                    {
                        LscInfo lsc = new LscInfo();
                        lsc.LscID         = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        lsc.LscName       = ComUtility.DBNullStringHandler(rdr["LscName"]);
                        lsc.LscIP         = ComUtility.DBNullStringHandler(rdr["LscIP"]);
                        lsc.LscPort       = ComUtility.DBNullInt32Handler(rdr["LscPort"]);
                        lsc.LscUID        = ComUtility.DBNullStringHandler(rdr["LscUID"]);
                        lsc.LscPwd        = ComUtility.DBNullStringHandler(rdr["LscPwd"]);
                        lsc.BeatInterval  = ComUtility.DBNullInt32Handler(rdr["BeatInterval"]);
                        lsc.BeatDelay     = ComUtility.DBNullInt32Handler(rdr["BeatDelay"]);
                        lsc.DBServer      = ComUtility.DBNullStringHandler(rdr["DBServer"]);
                        lsc.DBPort        = ComUtility.DBNullInt32Handler(rdr["DBPort"]);
                        lsc.DBName        = ComUtility.DBNullStringHandler(rdr["DBName"]);
                        lsc.DBUID         = ComUtility.DBNullStringHandler(rdr["DBUID"]);
                        lsc.DBPwd         = ComUtility.DBNullStringHandler(rdr["DBPwd"]);
                        lsc.HisDBServer   = ComUtility.DBNullStringHandler(rdr["HisDBServer"]);
                        lsc.HisDBPort     = ComUtility.DBNullInt32Handler(rdr["HisDBPort"]);
                        lsc.HisDBName     = ComUtility.DBNullStringHandler(rdr["HisDBName"]);
                        lsc.HisDBUID      = ComUtility.DBNullStringHandler(rdr["HisDBUID"]);
                        lsc.HisDBPwd      = ComUtility.DBNullStringHandler(rdr["HisDBPwd"]);
                        lsc.Connected     = ComUtility.DBNullBooleanHandler(rdr["Connected"]);
                        lsc.ChangeTime    = ComUtility.DBNullDateTimeHandler(rdr["ChangedTime"]);
                        lsc.MaxNodeModify = null;
                        lsc.MaxChangeLog  = null;
                        lsc.Enabled       = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);

                        lscList.Add(lsc);
                    }
                }

                return(lscList);
            } catch {
                throw;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Method to get all the reservation nodes information
        /// </summary>
        public List <NodeInReservationInfo> GetReservationNodes(string id)
        {
            SqlParameter[] parms = { new SqlParameter("@ReservationId", SqlDbType.VarChar, 100) };
            parms[0].Value = id;

            var entities = new List <NodeInReservationInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_LSC_GETRESERVATIONODES, parms)) {
                while (rdr.Read())
                {
                    var entity = new NodeInReservationInfo {
                        ReservationId = ComUtility.DBNullStringHandler(rdr["ReservationId"]),
                        NodeId        = ComUtility.DBNullStringHandler(rdr["NodeId"]),
                        NodeType      = ComUtility.DBNullResNodeHandler(rdr["NodeType"])
                    };

                    entities.Add(entity);
                }
            }

            return(entities);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Method to get all the reservations information
        /// </summary>
        public List <ReservationInfo> GetReservations()
        {
            var entities = new List <ReservationInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_LSC_GETRESERVATIONS, null)) {
                while (rdr.Read())
                {
                    var entity = new ReservationInfo {
                        LscId       = ComUtility.DBNullInt32Handler(rdr["LscId"]),
                        Id          = ComUtility.DBNullStringHandler(rdr["Id"]),
                        Name        = ComUtility.DBNullStringHandler(rdr["Name"]),
                        StartTime   = ComUtility.DBNullDateTimeHandler(rdr["StartTime"]),
                        EndTime     = ComUtility.DBNullDateTimeHandler(rdr["EndTime"]),
                        Comment     = ComUtility.DBNullStringHandler(rdr["Comment"]),
                        CreatedTime = ComUtility.DBNullDateTimeHandler(rdr["CreatedTime"]),
                        Project     = new ProjectInfo {
                            Id           = ComUtility.DBNullStringHandler(rdr["PId"]),
                            Name         = ComUtility.DBNullStringHandler(rdr["PName"]),
                            StartTime    = ComUtility.DBNullDateTimeHandler(rdr["PStartTime"]),
                            EndTime      = ComUtility.DBNullDateTimeHandler(rdr["PEndTime"]),
                            Responsible  = ComUtility.DBNullStringHandler(rdr["PResponsible"]),
                            ContactPhone = ComUtility.DBNullStringHandler(rdr["PContactPhone"]),
                            Company      = ComUtility.DBNullStringHandler(rdr["PCompany"]),
                            Comment      = ComUtility.DBNullStringHandler(rdr["PComment"]),
                            CreatedTime  = ComUtility.DBNullDateTimeHandler(rdr["PCreatedTime"])
                        }
                    };

                    entities.Add(entity);
                }
            }

            foreach (var entity in entities)
            {
                entity.Nodes = GetReservationNodes(entity.Id);
            }

            return(entities);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Method to get system parameters
        /// </summary>
        /// <param name="paraCode">paraCode</param>
        public List <SysParamInfo> GetSysParams(int paraCode)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@ParaCode", SqlDbType.Int) };
                parms[0].Value = paraCode;

                var sysParms = new List <SysParamInfo>();
                using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_ORDER_GETSYSPARAMS, parms)) {
                    while (rdr.Read())
                    {
                        var parm = new SysParamInfo();
                        parm.ID          = ComUtility.DBNullInt32Handler(rdr["ID"]);
                        parm.ParaCode    = ComUtility.DBNullInt32Handler(rdr["ParaCode"]);
                        parm.ParaData    = ComUtility.DBNullInt32Handler(rdr["ParaData"]);
                        parm.ParaDisplay = ComUtility.DBNullStringHandler(rdr["ParaDisplay"]);
                        parm.Note        = ComUtility.DBNullStringHandler(rdr["Note"]);
                        sysParms.Add(parm);
                    }
                }
                return(sysParms);
            } catch { throw; }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Get devices from database.
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="devId">devId</param>
        /// <returns>devices list</returns>
        public List <DevInfo> GetDevices(Int32 lscId, Int32 devId)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int),
                                     new SqlParameter("@DevID", SqlDbType.Int) };
            parms[0].Value = lscId;
            parms[1].Value = ComUtility.DBNullInt32Checker(devId);

            var devices = new List <DevInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_COMMON_GETDEVICES, parms)) {
                while (rdr.Read())
                {
                    var dev = new DevInfo();
                    dev.LscID   = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    dev.DevID   = ComUtility.DBNullInt32Handler(rdr["DevID"]);
                    dev.DevName = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    dev.DevDesc = ComUtility.DBNullStringHandler(rdr["DevDesc"]);
                    dev.StaID   = ComUtility.DBNullInt32Handler(rdr["StaID"]);
                    devices.Add(dev);
                }
            }

            return(devices);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Method to add all the reservation information
        /// </summary>
        public void AddReservations(string connectionString, List <BookingInfo> bookings)
        {
            SqlParameter[] parms1 = { new SqlParameter("@LscID",  SqlDbType.Int),
                                      new SqlParameter("@ProjID", SqlDbType.VarChar, 50) };
            SqlParameter[] parms2 = { new SqlParameter("@BookingUserID",   SqlDbType.Int),
                                      new SqlParameter("@ProjID",          SqlDbType.VarChar,    50),
                                      new SqlParameter("@ProjName",        SqlDbType.VarChar,   100),
                                      new SqlParameter("@ProjDesc",        SqlDbType.VarChar,   200),
                                      new SqlParameter("@LscIncluded",     SqlDbType.Int),
                                      new SqlParameter("@StaIncluded",     SqlDbType.VarChar),
                                      new SqlParameter("@DevIncluded",     SqlDbType.VarChar),
                                      new SqlParameter("@StartTime",       SqlDbType.DateTime),
                                      new SqlParameter("@EndTime",         SqlDbType.DateTime),
                                      new SqlParameter("@ProjStatus",      SqlDbType.Int),
                                      new SqlParameter("@IsComfirmed",     SqlDbType.Bit),
                                      new SqlParameter("@ComfirmedUserID", SqlDbType.Int),
                                      new SqlParameter("@ComfirmedTime",   SqlDbType.DateTime),
                                      new SqlParameter("@IsChanged",       SqlDbType.Bit),
                                      new SqlParameter("@BookingTime",     SqlDbType.DateTime) };

            SqlHelper.TestConnection(connectionString);
            using (var conn = new SqlConnection(connectionString)) {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                try {
                    foreach (var booking in bookings)
                    {
                        parms1[0].Value = ComUtility.DBNullInt32Checker(booking.LscId);
                        parms1[1].Value = ComUtility.DBNullString2Checker(booking.Id);
                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_SELECT_LSC_DELETERESERVATION, parms1);

                        foreach (var project in booking.Projects)
                        {
                            parms2[0].Value  = ComUtility.DBNullInt32Checker(project.BookingUserID);
                            parms2[1].Value  = ComUtility.DBNullString2Checker(project.ProjID);
                            parms2[2].Value  = ComUtility.DBNullString2Checker(project.ProjName);
                            parms2[3].Value  = ComUtility.DBNullString2Checker(project.ProjDesc);
                            parms2[4].Value  = ComUtility.DBNullInt32Checker(project.LscIncluded);
                            parms2[5].Value  = ComUtility.DBNullString2Checker(project.StaIncluded);
                            parms2[6].Value  = ComUtility.DBNullString2Checker(project.DevIncluded);
                            parms2[7].Value  = ComUtility.DBNullDateTimeChecker(project.StartTime);
                            parms2[8].Value  = ComUtility.DBNullDateTimeChecker(project.EndTime);
                            parms2[9].Value  = ComUtility.DBNullInt32Checker(project.ProjStatus);
                            parms2[10].Value = project.IsComfirmed;
                            parms2[11].Value = ComUtility.DBNullInt32Checker(project.ComfirmedUserID);
                            parms2[12].Value = ComUtility.DBNullDateTimeChecker(project.ComfirmedTime);
                            parms2[13].Value = project.IsChanged;
                            parms2[14].Value = ComUtility.DBNullDateTimeChecker(project.BookingTime);

                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_SELECT_LSC_ADDRESERVATION, parms2);
                        }
                    }

                    trans.Commit();
                } catch {
                    trans.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Method to save trend alarm information
        /// </summary>
        /// <param name="alarms">alarms</param>
        public void SaveTrendAlarms(List <TrendAlarmInfo> alarms)
        {
            using (var conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction)) {
                conn.Open();
                using (var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) {
                    try {
                        SqlParameter[] parms = { new SqlParameter("@LscID",                 SqlDbType.Int),
                                                 new SqlParameter("@Area1Name",             SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@Area2Name",             SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@Area3Name",             SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@Area4Name",             SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@StaName",               SqlDbType.NVarChar,  100),
                                                 new SqlParameter("@DevName",               SqlDbType.NVarChar,  100),
                                                 new SqlParameter("@NodeID",                SqlDbType.Int),
                                                 new SqlParameter("@NodeType",              SqlDbType.Int),
                                                 new SqlParameter("@NodeName",              SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@AlarmType",             SqlDbType.NVarChar,   20),
                                                 new SqlParameter("@AlarmStatus",           SqlDbType.Int),
                                                 new SqlParameter("@AlarmLevel",            SqlDbType.Int),
                                                 new SqlParameter("@StartValue",            SqlDbType.Real),
                                                 new SqlParameter("@AlarmValue",            SqlDbType.Real),
                                                 new SqlParameter("@DiffValue",             SqlDbType.Real),
                                                 new SqlParameter("@StartTime",             SqlDbType.DateTime),
                                                 new SqlParameter("@AlarmTime",             SqlDbType.DateTime),
                                                 new SqlParameter("@EventTime",             SqlDbType.DateTime),
                                                 new SqlParameter("@ConfirmName",           SqlDbType.NVarChar,   20),
                                                 new SqlParameter("@ConfirmTime",           SqlDbType.DateTime),
                                                 new SqlParameter("@EndName",               SqlDbType.NVarChar,   20),
                                                 new SqlParameter("@EndTime",               SqlDbType.DateTime),
                                                 new SqlParameter("@StartIsAddAlarmList",   SqlDbType.Bit),
                                                 new SqlParameter("@EndIsAddAlarmList",     SqlDbType.Bit),
                                                 new SqlParameter("@ConfirmIsAddAlarmList", SqlDbType.Bit) };

                        foreach (var alarm in alarms)
                        {
                            parms[0].Value  = alarm.LscID;
                            parms[1].Value  = ComUtility.DBNullStringChecker(alarm.Area1Name);
                            parms[2].Value  = ComUtility.DBNullStringChecker(alarm.Area2Name);
                            parms[3].Value  = ComUtility.DBNullStringChecker(alarm.Area3Name);
                            parms[4].Value  = ComUtility.DBNullStringChecker(alarm.Area4Name);
                            parms[5].Value  = ComUtility.DBNullStringChecker(alarm.StaName);
                            parms[6].Value  = ComUtility.DBNullStringChecker(alarm.DevName);
                            parms[7].Value  = alarm.NodeID;
                            parms[8].Value  = alarm.NodeType;
                            parms[9].Value  = ComUtility.DBNullStringChecker(alarm.NodeName);
                            parms[10].Value = ComUtility.DBNullStringChecker(alarm.AlarmType);
                            parms[11].Value = ComUtility.DBNullInt32Checker(alarm.AlarmStatus);
                            parms[12].Value = ComUtility.DBNullInt32Checker(alarm.AlarmLevel);
                            parms[13].Value = ComUtility.DBNullFloatHandler(alarm.StartValue);
                            parms[14].Value = ComUtility.DBNullFloatHandler(alarm.AlarmValue);
                            parms[15].Value = ComUtility.DBNullFloatHandler(alarm.DiffValue);
                            parms[16].Value = ComUtility.DBNullDateTimeChecker(alarm.StartTime);
                            parms[17].Value = ComUtility.DBNullDateTimeChecker(alarm.AlarmTime);
                            parms[18].Value = ComUtility.DBNullDateTimeChecker(alarm.EventTime);
                            parms[19].Value = ComUtility.DBNullStringChecker(alarm.ConfirmName);
                            parms[20].Value = ComUtility.DBNullDateTimeChecker(alarm.ConfirmTime);
                            parms[21].Value = ComUtility.DBNullStringChecker(alarm.EndName);
                            parms[22].Value = ComUtility.DBNullDateTimeChecker(alarm.EndTime);
                            parms[23].Value = alarm.StartIsAddAlarmList;
                            parms[24].Value = alarm.EndIsAddAlarmList;
                            parms[25].Value = alarm.ConfirmIsAddAlarmList;

                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_INSERT_ALARM_SAVETRENDALARMS, parms);
                        }

                        trans.Commit();
                    } catch {
                        trans.Rollback();
                        throw;
                    }
                }
            }
        }