public static void Delete(UpgradePackage UpgradePackage)
 {
     try
     {
         bool result = (new PackageBusinesses()).DeletePackage(UpgradePackage.Id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static void Insert(UpgradePackage UpgradePackage)
        {
            try
            {
                // 存DB
                if ((int)FreightForwarder.Common.PackageSavingType.DB == UpgradePackage.SavingType)
                {
                    (new PackageBusinesses()).AddUpgradePackage(UpgradePackage);
                }
                else
                {
                    string folder = System.Web.HttpContext.Current.Server.MapPath("~/packages");
                    string filename = System.IO.Path.Combine(folder, UpgradePackage.FileName);

                    System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    fs.Write(UpgradePackage.FileBytes, 0, UpgradePackage.FileBytes.Length);
                    fs.Flush();
                    fs.Close();

                    string configfile = System.Web.HttpContext.Current.Server.MapPath("~/upgrade-packages.xml");
                    //XmlDocument doc = XMLHelper.xmlDoc(configfile);

                    XmlDocument doc = new XmlDocument();
                    doc.Load(configfile);
                    XmlNode pcnode = doc.SelectSingleNode("Packages/PackageCollection");
                    pcnode.AppendChild(UpgradePackage.ToXmlElement(doc));
                    doc.Save(configfile);
                    //XmlNodeList partlistNode = assistXml.SelectNodes("Assist/PartCollection/Part");

                    //foreach (XmlNode node in partlistNode)
                    //{
                    //    Part part = new Part();
                    //    part.FromXmlNode(node);
                    //    Parts.Add(part);
                    //}
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
 public bool AddUpgradePackage(UpgradePackage entity)
 {
     return (new DBHelper()).AddUpgradePackage(entity);
 }
Ejemplo n.º 4
0
 public bool AddUpgradePackage(UpgradePackage entity)
 {
     using (FFDBContext context = new FFDBContext())
     {
         try
         {
             context.UpgradePackages.Add(entity);
             context.SaveChanges();
             return true;
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }