Ejemplo n.º 1
0
        public static int sendVerifyPhoneMsg(string phoneNum, string content)
        {
            if (phoneNum.Length != 11)
            {
                return(-1);
            }
            //设置全局参数:路径和是否需要日志
            GlobalParams gp = new GlobalParams();

            gp.setRequestPath("/sms/v2/std/");
            gp.setNeedlog(1);
            ConfigManager.setGlobalParams(gp);
            //设置用户账号信息
            int result = setAccountInfo();

            if (result != 0)
            {
                return(result);
            }
            // 是否保持长连接 false:否;true:是
            bool isKeepAlive = false;
            // 实例化短信处理对象
            ISMS sms = new SmsSendConn(isKeepAlive);

            result = singleSend(sms, "E104Y4", phoneNum, content);
            return(result);
        }
Ejemplo n.º 2
0
        public override string GetScript()
        {
            ShardMapManagerDatabaseNameSuffix = TaskOptions["ShardMapManagerDatabaseNameSuffix"];
            Shard0DatabaseNameSuffix          = TaskOptions["Shard0DatabaseNameSuffix"];
            Shard1DatabaseNameSuffix          = TaskOptions["Shard1DatabaseNameSuffix"];
            UserName         = LocalParams.FirstOrDefault(p => p.Name == "SqlCollectionUser")?.Value;
            Password         = LocalParams.FirstOrDefault(p => p.Name == "SqlCollectionPassword")?.Value;
            DatabasePrefix   = LocalParams.FirstOrDefault(p => p.Name == "SqlDbPrefix")?.Value;
            ServerInstance   = GlobalParams.FirstOrDefault(p => p.Name == "SqlServer")?.Value;
            SqlAdminUser     = GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminUser")?.Value;
            SqlAdminPassword = GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminPassword")?.Value;

            string baseScript = base.GetScript();

            if (UnInstall)
            {
                return(baseScript);
            }

            //This script isn't invoked during uninstall. It's Ok.
            return(baseScript += scriptTemaplate
                                 .Replace("$(ServerInstance)", ServerInstance)
                                 .Replace("$(SqlAdminUser)", SqlAdminUser)
                                 .Replace("$(SqlAdminPassword)", SqlAdminPassword)
                                 .Replace("$(UserName)", UserName)
                                 .Replace("$(Password)", Password)
                                 .Replace("$(DatabasePrefix)", DatabasePrefix)
                                 .Replace("$(ShardMapManagerDatabaseNameSuffix)", ShardMapManagerDatabaseNameSuffix)
                                 .Replace("$(Shard0DatabaseNameSuffix)", Shard0DatabaseNameSuffix)
                                 .Replace("$(Shard1DatabaseNameSuffix)", Shard1DatabaseNameSuffix));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存修改后密码信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <OperateStatus> SaveChangePassword(ChangePasswordInput input)
        {
            var operateStatus = new OperateStatus();

            //后台再次验证是否一致
            if (!input.NewPassword.Equals(input.ConfirmNewPassword))
            {
                operateStatus.Message = string.Format(Chs.Error, "录入的新密码和确认密码不一致。");
                return(operateStatus);
            }
            //旧密码是否正确
            operateStatus = await CheckOldPassword(new CheckSameValueInput()
            {
                Id = input.Id, Param = input.OldPassword
            });

            if (operateStatus.ResultSign == ResultSign.Error)
            {
                return(operateStatus);
            }
            //将传入的密码加密
            var encryptPwd = DEncryptUtil.Encrypt(input.NewPassword, GlobalParams.Get("pwdKey").ToString());

            if (await _userInfoRepository.ResetPassword(new ResetPasswordInput
            {
                EncryptPassword = encryptPwd,
                Id = input.Id
            }))
            {
                operateStatus.ResultSign = ResultSign.Successful;
                operateStatus.Message    = string.Format(ResourceSystem.重置密码成功, input.NewPassword);
            }
            return(operateStatus);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     保存系统配置项信息
        /// </summary>
        /// <param name="doubleWays">系统配置项信息</param>
        /// <returns></returns>
        public async Task <OperateStatus> SaveConfig(IEnumerable <SystemConfigDoubleWay> doubleWays)
        {
            OperateStatus operateStatus = new OperateStatus();

            //更新
            try
            {
                foreach (var config in doubleWays)
                {
                    config.V = DEncryptUtil.HttpUtilityUrlEncode(config.V);
                    //更新对应值
                    var c = await GetByIdAsync(config.C);

                    c.Value = config.V;
                    if (await _configRepository.UpdateAsync(c) > 0)
                    {
                        GlobalParams.Set(c.Code, config.V);
                    }
                }
                operateStatus.Message    = Chs.Successful;
                operateStatus.ResultSign = ResultSign.Successful;
            }
            catch (Exception e)
            {
                LogWriter.WriteLog(FolderName.Exception, e);
            }
            return(operateStatus);
        }
Ejemplo n.º 5
0
        public UIMFRun(string fileName)
            : this()
        {
            Check.Require(File.Exists(fileName), "UIMF file does not exist.");
            Filename = fileName;


            _globalParams = UIMFLibraryAdapter.getInstance(this.Filename).Datareader.GetGlobalParams();

            Check.Ensure(_globalParams != null, "UIMF file's Global parameters could not be initialized. Check UIMF file to make sure it is a valid file.");

            var baseFilename = Path.GetFileName(Filename);

            if (baseFilename != null)
            {
                DatasetName = baseFilename.Substring(0, baseFilename.LastIndexOf('.'));
            }
            DataSetPath = Path.GetDirectoryName(fileName);

            MinLCScan = GetMinPossibleLCScanNum();
            MaxLCScan = GetMaxPossibleLCScanNum();

            MinIMSScan = GetMinPossibleIMSScanNum();
            MaxIMSScan = GetMaxPossibleIMSScanNum();

            GetMSLevelInfo();
            ContainsMSMSData = CheckRunForMSMSData();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// The total number of frames in the run
 /// </summary>
 /// <returns></returns>
 public int GetNumFrames()
 {
     if (_globalParams == null)
     {
         _globalParams = UIMFLibraryAdapter.getInstance(Filename).Datareader.GetGlobalParams();
     }
     return(_globalParams.NumFrames);
 }
Ejemplo n.º 7
0
        public JsonResult GetLogZTree()
        {
            var tree = new List <TreeEntity>();
            var path = GlobalParams.Get("logPath").ToString();

            GetFiles(path, ref tree);
            return(Json(tree.OrderByDescending(o => o.name).ToList()));
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     赋值Cookie并加密
 /// </summary>
 /// <param name="userName">用户名</param>
 /// <param name="user">用户信息</param>
 /// <param name="rememberMe">记住我</param>
 public static void SetAuthCookie(string userName, PrincipalUser user, bool rememberMe)
 {
     //如果为记住我
     //if (rememberMe)
     //配置文件中读取记住我时间
     _cookieSaveDays = Convert.ToDouble(GlobalParams.Get("rememberMeDay").ToString());
     //赋值Cookie信息
     SetAuthCookie(userName, user, rememberMe, _cookieSaveDays);
 }
Ejemplo n.º 9
0
    void Start()
    {
        GlobalParams.ChangeLevel(1);
        timer    = GlobalParams.SpawnRate;
        OldTimer = timer;

        GameState = GameStates.Playng;

        BlnArr.Shuffle();
        GameObject InstanceBln = Instantiate(Blns[Random.Range(0, Blns.Count)], new Vector2(BlnArr[BlnArrayIndex], -8), Quaternion.identity) as GameObject;
    }
Ejemplo n.º 10
0
        private void UpdateCredentialsInCache(string email, string token)
        {
            AppPreferences ap = new AppPreferences(this);

            ap.PutString("email", email);
            ap.PutString("token", token);
            ap.Commit();

            GlobalParams.getInstance().setEmail(email);
            GlobalParams.getInstance().setToken(token);
        }
Ejemplo n.º 11
0
        private void OnItemClick(object sender, int position)
        {
            string title = _listItems[position].Title;

            ap.PutString("title", title);
            ap.Commit();

            GlobalParams.getInstance().setTitle(title);

            StartActivity(_listItems[position].PageType);
        }
Ejemplo n.º 12
0
    void Update()
    {
        if (!GlobalParams.isActive)
        {
            return;
        }
        if (GlobalParams.Score % 50 == 0 && GlobalParams.Score != 0 && !GlobalParams.showScoreInGame)
        {
            GlobalParams.showScoreInGame = true;
            GlobalParams.isActive        = false;
            if (Gameover_Panel.gameObject.activeInHierarchy == false)
            {
                Gameover_Panel.gameObject.SetActive(true);
            }
            GlobalParams.ChangeLevel(1);
            scoreText.text = "თქვენ მოაგროვეთ " + GlobalParams.Score + " ქულა";
        }
        timer -= Time.deltaTime;
        if (timer <= 0)
        {
            //კლონს რომ მივწვდეთ, ვაქცევთ "GameObject"-ად.
            if (BlnArrayIndex == BlnArr.Length - 1)
            {
                BlnArr.Shuffle();
                BlnArrayIndex = 0;
            }
            else
            {
                BlnArrayIndex++;
            }

            GameObject InstanceBln = Instantiate(Blns [Random.Range(0, Blns.Count)], new Vector2(BlnArr [BlnArrayIndex], -6), Quaternion.identity) as GameObject;

            if (!GlobalParams.WithExample)
            {
                //მაშინ გამოვიძახოთ მაგალითიანი ბუშტი.
                InstanceBln.GetComponent <BallScript> ().showExample();
                GenerateBtnsNumbers();
                GlobalParams.BlnWithExample = InstanceBln;
            }
            timer = OldTimer;
        }
        if (GlobalParams.Passedblns == GlobalParams.Maxpassedblns && GlobalParams.isActive)
        {
            GlobalParams.isActive   = false;
            GlobalParams.Passedblns = 0;
            if (Gameover_Panel.gameObject.activeInHierarchy == false)
            {
                Gameover_Panel.gameObject.SetActive(true);
            }
            GlobalParams.ChangeLevel(1);
            scoreText.text = "თქვენ მოაგროვეთ " + GlobalParams.Score + " ქულა";
        }
    }
Ejemplo n.º 13
0
 public void InitParams()
 {
     try
     {
         using (AMSEntities amsContext = new AMSEntities())
         {
             GlobalParams gp = new GlobalParams(amsContext);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex);
     }
 }
Ejemplo n.º 14
0
        private void UpdatePesquisasInCache()
        {
            List <Pesquisa> listaPesquisa = serviceWrapper.DespesasPorPesquisa();

            //ADD LISTA DE PESQUISA EM CACHE
            AppPreferences ap = new AppPreferences(this);

            ap.PutListStringSet("listaPesquisa", listaPesquisa);
            ap.Commit();
            //var lst = ap.GetString("listaPesquisa", "");
            //var lsts = JsonConvert.DeserializeObject<List<Pesquisa>>(lst);

            GlobalParams.getInstance().setListaPesquisas(listaPesquisa);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     验证旧密码是否输入正确
        /// </summary>
        /// <param name="input">需要验证的参数</param>
        /// <returns></returns>
        public async Task <OperateStatus> CheckOldPassword(CheckSameValueInput input)
        {
            var operateStatus = new OperateStatus();

            input.Param = DEncryptUtil.Encrypt(input.Param, GlobalParams.Get("pwdKey").ToString());
            if (!await _userInfoRepository.CheckOldPassword(input))
            {
                operateStatus.ResultSign = ResultSign.Error;
                operateStatus.Message    = string.Format("旧密码不正确");
            }
            else
            {
                operateStatus.ResultSign = ResultSign.Successful;
            }
            return(operateStatus);
        }
Ejemplo n.º 16
0
    public List <int> GetFormationLvs()
    {
        if (this.formation_lvs == null)
        {
            GlobalParams globalParams = DataReader <GlobalParams> .Get("formationOpenLv");

            string[] array = globalParams.value.Split(new char[]
            {
                ';'
            });
            this.formation_lvs = new List <int>();
            for (int i = 0; i < array.Length; i++)
            {
                this.formation_lvs.Add(int.Parse(array[i]));
            }
        }
        return(this.formation_lvs);
    }
Ejemplo n.º 17
0
    protected static void RecoverSelfActPoint(EntityParent target, float deltaTime)
    {
        if (target.ActPoint == target.ActPointLmt)
        {
            return;
        }
        GlobalParams globalParams = DataReader <GlobalParams> .Get("actionpoint_restore_i");

        if (globalParams.value == string.Empty)
        {
            return;
        }
        int num = (int)((double)target.ActPoint + (double)float.Parse(globalParams.value) * 0.001 * (double)deltaTime);

        if (num > target.ActPointLmt)
        {
            num = target.ActPointLmt;
        }
        target.SetValue(AttrType.ActPoint, num, true);
    }
Ejemplo n.º 18
0
 /// <summary>
 ///     从数据库中读取配置信息
 /// </summary>
 private static void LoadConfig()
 {
     //如果没有加载则进行加载
     if (!hasLoad)
     {
         lock (obj)
         {
             if (!hasLoad)
             {
                 //读取log4net配置文件信息
                 var configStr = (string)GlobalParams.Get("log4net");
                 //序列化xml
                 var xml = new XmlDocument();
                 xml.LoadXml(configStr);
                 XmlConfigurator.Configure(xml.DocumentElement);
                 hasLoad = true;
             }
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 重写基类
        /// </summary>
        public override void WriteLog()
        {
            //写入数据库
            base.WriteLog();
            string exceptionHtml = ExceptionHtml(log);

            //是否发送邮件
            if (bool.Parse(GlobalParams.Get("errorSendMail").ToString()))
            {
                string    fromAccount = GlobalParams.Get("errorSendMailFromAccount").ToString();
                string    fromPwd     = GlobalParams.Get("errorSendMailFromPwd").ToString();
                string    toAccount   = GlobalParams.Get("errorSendMailToAccount").ToString();
                string    toSmtp      = GlobalParams.Get("errorSendMailSmtp").ToString();
                bool      toSmtpSsl   = bool.Parse(GlobalParams.Get("errorSendMailSmtpSsl").ToString());
                EmailUtil email       = new EmailUtil(toAccount, fromAccount, "错误接受者", "系统错误提醒", "系统发生错误", exceptionHtml, true);
                email.SetSmtp(fromPwd, toSmtp, toSmtpSsl);
            }
            //写入文本
            LogWriter.WriteLog(FolderName.Exception, exceptionHtml);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     根据用户Id重置某人密码
        /// </summary>
        /// <param name="input">用户Id</param>
        /// <returns></returns>
        public async Task <OperateStatus> ResetPassword(IdInput input)
        {
            var operateStatus = new OperateStatus();
            //获取系统默认配置重置密码
            var password = GlobalParams.Get("resetPassword").ToString();
            //加密密码
            //将传入的密码加密
            var encryptPwd = DEncryptUtil.Encrypt(password, GlobalParams.Get("pwdKey").ToString());

            if (await _userInfoRepository.ResetPassword(new ResetPasswordInput
            {
                EncryptPassword = encryptPwd,
                Id = input.Id
            }))
            {
                operateStatus.ResultSign = ResultSign.Successful;
                operateStatus.Message    = string.Format(ResourceSystem.重置密码成功, password);
            }
            return(operateStatus);
        }
Ejemplo n.º 21
0
    public void Connect(GameModel gameModel, List <GuestParams> guestList, GameObjectPool pool,
                        GlobalParams globalParams,
                        CommonAssets commonAssets, Camera camera1,
                        Transform bubbleContainer, Transform minigameContainer, PlayerController playerController)
    {
        _gameModel         = gameModel;
        _pool              = pool;
        _globalParams      = globalParams;
        _commonAssets      = commonAssets;
        _camera            = camera1;
        _bubbleContainer   = bubbleContainer;
        _minigameContainer = minigameContainer;
        _playerController  = playerController;

        foreach (var guestParams in guestList)
        {
            CreateGuest(guestParams);
        }

        EventManager.OnClueGet += AddClue;
    }
Ejemplo n.º 22
0
        /// <summary>
        ///     根据登录代码和密码查询用户信息
        /// </summary>
        /// <param name="input">登录名、密码等</param>
        /// <returns></returns>
        public async Task <OperateStatus <SystemUserOutput> > CheckUserByCodeAndPwd(UserLoginInput input)
        {
            var operateStatus = new OperateStatus <SystemUserOutput>();
            //将传入的密码加密
            var encryptPwd = DEncryptUtil.Encrypt(input.Pwd, GlobalParams.Get("pwdKey").ToString());

            //查询信息
            input.Pwd = encryptPwd;
            var data = await _userInfoRepository.CheckUserByCodeAndPwd(input);

            //是否存在
            if (data == null)
            {
                operateStatus.ResultSign = ResultSign.Error;
                operateStatus.Message    = ResourceSystem.用户名或密码错误;
                return(operateStatus);
            }
            //是否冻结
            if (data.IsFreeze)
            {
                operateStatus.ResultSign = ResultSign.Error;
                operateStatus.Message    = ResourceSystem.登录用户已冻结;
                return(operateStatus);
            }
            //成功
            operateStatus.ResultSign = ResultSign.Successful;
            operateStatus.Message    = "/";
            operateStatus.Data       = data;
            if (data.FirstVisitTime == null)
            {
                //更新用户最后一次登录时间
                _userInfoRepository.UpdateFirstVisitTime(new IdInput(data.UserId));
            }
            //更新用户最后一次登录时间
            _userInfoRepository.UpdateLastLoginTime(new IdInput(data.UserId));
            return(operateStatus);
        }
Ejemplo n.º 23
0
    public void ManualStart(GlobalParams globalParams, FlipperParams parameters)
    {
        this.globalParams       = globalParams;
        transform.localPosition = new Vector3(parameters.x, parameters.y, 0f);
        transform.localRotation = Quaternion.Euler(0f, 0f, parameters.rotation);

        joint.useLimits = true;
        var limits = new JointAngleLimits2D();

        limits.min = parameters.angleMin;
        limits.max = parameters.angleMax;
        var xOffset = parameters.length * 0.5f;

        if (parameters.isLeft)
        {
            limits.min = -parameters.angleMin;
            limits.max = -parameters.angleMax;
        }
        else
        {
            xOffset    = -xOffset;
            limits.min = parameters.angleMin;
            limits.max = parameters.angleMax;
        }
        joint.limits    = limits;
        collider.offset = new Vector2(xOffset, 0f);
        collider.size   = new Vector2(parameters.length, parameters.thickness);
        modelObject.transform.localPosition = new Vector3(xOffset, 0f, 0f);
        modelObject.transform.localScale    = new Vector3(parameters.length, parameters.thickness, 1f);
        var motor = new JointMotor2D();

        motor.maxMotorTorque = float.MaxValue;
        motor.motorSpeed     = globalParams.flipperMotorSpeed;
        motor.motorSpeed    *= parameters.isLeft ? -1f : 1f;
        joint.motor          = motor;
        joint.useMotor       = false;
    }
Ejemplo n.º 24
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ap = new AppPreferences(this);

            SetContentView(Resource.Layout.activity_list);

            _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(_toolbar);

            SupportActionBar.Title = GlobalParams.getInstance().getTitle();

            _rv = FindViewById <RecyclerView>(Resource.Id.rv);
            _rv.HasFixedSize = true;

            _rvLayoutManager = new LinearLayoutManager(this);
            _rv.SetLayoutManager(_rvLayoutManager);

            _listItems = new List <ListItem> {
                new ListItem {
                    Title = "Nova entrevista", PageType = typeof(QuestionarioActivity)
                },
                //new ListItem {Title = "Nova entrevista", PageType = typeof(QuestionarioFinalActivity)},
                new ListItem {
                    Title = "Mapa", PageType = typeof(MapaActivity)
                },
                new ListItem {
                    Title = "Despesas", PageType = typeof(DespesaActivity)
                }
            };

            _adapter            = new CustomAdapter(_listItems, this.Resources);
            _adapter.ItemClick += OnItemClick;
            _rv.SetAdapter(_adapter);
        }
Ejemplo n.º 25
0
        public void CreateDB_test1(int frameCountToWrite)
        {
            DataReaderTests.DataReaderTests.PrintMethodName(System.Reflection.MethodBase.GetCurrentMethod());

            var fiTarget = new FileInfo(FileRefs.WriterTest10Frames);

            if (fiTarget.Exists)
            {
                fiTarget.Delete();
            }

            var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();

            using (var writer = new DataWriter(fiTarget.FullName, executingAssembly))
            {
                writer.CreateTables("int");

                var globalParameters = new GlobalParams();

                globalParameters.AddUpdateValue(GlobalParamKeyType.Bins, 400000)
                .AddUpdateValue(GlobalParamKeyType.BinWidth, 0.25)
                .AddUpdateValue(GlobalParamKeyType.DateStarted, DateTime.Now)
                .AddUpdateValue(GlobalParamKeyType.NumFrames, frameCountToWrite)
                .AddUpdateValue(GlobalParamKeyType.TOFIntensityType, "ADC");

                writer.InsertGlobal(globalParameters)
                .AddUpdateGlobalParameter(GlobalParamKeyType.TimeOffset, 1)
                .AddUpdateGlobalParameter(GlobalParamKeyType.InstrumentName, "IMS_Test");

                Console.WriteLine("Adding frame 1");

                const float SECONDS_PER_FRAME = 1.25f;

                var randGenerator = new Random();

                for (var frameNum = 1; frameNum <= frameCountToWrite; frameNum++)
                {
                    var fp = new FrameParams();

                    fp.AddUpdateValue(FrameParamKeyType.FrameType, (int)UIMFData.FrameType.MS1)
                    .AddUpdateValue(FrameParamKeyType.CalibrationSlope, 0.3476349957054481)
                    .AddUpdateValue(FrameParamKeyType.CalibrationIntercept, 0.03434148864746093)
                    .AddUpdateValue(FrameParamKeyType.AverageTOFLength, 163366.6666666667)
                    .AddUpdateValue(FrameParamKeyType.StartTimeMinutes, frameNum * SECONDS_PER_FRAME)
                    .AddUpdateValue(FrameParamKeyType.Scans, 600);

                    writer.InsertFrame(frameNum, fp);

                    for (var scanNumber = 1; scanNumber <= 600; scanNumber++)
                    {
                        if (scanNumber == 1 | scanNumber % 100 == 0)
                        {
                            Console.WriteLine("Adding frame " + frameNum + ", scan " + scanNumber);
                        }

                        var intensities = new int[148000];

                        for (var i = 0; i < intensities.Length; i++)
                        {
                            var nextRandom = randGenerator.Next(0, 255);
                            if (nextRandom < 250)
                            {
                                intensities[i] = 0;
                            }
                            else
                            {
                                intensities[i] = nextRandom;
                            }
                        }

                        writer.InsertScan(frameNum, fp, scanNumber, intensities, globalParameters.BinWidth);
                    }
                }

                writer.UpdateGlobalStats();

                Console.WriteLine("Wrote 10 frames of data to " + fiTarget.FullName);
            }
        }
Ejemplo n.º 26
0
 public GameController(ModuleManager moduleManager, GlobalParams globalParams, GameObjectPool pool)
 {
     _moduleManager = moduleManager;
     GlobalParams   = globalParams;
     Pool           = pool;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// 执行方法前进入该重置方法
        ///     1、一个帐号只能在一个地方登录
        ///     2、权限验证
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //获取当前登录人员信息
            PrincipalUser currentUser = FormAuthenticationExtension.Current(HttpContext.Current.Request);

            #region 是否具有忽略验证特性
            //是否具有忽略特性:若有忽略特性则不进行其他的验证
            if (filterContext.ActionDescriptor.IsDefined(typeof(IgnoreAttribute), false))
            {
                return;
            }
            #endregion

            #region 一个帐号只能在一个浏览器登录
            if (GlobalParams.Get("loginOnce").ToString() == "是")
            {
                //如果当前登录人员信息不为空
                if (currentUser != null)
                {
                    //检查对应登录状态缓存是否为空
                    if (HttpRuntime.Cache[currentUser.Code] != null)
                    {
                        if (filterContext.HttpContext.Session != null &&
                            HttpRuntime.Cache[currentUser.Code].ToString() !=
                            filterContext.HttpContext.Session.SessionID)
                        {
                            //清空Session
                            filterContext.HttpContext.Session.Remove(currentUser.Code);
                            //清空Cookie
                            FormAuthenticationExtension.SignOut();
                            //跳转强制下线界面
                            ErrorRedirect(filterContext, "/Error/HaveLogin");
                        }
                    }
                    //否则重新赋值Cache
                    else
                    {
                        if (filterContext.HttpContext.Session != null)
                        {
                            filterContext.HttpContext.Session[currentUser.Code] = currentUser.UserId;
                            HttpRuntime.Cache[currentUser.Code] = filterContext.HttpContext.Session.SessionID;
                        }
                    }
                }
            }
            #endregion

            #region 用户是否登录
            PrincipalUser principalUser = FormAuthenticationExtension.Current(HttpContext.Current.Request);
            if (principalUser == null)
            {
                ErrorRedirect(filterContext, "/Error/ReturnToLogin");
                return;
            }
            #endregion

            #region 是否具有HttpPost/HttpGet请求验证
            var isAjaxRequest = filterContext.HttpContext.Request.IsAjaxRequest();
            #endregion

            #region 验证该方法是否需要进行权限验证
            //todo:1、获取用户信息。2、从缓存中获取该用户权限,若没有数据则从数据库中重新拉取(有可能缓存失效),再将权限数据填充到缓存中。
            //配置的当前系统代码
            string appCode = ConfigurationManager.AppSettings["AppCode"];
            //区域
            string area = string.Empty;
            //控制器
            string controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            //方法
            string action    = filterContext.ActionDescriptor.ActionName;
            var    routeData = filterContext.RequestContext.RouteData;
            if (routeData.DataTokens["area"] != null)
            {
                area = routeData.DataTokens["area"].ToString();
            }
            //调用Api接口查看是否具有该权限
            string apiUrl = ConfigurationManager.AppSettings["SolutionApiUrl"];

            //是否为Ajax请求,若是Ajax请求则不进行界面验证(此处只验证视图)
            if (!isAjaxRequest)
            {
                if (currentUser != null)
                {
                    //string request = RequestUtil.SendPostRequest(apiUrl + "api/System/Permission/GetSystemPermissionsMvcRote",
                    //"UserId=" + currentUser.UserId + "&AppCode=" + appCode + "&Area=" + area + "&Controller=" + controller + "&Action=" + action);
                    //OperateStatus operateStatus = request.Deserialize<OperateStatus>();
                    //if (operateStatus.ResultSign == ResultSign.Error)
                    //{
                    //     //ErrorRedirect(filterContext, "/Error/Warn");
                    //}
                }
            }

            #endregion
        }
Ejemplo n.º 28
0
        public override bool ProcessDataFile(string strDataFilePath, clsDatasetFileInfo datasetFileInfo)
        {
            // Returns True if success, False if an error

            DataReader   objUIMFReader   = null;
            GlobalParams objGlobalParams = null;

            var intMasterFrameNumList = new int[1];

            // Obtain the full path to the file
            var fiFileInfo = new FileInfo(strDataFilePath);

            if (!fiFileInfo.Exists)
            {
                return(false);
            }

            // Future, optional: Determine the DatasetID
            // Unfortunately, this is not present in metadata.txt
            // intDatasetID = LookupDatasetID(strDatasetName)
            var intDatasetID = 0;

            datasetFileInfo.FileSystemCreationTime     = fiFileInfo.CreationTime;
            datasetFileInfo.FileSystemModificationTime = fiFileInfo.LastWriteTime;

            // The acquisition times will get updated below to more accurate values
            datasetFileInfo.AcqTimeStart = datasetFileInfo.FileSystemModificationTime;
            datasetFileInfo.AcqTimeEnd   = datasetFileInfo.FileSystemModificationTime;

            datasetFileInfo.DatasetID     = intDatasetID;
            datasetFileInfo.DatasetName   = GetDatasetNameViaPath(fiFileInfo.Name);
            datasetFileInfo.FileExtension = fiFileInfo.Extension;
            datasetFileInfo.FileSizeBytes = fiFileInfo.Length;

            datasetFileInfo.ScanCount = 0;

            mDatasetStatsSummarizer.ClearCachedData();

            var blnReadError           = false;
            var blnInaccurateStartTime = false;

            try
            {
                // Use the UIMFLibrary to read the .UIMF file
                objUIMFReader = new DataReader(fiFileInfo.FullName);
            }
            catch (Exception ex)
            {
                // File open failed
                OnErrorEvent("Call to .OpenUIMF failed for " + fiFileInfo.Name + ": " + ex.Message, ex);
                blnReadError = true;
            }

            if (!blnReadError)
            {
                try
                {
                    // First obtain the global parameters
                    objGlobalParams = objUIMFReader.GetGlobalParams();
                }
                catch (Exception)
                {
                    // Read error
                    blnReadError = true;
                }
            }

            if (!blnReadError)
            {
                // Read the file info

                var dctMasterFrameList = new Dictionary <int, DataReader.FrameType>();

                try
                {
                    // Construct a master list of frame numbers and frame types
                    dctMasterFrameList = objUIMFReader.GetMasterFrameList();

                    if (dctMasterFrameList.Count > 0)
                    {
                        // Copy the frame numbers into an array so that we can assure it's sorted
                        intMasterFrameNumList = new int[dctMasterFrameList.Keys.Count];
                        dctMasterFrameList.Keys.CopyTo(intMasterFrameNumList, 0);

                        Array.Sort(intMasterFrameNumList);
                    }

                    // Extract the acquisition time information
                    // The Global_Parameters table records the start time of the entire dataset in field DateStarted
                    // The Frame_Parameters table records the start time of reach frame in field StartTime

                    // The DateStarted column in the Global_Parameters table should be represented by one of these values
                    //   A text-based date, like "5/2/2011 4:26:59 PM"; example: Sarc_MS2_26_2Apr11_Cheetah_11-02-18_inverse.uimf
                    //   A text-based date (no time info), like "Thursday, January 13, 2011"; example: QC_Shew_11_01_pt5_c2_030311_earth_4ms_0001
                    //   A tick-based date, like 129272890050787740 (number of ticks since January 1, 1601); example: BATs_TS_01_c4_Eagle_10-02-06_0000

                    // The StartTime column in the Frame_Parameters table should be represented by one of these values
                    //   Integer between 0 and 1440 representing number of minutes since midnight (can loop from 1439.9 to 0); example: Sarc_MS2_26_2Apr11_Cheetah_11-02-18_inverse.uimf
                    //   Integer between 0 and 60 representing number of minutes since past the current hour (can loop from 59.9 to 0); example: BATs_TS_01_c4_Eagle_10-02-06_0000.uimf
                    //   A tick-based date, like 634305349108974800 (number of ticks since January 1, 0001); example: QC_Shew_11_01_pt5_c2_030311_earth_4ms_0001
                    //   A negative number representing number of minutes from the start of the run in UTC time to the start of the current frame, in local time; example: Sarc_P08_G03_0747_7Dec11_Cheetah_11-09-05.uimf
                    //      Examine values: Frame 1 has StartTime = -479.993 and Frame 1177 has StartTime = -417.509
                    //   A positive integer representing number of minutes since the start of the run
                    //      Theoretically, this will be the case for IMS_TOF_4 acquired after 12/14/2011

                    double dblRunTime = 0;

                    // First examine objGlobalParams.DateStarted
                    try
                    {
                        var blnValidStartTime      = false;
                        var strReportedDateStarted = objGlobalParams.GetValue(GlobalParamKeyType.DateStarted);

                        if (!DateTime.TryParse(strReportedDateStarted, out var dtReportedDateStarted))
                        {
                            // Invalid date; log a message
                            OnWarningEvent(".UIMF file has an invalid DateStarted value in table Global_Parameters: " + strReportedDateStarted + "; " +
                                           "will use the time the datafile was last modified");
                            blnInaccurateStartTime = true;
                        }
                        else
                        {
                            if (dtReportedDateStarted.Year < 450)
                            {
                                // Some .UIMF files have DateStarted values represented by huge integers, e.g. 127805472000000000 or 129145004045937500; example: BATs_TS_01_c4_Eagle_10-02-06_0000
                                // These numbers are the number of ticks since 1 January 1601 (where each tick is 100 ns)
                                // This value is returned by function GetSystemTimeAsFileTime (see http://en.wikipedia.org/wiki/System_time)

                                // When SQLite parses these numbers, it converts them to years around 0410
                                // To get the correct year, simply add 1600

                                dtReportedDateStarted = dtReportedDateStarted.AddYears(1600);
                                blnValidStartTime     = true;
                            }
                            else if (dtReportedDateStarted.Year <2000 | dtReportedDateStarted.Year> DateTime.Now.Year + 1)
                            {
                                // Invalid date; log a message
                                OnWarningEvent(".UIMF file has an invalid DateStarted value in table Global_Parameters: " + strReportedDateStarted + "; " +
                                               "will use the time the datafile was last modified");
                                blnInaccurateStartTime = true;
                            }
                            else
                            {
                                blnValidStartTime = true;
                            }
                        }

                        if (blnValidStartTime)
                        {
                            datasetFileInfo.AcqTimeStart = dtReportedDateStarted;

                            // Update the end time to match the start time; we'll update it below using the start/end times obtained from the frame parameters
                            datasetFileInfo.AcqTimeEnd = datasetFileInfo.AcqTimeStart;
                        }
                    }
                    catch (Exception ex2)
                    {
                        OnWarningEvent("Exception extracting the DateStarted date from table Global_Parameters in the .UIMF file: " + ex2.Message);
                    }

                    // NumFrames is the total number of frames in the file (for all frame types)
                    datasetFileInfo.ScanCount = objGlobalParams.NumFrames;
                    if (intMasterFrameNumList.Length > datasetFileInfo.ScanCount)
                    {
                        datasetFileInfo.ScanCount = intMasterFrameNumList.Length;
                    }

                    if (intMasterFrameNumList.Length > 0)
                    {
                        // Ideally, we would lookup the acquisition time of the first frame and the last frame, then subtract the two times to determine the run time
                        // However, given the odd values that can be present in the StartTime field, we need to construct a full list of start times and then parse it

                        // Get the start time of the first frame
                        // See above for the various numbers that could be stored in the StartTime column
                        var objFrameParams = objUIMFReader.GetFrameParams(intMasterFrameNumList[0]);
                        var dblStartTime   = objFrameParams.GetValueDouble(FrameParamKeyType.StartTimeMinutes);

                        // Get the start time of the last frame
                        // If the reported start time is zero, then step back until a non-zero start time is reported

                        var    frameIndex = intMasterFrameNumList.Length - 1;
                        double dblEndTime;
                        do
                        {
                            objFrameParams = objUIMFReader.GetFrameParams(intMasterFrameNumList[frameIndex]);
                            dblEndTime     = objFrameParams.GetValueDouble(FrameParamKeyType.StartTimeMinutes);

                            if (Math.Abs(dblEndTime) < float.Epsilon)
                            {
                                frameIndex -= 1;
                            }
                        } while (Math.Abs(dblEndTime) < float.Epsilon && frameIndex >= 0);

                        // Check whether the StartTime and EndTime values are based on ticks
                        if (dblStartTime >= 1E+17 & dblEndTime > 1E+17)
                        {
                            // StartTime and Endtime were stored as the number of ticks (where each tick is 100 ns)
                            // Tick start date is either 1 January 1601 or 1 January 0001

                            var dtRunTime = DateTime.MinValue.AddTicks((long)(dblEndTime - dblStartTime));

                            dblRunTime = dtRunTime.Subtract(DateTime.MinValue).TotalMinutes;

                            // In some .UIMF files, the DateStarted column in Global_Parameters is simply the date, and not a specific time of day
                            // If that's the case, then update datasetFileInfo.AcqTimeStart to be based on dblRunTime
                            if (datasetFileInfo.AcqTimeStart.Date == datasetFileInfo.AcqTimeStart)
                            {
                                var dtReportedDateStarted = DateTime.MinValue.AddTicks((long)dblStartTime);

                                if (dtReportedDateStarted.Year < 500)
                                {
                                    dtReportedDateStarted = dtReportedDateStarted.AddYears(1600);
                                }

                                if (dtReportedDateStarted.Year >= 2000 & dtReportedDateStarted.Year <= DateTime.Now.Year + 1)
                                {
                                    // Date looks valid
                                    if (blnInaccurateStartTime)
                                    {
                                        datasetFileInfo.AcqTimeStart = dtReportedDateStarted;
                                        datasetFileInfo.AcqTimeEnd   = datasetFileInfo.AcqTimeStart;
                                    }
                                    else
                                    {
                                        // How does it compare to datasetFileInfo.AcqTimeStart?
                                        if (dtReportedDateStarted.Subtract(datasetFileInfo.AcqTimeStart).TotalHours < 24)
                                        {
                                            // Update the date
                                            datasetFileInfo.AcqTimeStart = dtReportedDateStarted;
                                            datasetFileInfo.AcqTimeEnd   = datasetFileInfo.AcqTimeStart;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            // Ideally, we'd just compute RunTime like this: dblRunTime = dblEndTime - dblStartTime
                            // But, given the idiosyncracies that can occur, we need to construct a full list of start times

                            var    lstStartTimes   = new List <double>();
                            double dblEndTimeAddon = 0;

                            for (var intIndex = 0; intIndex <= intMasterFrameNumList.Length - 1; intIndex++)
                            {
                                objFrameParams = objUIMFReader.GetFrameParams(intMasterFrameNumList[intIndex]);
                                lstStartTimes.Add(objFrameParams.GetValueDouble(FrameParamKeyType.StartTimeMinutes));
                            }

                            // Some datasets erroneously have zeroes stored in the .UIMF file for the StartTime of the last two frames; example: Sarc_MS2_26_2Apr11_Cheetah_11-02-18_inverse
                            // Check for this and remove them
                            var intFrameCountRemoved = 0;
                            while ((Math.Abs(lstStartTimes[lstStartTimes.Count - 1]) < float.Epsilon))
                            {
                                lstStartTimes.RemoveAt(lstStartTimes.Count - 1);
                                intFrameCountRemoved += 1;
                                if (lstStartTimes.Count == 0)
                                {
                                    break;
                                }
                            }

                            if (intFrameCountRemoved > 0)
                            {
                                if (lstStartTimes.Count > 2)
                                {
                                    // Compute the amount of time (in minutes) to addon to the total run time
                                    // We're computing the time between two frames, and multiplying that by intFrameCountRemoved
                                    dblEndTimeAddon += intFrameCountRemoved * (lstStartTimes[lstStartTimes.Count - 1] - lstStartTimes[lstStartTimes.Count - 2]);
                                }
                            }

                            // Now check for the StartTime changing to a smaller number from one frame to the next
                            // This could happen if the StartTime changed from 1439 to 0 as the system clock hits midnight
                            // Or if the StartTime changes from 59.9 to 0 as the system clock hits the top of a new hour
                            for (var intIndex = 1; intIndex <= lstStartTimes.Count - 1; intIndex++)
                            {
                                if (lstStartTimes[intIndex] < lstStartTimes[intIndex - 1])
                                {
                                    if (lstStartTimes[intIndex - 1] > 1439)
                                    {
                                        dblEndTimeAddon += 1440;
                                    }
                                    else if (lstStartTimes[intIndex - 1] > 59.7)
                                    {
                                        dblEndTimeAddon += 60;
                                    }
                                }
                            }

                            if (lstStartTimes.Count > 0)
                            {
                                // Compute the runtime
                                // Luckily, even if dblStartTime is -479.993 and dblEntTime is -417.509, this works out to a positive, accurate runtime
                                dblEndTime = lstStartTimes[lstStartTimes.Count - 1];
                                dblRunTime = dblEndTime + dblEndTimeAddon - dblStartTime;
                            }
                        }
                    }
                    else
                    {
                        dblRunTime = 0;
                    }

                    if (dblRunTime > 0)
                    {
                        if (dblRunTime > 24000)
                        {
                            OnWarningEvent("Invalid runtime computed using the StartTime value from the first and last frames: " + dblRunTime);
                        }
                        else
                        {
                            if (blnInaccurateStartTime)
                            {
                                datasetFileInfo.AcqTimeStart = datasetFileInfo.AcqTimeEnd.AddMinutes(-dblRunTime);
                            }
                            else
                            {
                                datasetFileInfo.AcqTimeEnd = datasetFileInfo.AcqTimeStart.AddMinutes(dblRunTime);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    OnWarningEvent("Exception extracting acquisition time information: " + ex.Message);
                }

                if (mSaveTICAndBPI || mCreateDatasetInfoFile || mCreateScanStatsFile || mSaveLCMS2DPlots)
                {
                    // Load data from each frame
                    // This is used to create the TIC and BPI plot, the 2D LC/MS plot, and/or to create the Dataset Info File
                    LoadFrameDetails(objUIMFReader, dctMasterFrameList, intMasterFrameNumList);
                }

                if (mComputeOverallQualityScores)
                {
                    // Note that this call will also create the TICs and BPIs
                    ComputeQualityScores(objUIMFReader, datasetFileInfo, dctMasterFrameList, intMasterFrameNumList);
                }
            }

            // Close the handle to the data file
            objUIMFReader?.Dispose();

            // Read the file info from the file system
            // (much of this is already in datasetFileInfo, but we'll call UpdateDatasetFileStats() anyway to make sure all of the necessary steps are taken)
            UpdateDatasetFileStats(fiFileInfo, intDatasetID);

            // Copy over the updated filetime info from datasetFileInfo to mDatasetFileInfo
            mDatasetStatsSummarizer.DatasetFileInfo.FileSystemCreationTime     = datasetFileInfo.FileSystemCreationTime;
            mDatasetStatsSummarizer.DatasetFileInfo.FileSystemModificationTime = datasetFileInfo.FileSystemModificationTime;
            mDatasetStatsSummarizer.DatasetFileInfo.DatasetID     = datasetFileInfo.DatasetID;
            mDatasetStatsSummarizer.DatasetFileInfo.DatasetName   = string.Copy(datasetFileInfo.DatasetName);
            mDatasetStatsSummarizer.DatasetFileInfo.FileExtension = string.Copy(datasetFileInfo.FileExtension);
            mDatasetStatsSummarizer.DatasetFileInfo.AcqTimeStart  = datasetFileInfo.AcqTimeStart;
            mDatasetStatsSummarizer.DatasetFileInfo.AcqTimeEnd    = datasetFileInfo.AcqTimeEnd;
            mDatasetStatsSummarizer.DatasetFileInfo.ScanCount     = datasetFileInfo.ScanCount;
            mDatasetStatsSummarizer.DatasetFileInfo.FileSizeBytes = datasetFileInfo.FileSizeBytes;

            return(!blnReadError);
        }
Ejemplo n.º 29
0
 public void Connect(Camera camera1, GlobalParams globalParams)
 {
     _camera       = camera1;
     _globalParams = globalParams;
 }
Ejemplo n.º 30
0
 public void ChangeSceneWithParams(int lvl, int run_type, int game_mode)
 {
     GlobalParams.Initialize(run_type, game_mode);
     preloader.SetActive(true);
     StartCoroutine(LoadAsyncScene(lvl));
 }