Example #1
0
        static int Main(string[] args)
        {
            EasyWinScpScript.Infrastructure.Logger logger = new EasyWinScpScript.Infrastructure.Logger(ParameterLoader.GetParameter(args, "Log"), ParameterLoader.IsEnableLogging(args));
            try
            {
                logger.LogSeperator('-');
                logger.Log("Collecting connection information...");
                ParameterLoader.AddLogger(logger);
                ConnectionInfo connectionInfo = new ConnectionInfo();
                if (ParameterLoader.IsDBConnection(args))
                {
                    logger.Log("Database call found");
                    ParameterLoader.LoadFromDataBase(args, connectionInfo);
                }
                if (ParameterLoader.isParameterLoad(args))
                {
                    logger.Log("Loading connection info from parameters");
                    ParameterLoader.LoadFromParameters(args, connectionInfo);
                }
                logger.LogSeperator('-');
                Connection conn = new Connection(connectionInfo, logger);

                conn.Initialize();
                string searchPattern   = ParameterLoader.GetParameter(args, "Search_Pattern", "*");
                string sftpAction      = ParameterLoader.GetParameter(args, "SFTP_Action").ToLower();
                string localDirectory  = ParameterLoader.GetParameter(args, "Local_Directory");
                string remoteDirectory = ParameterLoader.GetParameter(args, "Remote_Directory");

                if (sftpAction.Equals(ConfigurationManager.AppSettings["PUT"]))
                {
                    conn.PutFilesInRemoteDirectory(conn.GetFiles(localDirectory, searchPattern), remoteDirectory);
                }
                else if (sftpAction.Equals(ConfigurationManager.AppSettings["PUT_DELETE"]))
                {
                    conn.PutFilesInRemoteDirectory(conn.GetFiles(localDirectory, searchPattern), remoteDirectory, true);
                }
                else if (sftpAction.Equals(ConfigurationManager.AppSettings["GET"]))
                {
                    conn.GetFilesInRemoteDirectory(conn.GetRemoteFiles(remoteDirectory, searchPattern), localDirectory);
                }
                else if (sftpAction.Equals(ConfigurationManager.AppSettings["GET_DELETE"]))
                {
                    conn.GetFilesInRemoteDirectory(conn.GetRemoteFiles(remoteDirectory, searchPattern), localDirectory, true);
                }
                else if (sftpAction.Equals(ConfigurationManager.AppSettings["GET_REMOTE_FILES"]))
                {
                    writeFile(conn.GetRemoteFiles(remoteDirectory, searchPattern), ParameterLoader.GetParameter(args, "Output_File"));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex);
                return(0);
            }
            finally
            {
                logger.Close();
            }
            return(1000);
        }
Example #2
0
            public void Initialize(AnalyzerOptions options)
            {
                if (isInitialized)
                {
                    return;
                }

                lock (@lock)
                {
                    if (isInitialized)
                    {
                        return;
                    }

                    isInitialized = true;

                    var sonarLintXml = options.AdditionalFiles
                                       .FirstOrDefault(f => ParameterLoader.IsSonarLintXml(f.Path));

                    if (sonarLintXml == null)
                    {
                        return;
                    }

                    var document = XDocument.Load(sonarLintXml.Path);

                    enabledRules = document.Descendants("Rule")
                                   .Select(r => r.Element("Key")?.Value)
                                   .WhereNotNull()
                                   .ToHashSet();
                }
            }
