コード例 #1
0
        private ParkingSingleton(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            log = LogFactory.GetLogger("ParkingSingleton");

            #region 给主页面显示用的
            MainCallback <Location> .Instance().WatchEvent += FileWatch_LctnWatchEvent;

            MainCallback <Device> .Instance().WatchEvent += FileWatch_DeviceWatchEvent;

            MainCallback <ImplementTask> .Instance().WatchEvent += FileWatch_IMPTaskWatchEvent;

            MainCallback <WorkTask> .Instance().WatchEvent += FileWatch_WatchEvent;

            #endregion

            #region 个推
            SingleCallback.Instance().ICCardWatchEvent  += ParkingSingleton_ICCardWatchEvent;
            SingleCallback.Instance().FaultsWatchEvent  += ParkingSingleton_FaultsWatchEvent;
            SingleCallback.Instance().PlateWatchEvent   += ParkingSingleton_PlateWatchEvent;
            SingleCallback.Instance().FixLocsWatchEvent += ParkingSingleton_FixLocsWatchEvent;
            #endregion

            #region 给云服务数据推送的
            CloudCallback.Instance().ParkingRcdWatchEvent += ParkingSingleton_ParkingRcdWatchEvent;
            CloudCallback.Instance().MasterTaskWatchEvent += ParkingSingleton_MasterTaskWatchEvent;
            CloudCallback.Instance().ImpTaskWatchEvent    += ParkingSingleton_ImpTaskWatchEvent;
            CloudCallback.Instance().SendSMSWatchEvent    += ParkingSingleton_SendSMSWatchEvent;
            #endregion
        }
コード例 #2
0
ファイル: DropdownGUI.cs プロジェクト: Cippman/Unity-Member
        /// <summary>
        /// Displays a single-option dropdown.
        /// </summary>
        public static void DropdownSingle
        (
            Vector2 position,
            SingleCallback callback,
            IEnumerable <DropdownOption <T> > options,
            DropdownOption <T> selectedOption,
            DropdownOption <T> noneOption
        )
        {
            var hasMultipleDifferentValues = EditorGUI.showMixedValue;

            ICollection <DropdownOption <T> > optionsCache = null;

            bool hasOptions;

            if (options != null)
            {
                optionsCache = options.CacheToCollection();
                hasOptions   = optionsCache.Count > 0;
            }
            else
            {
                hasOptions = false;
            }

            GenericMenu menu = new GenericMenu();

            GenericMenu.MenuFunction2 menuCallback = (o) =>
            {
                callback((T)o);
            };

            if (noneOption != null)
            {
                bool on = !hasMultipleDifferentValues && (selectedOption == null || Equal(selectedOption.value, noneOption.value));

                menu.AddItem(new GUIContent(noneOption.label), on, menuCallback, noneOption.value);
            }

            if (noneOption != null && hasOptions)
            {
                menu.AddSeparator(string.Empty);
            }

            if (hasOptions)
            {
                foreach (var option in optionsCache)
                {
                    bool on = !hasMultipleDifferentValues && (selectedOption != null && Equal(selectedOption.value, option.value));

                    menu.AddItem(new GUIContent(option.label), on, menuCallback, option.value);
                }
            }

            menu.DropDown(new Rect(position, Vector2.zero));
        }
コード例 #3
0
        public void Unsubscribe(string eventName, SingleCallback callback)
        {
#if _KISHITECH_UNITY_DEBUG_LOG_
            Debug.Log($"Unsubscribe({eventName}, {callback})");
#endif // #if _KISHITECH_UNITY_DEBUG_LOG_

            if (m_EventDictionary.ContainsKey(eventName))
            {
                m_EventDictionary[eventName] = (SingleCallback)m_EventDictionary[eventName] - callback;
            }
        }
