Esempio n. 1
0
        /// <summary>
        /// Get access level by Id
        /// </summary>
        /// <param name="accessLvId">ID of access level need get</param>
        /// <returns>one access level object</returns>
        public static AccessLevel LoadAccessLevelById(string accessLvId)
        {
            AccessLevel accessLevel = null;
            DataTable   dt          = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.AccessLevelQry("Q", accessLvId, "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["accessLevelID"].ToString();
                    string Name = dr["accessLevelName"].ToString();

                    List <Door>     doors     = GetDoors(Id);
                    List <Schedule> schedules = GetSchedules(Id);

                    accessLevel = new AccessLevel(Id, Name, doors, schedules);
                }
                return(accessLevel);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static List <OperatorLevel> GetAllOptLevel()
        {
            List <OperatorLevel> operatorLevels = new List <OperatorLevel>();
            DataTable            dt             = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.OperatorQuery("Q", "", "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["optLevelid"].ToString();
                    string Name = dr["optLevelName"].ToString();

                    OperatorLevel operatorLevel = new OperatorLevel(Id, Name);
                    operatorLevels.Add(operatorLevel);
                }
                return(operatorLevels);
            }
            catch (Exception ex)
            {
                return(operatorLevels);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get user group from DB
        /// </summary>
        /// <param name="groupId">ID of user group need get</param>
        /// <returns>One group user object</returns>
        public static GroupUser LoadGroupUserById(string groupId)
        {
            DataTable dt        = null;
            GroupUser groupUser = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupUserQuery("Q", groupId, "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id        = dr["groupId"].ToString();
                    string groupName = dr["groupName"].ToString();

                    List <Users> listUsers = Users.LoadUsersByGroup(groupId);

                    groupUser = new GroupUser(groupId, groupName, listUsers);
                }
                return(groupUser);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get all schedules in DB
        /// </summary>
        /// <returns>List of scheduls in DB</returns>
        public static List <Schedule> LoadAllSchedule()
        {
            List <Schedule> schedules = new List <Schedule>();
            DataTable       dt        = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.ScheduleQry("Q", "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id          = dr["scheduleId"].ToString();
                    string Name        = dr["scheduleName"].ToString();
                    string description = dr["description"].ToString();

                    Schedule schedule = new Schedule(Id, Name, description);
                    schedules.Add(schedule);
                }
                return(schedules);
            }
            catch (Exception ex)
            {
                return(schedules);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Get door by Id
        /// </summary>
        /// <param name="doorId">ID of door need get</param>
        /// <returns>one door object</returns>
        public static Door LoadDoorById(string doorId)
        {
            Door      door = new Door();
            DataTable dt   = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DoorQuery("Q", doorId, "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id       = dr["doorId"].ToString();
                    string Name     = dr["doorName"].ToString();
                    string deviceId = dr["deviceId"].ToString();
                    Device device   = Device.LoadDeviceById(deviceId);
                    string rNumber  = dr["readerNumber"].ToString();
                    string iNumber  = dr["inputNumber"].ToString();
                    string oNumber  = dr["outputNumber"].ToString();
                    string reNumber = dr["relayNumber"].ToString();

                    door = new Door(Id, Name, device, rNumber, iNumber, oNumber, reNumber);
                }
                return(door);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 6
0
        public static List <Card> LoadAllCard()
        {
            List <Card> cards = new List <Card>();
            DataTable   dt    = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.CardDetailQuery("Q", "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string cardNo = dr["cardNo"].ToString();
                    string cardId = dr["cardId"].ToString();

                    Card c = new Card(cardId, cardNo);
                    cards.Add(c);
                }
                return(cards);
            }
            catch (Exception ex)
            {
                return(cards);
            }
            return(cards);
        }
Esempio n. 7
0
        /// <summary>
        /// Add access level
        /// </summary>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string Add(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                //Add aclv master
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.AccessLevelSave("A", groupId, GroupName, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();

                //Add schedule of aclv
                foreach (Schedule s in listSchedule)
                {
                    result = AddSchedule(groupId, s.ScheduleId, creator);
                }

                //Add door of aclv
                foreach (Door d in listDoor)
                {
                    result = AddSchedule(groupId, d.DoorId, creator);
                }

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access level class - Add: {0}", ex.ToString()));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Get access group base on group id from DB
        /// </summary>
        /// <returns>one group access object</returns>
        public static GroupAccess GetAccessGroupById(string groupId)
        {
            GroupAccess groupAccesses = null;
            DataTable   dt            = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessQuery("Q", groupId, "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id          = dr["groupId"].ToString();
                    string Name        = dr["groupName"].ToString();
                    string description = dr["groupDescription"].ToString();

                    //Get user in group
                    List <Users> users = Users.LoadUsersByACGroup(Id);

                    //Get Guser in group
                    List <GroupUser> groupUsers = GroupUser.LoadUserGroupByACGroup(Id);

                    //Get Access Lv in group
                    List <AccessLevel> accessLevels = AccessLevel.LoadAccessLevelByACGroup(Id);

                    groupAccesses = new GroupAccess(Id, Name, description, accessLevels, users, groupUsers);
                }
                return(groupAccesses);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Get attendance of each person by date
        /// </summary>
        /// <param name="attendanceDate">date need to get attendance data</param>
        /// <returns>List of event</returns>
        public static List <Event> LoadAttendance(DateTime attendanceDate)
        {
            List <Event> events = new List <Event>();
            DataTable    dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.AttendanceQuery("A", attendanceDate);
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    DateTime eDate     = Convert.ToDateTime(dr["eventDate"].ToString());
                    string   dName     = dr["deviceName"].ToString();
                    string   dIP       = dr["device"].ToString();
                    string   ePerson   = dr["personName"].ToString();
                    string   eCardNo   = dr["cardNo"].ToString();
                    string   eDoorName = dr["doorName"].ToString();
                    string   eStatus   = dr["status"].ToString();
                    string   eGroup    = dr["company"].ToString();

                    Event e = new Event(eDate, dName, dIP, ePerson, eCardNo, eDoorName, eStatus, eGroup);
                    events.Add(e);
                }
                return(events);
            }
            catch (Exception ex)
            {
                return(events);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Get event with conditions
        /// </summary>
        /// <param name="SDate">start time</param>
        /// <param name="EDate">end time</param>
        /// <param name="CardNo">card no</param>
        /// <returns>List of events</returns>
        public static List <Event> LoadEventFilter(string SDate, string EDate, string CardNo)
        {
            List <Event> events = new List <Event>();
            DataTable    dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.EventQry("Q", "", CardNo, SDate, EDate);
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    DateTime eDate     = Convert.ToDateTime(dr["eventDate"].ToString());
                    string   dName     = dr["deviceName"].ToString();
                    string   dIP       = dr["device"].ToString();
                    string   ePerson   = dr["personName"].ToString();
                    string   eCardNo   = dr["cardNo"].ToString();
                    string   eDoorName = dr["doorName"].ToString();
                    string   eStatus   = dr["status"].ToString();

                    Event e = new Event(eDate, dName, dIP, ePerson, eCardNo, eDoorName, eStatus);
                    events.Add(e);
                }
                return(events);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Get device by device id from DB
        /// </summary>
        /// <param name="deviceId">Id of device need get</param>
        /// <returns>One device object</returns>
        public static Device LoadDeviceById(string deviceId)
        {
            Device    device = new Device();
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DeviceQuery("Q", deviceId, "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["deviceId"].ToString();
                    string Name = dr["deviceName"].ToString();
                    string ip   = dr["deviceIP"].ToString();

                    device = new Device(Id, Name, ip);
                }
                return(device);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Get all device info from DB
        /// </summary>
        /// <returns>List of device</returns>
        public static List <Device> LoadAllDevices()
        {
            List <Device> devices = new List <Device>();
            DataTable     dt      = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DeviceQuery("Q", "", "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["deviceId"].ToString();
                    string Name = dr["deviceName"].ToString();
                    string ip   = dr["deviceIP"].ToString();

                    Device device = new Device(Id, Name, ip);
                    devices.Add(device);
                }
                return(devices);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Update user info in DB
        /// </summary>
        /// <param name="groupUser">group user id include user</param>
        /// <param name="groupAccess">group access id include user</param>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string Update(string groupUser, string groupAccess, string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                //Update user master
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.UserSave("U", id, optLevel, userName, passWord, name, avatar, email, phoneNo, status, startDate, experiedDate, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();

                if (result == "OK")
                {
                    //Delete user in old group user
                    GroupUser group = new GroupUser("", "");
                    result = group.DeleteUser(id, creator);

                    if (result == "OK")
                    {
                        //Add user to user group
                        GroupUser group1 = new GroupUser(groupUser, "");
                        result = group1.AddUser(id, creator);

                        if (result == "OK")
                        {
                            //Delete user in old access group
                            GroupAccess accessGroup = new GroupAccess("", "");
                            result = accessGroup.DeleteUser(id, creator);

                            if (result == "OK")
                            {
                                //Add user to access group
                                GroupAccess accessGroup1 = new GroupAccess(groupAccess, "");
                                result = accessGroup1.AddUser(id, creator);

                                if (result == "OK")
                                {
                                    //Add card
                                    foreach (Card c in listCard)
                                    {
                                        result = c.Add(creator);
                                        result = c.AddUser(id, creator);
                                    }
                                }
                            }
                        }
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("User class - Update: {0}", ex.ToString()));
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Get user from DB by user id
        /// </summary>
        /// <param name="id">ID of user need get</param>
        /// <returns>one user object</returns>
        public static Users LoadUsersById(string id)
        {
            Users     users = null;
            DataTable dt    = null;

            byte[]   avatar = null;
            DateTime start  = DateTime.Today;
            DateTime end    = DateTime.Today;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.UserQuery("Q", id, "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id       = dr["userId"].ToString();
                    string Name     = dr["personName"].ToString();
                    string userName = dr["userName"].ToString();
                    string passWord = dr["password"].ToString();
                    string email    = dr["email"].ToString();
                    string phoneNo  = dr["phoneNo"].ToString();
                    bool   status   = Convert.ToBoolean(dr["status"]);
                    string optLevel = dr["optLevel"].ToString();
                    string s        = dr["avatar"].ToString();
                    if (s != "")
                    {
                        avatar = (byte[])dr["avatar"];
                    }
                    string sStart = dr["startDate"].ToString();
                    if (sStart != "")
                    {
                        start = Convert.ToDateTime(sStart);
                    }
                    string sEnd = dr["experiedDate"].ToString();
                    if (sEnd != "")
                    {
                        end = Convert.ToDateTime(sEnd);
                    }

                    List <Card> cards = Card.LoadCardByUserId(Id);

                    users = new Users(Id, Name, userName, passWord, email, phoneNo, status, optLevel, cards, avatar, start, end);
                }
                return(users);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Get login history
        /// </summary>
        /// <param name="sDate">start time</param>
        /// <param name="eDate">end time</param>
        /// <returns></returns>
        public static DataTable LoadLogin(DateTime sDate, DateTime eDate)
        {
            DataTable dt = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.LoginQuery("Q", sDate, eDate);
                dt = ds.Tables[0];
                return(dt);
            }
            catch (Exception ex)
            {
                return(dt);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// statistic event from first of month to end of month
        /// </summary>
        /// <param name="SDate">start time</param>
        /// <param name="EDate">end time</param>
        /// <returns>Data set have 3 table :DENY, GRANTED, NOT_DEFINED</returns>
        public static DataSet LoadEventByMonth(string SDate, string EDate)
        {
            List <Event> events = new List <Event>();
            DataSet      ds     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                ds = client.EventQry("M", "", "", SDate, EDate);

                return(ds);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Get schdule by schedule ID
        /// </summary>
        /// <param name="scheduleId">ID of schedule need get</param>
        /// <returns>One schedule object</returns>
        public static Schedule LoadScheduleById(string scheduleId)
        {
            Schedule      schedule = new Schedule();
            List <Period> periods  = new List <Period>();

            DataTable dt  = null;
            DataTable dt1 = NewMethod();

            try
            {
                //Get schedule master
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.ScheduleQry("Q", scheduleId, "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id          = dr["scheduleId"].ToString();
                    string Name        = dr["scheduleName"].ToString();
                    string description = dr["description"].ToString();

                    schedule = new Schedule(Id, Name, description);
                }

                //Get periods in schedule
                ServiceReference1.WSACUSoapClient client1 = new ServiceReference1.WSACUSoapClient();
                DataSet ds1 = client1.PeriodQuery("Q", scheduleId);
                dt1 = ds1.Tables[0];

                foreach (DataRow dr in dt1.Rows)
                {
                    string   dayInWeek = dr["DayInWeek"].ToString();
                    DateTime startTime = DateTime.ParseExact(dr["StartTime"].ToString(), "HH:mm:ss", CultureInfo.InvariantCulture);
                    DateTime endTime   = DateTime.ParseExact(dr["EndTime"].ToString(), "HH:mm:ss", CultureInfo.InvariantCulture);

                    Period period = new Period(dayInWeek, startTime, endTime);
                    periods.Add(period);
                }
                schedule.ListPeriod = periods;

                return(schedule);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Delete user into group
        /// </summary>
        /// <param name="userId">ID of user need delete</param>
        /// <param name="creator">user id login</param>
        /// <returns>OK or error from DB</returns>
        public string DeleteUser(string userId, string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupUserDetailSave("D", "", userId, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();
                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Group user class - Delete user: {0}", ex.ToString()));
            }
        }
Esempio n. 19
0
        /// <summary>
        /// update group user
        /// </summary>
        /// <param name="creator">user id login</param>
        /// <returns>OK or error from DB</returns>
        public string Update(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupUserSave("U", groupId, groupName, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();
                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Group user class - Update: {0}", ex.ToString()));
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Auto generate access level id base on max id on DB
        /// </summary>
        /// <returns>ID: ACSxxxxxxx </returns>
        public static string GenId()
        {
            string    id = null;
            DataTable dt = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.AccessLevelQry("S", "", "");
                dt = ds.Tables[0];
                id = dt.Rows[0][0].ToString();
                return(id);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Add user into access group
        /// </summary>
        /// <param name="userId">Id of user need add</param>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string AddUser(string userId, string creator)
        {
            string    Result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessUSave("A", groupId, userId, creator, DateTime.Today);
                dt     = ds.Tables[0];
                Result = dt.Rows[0][0].ToString();
                return(Result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access group class - Add user: {0}", ex.ToString()));
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Delete all user group in access group
        /// </summary>
        /// <param name="groupid">Id of access group need delete</param>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public static string DeleteAllUserGroup(string groupid, string creator)
        {
            string    Result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessUGSave("D", groupid, "", creator, DateTime.Today);
                dt     = ds.Tables[0];
                Result = dt.Rows[0][0].ToString();
                return(Result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access group class - Delete all user group: {0}", ex.ToString()));
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Delete access group
        /// </summary>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string Delete(string creator)
        {
            string    Result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessSave("D", groupId, groupName, groupDescription, creator, DateTime.Today);
                dt     = ds.Tables[0];
                Result = dt.Rows[0][0].ToString();
                return(Result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access group class - Delete: {0}", ex.ToString()));
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Uddate schedule info
        /// </summary>
        /// <param name="creator">User login id</param>
        /// <returns>Result of command: OK or get error from DB</returns>
        public string Update(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;
            DataTable dt1    = null;

            try
            {
                //Update schedule master
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.ScheduleSave("U", scheduleId, scheduleName, description, creator, DateTime.Now);
                dt = ds.Tables[0];

                //Delete old period
                result = DeleteAllPeriod(scheduleId, creator);

                if (dt.Rows[0][0].ToString() == "OK")
                {
                    //Add new period
                    foreach (Period p in listPeriod)
                    {
                        ServiceReference1.WSACUSoapClient client1 = new ServiceReference1.WSACUSoapClient();
                        DataSet ds1 = client.PeriodSave("A", scheduleId, p.DayInWeek, p.startTime, p.endTime, creator, DateTime.Now);
                        dt1 = ds1.Tables[0];

                        if (dt1.Rows[0][0].ToString() != "OK")
                        {
                            result = dt1.Rows[0][0].ToString();
                            break;
                        }
                    }
                }
                else
                {
                    result = dt.Rows[0][0].ToString();
                }

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Schedule class - Update: {0}", ex.ToString()));
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Update access group info
        /// </summary>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string Update(string creator)
        {
            string    Result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessSave("U", groupId, groupName, groupDescription, creator, DateTime.Today);
                dt     = ds.Tables[0];
                Result = dt.Rows[0][0].ToString();

                //Delete old user
                Result = DeleteAllUser(groupId, creator);

                //Add user
                foreach (Users u in listUsers)
                {
                    Result = AddUser(u.Id, creator);
                }

                //Delete old user group
                Result = DeleteAllUserGroup(groupId, creator);
                //Add Guser
                foreach (GroupUser gu in listGroupUsers)
                {
                    Result = AddUserGroup(gu.groupId, creator);
                }

                //Delete old accessLv
                Result = DeleteAllAccesslv(groupId, creator);
                //Add accesslv
                foreach (AccessLevel ac in accessLv)
                {
                    Result = AddAccessLevel(ac.groupId, creator);
                }
                return(Result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access group class - Update: {0}", ex.ToString()));
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Auto generate access group id base on max group id from DB
        /// </summary>
        /// <returns>Group ID: ACGxxxxxxx</returns>
        public static string GenGroupId()
        {
            string    Id = "";
            DataTable dt = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.GroupAccessQuery("S", "", "");
                dt = ds.Tables[0];
                Id = dt.Rows[0][0].ToString();

                return(Id);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Update door info
        /// </summary>
        /// <param name="creator">User login</param>
        /// <returns>OK or error from DB</returns>
        public string Update(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DoorSave("U", doorId, doorName, DeviceControl.DeviceId, readerNumber, inputNumber, outputNumber, relayNumber, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Door class - Update: {0}", ex.ToString()));
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Change password login
        /// </summary>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public string ChangePass(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.UserSave("C", id, optLevel, userName, passWord, name, avatar, email, phoneNo, status, startDate, experiedDate, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("User class - Change password: {0}", ex.ToString()));
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Delete Schedule
        /// </summary>
        /// <param name="creator">User login id</param>
        /// <returns>OK or get error from DB</returns>
        public string Delete(string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                //Delete schedule master and detail (in DB delete detail command)
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.ScheduleSave("D", scheduleId, "", "", creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();
                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Schedule class - Delete: {0}", ex.ToString()));
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Add door to accesslevel
        /// </summary>
        /// <param name="accessLvId">ID of access level need add</param>
        /// <param name="doorId">id of door need add</param>
        /// <param name="creator">user login id</param>
        /// <returns>OK or error from DB</returns>
        public static string AddDoor(string accessLvId, string doorId, string creator)
        {
            string    result = "OK";
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.AccessLevelDSave("A", accessLvId, doorId, creator, DateTime.Now);
                dt     = ds.Tables[0];
                result = dt.Rows[0][0].ToString();

                return(result);
            }
            catch (Exception ex)
            {
                return(string.Format("Access level class - Add door: {0}", ex.ToString()));
            }
        }