示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     WindowLog.Info("Config::Save", "Saving new configuration");
     Program.ini.Write("Display", "CacheDataDisplayMode", comboBox1.Text);
     Program.cacheDataDisplayMode = comboBox1.Text;
     this.Close();
 }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            WindowLog.Init(this);
            WindowLog.Debug("Main::Load", "Loading settings from INI file");

            Program.CreateIniFile();

            Program.cacheDataDisplayMode = Program.ini.Read("Display", "CacheDataDisplayMode");

            if (Database.Database.Init() == false)
            {
                WindowLog.Error("Main::Load", "Cannot connect to database");
                Application.Exit();
            }

            WindowLog.Debug("Main::Load", "Loading cache names for common cache");

            // Load the cache list for common caches
            cacheNames = CacheDB.GetCommonCacheNames();

            foreach (string name in cacheNames)
            {
                WindowLog.Debug("Main::Load", "Adding cache " + name + " to cache list");
                listBox1.Items.Add(name);
            }

            WindowLog.Debug("Main::Load", "Application started");
        }
示例#3
0
文件: Cache.cs 项目: Tratos/EVESharp
        private static bool LoadCacheFor(string name, bool force)
        {
            WindowLog.Debug("Cache::LoadCacheFor", "Loading cache " + name);

            // First search for the cache
            if (cacheData.ContainsKey(name) == true)
            {
                if (force == false)
                {
                    return(true);
                }

                cacheData.Remove(name);
            }

            PyTuple data = Database.CacheDB.GetCacheData(name);

            if (data == null)
            {
                return(false);
            }

            cacheData.Add(name, data);

            return(true);
        }
示例#4
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static bool UpdateCacheName(string name, string newName)
        {
            WindowLog.Debug("Cache::UpdateCacheName", "Changin cache name...");

            if (Database.CacheDB.UpdateCacheName(name, newName) == false)
            {
                return(false);
            }

            UnloadCache(name);
            return(LoadCacheFor(name));
        }
示例#5
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static bool LoadUserCacheFor(int user, string name, bool force)
        {
            Dictionary <string, PyTuple> old = null;

            if (userCacheData.ContainsKey(user) == true)
            {
                if (userCacheData[user].ContainsKey(name) == true)
                {
                    if (force == false)
                    {
                        return(true);
                    }

                    userCacheData[user].Remove(name);
                }

                if (force == false)
                {
                    return(true);
                }

                // Store the actual cache data to reload only the required cacheName
                old = userCacheData[user];
                userCacheData.Remove(user);
            }

            // Get the cache data from the DB
            PyTuple data = Database.CacheDB.GetUserCacheData(user, name);

            if (data == null)
            {
                WindowLog.Error("Cache", "Cannot load cache data for user " + user + " of type " + name);
                return(false);
            }

            // If the data wasnt loaded yet create an empty dictionary
            if (old == null)
            {
                old = new Dictionary <string, PyTuple>();
            }

            // Add the cache loaded into the dictionary
            old.Add(name, data);

            // Load the dictionary with all the cache data into the userCacheData Dictionary
            userCacheData.Add(user, old);

            return(true);
        }
示例#6
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static bool SaveCacheFor(string name, byte[] data, long timestamp, int fakeNodeID)
        {
            if (Database.CacheDB.SaveCacheData(name, data, timestamp, fakeNodeID) == false)
            {
                WindowLog.Error("Cache", "Cannot save cache dat for " + name);
                return(false);
            }

            WindowLog.Debug("Cache", "Saved cache data for " + name);

            if (UpdateCache(name) == false)
            {
                WindowLog.Error("Cache", "Cannot update local cache info");
                return(false);
            }

            return(true);
        }
示例#7
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
            {
                Message.Error("Main::SaveFile", "Debes elejir la cache a guardar");
                return;
            }

            saveFileDialog1.Filter = "Archivos de cache(*.cache)|*.cache";
            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            PyObject cache = Cache.GetCache(listBox1.SelectedItem.ToString());

            PyCachedObject obj = new PyCachedObject();

            if (obj.Decode(cache) == false)
            {
                Message.Error("Main::SaveFile", "No se pudo obtener la información correctamente");
                return;
            }

            if (File.Exists(saveFileDialog1.FileName) == true)
            {
                try
                {
                    File.Delete(saveFileDialog1.FileName);
                }
                catch (Exception)
                {
                }
            }

            FileStream fp = File.OpenWrite(saveFileDialog1.FileName);

            fp.Write(obj.cache.Data, 0, obj.cache.Data.Length);

            fp.Close();

            WindowLog.Debug("Main::SaveFile", "Cache saved sucessful");
        }