コード例 #4
0
        public static void DropdownSingle
        (
            Vector2 position,
            SingleCallback callback,
            IEnumerable <DropdownOption <T> > options,
            DropdownOption <T> selectedOption,
            DropdownOption <T> noneOption,
            bool hasMultipleDifferentValues
        )
        {
            bool hasOptions = options != null && options.Any();

            GenericMenu menu = new GenericMenu();

            GenericMenu.MenuFunction2 menuCallback = (o) => { GUI.changed = true; callback((T)o); };

            if (noneOption != null)
            {
                bool on = !hasMultipleDifferentValues && (selectedOption == null || EqualityComparer <T> .Default.Equals(selectedOption.value, noneOption.value));

                menu.AddItem(new GUIContent(noneOption.label), on, menuCallback, noneOption.value);
            }

            if (noneOption != null && hasOptions)
            {
                menu.AddSeparator("");
            }

            if (hasOptions)
            {
                foreach (var option in options)
                {
                    bool on = !hasMultipleDifferentValues && (selectedOption != null && EqualityComparer <T> .Default.Equals(selectedOption.value, option.value));

                    menu.AddItem(new GUIContent(option.label), on, menuCallback, option.value);
                }
            }

            menu.DropDown(new Rect(position, Vector2.zero));
        }
コード例 #5
0
 private void OnFileSelected(string path)
 {
     BrowserOpen = false;
     SingleCallback?.Invoke(path);
 }