Example #3
0
        protected void ReadParameters(AnalyzerOptions options, string language)
        {
            var sonarLintAdditionalFile = options.AdditionalFiles
                                          .FirstOrDefault(f => ParameterLoader.ConfigurationFilePathMatchesExpected(f.Path));

            var projectOutputAdditionalFile = options.AdditionalFiles
                                              .FirstOrDefault(f => ParameterLoader.ConfigurationFilePathMatchesExpected(f.Path, ConfigurationAdditionalFile));

            if (sonarLintAdditionalFile == null ||
                projectOutputAdditionalFile == null)
            {
                return;
            }

            lock (parameterReadLock)
            {
                var xml      = XDocument.Load(sonarLintAdditionalFile.Path);
                var settings = xml.Descendants("Setting");
                ReadHeaderCommentProperties(settings);
                WorkDirectoryBasePath = File.ReadAllLines(projectOutputAdditionalFile.Path).FirstOrDefault(l => !string.IsNullOrEmpty(l));

                if (!string.IsNullOrEmpty(WorkDirectoryBasePath))
                {
                    var suffix = language == LanguageNames.CSharp
                        ? "cs"
                        : "vbnet";
                    WorkDirectoryBasePath = Path.Combine(WorkDirectoryBasePath, "output-" + suffix);
                    IsAnalyzerEnabled     = true;
                }
            }
        }
 /// <summary>
 /// Creates a new instance of <see cref="OverloadsBuilder"/>.
 /// </summary>
 /// <param name="debug">
 /// Whether the emitted code is to be debuggable.
 /// </param>
 /// <param name="stack">
 /// Place where the <see cref="PhpStack"/> instance can be loaded from.
 /// </param>
 /// <param name="loadValueParam">
 /// Delegate called when value parameter is to be loaded on evaluation stack.
 /// The target method should guarantee that a value is loaded on evaluation stack.
 /// </param>
 /// <param name="loadReferenceParam">
 /// Delegate called when PHP reference parameter is to be loaded on evaluation stack.
 /// The target method should guarantee that the object reference of type <see cref="PhpReference"/>
 /// is loaded on the evaluation stack. This object reference should not be a <B>null</B>.
 /// </param>
 /// <param name="loadOptParams">
 /// Delegate called when an array of optional arguments is to be loaded on evaluation stack.
 /// The target method should load that array on the evaluation stack.
 /// </param>
 public OverloadsBuilder(bool debug, IPlace stack,
                         ParameterLoader loadValueParam, ParameterLoader loadReferenceParam, ParametersLoader loadOptParams)
 {
     this.loadValueParam     = loadValueParam;
     this.loadReferenceParam = loadReferenceParam;
     this.loadOptParams      = loadOptParams;
     this.stack = stack;
     this.debug = debug;
 }
Example #5
0
 /// <summary>
 /// 初始化的时候
 /// </summary>
 /// <param name="requestContext"></param>
 protected override void Initialize(RequestContext requestContext)
 {
     //ajax提交上来的请求
     if (requestContext.HttpContext.Request.IsAjaxRequest() && requestContext.HttpContext.Request.RequestType.ToLower() == "post")
     {
         //封装一下ajax的数据
         RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
     }
     base.Initialize(requestContext);
 }
        public void SetParameterValues_WithWrongPropertyType_StringInsteadOfBoolean_DoesNotPopulateProperties()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\StringInsteadOfBoolean\\SonarLint.xml");
            var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.IsRegularExpression.Should().BeFalse(); // Default value
        }
Example #7
0
        public void SetParameterValues_WithBadPath_DoesNotPopulateProperties()
        {
            // Arrange
            var options  = TestHelper.CreateOptions("ResourceTests\\ThisPathDoesNotExist\\SonarLint.xml");
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(3); // Default value
        }
        public void SetParameterValues_WhenGivenSonarLintFileHasIntParameterType_PopulatesProperties()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\SonarLint.xml");
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(1); // Value from the xml file
        }
        public void SetParameterValues_WhenGivenSonarLintFileHasStringParameterType_OnlyOneParameter_PopulatesProperty()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\RuleWithStringParameter\\SonarLint.xml");
            var analyzer = new EnumNameShouldFollowRegex(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.FlagsEnumNamePattern.Should().Be("1"); // value from XML file
        }
        public void SetParameterValues_WhenGivenSonarLintFileHasBooleanParameterType_OnlyOneParameter_PopulatesProperty()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\RuleWithBooleanParameter\\SonarLint.xml");
            var analyzer = new CheckFileLicense(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.IsRegularExpression.Should().BeTrue(); // value from XML file
        }
        public void SetParameterValues_WhenGivenValidSonarLintFileAndDoesNotContainAnalyzerParameters_DoesNotPopulateProperties()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\SonarLint.xml");
            var analyzer = new LineLength(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(200); // Default value
        }
        public void SetParameterValues_WhenNoSonarLintIsGiven_DoesNotPopulateParameters()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\MyFile.xml");
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(3); // Default value
        }
        public void SetParameterValues_WithWrongPropertyType_StringInsteadOfInt_DoesNotPopulateProperties()
        {
            // Arrange
            var options  = CreateOptions("ResourceTests\\StringInsteadOfInt\\SonarLint.xml");
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(3); // Default value
        }
