Пример #1
0
        public void Read()
        {
            System.IO.StreamReader reader = null;
            try
            {
                if (System.IO.File.Exists(_FileName) == false)
                {
                    return;
                }
                if (!IsTextFile())
                {
                    return;
                }
                String MacSN = _mac.MachineSN;
                if (String.IsNullOrEmpty(MacSN))
                {
                    return;
                }
                reader = new System.IO.StreamReader(_FileName);
                ServiceStack.Redis.RedisClient client = new ServiceStack.Redis.RedisClient("127.0.0.1", 6379);
                if (client.Ping() == false)
                {
                    return;
                }
                client.Db = _mac.LocalDB;
                using (var trans = client.CreatePipeline())
                {
                    if (client.Exists("GCODE:" + _GCodeFile) == 1)
                    {
                        trans.QueueCommand(r => r.Remove("GCODE:" + _GCodeFile));
                        trans.Flush();
                    }
                    while (!reader.EndOfStream)
                    {
                        String GCodetext = reader.ReadLine();
                        trans.QueueCommand(r => r.AddItemToList("GCODE:" + _GCodeFile, GCodetext));
                    }
                    trans.Flush();
                }

                // reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("GCodeSender" + e.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
 public bool HasCache(string key)
 {
     return(client.Exists(key) == 1);
 }