示例#8
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
            {
                richTextBox2.Text = "";
                return;
            }

            if (Cache.UpdateCache(listBox1.SelectedItem.ToString()) == false)
            {
                WindowLog.Error("Main::LoadCache", "Error loading cache");
                return;
            }

            PyObject cache = Cache.GetCache(listBox1.SelectedItem.ToString());

            PyCachedObject obj = new PyCachedObject();

            if (obj.Decode(cache) == false)
            {
                WindowLog.Error("Main::LoadCache", "Cannot decode the cache data");
                return;
            }

            if (Program.cacheDataDisplayMode == "Pretty")
            {
                try
                {
                    richTextBox2.Text = PrettyPrinter.Print(Unmarshal.Process <PyObject>(obj.cache.Data));
                }
                catch (Exception)
                {
                    WindowLog.Error("Main::LoadCache", "Cannot Unmarshal the cache data");
                    richTextBox2.Text = "Error";
                }
            }
            else
            {
                richTextBox2.Text = ByteToString(obj.cache.Data);
            }

            WindowLog.Debug("Main::LoadCache", "Cache loaded");
        }
示例#9
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static bool SaveUserCacheFor(int user, string name, PyObject data, long timestamp, int ownerType, string ownerName, int fakeNodeID)
        {
            byte[] marshaled = Marshal.Marshal.Process(data);

            if (Database.CacheDB.SaveUserCacheData(user, name, marshaled, timestamp, ownerName, ownerType, fakeNodeID) == false)
            {
                WindowLog.Error("Cache", "Cannot save usercache data for " + name);
                return(false);
            }

            WindowLog.Debug("Cache", "Saved usercache data for " + name);

            if (UpdateUserCache(user, name) == false)
            {
                WindowLog.Error("Cache", "Cannot update local usercache info");
                return(false);
            }

            return(true);
        }
示例#10
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static PyObject GetCacheData(string name)
        {
            if (LoadCacheFor(name) == false)
            {
                WindowLog.Error("Cache", "Cannot load cache data for cache " + name);
                return(null);
            }

            PyTuple cache = cacheData[name];

            if (cache == null)
            {
                return(null);
            }

            CacheInfo data = new CacheInfo();

            data.objectID  = new PyString(name);
            data.cacheTime = cache.Items[1].As <PyLongLong>().Value;
            data.nodeID    = cache.Items[2].As <PyIntegerVar>().Value;
            data.version   = cache.Items[3].As <PyIntegerVar>().Value; // This is a CRC of the buffer

            return(data.Encode());
        }
示例#11
0
        public static void Info(string svc, string message)
        {
            WindowLog.Debug(svc, message);

            MessageBox.Show(message, svc, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#12
0
        public static DialogResult Ask(string svc, string message)
        {
            WindowLog.Info(svc, message);

            return(MessageBox.Show(message, svc, MessageBoxButtons.YesNo, MessageBoxIcon.Question));
        }
示例#13
0
        public static void Error(string svc, string message)
        {
            WindowLog.Error(svc, message);

            MessageBox.Show(message, svc, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
示例#14
0
 private void salirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WindowLog.Warning("Main::ToolStrip", "User requested close");
     this.Close();
 }
示例#15
0
 private void Form1_Closing(object sender, FormClosingEventArgs e)
 {
     WindowLog.Debug("Main::Close", "Disconnecting from the database");
     Database.Database.Stop();
     WindowLog.Stop();
 }
示例#16
0
        private void copiaDeSeguridadCompletaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Message.Ask("Main::CompleteBackup", "¿Seguro que deseas hacer una copia de seguridad de toda la cache? Esto puede llevar varios minutos") == DialogResult.No)
            {
                return;
            }

            folderBrowserDialog1.Description = "Elije la carpeta de destino";
            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            bool asked = false;

            foreach (string name in cacheNames)
            {
                WindowLog.Debug("Main::CompleteBackup", "Saving cache " + name + " to file");

                string   filename = folderBrowserDialog1.SelectedPath + "/" + name + ".cache";
                PyObject cache    = Cache.GetCache(name);

                PyCachedObject obj = new PyCachedObject();

                if (obj.Decode(cache) == false)
                {
                    Message.Error("Main::CompleteBackup", "No se pudo obtener la información correctamente");
                    return;
                }

                if (File.Exists(filename) == true)
                {
                    if (!asked)
                    {
                        if (Message.Ask("Main::CompleteBackup", "Uno o más archivos ya existen, ¿desea reemplazarlos?") == DialogResult.No)
                        {
                            WindowLog.Error("Main::CompleteBackup", "Cancelled by the user");
                            return;
                        }
                    }

                    asked = true;

                    try
                    {
                        File.Delete(filename);
                    }
                    catch (Exception)
                    {
                    }
                }

                FileStream fp = File.OpenWrite(filename);

                fp.Write(obj.cache.Data, 0, obj.cache.Data.Length);

                fp.Close();

                WindowLog.Debug("Main::CompleteBackup", "Cache " + name + " saved correctly");
            }

            Message.Info("Main::CompleteBackup", "Cache guardada en " + folderBrowserDialog1.SelectedPath + " con éxito");
        }
示例#17
0
文件: Cache.cs 项目: Tratos/EVESharp
        public static void DeleteCache(string name)
        {
            WindowLog.Debug("Cache::DeleteCache", "Deleting cache " + name);

            Database.CacheDB.DeleteCache(name);
        }