Example #14
0
        /// <summary>
        /// 处理前
        /// </summary>
        /// <param name="requestContext"></param>
        protected override void Initialize(RequestContext requestContext)
        {
            try
            {
                if (requestContext.HttpContext.Request.IsAjaxRequest() && requestContext.HttpContext.Request.RequestType.ToLower() == "post")
                {
                    //预备给脚本端的数据获取接口
                    RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
                }
                else
                {
                    //直接post的加密接口
                    //RequestParameters = ParameterLoader.LoadSecurityParameters(requestContext.HttpContext.Request.InputStream);
                    RequestParameters = ParameterLoader.LoadAjaxPostParameters(requestContext.HttpContext.Request.InputStream);
                    if (!string.IsNullOrEmpty(RequestParameters.identity) && !string.IsNullOrWhiteSpace(RequestParameters.identity))
                    {
                        //保存在Session中
                        SessionInfo session = (SessionInfo)requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME];

                        //session里面没有
                        if (session != null && session.SessionUser != null && session.SessionUser.User != null)
                        {
                            //如果传入token不一致,以客户端为准
                            if (session.SessionUser.User.ID.ToString() != RequestParameters.identity)
                            {
                                var login = DIEntity.GetInstance().GetImpl <ILogin>();
                                session.SessionUser.User = login.GetAppLoginInfo(RequestParameters.identity);
                                requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME] = session;
                            }
                            else
                            {
                                SessionUser = session.SessionUser.User;
                            }
                        }
                        else
                        {
                            var         login = DIEntity.GetInstance().GetImpl <ILogin>();
                            SessionInfo info  = new SessionInfo();
                            info.SessionUser.User = login.GetAppLoginInfo(RequestParameters.identity);
                            requestContext.HttpContext.Session[SessionInfo.APISESSION_NAME] = info;
                            SessionUser = info.SessionUser.User;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                SystemLog.Logs.GetLog().WriteErrorLog(e);
            }
            base.Initialize(requestContext);
        }
        public void SetParameterValues_WhenGivenValidSonarLintFileAndDoesNotContainAnalyzerParameters_DoesNotPopulateProperties()
        {
            // Arrange
            var additionalText = new Mock <AdditionalText>();

            additionalText.Setup(x => x.Path).Returns("ResourceTests\\SonarLint.xml");
            var options  = new AnalyzerOptions(ImmutableArray.Create(additionalText.Object));
            var analyzer = new LineLength(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(200); // Default value
        }
        public void SetParameterValues_WhenGivenValidSonarLintFileAndContainsAnalyzerParameters_PopulatesProperties()
        {
            // Arrange
            var additionalText = new Mock <AdditionalText>();

            additionalText.Setup(x => x.Path).Returns("ResourceTests\\SonarLint.xml");
            var options  = new AnalyzerOptions(ImmutableArray.Create(additionalText.Object));
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act
            ParameterLoader.SetParameterValues(analyzer, options);

            // Assert
            analyzer.Maximum.Should().Be(1); // Value from the xml file
        }
Example #17
0
        protected sealed override void Initialize(SonarAnalysisContext context)
        {
            var analysisContext = new ParameterLoadingAnalysisContext(context);

            Initialize(analysisContext);

            context.RegisterCompilationStartAction(
                cac =>
            {
                ParameterLoader.SetParameterValues(this, cac.Options);
                foreach (var compilationStartActions in analysisContext.CompilationStartActions)
                {
                    compilationStartActions(cac);
                }
            });
        }
Example #18
0
        public void FindMSPeaksTest1()
        {
            ParameterLoader loader = new ParameterLoader();

            loader.LoadParametersFromFile(parameterFilename);

            Run run = new IMFRun(imfFilepath);


            run.CurrentScanSet = new ScanSet(1, 1, 100000);

            ResultCollection resultcollection = new ResultCollection(run);

            Task msgen = new GenericMSGenerator();

            msgen.Execute(resultcollection);

            DeconToolsPeakDetector peakfinder = new DeconToolsPeakDetector(loader.PeakParameters);

            peakfinder.Execute(resultcollection);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < resultcollection.Run.PeakList.Count; i++)
            {
                MSPeak mspeak = (MSPeak)resultcollection.Run.PeakList[i];


                sb.Append(resultcollection.Run.PeakList[i].XValue);
                sb.Append("\t");
                sb.Append(resultcollection.Run.PeakList[i].Height);
                sb.Append("\t");
                sb.Append(mspeak.SN);
                sb.Append("\t");
                sb.Append(resultcollection.Run.PeakList[i].Width);
                sb.Append("\t");
                sb.Append(Environment.NewLine);
            }
            Console.Write(sb.ToString());

            Assert.AreEqual(2438, resultcollection.Run.PeakList.Count);
            Assert.AreEqual(547.316411323136, Convert.ToDecimal(resultcollection.Run.PeakList[982].XValue));
            Assert.AreEqual(100385, resultcollection.Run.PeakList[982].Height);
        }
Example #19
0
        /// <summary>
        /// Parses the specified parameter if it exists.
        /// </summary>
        /// <param name="args">The array of parameter arguments you want to check.</param>
        /// <param name="parameter">The parameter you want to parse.</param>
        public static void ParseParameter(this string[] args, string parameter)
        {
            try
            {
                IParameter param = ParameterLoader.GetParameter(parameter);

                if (param.ExpectsValue)
                {
                    if (args.TryGetParameterValue(param.Name, out string value))
                    {
                        param.Parse(value);
                    }
                }
                else
                {
                    param.Parse("");
                }
            }
            catch { /* ignored */ }
        }
Example #20
0
        public Configuration(string path, AnalyzerLanguage language)
        {
            if (!ParameterLoader.ConfigurationFilePathMatchesExpected(path))
            {
                throw new ArgumentException(
                          $"Input configuration doesn't match expected file name: '{ParameterLoader.ParameterConfigurationFileName}'",
                          nameof(path));
            }

            Path      = path;
            analyzers = ImmutableArray.Create(GetAnalyzers(language).ToArray());

            var xml      = XDocument.Load(path);
            var settings = ParseSettings(xml);

            IgnoreHeaderComments = "true".Equals(settings[$"sonar.{language}.ignoreHeaderComments"], StringComparison.OrdinalIgnoreCase);

            Files = xml.Descendants("File").Select(e => e.Value).ToImmutableList();

            AnalyzerIds = xml.Descendants("Rule").Select(e => e.Elements("Key").Single().Value).ToImmutableHashSet();
        }
        public void SetParameterValues_CalledTwiceAfterChangeInConfigFile_UpdatesProperties()
        {
            // Arrange
            var sonarLintXmlRelativePath = "ResourceTests\\ToChange\\SonarLint.xml";
            var options  = CreateOptions(sonarLintXmlRelativePath);
            var analyzer = new ExpressionComplexity(); // Cannot use mock because we use reflection to find properties.

            // Act with the file on disk
            ParameterLoader.SetParameterValues(analyzer, options);
            analyzer.Maximum.Should().Be(1); // from the XML on disk

            // Update the file on disk
            var originalContent = File.ReadAllText(sonarLintXmlRelativePath);
            var modifiedContent = originalContent.Replace("<Value>1</Value>", "<Value>42</Value>");

            File.WriteAllText(sonarLintXmlRelativePath, modifiedContent);
            ParameterLoader.SetParameterValues(analyzer, options);
            analyzer.Maximum.Should().Be(42);

            // revert change
            File.WriteAllText(sonarLintXmlRelativePath, originalContent);
        }
Example #22
0
        public Configuration(string sonarLintFilePath, string protoFolderFilePath, AnalyzerLanguage language)
        {
            if (!ParameterLoader.ConfigurationFilePathMatchesExpected(sonarLintFilePath))
            {
                throw new ArgumentException(
                          $"Input configuration doesn't match expected file name: '{ParameterLoader.ParameterConfigurationFileName}'",
                          nameof(sonarLintFilePath));
            }

            this.language             = language;
            ProtoFolderAdditionalPath = protoFolderFilePath;

            SonarLintAdditionalPath = sonarLintFilePath;
            analyzers = ImmutableArray.Create(GetAnalyzers(language).ToArray());

            var xml      = XDocument.Load(sonarLintFilePath);
            var settings = ParseSettings(xml);

            IgnoreHeaderComments = "true".Equals(settings[$"sonar.{language}.ignoreHeaderComments"], StringComparison.OrdinalIgnoreCase);

            Files = xml.Descendants("File").Select(e => e.Value).ToImmutableList();

            AnalyzerIds = xml.Descendants("Rule").Select(e => e.Elements("Key").Single().Value).ToImmutableHashSet();

            if (settings.ContainsKey("sonar.sourceEncoding"))
            {
                try
                {
                    var encodingName = settings["sonar.sourceEncoding"];
                    Encoding = Encoding.GetEncoding(encodingName);
                }
                catch (ArgumentException)
                {
                    Program.Write($"Could not get encoding '{settings["sonar.sourceEncoding"]}'");
                }
            }
        }
Example #23
0
 /// <summary>
 /// 处理后
 /// </summary>
 /// <param name="filterContext"></param>
 protected override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     if (filterContext.Exception != default(Exception))
     {
         if (filterContext.Exception.GetType() == typeof(DomainInfoException))
         {
             var ex = filterContext.Exception as DomainInfoException;
             filterContext.ExceptionHandled = true;
             if (ex.IsLog)
             {
                 SystemLog.Logs.GetLog().WriteErrorLog(ex);
                 result.Succeeded     = false;
                 result.Msg           = ex.Message;
                 filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
             }
             else
             {
                 result.Succeeded     = false;
                 result.Msg           = ex.Message;
                 filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
             }
         }
         else
         {
             //处理controller的异常
             SystemLog.Logs.GetLog().WriteErrorLog(filterContext.Exception);
             filterContext.ExceptionHandled = true;
         }
     }
     else //if (filterContext.HttpContext.Request.IsAjaxRequest() && filterContext.HttpContext.Request.RequestType.ToLower() == "post")
     {
         //filterContext.Result = File(Security.EncryptionResponse(ParameterLoader.LoadResponseJSONStr(result)), "application/octet-stream");
         //var ret = Security.EncryptionResponse(ParameterLoader.LoadResponseJSONStr(result));
         //filterContext.HttpContext.Response.BinaryWrite(ret);
         filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
     }
 }
