예제 #1
0
 /// <summary>
 /// Method to get lscs information
 /// </summary>
 /// <param name="connectionString">connectionString</param>
 public List <LscInfo> GetLscs(string connectionString)
 {
     try {
         if (String.IsNullOrEmpty(connectionString))
         {
             connectionString = SqlHelper.ConnectionStringLocalTransaction;
         }
         var lscs = new List <LscInfo>();
         using (var rdr = SqlHelper.ExecuteReader(connectionString, CommandType.Text, SqlText.SQL_SELECT_LSC_GETLSCS, null)) {
             while (rdr.Read())
             {
                 var 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.ChangedTime  = ComUtility.DBNullDateTimeHandler(rdr["ChangedTime"]);
                 lsc.Enabled      = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                 lscs.Add(lsc);
             }
         }
         return(lscs);
     } catch { throw; }
 }
예제 #2
0
        /// <summary>
        /// Method to get lsc information
        /// </summary>
        /// <param name="lscId">lscId</param>
        public LscInfo GetLsc(int lscId)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int) };
                parms[0].Value = lscId;

                LscInfo lsc = null;
                using (var 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.ChangedTime  = ComUtility.DBNullDateTimeHandler(rdr["ChangedTime"]);
                        lsc.Enabled      = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    }
                }
                return(lsc);
            } catch { throw; }
        }
예제 #3
0
파일: User.cs 프로젝트: radtek/PecsSystem
        /// <summary>
        /// Method to get LSC user
        /// </summary>
        /// <param name="lscId">lscId</param>
        public List <LscUserInfo> GetUser(int lscId)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int) };
                parms[0].Value = lscId;

                var lscUsers = new List <LscUserInfo>();
                using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_USER_GETLSCUSER, parms)) {
                    while (rdr.Read())
                    {
                        var lscUser = new LscUserInfo();
                        lscUser.LscID                 = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        lscUser.LscName               = ComUtility.DBNullStringHandler(rdr["LscName"]);
                        lscUser.UserID                = ComUtility.DBNullInt32Handler(rdr["UserID"]);
                        lscUser.UserName              = ComUtility.DBNullStringHandler(rdr["UserName"]);
                        lscUser.UID                   = ComUtility.DBNullStringHandler(rdr["UID"]);
                        lscUser.OpLevel               = ComUtility.DBNullUserLevelHandler(rdr["OpLevel"]);
                        lscUser.LimitTime             = ComUtility.DBNullDateTimeHandler(rdr["LimitTime"]);
                        lscUser.TelePhone             = ComUtility.DBNullStringHandler(rdr["TelePhone"]);
                        lscUser.MobilePhone           = ComUtility.DBNullStringHandler(rdr["MobilePhone"]);
                        lscUser.Email                 = ComUtility.DBNullStringHandler(rdr["Email"]);
                        lscUser.Address               = ComUtility.DBNullStringHandler(rdr["Address"]);
                        lscUser.PostalCode            = ComUtility.DBNullStringHandler(rdr["PostalCode"]);
                        lscUser.Remark                = ComUtility.DBNullStringHandler(rdr["Remark"]);
                        lscUser.AlarmSoundFiterItem   = ComUtility.DBNullAlarmSoundFiterItemHandler(rdr["AlarmSoundFiterItem"]);
                        lscUser.AlarmStaticFiterItem  = ComUtility.DBNullAlarmStaticFiterItemHandler(rdr["AlarmStaticFiterItem"]);
                        lscUser.ActiveValuesFiterItem = ComUtility.DBNullActiveValuesFiterItemHandler(rdr["ActiveValuesFiterItem"]);
                        lscUser.Group                 = null;
                        lscUser.UDGroups              = null;
                        lscUser.Enabled               = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                        lscUsers.Add(lscUser);
                    }
                }
                return(lscUsers);
            } catch { throw; }
        }
예제 #4
0
        /// <summary>
        /// Method to get group
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="userId">userId</param>
        public GroupInfo GetGroup(int lscId, int userId)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@LscID",  SqlDbType.Int),
                                         new SqlParameter("@UserID", SqlDbType.Int) };
                parms[0].Value = lscId;
                parms[1].Value = userId;

                GroupInfo group = null;
                using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_GROUP_GETGROUP, parms)) {
                    if (rdr.Read())
                    {
                        group            = new GroupInfo();
                        group.LscID      = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                        group.GroupID    = ComUtility.DBNullInt32Handler(rdr["GroupID"]);
                        group.GroupName  = ComUtility.DBNullStringHandler(rdr["GroupName"]);
                        group.GroupType  = ComUtility.DBNullGroupTypeHandler(rdr["GroupType"]);
                        group.GroupNodes = null;
                        group.Enabled    = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    }
                }
                return(group);
            } catch { throw; }
        }
