예제 #1
0
        public static IList <T> ExecuteProcedurewithOutParameter <T>(string procedureName, System.Collections.ObjectModel.Collection <DBParameters> parameters, string databaseConnection, out Dictionary <string, string> dic)
        {
            dic = new Dictionary <string, string>();
            List <T> returnValue;

            // Create a suitable command type and add the required parameter
            using (SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(databaseConnection))
            {
                sqlConnection.Open();
                SqlCommand sqlCommand = new SqlCommand(procedureName, sqlConnection);
                sqlCommand.CommandType    = CommandType.StoredProcedure;
                sqlCommand.CommandTimeout = _appSetting;
                /*Add different Parameter from Model object Property*/
                AddParameters(ref sqlCommand, parameters);

                /*Execute Procedure from supplied Execution type*/
                returnValue = DataReaderToList <T>(sqlCommand.ExecuteReader());

                if (parameters.Any(a => a.Direction == ParameterDirection.Output))
                {
                    foreach (var db in parameters.Where(w => w.Direction == ParameterDirection.Output))
                    {
                        dic.Add(sqlCommand.Parameters[db.Name].ParameterName, Convert.ToString(sqlCommand.Parameters[db.Name].Value));
                    }
                }
            }
            return(returnValue);
        }
예제 #2
0
        public static object ExecuteProcedurewithOutParameter(string procedureName, ExecuteType executeType, System.Collections.ObjectModel.Collection <DBParameters> parameters, string databaseConnection, out Dictionary <string, string> dictionary)
        {
            dictionary = new Dictionary <string, string>();
            object returnValue;

            //// Create a suitable command type and add the required parameter
            using (SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(databaseConnection))
            {
                sqlConnection.Open();

                SqlCommand sqlCommand = new SqlCommand(procedureName, sqlConnection);
                sqlCommand.CommandType    = CommandType.StoredProcedure;
                sqlCommand.CommandTimeout = _appSetting;
                /*Add different Parameter from Model object Property*/
                AddParameters(ref sqlCommand, parameters);

                /*Execute Procedure from supplied Execution type*/
                if (executeType == ExecuteType.ExecuteScalar)
                {
                    returnValue = sqlCommand.ExecuteScalar();
                }
                else if (executeType == ExecuteType.ExecuteDataSet)
                {
                    DataSet dataSet = new DataSet();
                    dataSet.Locale = System.Globalization.CultureInfo.InvariantCulture;
                    SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCommand);
                    sqlAdapter.Fill(dataSet);
                    returnValue = dataSet;
                }
                else if (executeType == ExecuteType.ExecuteNonQuery)
                {
                    returnValue = sqlCommand.ExecuteNonQuery();
                }
                else if (executeType == ExecuteType.ExecuteReader)
                {
                    returnValue = sqlCommand.ExecuteReader();
                }
                else
                {
                    returnValue = "No Proper execute type provide";
                }

                if (parameters.Any(a => a.Direction == ParameterDirection.Output))
                {
                    foreach (var db in parameters.Where(w => w.Direction == ParameterDirection.Output))
                    {
                        dictionary.Add(sqlCommand.Parameters[db.Name].ParameterName, Convert.ToString(sqlCommand.Parameters[db.Name].Value));
                    }
                }
            }
            return(returnValue);
        }
        public Settings RegistryRead (Settings settings)
        {
			var settingsInformation = new List<RegistryEntry>();
			if (App.IsWindowsMachine) settingsInformation = (new Settings()).AsEnumerable(SettingsReturnType.Essential).ReadFromRegistry(registryRootValue, App.IsDebugging).ToList();
			else
			{
				var settingsFromFile = new System.Collections.ObjectModel.Collection<string>().AddFileContents(RegistryFile);
				if(settingsFromFile.Any())
				{
					for (var position = settingsFromFile.GetEnumerator(); position.MoveNext();)
					{
						var entry = position.Current.Split(new[] { RegistryEntry.Separator }, StringSplitOptions.RemoveEmptyEntries);
						settingsInformation.Add(new RegistryEntry(entry.First(), entry.Last()));
					}
				}
			}
			return settings.Replace(settingsInformation);
        }
        public Settings RegistryRead(Settings settings)
        {
            var settingsInformation = new List <RegistryEntry>();

            if (App.IsWindowsMachine)
            {
                settingsInformation = (new Settings()).AsEnumerable(SettingsReturnType.Essential).ReadFromRegistry(RegistryRoot, App.IsDebugging).ToList();
            }
            else
            {
                var settingsFromFile = new System.Collections.ObjectModel.Collection <string>().AddFileContents(RegistryFile);
                if (settingsFromFile.Any())
                {
                    for (var position = settingsFromFile.GetEnumerator(); position.MoveNext();)
                    {
                        var entry = position.Current.Split(new[] { RegistryEntry.Separator }, StringSplitOptions.RemoveEmptyEntries);
                        settingsInformation.Add(new RegistryEntry(entry.First(), entry.Last()));
                    }
                }
            }
            return(settings.Replace(settingsInformation));
        }