Example #24
0
        public void Read(AnalyzerOptions options)
        {
            var projectOutputAdditionalFile = options.AdditionalFiles
                                              .FirstOrDefault(UtilityAnalyzerBase.IsProjectOutput);

            var sonarLintAdditionalFile = options.AdditionalFiles
                                          .FirstOrDefault(f => ParameterLoader.ConfigurationFilePathMatchesExpected(f.Path));

            if (sonarLintAdditionalFile == null ||
                projectOutputAdditionalFile == null)
            {
                return;
            }

            var xml = XDocument.Load(sonarLintAdditionalFile.Path);

            EnabledRules = xml.Descendants("Rule")
                           .Select(r => r.Element("Key")?.Value)
                           .WhereNotNull()
                           .ToHashSet();

            ProjectOutputPath = File.ReadAllLines(projectOutputAdditionalFile.Path)
                                .FirstOrDefault(l => !string.IsNullOrEmpty(l));
        }
Example #25
0
		public ClrOverloadBuilder(ILEmitter/*!*/ il, ClrMethod/*!*/ method, ConstructedType constructedType,
			IPlace/*!*/ stack, IPlace/*!*/ instance, bool emitParentCtorCall,
			ParameterLoader/*!*/ loadValueArg, ParameterLoader/*!*/ loadReferenceArg)
		{
			this.il = il;
			this.method = method;
			this.constructedType = constructedType;
			this.stack = stack;
			this.instance = instance;
			this.loadValueArg = loadValueArg;
			this.loadReferenceArg = loadReferenceArg;
			this.emitParentCtorCall = emitParentCtorCall;

			this.overloads = new List<Overload>(method.Overloads);
			SortOverloads(this.overloads);
		}
