Example #1
0
        private void _SQLColumnSampleData(SqlInstances sqlInstances)
        {
            if (0 == databases.Count)
            {
                sD = new SQLDatabase(credentials);
                sD.SetInstance(sqlInstances.ServerInstance);
                if (nodefaults)
                {
                    sD.EnableNoDefaultsFilter();
                }
                if (hasAccess)
                {
                    sD.EnableHasAccessFilter();
                }
                if (sysadmin)
                {
                    sD.EnableSysAdminFilter();
                }
                sD.Query();
                databases = sD.GetResults();
            }

            SQLColumnSampleData sCSD = new SQLColumnSampleData(credentials);

            Console.WriteLine("=====");
            Console.WriteLine("Instance : {0}", sqlInstances.ServerInstance);
            Console.WriteLine("=====");
            Console.WriteLine("{0,-20}{1,-20}{2,-20}{3,-20}", "Database", "Table", "Column", "Data");
            Console.WriteLine("{0,-20}{1,-20}{2,-20}{3,-20}", "========", "=====", "======", "====");

            sCSD.SetComputerName(sqlInstances.Server);
            sCSD.SetInstance(sqlInstances.ServerInstance);
            var results = new List <SQLColumnSampleData.SampleData>();

            foreach (var d in sD.GetResults())
            {
                sCSD.SetDatabase(d.DatabaseName);
                foreach (var f in SearchKeywords.Split(','))
                {
                    sCSD.AddSearchKeywords(f);
                }
                if (ValidateCC)
                {
                    sCSD.EnableValidateCC();
                }
                if (!string.IsNullOrEmpty(SampleSize))
                {
                    int size = 5;
                    if (int.TryParse(SampleSize, out size))
                    {
                        sCSD.SetSampleSize(size);
                    }
                }
                sCSD.Query();
                var r = sCSD.GetResults();
                results.AddRange(r);
                foreach (var s in r)
                {
                    Console.WriteLine("{0,-20}{1,-20}{2,-20}{3,-20}", s.DatabaseName, s.TableName, s.ColumnName, s.ColumnData);
                }
            }
            _PrintOutput(results);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="searchKeywords">SearchKeywords</param>
 public SetSearchKeywordsAction(SearchKeywords searchKeywords)
 {
     this.Action         = "setSearchKeywords";
     this.SearchKeywords = searchKeywords;
 }
Example #3
0
        public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)
        {
            this.functionDescriptor = functionDescriptor;

            Name = functionDescriptor.UserFriendlyName;

            if (functionDescriptor.IsOverloaded)
            {
                var parameters = new StringBuilder();
                parameters.Append("(");
                parameters.Append(String.Join(", ", functionDescriptor.Parameters.Select(x => x.Name)));
                parameters.Append(")");

                Parameters = parameters.ToString();
            }

            FullCategoryName = functionDescriptor.Category;
            Description      = functionDescriptor.Description;
            Assembly         = functionDescriptor.Assembly;

            ElementType = ElementTypes.ZeroTouch;

            if (functionDescriptor.IsBuiltIn)
            {
                ElementType |= ElementTypes.BuiltIn;
            }

            if (functionDescriptor.IsPackageMember)
            {
                ElementType |= ElementTypes.Packaged;
            }

            inputParameters  = new List <Tuple <string, string> >(functionDescriptor.InputParameters);
            outputParameters = new List <string>()
            {
                functionDescriptor.ReturnType.ToShortString()
            };

            foreach (var tag in functionDescriptor.GetSearchTags())
            {
                SearchKeywords.Add(tag);
            }

            var weights = functionDescriptor.GetSearchTagWeights();

            foreach (var weight in weights)
            {
                // Search tag weight can't be more then 1.
                if (weight <= 1)
                {
                    keywordWeights.Add(weight);
                }
            }

            int weightsCount = weights.Count();

            // If there weren't added weights for search tags, then add default value - 0.5
            if (weightsCount != SearchKeywords.Count)
            {
                int numberOfLackingWeights = SearchKeywords.Count - weightsCount;

                // Number of lacking weights should be more than 0.
                // It can be less then 0 only if there was some mistake in xml file.
                if (numberOfLackingWeights > 0)
                {
                    for (int i = 0; i < numberOfLackingWeights; i++)
                    {
                        keywordWeights.Add(0.5);
                    }
                }
            }

            iconName = GetIconName();
        }
Example #4
0
 /// <summary>
 /// 將物件資料從檔案中讀取出來
 /// </summary>
 public async Task ReadFromFileAsync()
 {
     Item = await IsolatedStorageJSON <SearchKeywords> .LoadFromFileAsync(this.DataFolderName, this.DataFileName);
 }