Example #1
0
        /// <summary>
        /// 根据老师获取电脑室的IP、主机名和坐标
        /// select Pip,Pmachine,Px,Py from Computers
        /// </summary>
        /// <param name="Ph"></param>
        /// <returns></returns>
        public SeatCollect GetSeat(string Pm)
        {
            SeatCollect sct   = new SeatCollect();
            DataTable   dt    = dal.GetSeat(Pm);
            int         count = dt.Rows.Count;

            sct.Dt     = dt;
            sct.Online = count;
            sct.Column = 8;
            if (count > 6)
            {
                int       beginX = Int32.Parse(dt.Rows[0][2].ToString());//获取初始X坐标
                ArrayList arrayX = new ArrayList();
                arrayX.Add(beginX);

                #region    标准化X坐标  同列偏移60内 自动垂直对齐  dt

                for (int i = 0; i < count; i++)
                {
                    int Px = Int32.Parse(dt.Rows[i][2].ToString());//读取某IP的X坐标
                    if (Px > beginX + 60)
                    {
                        beginX = Px;//得到当前X坐标
                        arrayX.Add(beginX);
                    }
                    else
                    {
                        dt.Rows[i][2] = beginX; //如果小于差值则全部设置为当前值
                    }
                }
                #endregion

                DataView dv = dt.DefaultView;
                dv.Sort = "Py  Asc";
                DataTable dt2    = dv.ToTable();                           //得到按Y坐标排序的表
                int       beginY = Int32.Parse(dt2.Rows[0][3].ToString()); //获取初始Y坐标
                ArrayList arrayY = new ArrayList();
                arrayY.Add(beginY);

                #region    标准化Y坐标   同行偏移60内 自动水平对齐 dt2

                for (int i = 0; i < count; i++)
                {
                    int Py = Int32.Parse(dt2.Rows[i][3].ToString());//读取某IP的X坐标
                    if (Py > beginY + 60)
                    {
                        beginY = Py;//得到当前Y坐标
                        arrayY.Add(beginY);
                    }
                    else
                    {
                        dt2.Rows[i][3] = beginY; //如果小于差值则全部设置为当前值
                    }
                }
                #endregion

                #region 查询标准位置,在表中存在不存在,不存在则添加空位
                int empty = 0;
                for (int i = 0; i < arrayX.Count; i++)
                {
                    int x = Int32.Parse(arrayX[i].ToString());
                    for (int j = 0; j < arrayY.Count; j++)
                    {
                        int y = Int32.Parse(arrayY[j].ToString());
                        //查询标准位置,在表中存在不存在,不存在则添加记录
                        if (dt2.Select("Px=" + x + " and Py=" + y).Length < 1)
                        {
                            empty++;
                            DataRow dr = dt2.NewRow();//Pip,Pmachine,Px,Py
                            dr[0] = "";
                            dr[1] = "";
                            dr[2] = x;
                            dr[3] = y;
                            dt2.Rows.Add(dr);
                        }
                    }
                }
                #endregion

                DataView dvok = dt2.DefaultView;
                dvok.Sort = "Px Asc , Py Asc";

                DataTable dt3 = dvok.ToTable();//得到最终标准格式位置表(带空位)
                dt.Dispose();
                dt2.Dispose();
                sct.Column = arrayX.Count;
                sct.Dt     = dt3;
            }
            return(sct);
        }
Example #2
0
        /// <summary>
        /// 查询开始上课页面,班级签到列表
        /// </summary>
        /// <param name="Sgrade"></param>
        /// <param name="Sclass"></param>
        /// <param name="Qyear"></param>
        /// <param name="Qmonth"></param>
        /// <param name="Qday"></param>
        /// <param name="signsort"></param>
        /// <param name="hid"></param>
        /// <returns></returns>
        public SeatCollect StartSignTable(int Sgrade, int Sclass, int Qyear, int Qmonth, int Qday, string pcroom)
        {
            SeatCollect sct = new SeatCollect();

            sct.Dt     = dal.StartSignClass(Sgrade, Sclass, Qyear, Qmonth, Qday, "1").Tables[0];
            sct.Online = sct.Dt.Rows.Count; //在线人数
            sct.Column = 8;                 //列数
            if (!string.IsNullOrEmpty(pcroom) && sct.Online > 0)
            {
                //Qid,Qip, Qnum, Qname,Sleader,Sgroup,Sgtitle,left(Qmachine,12) as QmachineShort,right(Qdate,8) as Qdate,Qattitude,Qnote,Qwork,Qgroup,Qgscore
                DataTable   studt  = sct.Dt;
                Computers   cbll   = new LearnSite.BLL.Computers();
                SeatCollect cmpsct = cbll.GetSeat(pcroom);//select Pip,Pmachine,Px,Py from Computers
                sct.Column = cmpsct.Column;
                DataTable cmpdt  = cmpsct.Dt;
                int       scount = studt.Rows.Count;
                int       pcount = cmpdt.Rows.Count;
                ArrayList empty  = new ArrayList();
                if (scount > 0 && pcount > 0)
                {
                    studt.Columns.Add("Px", typeof(int));
                    studt.Columns.Add("Py", typeof(int));//增加坐标字段
                    for (int i = 0; i < pcount; i++)
                    {
                        string pip   = cmpdt.Rows[i][0].ToString();
                        bool   find  = false;
                        int    tempj = -1;
                        for (int j = 0; j < scount; j++)
                        {
                            string sip = studt.Rows[j][1].ToString();
                            if (pip.Equals(sip))
                            {
                                find  = true;//如果相等,说明找到,跳出循环
                                tempj = j;
                                break;
                            }
                        }
                        if (!find)
                        {
                            empty.Add(i); //如果找不到,则收集序号
                        }
                        else
                        {
                            if (tempj > -1) //如果找到,则给学生表增加坐标位置
                            {
                                studt.Rows[tempj][13] = cmpdt.Rows[i][2];
                                studt.Rows[tempj][14] = cmpdt.Rows[i][3];
                            }
                        }
                    }

                    for (int k = 0; k < empty.Count; k++)
                    {
                        int emindex = Int32.Parse(empty[k].ToString());
                        //select Pip,Pmachine,Px,Py from Computers
                        string  pm = cmpdt.Rows[emindex][1].ToString();
                        int     px = Int32.Parse(cmpdt.Rows[emindex][2].ToString());
                        int     py = Int32.Parse(cmpdt.Rows[emindex][3].ToString());
                        DataRow dr = studt.NewRow();
                        //select distinct Qid,Qip, Qnum, Qname,Sleader,Sgroup,Sgtitle,Qattitude,left(Qmachine,12) as QmachineShort,Qnote,Qwork,Qgroup,Qgscore
                        dr[0]  = 0;
                        dr[1]  = "";
                        dr[2]  = "";
                        dr[3]  = "";
                        dr[4]  = false;
                        dr[5]  = 0;
                        dr[6]  = "";
                        dr[7]  = 0;
                        dr[8]  = pm;
                        dr[9]  = "";
                        dr[10] = 0;
                        dr[11] = 0;
                        dr[12] = 0;
                        dr[13] = px;
                        dr[14] = py;
                        studt.Rows.Add(dr);
                    }
                    DataView dv = studt.DefaultView;
                    dv.Sort = "Px Asc , Py Asc";
                    DataTable dt = dv.ToTable();
                    sct.Dt = dt;
                }
            }
            return(sct);
        }