Example #26
0
        /// <summary>
        /// 处理后
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var isAjaxRequest /*是否是ajax异步请求*/ = filterContext.HttpContext.Request.IsAjaxRequest();
            var requestType /*请求类型*/          = filterContext.HttpContext.Request.RequestType.ToLower();

            //如果响应遇到异常
            if (filterContext.Exception != default(Exception))
            {
                //DomainInfoException表示这个是自定义的信息
                if (filterContext.Exception is DomainInfoException)
                {
                    var ex = filterContext.Exception as DomainInfoException;
                    if (ex != null && ex.IsLog)
                    {
                        SystemLog.Logs.GetLog().WriteErrorLog(ex);/*记录日志*/
                        result.Succeeded     = false;
                        result.Msg           = ex.Message;
                        filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
                    }
                    else
                    {
                        result.Succeeded     = false;
                        result.Msg           = ex != null ? ex.Message : "后台执行中出现异常";
                        filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
                    }
                    filterContext.ExceptionHandled = true;
                }
                else
                {
                    //处理controller的异常
                    SystemLog.Logs.GetLog().WriteErrorLog(filterContext.Exception);
                    result.Succeeded               = false;
                    result.Msg                     = filterContext.Exception.Message;
                    filterContext.Result           = Content(ParameterLoader.LoadResponseJSONStr(result));
                    filterContext.ExceptionHandled = true;
                }
            }
            else if (isAjaxRequest && requestType == "post")
            {
                //请求是脚本 ajax POST 的请求
                filterContext.Result = Content(ParameterLoader.LoadResponseJSONStr(result));
            }
            else if (isAjaxRequest && requestType == "get")
            {
                //这里一般是通过easyui的panel或者dialog的get请求请求部分数据的处理
                var controller = filterContext.RequestContext.RouteData.Values["controller"].ToString().ToLower();
                var action     = filterContext.RequestContext.RouteData.Values["action"].ToString().ToLower();

                //排除登录和菜单、首页还有不需要按钮的标识,如果非登录和菜单、首页,
                //你需要载入按钮的话,那么把NeedMenuButton置为true就可以了
                if (controller != "login" && controller != "menu" && controller != "main" && action == "index" || NeedMenuButton)
                {
                    //请求是get请求,一般都是打开某个菜单,获取会话中的用户权限菜单信息
                    var menuinfo = GetSessionInfo(SessionInfo.USER_MENUS /*用户的权限和菜单等信息*/) as UserRoleMenuInfo;

                    if (menuinfo != null)
                    {
                        //找到当前控制器对应的菜单信息
                        var userMenu = menuinfo.AllMenu.Where(m =>
                        {
                            return(m.sUrl.Split(new char[] { '/' }).Last().ToLower() == controller);
                        }).FirstOrDefault();

                        if (userMenu != default(UserMenu))
                        {
                            //添加这个菜单有的btn,这里是会排序的,如果编辑了菜单按钮的排序,刷新就可以了
                            filterContext.Controller.ViewData.Add("btns", userMenu.Buttons.OrderBy(m => m.iOrder).ToList());
                        }
                    }
                }
            }
            else
            {
                //其他方式的请求:暂无处理
            }
        }
