Ejemplo n.º 1
0
 private CacheOrder getCachedOrder(string existingOrderFile)
 {
     try
     {
         string xml = File.ReadAllText(existingOrderFile);
         return(CacheOrder.ParseXml(xml));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
        public CacheOrder[] GetAllOrders()
        {
            List <CacheOrder> cachedOrders = new List <CacheOrder>();

            foreach (string file in getOrderFiles())
            {
                // wrap in try/catch in case file is corrupted
                try
                {
                    string     xml        = File.ReadAllText(file);
                    CacheOrder cacheOrder = CacheOrder.ParseXml(xml);
                    if (cacheOrder == null)
                    {
                        // assume corrupted file and delete
                        try
                        {
                            File.Delete(file);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        cachedOrders.Add(cacheOrder);
                    }
                }
                catch
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch
                    {
                    }
                }
            }
            return(cachedOrders.ToArray());
        }
Ejemplo n.º 3
0
 public CacheOrder GetOrder(int orderID)
 {
     try
     {
         List <string> orderFiles = getOrderFiles();
         foreach (string file in orderFiles)
         {
             if (file.Contains(orderID.ToString()) == true)
             {
                 if (orderID.ToString() == Path.GetFileNameWithoutExtension(file).Replace(orderFilePrefix, ""))
                 {
                     string xml = File.ReadAllText(file);
                     return(CacheOrder.ParseXml(xml));
                 }
             }
         }
         return(null);
     }
     catch
     {
         return(null);
     }
 }