Beispiel #1
0
 public OrganInfoListItemViewModel(OrganInfo organInfo)
 {
     Id          = organInfo.Id;
     Name        = organInfo.Name;
     Description = organInfo.Description;
     OutsideHumanPossibleTime = organInfo.OutsideHumanPossibleTime;
 }
    public void CustomStart()
    {
        if (gameManager == null)
        {
            gameManager = GameManager.gameManager;
        }
        organManager         = gameManager.organManager;
        myOrganViewAnimation = transform.GetComponent <OrganView_UI_Animation>();
        plateletManager      = FindObjectOfType <PlatletManager>();
        organDispalyInfo     = FindObjectOfType <OrganInfo>();


        plateletManager.CustomStart();
        UpdateUnlockedOrgans();
        UpdateOrgans();
        UpdateButtons();
        SetOrganIndicator();
        UpdateNewOrganUI();
        AudioManager.Instance.Play("Music");
    }
Beispiel #3
0
        public IActionResult AddOrganInfo(EditOrganInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                // TODO: ne ok
            }

            var result = ContentExecute <OrganInfoDetailsViewModel>(() =>
            {
                var organInfo = new OrganInfo
                {
                    Name        = model.Name,
                    Description = model.Description,
                    OutsideHumanPossibleTime = model.OutsideHumanPossibleTime
                };
                var newOrganInfo = _organInfoService.AddOrganInfo(organInfo);
                return(new OrganInfoDetailsViewModel(newOrganInfo));
            });

            return(Json(result));
        }
Beispiel #4
0
        /// <summary>
        /// 线程方法
        /// </summary>
        /// <param name="pObj"></param>
        void ThreadFun(object pObj) // 来自委托:ParameterizedThreadStart
        {
            Orgaization organEntity = (Orgaization)pObj;

            try
            {
                //根据企业ID.获取对应企业的服务地址
                OrganInfo organInfo = null;
                CommonCache.organServiceList.TryGetValue(organEntity.OrganID, out organInfo);

                if (organInfo == null)
                {
                    Console.WriteLine("当前企业(" + organEntity.OrganDESC + ")下没有配置服务地址,请联系管理员!");
                    return;
                }

                ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client("BasicHttpBinding_IService1", organInfo.ServiceAddress);

                //WCF未正常开放时.结束当前企业的循环
                if (sc.State == CommunicationState.Closed || sc.State == CommunicationState.Faulted)
                {
                    Console.WriteLine("未能连接客户端服务,请联系管理员!");
                    return;
                }

                //设备列表
                List <DeviceInfo> deviceList = null;
                //根据企业ID获取企业下的设备列表
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    string sql = "SELECT Id,DeviceCode,DeviceName FROM aifishingep.deviceinfo T WHERE T.ORGANID = @OrganID ORDER BY DeviceCode ";
                    List <DataParameter> dataParameter = new List <DataParameter>();
                    dataParameter.Add(new DataParameter {
                        ParameterName = "OrganID", DataType = DbType.String, Value = organEntity.OrganID
                    });
                    //插入基本信息
                    deviceList = session.GetList <DeviceInfo>(sql, dataParameter.ToArray()).ToList();
                }

                if (deviceList == null || deviceList.Count == 0)
                {
                    Console.WriteLine("当前企业下没有可用设备,请联系管理员!");
                    return;
                }

                //循环设备
                foreach (DeviceInfo di in deviceList)
                {
                    HandleResult handleResult = null;
                    //判断企业的数据记录表中是不有记录.没有记录从数据库中取现有数据的最小日期
                    using (IDataSession session = AppDataFactory.CreateMainSession())
                    {
                        string sql = @"SELECT MAX(HandleEndTime) AS HandleEndTime FROM aifishingep.exchangeresult T 
                                        WHERE T.ORGANID = @OrganID AND T.DeviceSN = @DeviceSN";
                        List <DataParameter> dataParameter = new List <DataParameter>();
                        dataParameter.Add(new DataParameter {
                            ParameterName = "OrganID", DataType = DbType.String, Value = organEntity.OrganID
                        });
                        dataParameter.Add(new DataParameter {
                            ParameterName = "DeviceSN", DataType = DbType.String, Value = di.DeviceSN
                        });
                        //获取转发记录中时间的最大值
                        handleResult = session.Get <HandleResult>(sql, dataParameter.ToArray());
                    }
                    //查询的起始时间
                    DateTime st;
                    //如果没有已处理记录
                    if (handleResult != null && handleResult.HandleEndTime != new DateTime())
                    {
                        st = handleResult.HandleEndTime;
                    }
                    else
                    {
                        Console.WriteLine("当前企业没数据转发记录!");
                        //查询设备ID的最小日期值
                        st = getMinDate(di.DeviceSN);
                    }

                    //起始时间不存在或者没有记录
                    if (st == null || st == new DateTime())
                    {
                        continue;
                    }

                    //st = DateTime.Parse("2018-03-28 21:01:02");

                    //取出当前时间的前一分钟
                    DateTime currTime = DateTime.Now.AddMilliseconds(eachHandleLastTime);

                    //起始时间+设置的时间间隔.计算出理论结束时间
                    DateTime et = st.AddMilliseconds(eachHandleTime);
                    //跳出循环flag
                    bool looping = true;
                    while (looping)
                    {
                        //理论结束时间大于当前时间时.使用当前时间获取数据
                        if (et >= currTime)
                        {
                            //当前时间的前一分钟设置为结束时间
                            et = currTime;
                            //执行完成后要退回循环
                            looping = false;
                        }

                        bool handResult = doSaveData(sc, organEntity.OrganID, di.DeviceSN, st, et);

                        //数据未成功保存时,跳出当前循环
                        if (!handResult)
                        {
                            Console.WriteLine("转发企业(" + organEntity.OrganDESC + ")-设备(" + di.DeviceSN + ")-起始时间(" + st.ToString("yyyy-MM-dd HH:mm:ss") + ")-结束时间(" + et.ToString("yyyy-MM-dd HH:mm:ss") + "),发生异常请联系管理员!");
                            break;
                        }

                        //没有退出循环.继续增加指定时间
                        if (looping)
                        {
                            st = et;
                            //循环完.再为结束时间增加指定间隔的时间量
                            et = et.AddMilliseconds(eachHandleTime);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Thread oldThread = null;
                //清空缓存中企业对应的线程信息
                CommonCache.threadList.TryGetValue(organEntity.OrganID, out oldThread);
                if (oldThread.ThreadState != ThreadState.Stopped)
                {
                    CommonCache.threadList.TryRemove(organEntity.OrganID, out oldThread);
                    oldThread.Abort();
                }
            }
        }
Beispiel #5
0
 public OrganInfo UpdateOrganInfo(OrganInfo organInfo)
 {
     return(_organInfoRepository.Update(organInfo));
 }
Beispiel #6
0
 public OrganInfo AddOrganInfo(OrganInfo organInfo)
 {
     return(_organInfoRepository.Add(organInfo));
 }