示例#1
0
        public static List <string> GetGroupIDConnection()
        {
            bool isHost = SettingModels.isHostEnabled();

            string query = "";

            string IP = HttpHandler.GetIPAddress();

            string[] computer_name = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName.Split(new Char[] { '.' });
            string   HostName      = computer_name[0].ToString().ToUpper();

            if (isHost == true)
            {
                query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and (a.HostID='" + HostName + "' or a.HostID='" + IP + "') and b.isEnabled=1";
            }
            else
            {
                query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and b.isEnabled=1";
            }

            DataTable dt = new DataTable();

            dt = DBModel.CustomSelectQuery(query);

            List <string> result = new List <string>();

            foreach (DataRow dr in dt.Rows)
            {
                string Name = dr["GroupName"].ToString();
                query = "Select ID,EquipID from EquipmentTable where EquipID='" + Name + "'";
                DataTable dt2 = new DataTable();
                dt2 = DBModel.CustomSelectQuery(query);
                foreach (DataRow dr2 in dt2.Rows)
                {
                    string ID      = "";
                    string EquipID = "";
                    ID      = dr2["ID"].ToString();
                    EquipID = dr2["EquipID"].ToString();
                    string temp = ID + ":" + EquipID;
                    result.Add(temp);
                }
            }

            return(result);
        }
示例#2
0
        public static List <EquipmentGroupObject> GetEnrolledGroup()
        {
            int groupCount = 0;

            try
            {
                bool isHost = SettingModels.isHostEnabled();

                string query = "";

                string IP = HttpHandler.GetIPAddress();

                string[] computer_name = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName.Split(new Char[] { '.' });
                string   HostName      = computer_name[0].ToString().ToUpper();

                if (isHost == true)
                {
                    query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and (a.HostID='" + HostName + "' or a.HostID='" + IP + "') and b.isEnabled=1";
                }
                else
                {
                    query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and b.isEnabled=1";
                }

                DataTable dt = new DataTable();
                dt = DBModel.CustomSelectQuery(query);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        List <EquipmentGroupObject> obj = new List <EquipmentGroupObject>();
                        foreach (DataRow dr in dt.Rows)
                        {
                            EquipmentGroupObject temp = new EquipmentGroupObject();
                            temp.ID        = Convert.ToInt32(dr["GroupID"].ToString());
                            temp.GroupName = dr["GroupName"].ToString();

                            var check = hasChildGroup(temp.ID.ToString());

                            if (check == true)
                            {
                                obj.Add(temp);
                            }
                        }

                        groupCount = dt.Rows.Count;
                        CreateGroupCountSessionCookie(groupCount);

                        return(obj);
                    }
                    else
                    {
                        groupCount = 0;
                        CreateGroupCountSessionCookie(groupCount);

                        return(null);
                    }
                }
                else
                {
                    groupCount = 0;
                    CreateGroupCountSessionCookie(groupCount);

                    return(null);
                }
            }
            catch
            {
                //handle error
                groupCount = 0;
                CreateGroupCountSessionCookie(groupCount);

                return(null);
            }
        }