Example #1
0
        /// <summary>
        /// 获取当前连接到的数据库的类型(0.未设置;1.服务端数据库;2.客户端数据库)
        /// </summary>
        /// <returns></returns>
        public static int GetCurrentServerType()
        {
            var bll  = new DbIdentityBll();
            var list = bll.QueryAll();

            if (list.Any())
            {
                var m = list.First();
                return(m.Identity);
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        public void InitUsb()
        {
            try
            {
                var identityBll = new DbIdentityBll();
                var list        = identityBll.QueryAll().ToList();
                if (!list.Any())
                {
                    // TODO: 向表 DbIdentity 新增数据库标识
                    // TODO: 将新增的数据插入 list 中
                    var identity = Utils.AddDbIdentity();
                    list.Add(identity);
                }

                var dbIdentity = list.First();
                var maxId      = (int)new DbUpdateLogBll().GetMaxId();

                var syncDir = Path.Combine(RootDir, SyncDir);
                Directory.CreateDirectory(syncDir);

                var identityFile = Path.Combine(syncDir, IdentifyFilename);
                File.Create(identityFile);

                var syncInfo = new SyncInfo
                {
                    DbIdentity         = dbIdentity.UniqueId,
                    ServerWriteSuccess = true,
                    ClientNewDataFlag  = false,
                    DbUpdateLogMaxId   = maxId
                };
                WriteSyncInfo(syncInfo);
            }
            catch (Exception e)
            {
                throw new Exception("未检测到机务运用管控系统的服务,请联系管理员");
            }
        }