Exemplo n.º 1
0
        private void LoadRepeater()
        {
            using (AppDataContext db = new AppDataContext())
            {
                if (Session["TagLogFilter"] != null)
                {
                    tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                    string tagFilterCondition = tagLogFilter.ConditionDescription;
                }

                //过滤条件
                //tagLogFilter.SelectedGroupIdArray = new int[1] { (int)_userType };  //20091228 add
                string strWhere = LocatingMonitorUtils.ConstructSQLWhere(tagLogFilter);
                strWhere += (strWhere.Trim() == "") ? "IsDisappeared<0" : " AND IsDisappeared<0";
                strWhere += " AND hostgroupid= " + ((int)_userType).ToString();
                string zSortDir = "desc";
                if (_sortDir == SortDirection.Ascending)
                {
                    zSortDir = "";
                }

                int     totalCount = 0;
                DataSet ds         = DBPositionLog.GetPositionLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                p.RecordCount = totalCount;
                if (ds.Tables.Count != 0)
                {
                    list.DataSource = ds.Tables[0].DefaultView;
                    list.DataBind();
                }
            }
        }
        private void LoadRepeater()
        {
            //---add by tan 2009-10-5---//
            using (AppDataContext db = new AppDataContext())
            {
                if (Session["TagLogFilter"] != null)
                {
                    tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                    string tagFilterCondition = tagLogFilter.ConditionDescription;
                }


                string strWhere = LocatingMonitorUtils.ConstructSQLWhere(tagLogFilter);

                strWhere += (strWhere.Trim() == "") ? "hostgroupid= " + ((int)_userType).ToString() : " AND hostgroupid= " + ((int)_userType).ToString();
                //if (strWhere.Trim().Length <= 0)
                //{
                //    itotalrecords = db.pNetRadio_AllRecords("view_TagPositionLogView", ref itotalrecords);
                //    p.RecordCount = Convert.ToInt32(itotalrecords);
                //}

                string zSortDir = "desc";
                if (_sortDir == SortDirection.Ascending)
                {
                    zSortDir = "";
                }


                //SqlCommand myCommand;
                //SqlConnection myConnection = (SqlConnection)db.Connection;

                //myCommand = new SqlCommand("pNetRadio_PageRecords", myConnection);
                //myCommand.CommandType = CommandType.StoredProcedure;
                //myCommand.CommandTimeout = 600;

                //int? itotalrecords = 0;
                //myCommand.Parameters.Add("@tblName", "DBViewTagPositionLog as A JOIN  object_HostGroup as B ON A.hostid=B.hostid and B.hostgroupid= " + (int)_userType + " and " + strWhere);
                //myCommand.Parameters.Add("@strGetFields", "A.TagId,A.hostid,A.HostName,A.FacilityName,A.CoordinatesName,A.IsDisappeared,A.WriteTime,A.MapId");
                //myCommand.Parameters.Add("@fldName", " "+_zSortKey);
                //myCommand.Parameters.Add("@strWhere", "");
                //myCommand.Parameters.Add("@PageSize", p.PageSize);
                //myCommand.Parameters.Add("@PageIndex", p.PageIndex);
                //myCommand.Parameters.Add("@Sort", zSortDir);
                //myCommand.Parameters.Add("@totalRecords", itotalrecords);

                //SqlDataAdapter adapter = new SqlDataAdapter();
                //SqlParameter Par = myCommand.Parameters.AddWithValue("@rowcount", SqlDbType.Int);
                //Par.Direction = ParameterDirection.Output;


                //myConnection.Open();
                //myCommand.ExecuteNonQuery();
                //adapter.SelectCommand = myCommand;
                //DataSet ds = new DataSet();
                //adapter.Fill(ds, "view_TagPositionLogView");
                //myConnection.Close();

                ////取得过滤后的总记录数
                //if (strWhere != "")
                //    p.RecordCount = Int32.Parse(Par.Value.ToString());
                int     totalCount = 0;
                DataSet ds         = DBPositionLog.GetPositionLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                p.RecordCount = totalCount;
                if (ds.Tables.Count != 0)
                {
                    list.DataSource = ds.Tables[0].DefaultView;
                    list.DataBind();
                }
            }

            /*using (AppDataContext db = new AppDataContext()) {
             *
             *  var query = db.TagPositionLogViews
             *      .OrderByDescending(x => x.Id)
             *      .Select(x => new TagPositionLogView {
             *          TagId = x.TagId,
             *          TagName = x.TagName,
             *          FacilityId = x.FacilityId,
             *          FacilityName = x.FacilityName,
             *          MapId = x.MapId,
             *          CoordinatesId = x.CoordinatesId,
             *          CoordinatesName = x.CoordinatesName,
             *          WriteTime = x.WriteTime
             *      });
             *
             *  query = query.Where(x => x.WriteTime >= tagLogFilter.FromTime);
             *  query = query.Where(x => x.WriteTime < tagLogFilter.ToTime);
             *
             *  if (tagLogFilter.TagNameKeyword.Length > 0) {
             *      query = query.Where(x => x.TagName.Contains(tagLogFilter.TagNameKeyword));
             *  }
             *
             *  if (tagLogFilter.SelectedGroupIdArray != null) {
             *      int[] coveredTagIdArray = TagGroupCoverage.GetCoveredTagIdArray(tagLogFilter.SelectedGroupIdArray);
             *      query = query.Where(x => coveredTagIdArray.Contains(x.TagId));
             *  }
             *
             *  if (tagLogFilter.FacilityFilterRowVisible && tagLogFilter.MapId > 0) {
             *      query = query.Where(x => x.MapId == tagLogFilter.MapId);
             *  }
             *
             *  switch ((TagUserType)Fetch.QueryUrlAsIntegerOrDefault("userType", 1)) {
             *      default:
             *          break;
             *      case TagUserType.Cop:
             *          var arr1 = HostTagGroupStatus.All().Where(u => u.TagId != 0 && u.HostGroupId == (byte)TagUserType.Cop).Select(u => u.TagId).ToArray();
             *          query = query.Where(x => arr1.Contains(x.TagId));
             *          break;
             *      case TagUserType.Culprit:
             *          var arr2 = HostTagGroupStatus.All().Where(u => u.TagId != 0 && u.HostGroupId == (byte)TagUserType.Culprit).Select(u => u.TagId).ToArray();
             *          query = query.Where(x => arr2.Contains(x.TagId));
             *          break;
             *  }
             *
             *  p.RecordCount = query.Count();
             *  query = query.Skip(p.RecordOffset).Take(p.PageSize);
             *
             *  list.DataSource = query.ToList();
             *  list.DataBind();
             * }*/
        }