예제 #5
0
        /// <summary>
        /// Method to save LSC user defind group tree nodes
        /// </summary>
        /// <param name="connectionString">connectionString</param>
        /// <param name="group">group</param>
        public UDGroupInfo SaveLSCUDGroupTreeNodes(string connectionString, UDGroupInfo group)
        {
            try {
                SqlHelper.TestConnection(connectionString);
                using (var conn = new SqlConnection(connectionString)) {
                    conn.Open();
                    var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                    try {
                        SqlParameter[] parms1 = { new SqlParameter("@LscID",       SqlDbType.Int),
                                                  new SqlParameter("@UserID",      SqlDbType.Int),
                                                  new SqlParameter("@UDGroupID",   SqlDbType.Int),
                                                  new SqlParameter("@UDGroupName", SqlDbType.VarChar, 40),
                                                  new SqlParameter("@Enabled",     SqlDbType.Bit) };

                        if (group.LscID != ComUtility.DefaultInt32)
                        {
                            parms1[0].Value = group.LscID;
                        }
                        else
                        {
                            parms1[0].Value = DBNull.Value;
                        }

                        if (group.UserID != ComUtility.DefaultInt32)
                        {
                            parms1[1].Value = group.UserID;
                        }
                        else
                        {
                            parms1[1].Value = DBNull.Value;
                        }

                        if (group.UDGroupID != ComUtility.DefaultInt32)
                        {
                            parms1[2].Value = group.UDGroupID;
                        }
                        else
                        {
                            parms1[2].Value = DBNull.Value;
                        }

                        if (group.UDGroupName != ComUtility.DefaultString)
                        {
                            parms1[3].Value = group.UDGroupName;
                        }
                        else
                        {
                            parms1[3].Value = DBNull.Value;
                        }

                        parms1[4].Value = group.Enabled;

                        using (var rdr = SqlHelper.ExecuteReader(trans, CommandType.Text, SqlText.SQL_INSERT_GROUP_SAVELSCUDGROUPTREENODES1, parms1)) {
                            if (rdr.Read())
                            {
                                group.LscID       = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                                group.UserID      = ComUtility.DBNullInt32Handler(rdr["UserID"]);
                                group.UDGroupID   = ComUtility.DBNullInt32Handler(rdr["UDGroupID"]);
                                group.UDGroupName = ComUtility.DBNullStringHandler(rdr["UDGroupName"]);
                                group.Enabled     = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                            }
                        }

                        SqlParameter[] parms2 = { new SqlParameter("@LscID",      SqlDbType.Int),
                                                  new SqlParameter("@UserID",     SqlDbType.Int),
                                                  new SqlParameter("@UDGroupID",  SqlDbType.Int),
                                                  new SqlParameter("@NodeID",     SqlDbType.Int),
                                                  new SqlParameter("@NodeType",   SqlDbType.Int),
                                                  new SqlParameter("@LastNodeID", SqlDbType.Int),
                                                  new SqlParameter("@TreeIndex",  SqlDbType.Int) };

                        foreach (var gNode in group.UDGroupNodes)
                        {
                            if (group.LscID != ComUtility.DefaultInt32)
                            {
                                parms2[0].Value = group.LscID;
                            }
                            else
                            {
                                parms2[0].Value = DBNull.Value;
                            }

                            if (group.UserID != ComUtility.DefaultInt32)
                            {
                                parms2[1].Value = group.UserID;
                            }
                            else
                            {
                                parms2[1].Value = DBNull.Value;
                            }

                            if (group.UDGroupID != ComUtility.DefaultInt32)
                            {
                                parms2[2].Value = group.UDGroupID;
                            }
                            else
                            {
                                parms2[2].Value = DBNull.Value;
                            }

                            if (gNode.NodeID != ComUtility.DefaultInt32)
                            {
                                parms2[3].Value = gNode.NodeID;
                            }
                            else
                            {
                                parms2[3].Value = DBNull.Value;
                            }

                            if (gNode.NodeType != EnmNodeType.Null)
                            {
                                parms2[4].Value = (int)gNode.NodeType;
                            }
                            else
                            {
                                parms2[4].Value = DBNull.Value;
                            }

                            if (gNode.LastNodeID != ComUtility.DefaultInt32)
                            {
                                parms2[5].Value = gNode.LastNodeID;
                            }
                            else
                            {
                                parms2[5].Value = DBNull.Value;
                            }

                            if (gNode.TreeIndex != ComUtility.DefaultInt32)
                            {
                                parms2[6].Value = gNode.TreeIndex;
                            }
                            else
                            {
                                parms2[6].Value = DBNull.Value;
                            }

                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_INSERT_GROUP_SAVELSCUDGROUPTREENODES2, parms2);
                        }
                        trans.Commit();
                        return(group);
                    } catch { trans.Rollback(); throw; }
                }
            } catch { throw; }
        }