using System; namespace lliurex { namespace controlcenter { public class StatusManager { // public const string file_path="/usr/share/zero-center/applications/app_status.sts"; public System.Collections.Generic.Dictionary values; public StatusManager () { try { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput=true; p.StartInfo.FileName = "bash"; p.StartInfo.Arguments="/usr/sbin/zero-sqlmanager -l"; p.Start(); string output=p.StandardOutput.ReadToEnd(); // Console.WriteLine("We're getting..."); // Console.WriteLine(output); p.WaitForExit(); values=new System.Collections.Generic.Dictionary(); string[] strArr = null; char[] split_chr= { ' ','\n' }; strArr = output.Split(split_chr); for (int i=0; i<=strArr.Length - 2; i++) { // Console.WriteLine(i + " " + strArr[i]); values.Add(strArr[i],int.Parse(strArr[i+1])); i++; } /* foreach (System.Collections.Generic.KeyValuePair n in values) { Console.WriteLine(n); // Console.WriteLine(n.Key); // Console.WriteLine(n.Value); } */ } catch(System.ComponentModel.Win32Exception w) { Console.WriteLine(w.Message); Console.WriteLine(w.ErrorCode.ToString()); Console.WriteLine(w.NativeErrorCode.ToString()); Console.WriteLine(w.StackTrace); Console.WriteLine(w.Source); Exception e=w.GetBaseException(); Console.WriteLine(e.Message); } } public void printReadList() { foreach (System.Collections.Generic.KeyValuePair n in values) { Console.WriteLine("[Status Manager] * {0}",n); // Console.WriteLine(n.Key); // Console.WriteLine(n.Value); } } public int getState(string name) { bool found=false; int return_; int tmp=(int)Core.S_CONF_NEEDED; foreach (System.Collections.Generic.KeyValuePair n in values) { if (name==n.Key) { found=true; tmp=n.Value; } } if (found) { // Console.WriteLine("Found!"); return_=tmp; // Console.WriteLine(return_); } else { return_=404; } return return_; } } } }