示例#1
0
 private void logError(CheckReadOnlyDALResultMessage message, string errorMessage, string sourceFileName, int sourceLineNumber, string typeOfDALobj, string spName)
 {
     message.ErrorMessages.Add(errorMessage);
     message.SourceFileNames.Add(sourceFileName);
     message.SourceLineNumbers.Add(sourceLineNumber);
     message.TypeOfDALobjects.Add(typeOfDALobj);
     message.StoredProcedureNames.Add(spName);
 }
示例#2
0
        public void Analyze()
        {
            CheckReadOnlyDALResultMessage message = new CheckReadOnlyDALResultMessage();

            //Initialize response's message
            message.rootPath    = Path.GetDirectoryName(_projectFileName);
            message.projectName = Path.GetFileNameWithoutExtension(_projectFileName);

            ISymbol calledMethodSymbol;

            while ((calledMethodSymbol = getNextReadOnlyDALCalledMethod()) != null)
            {
                string spName          = null;
                string typeOfDALobject = calledMethodSymbol.ContainingType.ToString();

                try
                {
                    spName = getStoredProcName(calledMethodSymbol);

                    if (string.IsNullOrEmpty(spName))//cannot find SP, I should make a smartest search :(
                    {
                        logError(message, Resource1.StoredProcedureNotFoundError, _targetSrcFilesListEnumerator.Current, _targetFilesFetcher.CurrentSourceLineNumber, typeOfDALobject, spName);
                        continue;
                    }

                    if (!_sqlAnalyser.spIsReadOnly(spName))
                    {
                        logError(message, Resource1.StoredProcedureIsNotReadOnlyError, _targetSrcFilesListEnumerator.Current, _targetFilesFetcher.CurrentSourceLineNumber, typeOfDALobject, spName);
                    }
                }
                catch (Exception e)
                {
                    logError(message, e.Message, _targetSrcFilesListEnumerator.Current, _targetFilesFetcher.CurrentSourceLineNumber, typeOfDALobject, spName);
                }
            }

            message.print();
        }