Exemplo n.º 1
0
        private async Task <List <string> > WorkWithResult(Connect connect, string command)
        {
            return(await Task.Run(() =>
            {
                BMTools.BmDebug.Debug.SaveCall().Info(command);
                BMTools.BmDebug.Debug.SaveCall().Info("BEGIN" + " connect=" + connect.Name + " command=" + command);

                var oracle = new Ora();
                var answer = oracle.GetFromDb(connect, command);

                foreach (var a in answer)
                {
                    BMTools.BmDebug.Debug.SaveCall().Info("connect=" + connect.Name + " command=" + command + " DATA=", a);
                }

                BMTools.BmDebug.Debug.SaveCall().Info("END" + " connect=" + connect.Name + " command=" + command);

                return answer;
            }));
        }
Exemplo n.º 2
0
        private async void Work(Connect connect, string command)
        {
            BMTools.BmDebug.Debug.SaveCall().Info(command);
            BMTools.BmDebug.Debug.SaveCall().Info("BEGIN" + " connect=" + connect.Name + " command=" + command);

            var oracle = new Ora();
            var answer = oracle.GetFromDb(connect, command);

            foreach (var a in answer)
            {
                BMTools.BmDebug.Debug.SaveCall().Info("connect=" + connect.Name + " command=" + command + " DATA=", a);
            }

            if (command == Ora.OraStrings.SqlOperDay ||
                command == Ora.OraStrings.SqlLastDay ||
                command == Ora.OraStrings.SqlRegions)
            {
                connect.LastUsed = DateTime.Now;

                try
                {
                    if (answer.Count == 1 && answer[0].Contains("ORA-"))
                    {
                        throw new Exception();
                    }

                    if (command == Ora.OraStrings.SqlOperDay)
                    {
                        connect.OperDay = Convert.ToDateTime(answer[0]).ToShortDateString();
                    }
                    if (command == Ora.OraStrings.SqlLastDay)
                    {
                        connect.PrevDay = Convert.ToDateTime(answer[0]).ToShortDateString();
                    }
                    if (command == Ora.OraStrings.SqlRegions)
                    {
                        connect.Regions = answer[0];
                    }
                }
                catch
                {
                    if (command == Ora.OraStrings.SqlOperDay)
                    {
                        connect.OperDay = answer.Aggregate(string.Empty, (current, a) => current + (a + ";"));
                    }
                    if (command == Ora.OraStrings.SqlLastDay)
                    {
                        connect.PrevDay = answer.Aggregate(string.Empty, (current, a) => current + (a + ";"));
                    }
                    if (command == Ora.OraStrings.SqlRegions)
                    {
                        connect.Regions = answer.Aggregate(string.Empty, (current, a) => current + (a + ";"));
                    }
                }

                LoadList(connect);
            }
            else
            {
                throw new Exception("Unknown command");
            }

            BMTools.BmDebug.Debug.SaveCall().Info("END" + " connect=" + connect.Name + " command=" + command);
        }