Example #27
0
 private static bool IsProjectOutFolderPath(AdditionalText file) =>
 ParameterLoader.ConfigurationFilePathMatchesExpected(file.Path, ProjectOutFolderPathFileName);
Example #28
0
 /// <summary>
 /// Initializes <c>Consolation</c> systems.
 /// </summary>
 public static void Initialize() => ParameterLoader.Initialize(Assembly.GetCallingAssembly());
Example #29
0
		/// <summary>
		/// Creates a new instance of <see cref="OverloadsBuilder"/>.
		/// </summary>
		/// <param name="debug">
		/// Whether the emitted code is to be debuggable.
		/// </param>
		/// <param name="stack">
		/// Place where the <see cref="PhpStack"/> instance can be loaded from.
		/// </param>
		/// <param name="loadValueParam">
		/// Delegate called when value parameter is to be loaded on evaluation stack.
		/// The target method should guarantee that a value is loaded on evaluation stack.
		/// </param>
		/// <param name="loadReferenceParam">
		/// Delegate called when PHP reference parameter is to be loaded on evaluation stack.
		/// The target method should guarantee that the object reference of type <see cref="PhpReference"/> 
		/// is loaded on the evaluation stack. This object reference should not be a <B>null</B>.
		/// </param>
		/// <param name="loadOptParams">
		/// Delegate called when an array of optional arguments is to be loaded on evaluation stack.
		/// The target method should load that array on the evaluation stack.
		/// </param>
		public OverloadsBuilder(bool debug, IPlace stack,
			ParameterLoader loadValueParam, ParameterLoader loadReferenceParam, ParametersLoader loadOptParams)
		{
			this.loadValueParam = loadValueParam;
			this.loadReferenceParam = loadReferenceParam;
			this.loadOptParams = loadOptParams;
			this.stack = stack;
			this.debug = debug;
		}
