示例#1
0
        public SharedResultVM DatabaseReset(string zipName = "db/backup.zip")
        {
            return(SharedResultVM.Try(vm =>
            {
                if (HttpContext != null && new UserAgentTo(new ClientTo(HttpContext).UserAgent).IsBot)
                {
                    vm.Set(SharedEnum.RTag.refuse);
                    vm.Msg = "are you human?";
                }
                else
                {
                    var idb = new SharedDataKit.TransferVM.ImportDatabase
                    {
                        WriteConnectionInfo = new SharedDataKit.TransferVM.ConnectionInfo
                        {
                            ConnectionType = GlobalTo.TDB,
                            ConnectionString = SharedDbContext.FactoryTo.GetConn().Replace("Filename=", "Data Source=")
                        },
                        ZipPath = PathTo.Combine(GlobalTo.ContentRootPath, zipName),
                        WriteDeleteData = true
                    };

                    vm = SharedDataKit.DataKit.ImportDatabase(idb);
                }

                return vm;
            }));
        }
示例#2
0
        public SharedResultVM DatabaseImport(string zipName = "db/backup.zip", bool clearTable = false)
        {
            return(SharedResultVM.Try(vm =>
            {
                var idb = new SharedDataKit.TransferVM.ImportDatabase
                {
                    WriteConnectionInfo = new SharedDataKit.TransferVM.ConnectionInfo
                    {
                        ConnectionType = GlobalTo.TDB,
                        ConnectionString = SharedDbContext.FactoryTo.GetConn().Replace("Filename=", "Data Source=")
                    },
                    ZipPath = PathTo.Combine(GlobalTo.ContentRootPath, zipName),
                    WriteDeleteData = clearTable
                };

                vm = SharedDataKit.DataKit.ImportDatabase(idb);

                return vm;
            }));
        }