/// <summary> /// 设置区域通过记录 /// </summary> public void setPassChannel(string cardnum, string deptID, string deptcode, string dept, string wkname, string picpath, string wkcode, string channel, string region, string regionID, string strtype, string strInOut, string memo, string cardNUM, string cardID, string cardSN) { if (string.IsNullOrEmpty(wkcode)) { return; } ChannelWorker wk = findRecord(wkcode); if (null != wk && cardnum == wk.CardNum) { wk.SetWorker(dept, deptID, deptcode, wkname, picpath, wkcode, cardnum, channel, region, regionID, strtype, strInOut, memo); } else { ChannelWorker wkr = new ChannelWorker(dept, deptID, deptcode, wkname, picpath, wkcode, cardnum, channel, region, regionID, strtype, strInOut, memo); wkr.CardNUM = cardNUM; wkr.CardID = cardID; wkr.CardSN = cardSN; Monitor.Enter(listwk); if (null != wk) { listwk.Remove(wk); } listwk.Add(wkr); Monitor.PulseAll(listwk); Monitor.Exit(listwk); } }
/// <summary> /// 每间隔3个小时重置记录一次 /// </summary> public void ResetRecord() { NameObjectList ps = new NameObjectList(); DataTable t = query.getTable("工作区人员数汇总", ps); if (null != t) { tabRegionSum = t; } DataTable tab = query.getTable("卡号通道状态", ps); if (null == tab || tab.Rows.Count < 1) { return; } List <ChannelWorker> list = new List <ChannelWorker>(); string[] cols = { "部门", "部门ID", "部门代码", "姓名", "用户编号", "卡号", "门名称", "区域", "区域ID", "卡号NUM", "卡片序列号", "卡片SN" }; foreach (DataRow dr in tab.Rows) { string[] info = new string[12]; for (int i = 0; i < cols.Length; i++) { if (tab.Columns.Contains(cols[i])) { info[i] = Convert.ToString(dr[cols[i]]); } } ChannelWorker wk = new ChannelWorker(info[0], info[1], info[2], info[3], "", info[4], info[5], info[6], info[7], info[8], "", "", ""); wk.DtIn = DBNull.Value == dr["进入时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["进入时间"]); wk.DtRein = DBNull.Value == dr["重进时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["重进时间"]); wk.DtOut = DBNull.Value == dr["出离时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["出离时间"]); wk.DtReout = DBNull.Value == dr["重出时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["重出时间"]); wk.Memo = Convert.ToString(dr["刷卡状态"]); wk.CardNUM = info[9]; wk.CardID = info[10]; wk.CardSN = info[11]; list.Add(wk); } Monitor.Enter(listwk); listwk.Clear(); foreach (ChannelWorker wk in list) { listwk.Add(wk); } Monitor.PulseAll(listwk); Monitor.Exit(listwk); }
/// <summary> /// 设置区域通过记录 /// </summary> public void setPassChannel(string cardnum, string deptID, string deptcode, string dept, string wkname, string picpath, string wkcode, string channel, string region, string regionID, string strtype, string strInOut, string memo,string cardNUM, string cardID,string cardSN) { if (string.IsNullOrEmpty(wkcode)) return; ChannelWorker wk = findRecord(wkcode); if (null != wk && cardnum == wk.CardNum) wk.SetWorker(dept, deptID, deptcode, wkname, picpath, wkcode, cardnum, channel, region, regionID, strtype, strInOut, memo); else { ChannelWorker wkr = new ChannelWorker(dept, deptID, deptcode, wkname, picpath, wkcode, cardnum, channel, region, regionID, strtype, strInOut, memo); wkr.CardNUM = cardNUM; wkr.CardID = cardID; wkr.CardSN = cardSN; Monitor.Enter(listwk); if (null != wk) listwk.Remove(wk); listwk.Add(wkr); Monitor.PulseAll(listwk); Monitor.Exit(listwk); } }
/// <summary> /// 检查记录,超时离开的记录删除 /// </summary> private void checkRecord() { DateTime dtmin = DateTime.Now.AddYears(-10); DateTime dtvalid = DateTime.Now.AddDays(-2); DateTime dtout = DateTime.Now.AddHours(-1); Monitor.Enter(listwk); for (int i = listwk.Count - 1; i > -1; i--) { ChannelWorker wk = listwk[i]; if (null == wk) { listwk.RemoveAt(i); continue; } if (wk.DtReout > dtvalid || wk.DtRein > dtvalid || wk.DtOut > dtout || wk.DtIn > dtout) { continue; } listwk.RemoveAt(i); } Monitor.PulseAll(listwk); Monitor.Exit(listwk); }
/// <summary> /// 每间隔3个小时重置记录一次 /// </summary> public void ResetRecord() { NameObjectList ps = new NameObjectList(); DataTable t = query.getTable("工作区人员数汇总", ps); if (null != t) tabRegionSum = t; DataTable tab = query.getTable("卡号通道状态", ps); if (null == tab || tab.Rows.Count < 1) return; List<ChannelWorker> list = new List<ChannelWorker>(); string[] cols ={ "部门", "部门ID", "部门代码", "姓名", "用户编号", "卡号", "门名称", "区域", "区域ID", "卡号NUM", "卡片序列号", "卡片SN" }; foreach (DataRow dr in tab.Rows) { string[] info = new string[12]; for (int i = 0; i < cols.Length; i++) { if (tab.Columns.Contains(cols[i])) info[i] = Convert.ToString(dr[cols[i]]); } ChannelWorker wk = new ChannelWorker(info[0], info[1], info[2], info[3], "", info[4], info[5], info[6], info[7], info[8], "", "", ""); wk.DtIn = DBNull.Value == dr["进入时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["进入时间"]); wk.DtRein = DBNull.Value == dr["重进时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["重进时间"]); wk.DtOut = DBNull.Value == dr["出离时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["出离时间"]); wk.DtReout = DBNull.Value == dr["重出时间"] ? DateTime.MinValue : Convert.ToDateTime(dr["重出时间"]); wk.Memo = Convert.ToString(dr["刷卡状态"]); wk.CardNUM = info[9]; wk.CardID = info[10]; wk.CardSN = info[11]; list.Add(wk); } Monitor.Enter(listwk); listwk.Clear(); foreach (ChannelWorker wk in list) listwk.Add(wk); Monitor.PulseAll(listwk); Monitor.Exit(listwk); }
/// <summary> /// 读取区域信息 /// </summary> /// <param name="info">指令内容:service='readregionsum',id, region='regionid'</param> /// <param name="client">客户端连接信息</param> public void ReadRegionSum(NameValueCollection info, ClientInfo client) { if (null == info) { return; } string cmdid = info["id"]; string region = info["region"]; if (string.IsNullOrEmpty(cmdid) || string.IsNullOrEmpty(region)) { return; } Monitor.Enter(listwk); ChannelWorker[] wks = listwk.ToArray(); Monitor.PulseAll(listwk); Monitor.Exit(listwk); string tag = ""; int sum = 0; DateTime dtmin = DateTime.Today.AddYears(-10); for (int i = 0; i < wks.Length; i++) { ChannelWorker wk = wks[i]; if (null == wk || wk.RegionID != region) { continue; } if (wk.DtIn < dtmin && wk.DtRein < dtmin) { continue; } if (wk.DtOut < dtmin && wk.DtReout < dtmin) { sum++; } else { DateTime dtin = wk.DtRein > wk.DtIn ? wk.DtRein : wk.DtIn; DateTime dtout = wk.DtReout > wk.DtOut ? wk.DtReout : wk.DtOut; if (dtout < dtin) { sum++; } } } DataRow[] drs = tabRegionSum.Select("ID='" + region + "'"); if (drs.Length > 0) { tag = basefun.setvaltag(tag, "注册人员", Convert.ToString(drs[0]["注册人员"])); } tag = basefun.setvaltag(tag, "入内人员", Convert.ToString(sum)); NameValueCollection nvclient = new NameValueCollection(); string[,] map = { { "id", cmdid }, { "cmd", "TransFile.extend" }, { "service", "readwkregion" }, { "len", "0" } }; for (int i = 0; i < map.GetLength(0); i++) { nvclient.Add(map[i, 0], map[i, 1]); } byte[] data = Encoding.GetEncoding("GB2312").GetBytes(tag); nvclient["len"] = Convert.ToString(data.LongLength); byte[] context = SvrFileTrans.ParseInfo(nvclient); long len = context.LongLength; byte[] response = new byte[context.LongLength + data.LongLength]; Array.Copy(context, response, len); Array.Copy(data, 0, response, len, data.LongLength); Monitor.Enter(client); client.BufferResponse.Add(response); Monitor.PulseAll(client); Monitor.Exit(client); }