コード例 #6
0
ファイル: CWDevice.cs プロジェクト: moruiyi/Parking2017
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="alarmLst"></param>
        /// <returns></returns>
        public async Task <Response> UpdateAlarmListAsync(List <Alarm> alarmLst)
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("UpdateAlarmList");

            try
            {
                resp = await manager_alarm.UpdateAlarmListAsync(alarmLst);

                #region 报警记录写入数据库
                List <Alarm> faultLst = alarmLst.FindAll(f => f.Color == EnmAlarmColor.Red && f.Description.Contains("备用") == false);
                if (faultLst.Count > 0)
                {
                    new CWFaultLog().AddFaultRecord(faultLst);
                }
                #endregion

                #region 写状态位记录入数据库
                List <Alarm> statusLst = alarmLst.FindAll(f => f.Color == EnmAlarmColor.Green && f.Description.Contains("备用") == false);
                if (faultLst.Count > 0)
                {
                    new CWStatusLog().AddStateRecord(statusLst);
                }
                #endregion

                #region 推送至显示
                int warehouse            = alarmLst.First().Warehouse;
                int devicecode           = alarmLst.First().DeviceCode;
                List <BackAlarm> backlst = new List <BackAlarm>();

                List <Alarm> hasValueLst = await manager_alarm.FindListAsync(al => al.Warehouse == warehouse && al.DeviceCode == devicecode && al.Value == 1);

                foreach (Alarm ar in hasValueLst)
                {
                    if (ar.Description.Contains("备用"))
                    {
                        continue;
                    }
                    int type = 0;
                    if (ar.Color == EnmAlarmColor.Green)
                    {
                        type = 1;
                    }
                    else if (ar.Color == EnmAlarmColor.Red)
                    {
                        type = 2;
                    }

                    BackAlarm back = new BackAlarm
                    {
                        Type        = type,
                        Description = ar.Description
                    };

                    backlst.Add(back);
                }
                SingleCallback.Instance().WatchFaults(warehouse, devicecode, backlst);
                #endregion

                #region 向云服务请求短信发送
                if (faultLst.Count > 0)
                {
                    Alarm  myalarm = faultLst[0];
                    Device smg     = await FindAsync(d => d.Warehouse == myalarm.Warehouse && d.DeviceCode == myalarm.DeviceCode);

                    if (smg == null || smg.TaskID == 0)
                    {
                        return(resp);
                    }
                    //一定是作业时报警才上报
                    ImplementTask itask = await new CWTask().FindAsync(smg.TaskID);
                    if (itask == null)
                    {
                        return(resp);
                    }

                    SMSInfo sms = null;
                    if (dicSmsRequest.ContainsKey(smg.DeviceCode))
                    {
                        SMSInfo info = dicSmsRequest[smg.DeviceCode];
                        //同一个任务,只发送一次
                        if (info.Plate == itask.PlateNum)
                        {
                            return(resp);
                        }
                        //15分钟内只允许发送一条
                        DateTime rcdtime = DateTime.Parse(info.RcdTime);
                        if (DateTime.Compare(rcdtime, DateTime.Now.AddMinutes(15)) < 0)
                        {
                            return(resp);
                        }
                        ////内容重复的,一个小时内只发一次
                        //if (info.Message == myalarm.Description&& DateTime.Compare(rcdtime, DateTime.Now.AddHours(1)) < 0)
                        //{
                        //    return resp;
                        //}

                        sms = new SMSInfo {
                            warehouse  = smg.Warehouse,
                            DeviceCode = smg.DeviceCode,
                            Plate      = itask.PlateNum,
                            AutoStep   = smg.RunStep,
                            Message    = myalarm.Description,
                            RcdTime    = DateTime.Now.ToString()
                        };
                        dicSmsRequest[smg.DeviceCode] = sms;
                    }
                    else
                    {
                        sms = new SMSInfo
                        {
                            warehouse  = smg.Warehouse,
                            DeviceCode = smg.DeviceCode,
                            Plate      = itask.PlateNum,
                            AutoStep   = smg.RunStep,
                            Message    = myalarm.Description,
                            RcdTime    = DateTime.Now.ToString()
                        };

                        dicSmsRequest.Add(smg.DeviceCode, sms);
                    }

                    if (sms != null)
                    {
                        log.Info("发送短信 - " + sms.Message);

                        CloudCallback.Instance().SendSMSToCloud(sms);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(resp);
        }
コード例 #7
0
        /// <summary>
        /// 读卡
        /// </summary>
        /// <returns></returns>
        public ContentResult ReadCard()
        {
            Task.Factory.StartNew(() =>
            {
                Log log = LogFactory.GetLogger("ReadCard");
                try
                {
                    string msg = "null";
                    #region 网口的暂不用
                    //string ipaddrs = XMLHelper.GetRootNodeValueByXpath("root", "ICCardIPAddress");
                    //if (!string.IsNullOrEmpty(ipaddrs))
                    //{
                    //    ICCardReader reader = new ICCardReader(ipaddrs);
                    //    if (reader.Connect())
                    //    {
                    //        uint ICNum = 0;
                    //        int nback = reader.GetPhyscard(ref ICNum);
                    //        if (nback == 0)
                    //        {
                    //            msg = ICNum.ToString();
                    //            log.Info("ReadCard 时,物理卡号 - "+msg);
                    //        }
                    //        else
                    //        {
                    //            log.Info("ReadCard 时,找不到卡片!");
                    //        }
                    //    }
                    //    else
                    //    {
                    //        log.Info("ReadCard 时,无法建立连接!");
                    //    }
                    //    reader.Disconnect();
                    //}
                    //else
                    //{
                    //    log.Info("ReadCard 时,IP地址为空!");
                    //}
                    #endregion
                    #region usb刷卡器读卡操作
                    CIcCardRWOne mcIccdObj = new CIcCardRWOne();
                    bool isConn            = mcIccdObj.Connect();
                    if (isConn)
                    {
                        uint ICNum = 0;
                        int nback  = mcIccdObj.GetPhyscard(ref ICNum);
                        if (nback == 0)
                        {
                            msg = ICNum.ToString();
                            log.Info("ReadCard 时,物理卡号 - " + msg);
                        }
                        else
                        {
                            log.Info("ReadCard 时,找不到卡片!");
                        }
                    }
                    else
                    {
                        log.Info("ReadCard 时,无法建立连接!");
                    }
                    mcIccdObj.Disconnect();
                    #endregion

                    SingleCallback.Instance().WatchICCard(msg);
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                }
            });
            return(Content("读卡中..."));
        }
コード例 #8
0
        /// <summary>
        /// Render an editor popup and return the newly selected option.
        /// </summary>
        /// <param name="position">The position of the control.</param>
        /// <param name="callback">The function called when a value is selected.</param>
        /// <param name="options">The list of available options.</param>
        /// <param name="selectedOption">The selected option, or null for none.</param>
        /// <param name="noneOption">The option for "no selection", or null for none.</param>
        /// <param name="hasMultipleDifferentValues">Whether the content has multiple different values.</param>
        /// <param name="allowOuterOption">Whether a selected option not in range should be allowed.</param>
        public static void PopupSingle
        (
            Rect position,
            SingleCallback callback,
            IEnumerable <DropdownOption <T> > options,
            DropdownOption <T> selectedOption,
            DropdownOption <T> noneOption,
            bool hasMultipleDifferentValues,
            bool allowOuterOption = true
        )
        {
            string label;

            if (hasMultipleDifferentValues)
            {
                label = "\u2014";                 // Em Dash
            }
            else if (selectedOption == null)
            {
                if (noneOption != null)
                {
                    label = noneOption.label;
                }
                else
                {
                    label = string.Empty;
                }
            }
            else
            {
                label = selectedOption.label;
            }

            if (GUI.Button(position, label, EditorStyles.popup))
            {
                DropdownSingle
                (
                    new Vector2(position.xMin, position.yMax),
                    callback,
                    options,
                    selectedOption,
                    noneOption,
                    hasMultipleDifferentValues
                );
            }
            else if (selectedOption != null && !options.Select(o => o.value).Contains(selectedOption.value) && !allowOuterOption)
            {
                // Selected option isn't in range

                if (hasMultipleDifferentValues)
                {
                    // Do nothing
                }
                else if (noneOption != null)
                {
                    callback(noneOption.value);
                }
                else
                {
                    callback(default(T));
                }
            }
        }
コード例 #9
0
        public ActionResult Edit(CustomerModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            CWICCard cwiccd = new CWICCard();

            #region 验证用户名、车牌号
            //顾客姓名保证唯一的
            Customer other = cwiccd.FindCust(cu => cu.UserName == model.UserName && cu.ID != model.ID);
            if (other != null)
            {
                ModelState.AddModelError("", "当前顾客名-  " + model.UserName +
                                         " 已被占用,其车牌号- " + other.PlateNum + " ,请输入唯一的用户名!");
                return(View(model));
            }
            //车牌号码保证唯一的
            other = cwiccd.FindCust(cu => cu.PlateNum == model.PlateNum && cu.ID != model.ID);
            if (other != null)
            {
                ModelState.AddModelError("", "当前车牌号-  " + model.PlateNum +
                                         " 已被绑定,其顾客名- " + other.UserName + " ,请输入正确的车牌号!");
                return(View(model));
            }
            #endregion
            #region
            Customer cust    = cwiccd.FindCust(model.ID);
            Location origloc = null;
            //原来是否绑定
            if (cust.Type == EnmICCardType.FixedLocation)
            {
                origloc = new CWLocation().FindLocation(l => l.Warehouse == cust.Warehouse && l.Address == cust.LocAddress);
            }

            //是固定卡时
            if (model.Type == EnmICCardType.FixedLocation)
            {
                #region
                if (model.Warehouse == 0 || string.IsNullOrEmpty(model.LocAddress))
                {
                    ModelState.AddModelError("", "固定卡,请指定绑定的库区及车位号!");
                    return(View(model));
                }
                Location lctn = new CWLocation().FindLocation(lc => lc.Warehouse == model.Warehouse && lc.Address == model.LocAddress);
                if (lctn == null)
                {
                    ModelState.AddModelError("", "固定卡,请正确的库区及车位地址!");
                    return(View(model));
                }
                else
                {
                    //固定车位时,当前车位没有存车
                    if (lctn.Status != EnmLocationStatus.Space)
                    {
                        ModelState.AddModelError("", "当前车位:" + lctn.Address + " 已存车,卡号- " + lctn.ICCode + " ,请等待取车完成后再绑定!");
                        return(View(model));
                    }
                }

                Customer custo = cwiccd.FindCust(cc => cc.Warehouse == model.Warehouse && cc.LocAddress == model.LocAddress);
                if (custo != null)
                {
                    if (custo.ID != cust.ID)
                    {
                        ModelState.AddModelError("", "当前车位已被别的用户绑定");
                        return(View(model));
                    }
                }
                cust.Type       = model.Type;
                cust.Warehouse  = (int)model.Warehouse;
                cust.LocAddress = model.LocAddress;

                //释放原车位
                if (origloc != null)
                {
                    if (origloc.Address != lctn.Address)
                    {
                        SingleCallback.Instance().WatchFixLocation(origloc, 0, "", "", "");
                    }
                }
                //绑定当前车位
                SingleCallback.Instance().WatchFixLocation(lctn, 1, cust.UserName, cust.Deadline.ToString(), cust.PlateNum);
                #endregion
            }
            else
            {
                cust.Type       = model.Type;
                cust.Warehouse  = 0;
                cust.LocAddress = "";
                cust.StartDTime = DateTime.Parse("2017-1-1");
                cust.Deadline   = DateTime.Parse("2017-1-1");

                //释放原车位
                if (origloc != null)
                {
                    SingleCallback.Instance().WatchFixLocation(origloc, 0, "", "", "");
                }
            }

            ICCard oriIccd = cwiccd.Find(ic => ic.CustID == model.ID);
            ICCard newIccd = null;
            if (!string.IsNullOrEmpty(model.UserCode))
            {
                newIccd = cwiccd.Find(ic => ic.UserCode == model.UserCode);
                if (newIccd == null)
                {
                    ModelState.AddModelError("", "当前卡号没有注册!");
                    return(View(model));
                }
            }
            if (oriIccd == null)
            {
                //原先没有绑定的
                if (newIccd != null)
                {
                    newIccd.CustID = cust.ID;
                    cwiccd.Update(newIccd);
                }
            }
            else
            {
                if (newIccd == null)
                {
                    //释放原来卡号
                    //释放旧卡
                    oriIccd.CustID = 0;
                    cwiccd.Update(oriIccd);
                }
                else //两卡都存在
                {
                    //不是同一张卡
                    if (oriIccd.UserCode != newIccd.UserCode)
                    {
                        #region
                        if (newIccd.Status != EnmICCardStatus.Normal)
                        {
                            ModelState.AddModelError("", "卡已挂失或注销,无法绑定用户!");
                            return(View(model));
                        }
                        if (newIccd.CustID != 0)
                        {
                            Customer oricust = cwiccd.FindCust(newIccd.CustID);
                            if (oricust != null)
                            {
                                ModelState.AddModelError("", "该卡已被绑定,车主姓名:" + oricust.UserName);
                                return(View(model));
                            }
                        }
                        #endregion
                        //释放旧卡
                        oriIccd.CustID = 0;
                        cwiccd.Update(oriIccd);
                        //绑定新卡
                        newIccd.CustID = cust.ID;
                        cwiccd.Update(newIccd);
                    }
                }
            }

            //允许更新
            cust.PlateNum      = model.PlateNum;
            cust.MobilePhone   = model.MobilePhone;
            cust.UserName      = model.UserName;
            cust.FamilyAddress = model.FamilyAddress;

            cwiccd.UpdateCust(cust);


            #region 更新指纹
            CWFingerPrint cwfprint = new CWFingerPrint();
            if (model.FingerPrint1 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint1);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            if (model.FingerPrint2 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint2);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            if (model.FingerPrint3 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint3);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            #endregion

            #endregion
            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public ActionResult Add(CustomerModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            CWICCard cwiccd = new CWICCard();
            //顾客姓名保证唯一的
            Customer other = cwiccd.FindCust(cu => cu.UserName == model.UserName);

            if (other != null)
            {
                ModelState.AddModelError("", "当前顾客名-  " + model.UserName + " 已被占用,其车牌号- " + other.PlateNum + " ,请输入唯一的用户名!");
                return(View(model));
            }
            string plate = "";

            foreach (char vl in model.PlateNum)
            {
                if (Char.IsLetter(vl))
                {
                    plate += char.ToUpper(vl);
                }
                else
                {
                    plate += vl;
                }
            }

            model.PlateNum = plate;

            //车牌号码保证唯一的
            other = cwiccd.FindCust(cu => cu.PlateNum == model.PlateNum);
            if (other != null)
            {
                ModelState.AddModelError("", "当前车牌号-  " + model.PlateNum + " 已被绑定,其顾客名- " + other.UserName + " ,请输入正确的车牌号!");
                return(View(model));
            }
            Location lctn = null;

            #region
            if (model.Type == EnmICCardType.FixedLocation)
            {
                if (model.Warehouse == 0 || string.IsNullOrEmpty(model.LocAddress))
                {
                    ModelState.AddModelError("", "固定车位卡,请指定绑定车位!");
                    return(View(model));
                }
                lctn = new CWLocation().FindLocation(lc => lc.Warehouse == model.Warehouse && lc.Address == model.LocAddress);
                if (lctn == null)
                {
                    ModelState.AddModelError("", "绑定车位不存在,地址-" + model.LocAddress);
                    return(View(model));
                }
                else
                {
                    //固定车位时,当前车位没有存车
                    if (lctn.Status != EnmLocationStatus.Space)
                    {
                        ModelState.AddModelError("", "当前车位:" + lctn.Address + " 已存车,卡号- " + lctn.ICCode + " ,请等待取车完成后再绑定!");
                        return(View(model));
                    }
                }
            }

            ICCard iccd = null;
            if (!string.IsNullOrEmpty(model.UserCode))
            {
                #region
                iccd = cwiccd.Find(ic => ic.UserCode == model.UserCode);
                if (iccd == null)
                {
                    ModelState.AddModelError("", "当前用户卡号没有注册,请确保该卡已完成制卡!");
                    return(View(model));
                }
                if (iccd.Status != EnmICCardStatus.Normal)
                {
                    ModelState.AddModelError("", "该卡已挂失或注销,无法完成操作!");
                    return(View(model));
                }
                if (iccd.CustID != 0)
                {
                    Customer cust = cwiccd.FindCust(iccd.CustID);
                    if (cust != null)
                    {
                        ModelState.AddModelError("", "该卡已被绑定,车主姓名:" + cust.UserName);
                        return(View(model));
                    }
                }
                #endregion
            }

            Customer addcust = new Customer();
            if (model.Type == EnmICCardType.FixedLocation)
            {
                Customer cust = cwiccd.FindCust(cc => cc.Warehouse == model.Warehouse && cc.LocAddress == model.LocAddress);
                if (cust != null)
                {
                    ModelState.AddModelError("", "该车位已被其他卡绑定,无法使用该车位- " + model.LocAddress + " ,Warehouse- " + model.Warehouse);
                    return(View(model));
                }
                addcust.Warehouse  = (int)model.Warehouse;
                addcust.LocAddress = model.LocAddress;
            }

            addcust.UserName      = model.UserName;
            addcust.PlateNum      = model.PlateNum;
            addcust.FamilyAddress = model.FamilyAddress;
            addcust.MobilePhone   = model.MobilePhone;
            addcust.Type          = EnmICCardType.Temp;
            if ((int)model.Type > 0)
            {
                addcust.Type = model.Type;
            }
            addcust.StartDTime = DateTime.Parse("2017-1-1");
            addcust.Deadline   = DateTime.Parse("2017-1-1");

            Response resp = cwiccd.AddCust(addcust);
            if (resp.Code == 1)
            {
                //如果有卡号,则绑定顾客于卡号
                if (iccd != null)
                {
                    iccd.CustID = addcust.ID;
                    resp        = cwiccd.Update(iccd);
                }

                #region 绑定指纹,更新指纹信息
                CWFingerPrint fprint = new CWFingerPrint();
                if (!string.IsNullOrEmpty(model.FingerPrint1))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint1);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                if (!string.IsNullOrEmpty(model.FingerPrint2))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint2);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                if (!string.IsNullOrEmpty(model.FingerPrint3))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint3);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                #endregion
            }

            if (addcust.Type == EnmICCardType.FixedLocation)
            {
                SingleCallback.Instance().WatchFixLocation(lctn, 1, addcust.UserName, addcust.Deadline.ToString(), addcust.PlateNum);
            }

            #endregion
            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public void One(Entity entity, SingleCallback func)
        {
            int id = entity.Id;

            func(ref components.Elements[id]);
        }
コード例 #12
0
ファイル: CWPlate.cs プロジェクト: moruiyi/Parking2017
        public async Task <Response> AddPlateAsync(int warehouse, int hallID, string plateNum, string headimgpath, int trType)
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("AddPlate");

            string virtualPath = "";

            try
            {
                if (!string.IsNullOrEmpty(headimgpath))
                {
                    string[] pathArr = headimgpath.Split('\\');
                    int      count   = pathArr.Length;
                    if (count > 2)
                    {
                        if (string.IsNullOrEmpty(configpath))
                        {
                            configpath = XMLHelper.GetRootNodeValueByXpath("root", "PlateVirtualPath");
                        }
                        virtualPath = configpath + pathArr[count - 2] + @"/" + pathArr[count - 1];
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }

            PlateMappingDev mapping = await FindPlateAsync(warehouse, hallID);

            log.Warn("开始写车牌信息!");
            if (mapping == null)
            {
                PlateMappingDev mp = new PlateMappingDev {
                    Warehouse      = warehouse,
                    DeviceCode     = hallID,
                    PlateNum       = plateNum,
                    HeadImagePath  = virtualPath,
                    PlateImagePath = null,
                    InDate         = DateTime.Now
                };
                resp = await manager.AddAsync(mp);
            }
            else
            {
                log.Warn("更新车牌信息!");
                if (string.IsNullOrEmpty(mapping.PlateNum))
                {
                    mapping.PlateNum      = plateNum;
                    mapping.HeadImagePath = virtualPath;
                    mapping.InDate        = DateTime.Now;

                    resp = await manager.UpdateAsync(mapping);
                }
                else
                {
                    if (mapping.PlateNum != plateNum)
                    {
                        //车牌识别不一致,则先判断时间,当前步进
                        Device hall = await new CWDevice().FindAsync(d => d.Warehouse == warehouse && d.DeviceCode == hallID);
                        if (hall != null)
                        {
                            if (hall.InStep == 30)
                            {
                                resp.Message = "30步时不接收任何的车牌识别";
                                return(resp);
                            }
                        }
                        //在30秒内,有虚拟线圈触发,以当前的为准
                        if (DateTime.Compare(DateTime.Now, mapping.InDate.AddSeconds(30)) < 0 ||
                            DateTime.Compare(DateTime.Now, mapping.InDate.AddMinutes(5)) > 0)
                        {
                            //如果是虚拟线圈触发,则以当前为准
                            if (trType == 8)
                            {
                                mapping.PlateNum      = plateNum;
                                mapping.HeadImagePath = virtualPath;
                                mapping.InDate        = DateTime.Now;

                                resp = await manager.UpdateAsync(mapping);

                                if (resp.Code == 1)
                                {
                                    log.Info("更新车牌信息成功!");
                                }
                            }
                        }
                    }
                    else
                    {
                        //更新下页面
                        resp.Code = 1;
                    }
                }
            }
            //推送到页面中
            if (resp.Code == 1)
            {
                PlateDisplay disp = new PlateDisplay
                {
                    Warehouse    = warehouse,
                    DeviceCode   = hallID,
                    PlateNum     = plateNum,
                    HeadImgVPath = virtualPath,
                    RcdDtime     = DateTime.Now.ToString()
                };
                SingleCallback.Instance().WatchPlateInfo(disp);
            }
            return(resp);
        }