Beispiel #1
0
        /// <summary>
        /// Criação das Procedures
        /// </summary>
        public void CreateProcedures()
        {
            foreach (string fullPath in Directory.GetFiles(PathProcedures, "*.sql", SearchOption.AllDirectories)) // add para procurar em subDiretorios - SearchOption.AllDirectories
            {
                try
                {
                    string fileName = Path.GetFileName(fullPath);
                    if (!fileName.Contains(".sql"))
                    {
                        continue;
                    }

                    string scriptProcedure = File.ReadAllText(fullPath, Encoding.Default);

                    Procedure = Between(scriptProcedure, "--NAME{", "}");

                    if (Procedure.Contains("SEEDER") || Procedure.Contains("SEEDER"))
                    {
                        continue;
                    }

                    Console.WriteLine("Abrindo o Arquivo: " + Path.GetFileName(fileName));
                    HasProcedure();

                    Console.WriteLine("Criando Procedure: " + Procedure);
                    base.SqlServerExecuteProcedure(scriptProcedure);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }
            }
        }
Beispiel #2
0
        public List <Frame> FindCorrectFrames(List <string> InputList) //Метод поиска подходящих фреймов
        {
            List <Frame>  lf      = new List <Frame>();
            List <double> percent = new List <double>();

            Frame[] frames = fm.GetFrameList();
            CheckDefaultValues(frames);

            for (int i = 0; i < frames.Length; i++)
            {
                List <Slot> slots = frames[i].Slot;
                CheckSlots(slots);
            }
            AddCorrectFrames();
            SetTruthPercent(percent.Max());

            return(lf);

            void CheckDefaultValues(Frame[] arrFrames) //Метод соотношения значений default, которые наследуются, к настоящим значениям
            {
                int current_i = 0;

                for (int i = 0; i < arrFrames.Length; i++)
                {
                    for (int j = 0; j < arrFrames[i].Slot.Count; j++)
                    {
                        string value = arrFrames[i].Slot[j].Value;
                        current_i = i;
                        while (value == "default")
                        {
                            value = FindValue(current_i, j);
                        }
                        arrFrames[i].Slot[j].Value = value;
                    }
                }

                string FindValue(int index, int jndex) //поиск значения у родителя
                {
                    string ParentName = arrFrames[index].ParentName;

                    for (int i = 0; i < arrFrames.Length; i++)
                    {
                        if (ParentName == arrFrames[i].Name)
                        {
                            current_i = i;
                            return(arrFrames[i].Slot[jndex].Value);
                        }
                    }
                    return(null);
                }
            }

            void CheckSlots(List <Slot> slots) //Проверка слотов на достоверность
            {
                double allCheck = 0, trueCheck = 0;

                for (int i = 0; i < slots.Count; i++)
                {
                    string[] inputValues;
                    try
                    {
                        if (InputList[i][InputList[i].Length - 1] == '/')
                        {
                            InputList[i] = InputList[i].Remove(InputList[i].Length - 1);
                        }
                        inputValues = InputList[i].Split('/');
                    }
                    catch { inputValues = new string[] { "none" }; }
                    string[] slotValues = slots[i].Value.Split('/');

                    if (slots[i].Procedure == "null")
                    {
                        for (int j = 0; j < inputValues.Length; j++)
                        {
                            if (slotValues.Contains(inputValues[j]))
                            {
                                trueCheck++;
                            }
                            allCheck++;
                        }
                    }
                    else if (slots[i].Procedure == "if_needed" && slots[i].Value != "null")
                    {
                        int[] values = ConvertValuesToInt(inputValues);
                        int   max = values.Max(), min = values.Min();
                        slots[i].Value = ProcedureBase.FixComponentPrice(slots[i].Value).ToString();
                        if (CheckValuesWithProcedure(min, max, slots[i].Value))
                        {
                            trueCheck++;
                        }
                        allCheck++;
                    }
                }
                double per = trueCheck / allCheck * 100;

                percent.Add(per);

                int[] ConvertValuesToInt(string[] strArr) //Конвертация массива строк в массив чисел
                {
                    int[] ans = new int[strArr.Length];
                    for (int i = 0; i < ans.Length; i++)
                    {
                        try
                        {
                            ans[i] = Convert.ToInt32(strArr[i]);
                        }
                        catch { }
                    }
                    return(ans);
                }

                bool CheckValuesWithProcedure(double min, double max, string Procedure) //Метод сравнения слотов, которые определяются внешними процедурами
                {
                    if (Procedure.Contains(ProcedureBase.GetNameMethod()))
                    {
                        double price = ProcedureBase.FixComponentPrice(Procedure.ToLower());
                        if (price >= min && price <= max)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }

            void AddCorrectFrames() //метод добавления подходящих фреймов
            {
                for (int i = 0; i < percent.Count; i++)
                {
                    if (percent[i] == percent.Max())
                    {
                        lf.Add(frames[i]);
                    }
                }
            }
        }
Beispiel #3
0
        // Check account existence
        // Get all users
        public DataTable DoQuery()
        {
            _dbConnector.Connect();

            DataSet dataset = new DataSet("MainDataset");

            _dataTable = new DataTable();
            _dataTable = dataset.Tables.Add("MainTable");

            MySqlCommand command = new MySqlCommand(Procedure, _dbConnector.DbConnectionInstance)
            {
                CommandType = CommandType.StoredProcedure
            };

            if (Parameters?.Count > 0)
            {
                foreach (var parameter in Parameters)
                {
                    command.Parameters.AddWithValue(parameter.Key, parameter.Value);
                }
            }

            using (MySqlDataReader reader = command.ExecuteReader()) {
                if (!reader.HasRows)
                {
                    return(null);
                }

                int columCount = reader.FieldCount;
                for (int i = 0; i < columCount; i++)
                {
                    _dataTable.Columns.Add(reader.GetName(i));
                }

                if (Procedure == "GetResident" || Procedure == "GetResidentsList")
                {
                    _dataTable.Columns.Add("Mark for archive", typeof(bool));
                    _dataTable.Columns["Mark for archive"].DefaultValue = false;
                    _dataTable.Columns.Add("Generate QR", typeof(bool));
                    _dataTable.Columns["Generate QR"].DefaultValue = false;
                }
                else if (Procedure.Contains("GetArchive"))
                {
                    _dataTable.Columns.Add("Mark for restore", typeof(bool));
                    _dataTable.Columns["Mark for restore"].DefaultValue = false;
                }
                else if (Procedure == "GetAdmins")
                {
                    _dataTable.Columns.Add("Mark for delete", typeof(bool));
                    _dataTable.Columns["Mark for delete"].DefaultValue = false;
                }

                while (reader.Read())
                {
                    var currentRow = _dataTable.NewRow();
                    for (int i = 0; i < columCount; i++)
                    {
                        if (reader.IsDBNull(i))
                        {
                            currentRow[i] = string.Empty;
                            continue;
                        }

                        currentRow[i] = reader.GetString(i);
                    }

                    _dataTable.Rows.Add(currentRow);
                }
            }

            _dbConnector.Disconnect();

            return(_dataTable);
        }