Example #30
0
 internal static bool IsProjectOutput(AdditionalText file) =>
 ParameterLoader.ConfigurationFilePathMatchesExpected(file.Path, ConfigurationAdditionalFile);
 private static string GetSonarLintXmlPath(AnalyzerOptions options) =>
 options.AdditionalFiles.FirstOrDefault(f => ParameterLoader.IsSonarLintXml(f.Path))?.Path;
Example #32
0
        public void IMFcompareToCanonicalResults_noSumming()
        {
            //generate results using new framework

            int numScansSummed = 1;

            Run run = new IMFRun(imfFilepath);

            ResultCollection results = new ResultCollection(run);

            ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 231, 233, numScansSummed, 1, false);

            sscc.Create();

            ParameterLoader loader = new ParameterLoader();

            loader.LoadParametersFromFile(qtParameterfile1);

            foreach (ScanSet scanset in run.ScanSetCollection.ScanSetList)
            {
                run.CurrentScanSet = scanset;
                Task msgen = new GenericMSGenerator();
                msgen.Execute(results);


                Task peakDetector = new DeconToolsPeakDetector(loader.PeakParameters);
                peakDetector.Execute(results);

                Task horndecon = new HornDeconvolutor(loader.TransformParameters);
                horndecon.Execute(results);

                Task scanResultUpdater = new ScanResultUpdater();
                scanResultUpdater.Execute(results);
            }

            //read in results from canonical _isos
            List <IsosResult> canonIsos = readInIsos(canonIMFIsosFilename, Globals.MSFileType.PNNL_IMS);

            Assert.AreEqual(canonIsos.Count, results.ResultList.Count);

            //compare numbers

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < results.ResultList.Count; i++)
            {
                sb.Append("scanmass\t");
                sb.Append(results.ResultList[i].ScanSet.PrimaryScanNumber);
                sb.Append("\t");
                sb.Append(canonIsos[i].ScanSet.PrimaryScanNumber);
                sb.Append("\n");

                sb.Append("monoMass\t");
                sb.Append(results.ResultList[i].IsotopicProfile.MonoIsotopicMass.ToString("0.0000"));
                sb.Append("\t");
                sb.Append(canonIsos[i].IsotopicProfile.MonoIsotopicMass);
                sb.Append("\n");

                sb.Append("intens\t");
                sb.Append(results.ResultList[i].IsotopicProfile.IntensityAggregate);
                sb.Append("\t");
                sb.Append(canonIsos[i].IsotopicProfile.IntensityAggregate);
                sb.Append("\n");

                sb.Append("score\t");
                sb.Append(results.ResultList[i].IsotopicProfile.Score.ToString("0.0000"));
                sb.Append("\t");
                sb.Append(canonIsos[i].IsotopicProfile.Score);
                sb.Append("\n");

                sb.Append("FWHM\t");
                sb.Append(results.ResultList[i].IsotopicProfile.GetFWHM().ToString("0.0000"));
                sb.Append("\t");
                sb.Append(canonIsos[i].IsotopicProfile.GetFWHM());
                sb.Append("\n");

                sb.Append("s/n\t");
                sb.Append(results.ResultList[i].IsotopicProfile.GetSignalToNoise().ToString("0.0000"));
                sb.Append("\t");
                sb.Append(canonIsos[i].IsotopicProfile.GetSignalToNoise());
                sb.Append("\n");

                sb.Append("\n");
            }

            Console.Write(sb.ToString());
        }