Пример #1
0
 /// <summary>
 /// 初始化获取表格版本
 /// </summary>
 private void get()
 {
     try
     {
         timeVersions version = getVersion();
         if (count != version.Versions.Length)
         {
             if (Versions != null)
             {
                 unmanaged.Free(Versions);
                 Versions = null;
                 count    = 0;
             }
             Versions = unmanaged.Get(version.Versions.Length * sizeof(ulong), false).ULong;
             count    = version.Versions.Length;
         }
         fixed(ulong *versionFixed = version.Versions)
         {
             for (ulong *start = versionFixed, end = versionFixed + version.Versions.Length, write = Versions; start != end; *write++ = *start++)
             {
                 ;
             }
         }
         Version.Version = version.Version.Version;
         Version.Time    = version.Version.Time;
         getUpdate(Version, onUpdate);
         return;
     }
     catch (Exception error)
     {
         log.Error.Add(error, null, false);
     }
     Version.Time = 0;
     fastCSharp.threading.timerTask.Default.Add(tryGet, date.NowSecond.AddSeconds(2));
 }
Пример #2
0
        /// <summary>
        /// 获取表格版本
        /// </summary>
        /// <returns>表格版本</returns>
        public timeVersions Get()
        {
            fixed(ulong *versionFixed = version.Versions)
            {
                interlocked.CompareSetSleep0(ref versionLock);
                unsafer.memory.Copy(versions, versionFixed, version.Versions.Length * sizeof(ulong));
                timeVersions value = version;

                updateVersion = version.Version.Version;
                currentTable  = tables;
                versionLock   = 0;
                return(value);
            }
        }
Пример #3
0
        /// <summary>
        /// 表格版本
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="tableCount">表格数量</param>
        public tableVersion(string fileName, int tableCount)
        {
            this.fileName = fileName;
            versions      = unmanaged.Get(tableCount * sizeof(ulong), true).ULong;
            currentTable  = tables = unmanaged.Get(tableCount * sizeof(int), true).Int;
            int isFile = 0;

            try
            {
                if (File.Exists(fileName))
                {
                    byte[] data = File.ReadAllBytes(fileName);
                    fileName = file.MoveBak(fileName);
                    version  = serialize.deSerialize.Get <timeVersions>(data);
                    fixed(ulong *versionFixed = version.Versions)
                    {
                        unsafer.memory.Copy(versionFixed, versions, Math.Min(tableCount, version.Versions.Length) * sizeof(ulong));
                    }
                    if (version.Versions.Length < tableCount)
                    {
                        version.Versions = new ulong[tableCount];
                    }
                    isFile = 1;
                }
            }
            catch (Exception error)
            {
                log.Error.Add(error, "表格版本加载失败 " + fileName, false);
            }
            if (isFile == 0)
            {
                DateTime time = fastCSharp.pub.StartTime;
                version = new timeVersions {
                    Version = new timeVersion {
                        Time = (((uint)time.Second << 26) | ((uint)time.Minute << 20) | ((uint)time.Hour << 16) | ((uint)time.Day << 11) | ((uint)time.Month << 7)) ^ ((uint)time.Year)
                    }, Versions = new ulong[tableCount]
                };
            }
        }