예제 #5
0
        public override void Execute()
        {
            SrcMLFile testFile  = new SrcMLFile(this.File);
            XElement  firstFile = testFile.FileUnits.First();

            //get all the functions
            var containers = new System.Collections.ObjectModel.Collection <XName>()
            {
                SRC.Function, SRC.Constructor, SRC.Destructor
            };
            var funcs = from func in firstFile.Descendants()
                        where containers.Any(c => c == func.Name)
                        select func;

            Dictionary <XElement, string> functionComments = new Dictionary <XElement, string>();


            //grab the comment block for each function
            foreach (var func in funcs)
            {
                StringBuilder functionComment = new StringBuilder();

                var prevElements = func.ElementsBeforeSelf().Reverse();
                foreach (var element in prevElements)
                {
                    if (element.Name == SRC.Comment)
                    {
                        //add comment to beginning of comment block
                        functionComment.Insert(0, element.Value + System.Environment.NewLine);
                    }
                    else
                    {
                        //found something besides a comment
                        break;
                    }
                }

                functionComments[func] = functionComment.ToString();
            }

            AbbreviationExpander ae = new AbbreviationExpander();

            ae.Expand(Word, functionComments.First().Key, functionComments.First().Value, "");

            //string patternRegex;
            //string shortForm = Word;
            //StringBuilder sb = new StringBuilder(@"\b");
            //for (int i = 0; i < shortForm.Length - 1; i++)
            //{
            //    sb.AppendFormat(@"{0}\w+\s+", shortForm[i]);
            //}
            //sb.AppendFormat(@"{0}\w+\b", shortForm[shortForm.Length - 1]);
            //patternRegex = sb.ToString();

            //Console.WriteLine("Acronym regex: {0}", patternRegex);

            //string methodComment = functionComments.First().Value;
            //Match m = Regex.Match(methodComment, string.Format("({0})", patternRegex), RegexOptions.IgnoreCase);
            //if (m.Success)
            //{
            //    Console.WriteLine("Found match: {0}", m.Groups[1].Value);
            //}
        }
예제 #6
0
파일: Program.cs 프로젝트: abb-iss/Swum.NET
        public override void Execute()
        {
            SrcMLFile testFile = new SrcMLFile(this.File);
            XElement firstFile = testFile.FileUnits.First();

            //get all the functions
            var containers = new System.Collections.ObjectModel.Collection<XName>() { SRC.Function, SRC.Constructor, SRC.Destructor };
            var funcs = from func in firstFile.Descendants()
                        where containers.Any(c => c == func.Name)
                        select func;

            Dictionary<XElement, string> functionComments = new Dictionary<XElement, string>();


            //grab the comment block for each function
            foreach (var func in funcs)
            {
                StringBuilder functionComment = new StringBuilder();

                var prevElements = func.ElementsBeforeSelf().Reverse();
                foreach (var element in prevElements)
                {
                    if (element.Name == SRC.Comment)
                    {
                        //add comment to beginning of comment block
                        functionComment.Insert(0, element.Value + System.Environment.NewLine);
                    }
                    else
                    {
                        //found something besides a comment
                        break;
                    }
                }

                functionComments[func] = functionComment.ToString();
            }

            AbbreviationExpander ae = new AbbreviationExpander();
            ae.Expand(Word, functionComments.First().Key, functionComments.First().Value, "");

            //string patternRegex;
            //string shortForm = Word;
            //StringBuilder sb = new StringBuilder(@"\b");
            //for (int i = 0; i < shortForm.Length - 1; i++)
            //{
            //    sb.AppendFormat(@"{0}\w+\s+", shortForm[i]);
            //}
            //sb.AppendFormat(@"{0}\w+\b", shortForm[shortForm.Length - 1]);
            //patternRegex = sb.ToString();

            //Console.WriteLine("Acronym regex: {0}", patternRegex);

            //string methodComment = functionComments.First().Value;
            //Match m = Regex.Match(methodComment, string.Format("({0})", patternRegex), RegexOptions.IgnoreCase);
            //if (m.Success)
            //{
            //    Console.WriteLine("Found match: {0}", m.Groups[1].Value);
            //}
        }