Exemplo n.º 3
0
        private void LoadDefaultView()
        {
            //tagSelector.SelectedGroupId = -1;

            string zSortDir = "desc";

            if (_sortDir == SortDirection.Ascending)
            {
                zSortDir = "";
            }
            string strWhere = "";

            if (tagSelector.SelectedUserIds != null && tagSelector.SelectedUserIds.Length > 0)
            {
                string     hostIds   = "(";
                List <int> lGroupIds = new List <int>();
                for (int i = 0; i < tagSelector.SelectedUserIds.Length; i++)
                {
                    hostIds += tagSelector.SelectedUserIds[i].ToString();
                    HostTagGroupStatus hostGroup = HostTagGroupStatus.SelectByHostId(tagSelector.SelectedUserIds[i]);
                    if (hostGroup != null && !lGroupIds.Contains(hostGroup.HostGroupId))
                    {
                        lGroupIds.Add(hostGroup.HostGroupId);
                    }
                    if (i != (tagSelector.SelectedUserIds.Length - 1))
                    {
                        hostIds += ", ";
                    }
                }
                hostIds += ")";
                strWhere = "A.HostId in " + hostIds;

                if (lGroupIds.Count > 0)
                {
                    string zGroupIds = "(";
                    int    j         = 0;
                    foreach (int groupId in lGroupIds)
                    {
                        if (j == 0)
                        {
                            zGroupIds += groupId.ToString();
                        }
                        else
                        {
                            zGroupIds += ", " + groupId.ToString();
                        }
                        j++;
                    }
                    zGroupIds += ")";
                    strWhere  += " AND HostGroupId in " + zGroupIds;
                }
                DateTime dtFrom = DateTime.Parse(fromDate.Text);
                dtFrom    = new DateTime(dtFrom.Year, dtFrom.Month, dtFrom.Day, fromHour.SelectedIndex, fromMinute.SelectedIndex, 0);
                strWhere += " AND WriteTime >= '" + dtFrom.ToString("M/d/yyyy H:m:s") + "'";

                DateTime dtTo = DateTime.Parse(toDate.Text);
                dtTo      = new DateTime(dtTo.Year, dtTo.Month, dtTo.Day, toHour.SelectedIndex, toMinute.SelectedIndex, 59);
                strWhere += " AND WriteTime <= '" + dtTo.ToString("M/d/yyyy H:m:s") + "'";

                int     totalCount = 0;
                DataSet ds         = DBPositionLog.GetPositionLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                p.RecordCount = totalCount;
                if (ds.Tables.Count != 0)
                {
                    list.DataSource = ds.Tables[0].DefaultView;
                    list.DataBind();
                }
            }
        }
