示例#1
0
 partial void DeleteccfCategoryName_es(ccfCategoryName_es instance);
示例#2
0
 partial void InsertccfCategoryName_es(ccfCategoryName_es instance);
示例#3
0
 partial void UpdateccfCategoryName_es(ccfCategoryName_es instance);
示例#4
0
        private static void updateCategories(ISACFDataContext db)
        {
            FileInfo  indexFile = new FileInfo(Path.Combine(clsSettings.serviceSettings.dataDirectory.FullName, string.Format("{0}{1}{2}", xmlDestinationFolderName, Path.DirectorySeparatorChar, indexFileName)));
            XDocument xDocumentIndex;

            xDocumentIndex = XDocument.Load(indexFile.FullName);
            // Read only the Attribute name of each Category Element.
            var Categories = (from e in xDocumentIndex.Elements("CategoryIndex").Elements("Category")
                              where ((string)e.Element("name")) != string.Empty
                              select e).ToArray();

            if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Closed)
            {
                db.Connection.Open();
            }

            var CategoriesToBlock = (from e in db.ccfCategoryToBlocks
                                     select e.name).ToArray();

            ccfCategory        newCat       = null;
            ccfCategoryName_es newCatNameEs = null;

            foreach (XElement Category in Categories)
            {
                newCat                   = new ccfCategory();
                newCat.name              = Category.Attribute("name").Value;
                newCat.default_type      = Category.Element("default-type").Value;
                newCat.name_en           = Category.Element("name-en").Value;
                newCat.desc_en           = Category.Element("desc-en").Value;
                newCat.processForISARule = CategoriesToBlock.Contains(newCat.name);
                if (!string.IsNullOrEmpty(Category.Element("name-es").Value))
                {
                    newCatNameEs              = new ccfCategoryName_es();
                    newCatNameEs.id_Category  = newCat.ID;
                    newCatNameEs.name_es      = Category.Element("name-es").Value;
                    newCatNameEs.desc_es      = string.IsNullOrEmpty(Category.Element("desc-es").Value) ? DBNull.Value.ToString() : Category.Element("desc-es").Value;
                    newCat.ccfCategoryName_es = newCatNameEs;
                }
                db.ccfCategories.InsertOnSubmit(newCat);
                // Do cleanup.
                if (newCatNameEs != null)
                {
                    newCatNameEs = null;
                }
                if (newCat != null)
                {
                    newCat = null;
                }
            }
            db.SubmitChanges();

            if (db.Transaction == null & db.Connection.State == System.Data.ConnectionState.Open)
            {
                db.Connection.Close();
                db = null;
            }

            // Do some Cleanup.
            if (indexFile != null)
            {
                indexFile = null;
            }
            if (xDocumentIndex != null)
            {
                xDocumentIndex = null;
            }
            if (Categories != null)
            {
                Categories = null;
            }
            if (CategoriesToBlock != null)
            {
                CategoriesToBlock = null;
            }

            GC.Collect();
        }