Ejemplo n.º 1
0
        /// <summary>
        /// 获取最新版本
        /// </summary>
        /// <param name="Identifier"></param>
        /// <returns></returns>
        public InterfaceRet GetNewestVersion(string Identifier)
        {
            _ret.Clear();
            int minVersion, maxVersion;

            DBSynLog.GetVersionRange(Identifier, out minVersion, out maxVersion);
            _ret.data = maxVersion;
            return(_ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 传入需要更新各类数据的版本号,返回最新版本号或是需要整体更新
        /// 输入参数DataVersion包含客户端数据版本号
        /// 返回DataVersion包含最新版本号
        /// 版本号为0时表示没有变动数据
        /// 版本号为-1时表示版本过期
        /// </summary>
        /// <returns></returns>
        public InterfaceRet ReadDataVersion(string data)
        {
            _ret.Clear();
            DataVersion version = Newtonsoft.Json.JsonConvert.DeserializeObject <DataVersion>(data);

            //为果传入的版本号为0 则返回结果为-1
            if (version.Version == 0)
            {
                version.Version = -1;
                _ret.data       = version;
                return(_ret);
            }
            int minVersion, maxVersion;

            DBSynLog.GetVersionRange(version.Identifier, out minVersion, out maxVersion);

            if (minVersion == 0 && maxVersion == 0)//没有数据变动
            {
                version.Version = 0;
            }
            else
            if (version.Version < minVersion)    //数据版本过期
            {
                version.Version = -1;
            }
            else
            if (version.Version > maxVersion)        //异常版本
            {
                throw new Exception(string.Format("{0} 数据版本{1}大于服务器数据版本{2}", version.Identifier, version.Version, maxVersion));
            }
            else
            {
                version.Version = maxVersion;
            }
            _ret.data = version;
            return(_ret);
        }