Service.WindowsService.DoOracleSql C# (CSharp) Method

DoOracleSql() public method

public DoOracleSql ( string Program, string Input, string Compiler_args ) : Result
Program string
Input string
Compiler_args string
return Service.oracle.Result
        public oracle.Result DoOracleSql(string Program, string Input, string Compiler_args)
        {
            using (var service = new oracle.Service())
            {
                try
                {
                    bool ProgramCompressed = false;
                    if (!string.IsNullOrEmpty(Program) && Program.Length > 1000)
                    {
                        ProgramCompressed = true;
                        Program = GlobalUtils.Utils.Compress(Program);
                    }
                    bool InputCompressed = false;
                    if (!string.IsNullOrEmpty(Input) && Input.Length > 1000)
                    {
                        InputCompressed = true;
                        Input = GlobalUtils.Utils.Compress(Input);
                    }

                    bool bytes = true;
                    var res = service.DoWork(Program, Input, oracle.Languages.Oracle, GlobalUtils.TopSecret.Service_user, GlobalUtils.TopSecret.Service_pass, Compiler_args, bytes, ProgramCompressed, InputCompressed);

                    if (bytes)
                    {
                        if (res.Errors_Bytes != null)
                            res.Errors = System.Text.Encoding.Unicode.GetString(res.Errors_Bytes);
                        if (res.Warnings_Bytes != null)
                            res.Warnings = System.Text.Encoding.Unicode.GetString(res.Warnings_Bytes);
                        if (res.Output_Bytes != null)
                            res.Output = System.Text.Encoding.Unicode.GetString(res.Output_Bytes);
                    }
                    if (res.IsOutputCompressed)
                        res.Output = GlobalUtils.Utils.Decompress(res.Output);

                    return res;
                }
                catch (Exception ex)
                {
                    return new oracle.Result()
                    {
                        System_Error = string.Format("Error while calling service: {0}", ex.Message)
                    };
                }
            }
        }

Usage Example

Example #1
0
 static RundotnetData RunOracle(RundotnetData data)
 {
     WindowsService service = new WindowsService();
     Stopwatch watch = new Stopwatch();
     watch.Start();
     var res = service.DoOracleSql(data.Program, data.Input, data.CompilerArgs);
     watch.Stop();
     if (res != null)
     {
         if (string.IsNullOrEmpty(res.Stats))
             res.Stats = "";
         else
             res.Stats += ", ";
         res.Stats += string.Format("absolute service time: {0} sec", Math.Round((double)watch.ElapsedMilliseconds / (double)1000, 2));
         data.RunStats = res.Stats;
     }
     bool logged = false;
     if (!string.IsNullOrEmpty(res.System_Error))
     {
         reExp.Utils.Log.LogInfo("Oracle " + res.System_Error, null, "RunDotNet");
         data.Errors.Add(res.System_Error);
         Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Oracle: system error", (int)data.LanguageChoice, data.IsApi, false);
         return data;
     }
     if (!string.IsNullOrEmpty(res.Errors))
     {
         data.Errors.Add(res.Errors);
         if (!logged)
         {
             Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Oracle: error", (int)data.LanguageChoice, data.IsApi, false);
             logged = true;
         }
     }
     if (res.Exit_Code < 0)
     {
         data.Errors.Add(res.Exit_Status);
         if (!logged)
         {
             Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Oracle: negative exit code", (int)data.LanguageChoice, data.IsApi, false);
             logged = true;
         }
     }
     if (!string.IsNullOrEmpty(res.Warnings))
     {
         data.Warnings.Add(res.Warnings);
         if (!logged)
         {
             Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Oracle: warnings", (int)data.LanguageChoice, data.IsApi, true);
             logged = true;
         }
     }
     data.Output = res.Output;
     if (res.Files != null)
     {
         data.Files = new List<string>();
         foreach (var f in res.Files)
         {
             data.Files.Add(Convert.ToBase64String(f));
         }
     }
     if (!logged)
     {
         Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Oracle: ok", (int)data.LanguageChoice, data.IsApi, true);
         logged = true;
     }
     return data;
 }