Exemplo n.º 4
0
        private void LoadRepeater()
        {
            List <string> PatrolList = new List <string>();

            //int hostId = Fetch.QueryUrlAsIntegerOrDefault("hostId", 0);
            //int[] hostIds = tagSelector.SelectedUserIds;
            string[] hostnames = tagSelector.SelectedTagUsers.Select(_d => _d.UserName).ToArray();
            //---add by tan 2009-10-5---//
            using (AppDataContext db = new AppDataContext())
            {
                PatrolList = db.LocationGroups.Where(t => t.GroupId == (int)PrisonCoordinatesGroup.PatrolCorridor).Select(t => t.LocationId.ToString()).ToList();

                if (Session["TagLogFilter"] != null)
                {
                    //tagLogFilter = (NetRadio.LocatingMonitor.Controls.__TagLogFilter)Session["TagLogFilter"];
                    //string tagFilterCondition = tagLogFilter.ConditionDescription;
                }

                string coordinates = string.Join(",", PatrolList.ToArray());

                //string strWhere = ""; //LocatingMonitorUtils.ConstructSQLWhere(tagLogFilter);

                string strWhere = "hostgroupid= " + ((int)TagUserType.Cop).ToString() + " and CoordinatesId in (" + coordinates + ")";
                //if (strWhere.Trim().Length <= 0)
                //{
                //    itotalrecords = db.pNetRadio_AllRecords("view_TagPositionLogView", ref itotalrecords);
                //    p.RecordCount = Convert.ToInt32(itotalrecords);
                //}

                /*if (hostId > 0)
                 * {
                 *  HostTag hostTag = db.HostTags.Where(t => t.HostId == hostId).FirstOrDefault();
                 *
                 *  if (hostTag != null)
                 *  {
                 *      strWhere += " and HostName='" + hostTag.HostName + "'";
                 *  }
                 * }*/

                #region where

                string __where = "";
                foreach (string str in hostnames)
                {
                    if (__where.Length == 0)
                    {
                        __where += " HostName='" + str + "' ";
                    }
                    else
                    {
                        __where += " or HostName='" + str + "' ";
                    }
                }
                if (__where.Length != 0)
                {
                    strWhere += " and  ( " + __where + " )";
                }

                #endregion where end


                strWhere += " and (  writetime between '" + (fromDate.Text + " " + fromHour.SelectedValue + ":00:00") + "' and  '" + (toDate.Text + " " + toHour.SelectedValue + ":59:59") + "'  ) ";


                string zSortDir = "desc";
                if (_sortDir == SortDirection.Ascending)
                {
                    zSortDir = "";
                }


                //SqlCommand myCommand;
                //SqlConnection myConnection = (SqlConnection)db.Connection;

                //myCommand = new SqlCommand("pNetRadio_PageRecords", myConnection);
                //myCommand.CommandType = CommandType.StoredProcedure;
                //myCommand.CommandTimeout = 600;

                //int? itotalrecords = 0;
                //myCommand.Parameters.Add("@tblName", "DBViewTagPositionLog as A JOIN  object_HostGroup as B ON A.hostid=B.hostid and B.hostgroupid= " + (int)_userType + " and " + strWhere);
                //myCommand.Parameters.Add("@strGetFields", "A.TagId,A.hostid,A.HostName,A.FacilityName,A.CoordinatesName,A.IsDisappeared,A.WriteTime,A.MapId");
                //myCommand.Parameters.Add("@fldName", " "+_zSortKey);
                //myCommand.Parameters.Add("@strWhere", "");
                //myCommand.Parameters.Add("@PageSize", p.PageSize);
                //myCommand.Parameters.Add("@PageIndex", p.PageIndex);
                //myCommand.Parameters.Add("@Sort", zSortDir);
                //myCommand.Parameters.Add("@totalRecords", itotalrecords);

                //SqlDataAdapter adapter = new SqlDataAdapter();
                //SqlParameter Par = myCommand.Parameters.AddWithValue("@rowcount", SqlDbType.Int);
                //Par.Direction = ParameterDirection.Output;


                //myConnection.Open();
                //myCommand.ExecuteNonQuery();
                //adapter.SelectCommand = myCommand;
                //DataSet ds = new DataSet();
                //adapter.Fill(ds, "view_TagPositionLogView");
                //myConnection.Close();

                ////取得过滤后的总记录数
                //if (strWhere != "")
                //    p.RecordCount = Int32.Parse(Par.Value.ToString());

                try
                {
                    int     totalCount = 0;
                    DataSet ds         = DBPositionLog.GetPositionLog(strWhere, _zSortKey, zSortDir, p.PageSize, p.PageIndex, out totalCount);
                    p.RecordCount = totalCount;
                    if (ds.Tables.Count != 0)
                    {
                        list.DataSource = ds.Tables[0].DefaultView;
                        list.DataBind();
                    }
                }
                catch (Exception E)
                {
                    String ll = E.Source + ";" + E.Message;
                }
            }

            /*using (AppDataContext db = new AppDataContext()) {
             *
             *  var query = db.TagPositionLogViews
             *      .OrderByDescending(x => x.Id)
             *      .Select(x => new TagPositionLogView {
             *          TagId = x.TagId,
             *          TagName = x.TagName,
             *          FacilityId = x.FacilityId,
             *          FacilityName = x.FacilityName,
             *          MapId = x.MapId,
             *          CoordinatesId = x.CoordinatesId,
             *          CoordinatesName = x.CoordinatesName,
             *          WriteTime = x.WriteTime
             *      });
             *
             *  query = query.Where(x => x.WriteTime >= tagLogFilter.FromTime);
             *  query = query.Where(x => x.WriteTime < tagLogFilter.ToTime);
             *
             *  if (tagLogFilter.TagNameKeyword.Length > 0) {
             *      query = query.Where(x => x.TagName.Contains(tagLogFilter.TagNameKeyword));
             *  }
             *
             *  if (tagLogFilter.SelectedGroupIdArray != null) {
             *      int[] coveredTagIdArray = TagGroupCoverage.GetCoveredTagIdArray(tagLogFilter.SelectedGroupIdArray);
             *      query = query.Where(x => coveredTagIdArray.Contains(x.TagId));
             *  }
             *
             *  if (tagLogFilter.FacilityFilterRowVisible && tagLogFilter.MapId > 0) {
             *      query = query.Where(x => x.MapId == tagLogFilter.MapId);
             *  }
             *
             *  switch ((TagUserType)Fetch.QueryUrlAsIntegerOrDefault("userType", 1)) {
             *      default:
             *          break;
             *      case TagUserType.Cop:
             *          var arr1 = HostTagGroupStatus.All().Where(u => u.TagId != 0 && u.HostGroupId == (byte)TagUserType.Cop).Select(u => u.TagId).ToArray();
             *          query = query.Where(x => arr1.Contains(x.TagId));
             *          break;
             *      case TagUserType.Culprit:
             *          var arr2 = HostTagGroupStatus.All().Where(u => u.TagId != 0 && u.HostGroupId == (byte)TagUserType.Culprit).Select(u => u.TagId).ToArray();
             *          query = query.Where(x => arr2.Contains(x.TagId));
             *          break;
             *  }
             *
             *  p.RecordCount = query.Count();
             *  query = query.Skip(p.RecordOffset).Take(p.PageSize);
             *
             *  list.DataSource = query.ToList();
             *  list.DataBind();
             * }*/
        }