public void DeleteOriginalData(ArchiveBasicInfo info)
        {
            ArchiveSettings settings = ArchiveSettings.GetConfig();

            info.Context.DoAction <MaterialList>("Materials", materials =>
            {
                MaterialAdapter.Instance.DeleteMaterialsByResourceID(info.ResourceID);
                MaterialContentAdapter.Instance.Delete(b => b.AppendItem("RELATIVE_ID", info.ResourceID));
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到归档相关的配置信息
        /// </summary>
        /// <returns></returns>
        public static ArchiveSettings GetConfig()
        {
            ArchiveSettings result = (ArchiveSettings)ConfigurationBroker.GetSection("archiveSettings");

            if (result == null)
            {
                result = new ArchiveSettings();
            }

            return(result);
        }
Exemplo n.º 3
0
        public void Archive(ArchiveBasicInfo info)
        {
            LoadOriginalData(info);

            using (DbConnectionMappingContext context =
                       DbConnectionMappingContext.CreateMapping(ConnectionDefine.DBConnectionName, "Archive"))
            {
                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    SaveArchiveData(info);
                    scope.Complete();
                }
            }

            if (ArchiveSettings.GetConfig().DeleteOriginalData)
            {
                InnerDelete(info);
            }
        }
        public void SaveArchiveData(ArchiveBasicInfo info)
        {
            ArchiveSettings settings = ArchiveSettings.GetConfig();

            ORMappingItemCollection mappings = ORMapping.GetMappingInfo <Material>().Clone();

            mappings["CREATE_DATETIME"].BindingFlags        |= (ClauseBindingFlags.Update | ClauseBindingFlags.Insert);
            ORMappingContextCache.Instance[typeof(Material)] = mappings;

            try
            {
                MaterialAdapter.Instance.DeleteMaterialsByResourceID(info.ResourceID);
                MaterialContentAdapter.Instance.Delete(b => b.AppendItem("RELATIVE_ID", info.ResourceID));

                info.Context.DoAction <MaterialList>("Materials", materials =>
                {
                    DeltaMaterialList dml = new DeltaMaterialList();

                    materials.ForEach(m =>
                    {
                        dml.Inserted.Add(m);
                    });

                    MaterialAdapter.Instance.SaveDeltaMaterials(dml, false);

                    dml.Inserted.ForEach(m =>
                    {
                        if (m.Content != null)
                        {
                            MaterialContentAdapter.Instance.Update(m.Content);
                        }
                    });
                });
            }
            finally
            {
                ORMappingContextCache.Instance.Remove(typeof(Material));
            }
        }