Пример #1
0
 private void UpdateDossierFile(FileInfo fi)
 {
     using (Unpickler unpickler = new Unpickler())
     {
         using (FileStream fs = fi.OpenRead())
         {
             DossierData dossier = ParseDossierRawData(fi.Name, unpickler.load(fs));
             DossierDB.UpdateDossierData(fi.Name, fi.LastWriteTimeUtc.ToUnixTime(), dossier);
         }
     }
 }
Пример #2
0
        //UpdateDossierFilesData

        private void DossierFilesMonitor()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Wargaming.net/WorldOfTanks/dossier_cache";

            int counter = FILE_SCAN_INTERVAL;

            try
            {
                while (true)
                {
                    Thread.Sleep(100);
                    counter += 100;
                    if (counter < FILE_SCAN_INTERVAL)
                    {
                        continue;
                    }
                    counter = 0;

                    string[] files = Directory.GetFiles(path, "*.dat", SearchOption.TopDirectoryOnly);
                    foreach (string file in files)
                    {
                        FileInfo fi = new FileInfo(file);
                        if (fi.Extension.ToLower() != ".dat")
                        {
                            continue;
                        }

                        int dbTime = DossierDB.GetDossierFileParam(fi.Name, "modified");
                        int time   = fi.LastWriteTimeUtc.ToUnixTime();

                        if (time != dbTime)
                        {
                            UpdateDossierFile(fi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Log("DossierFiles ERROR: " + ex);
            }
        }
Пример #3
0
        /// <summary>
        /// Format: playerName;end;interval;count;group_type;data_fields;company_fields;clan_fields
        /// </summary>
        /// <param name="parameter"></param>
        private void ReadDossierInfoAsync(object parameter)
        {
            string res = null;

            try
            {
                string[] parameters    = (parameter as string).Split(';');
                string   playerName    = parameters[1];
                long     end           = long.Parse(parameters[2]);
                int      interval      = int.Parse(parameters[3]);
                int      count         = int.Parse(parameters[4]);
                int      groupType     = int.Parse(parameters[5]);
                string[] dataFields    = ((string)parameters[6]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] companyFields = ((string)parameters[7]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] clanFields    = ((string)parameters[8]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                //Program.Log("ReadDossierInfoAsync");

                DataTable table = null;
                for (int i = 0; i < count; ++i)
                {
                    long      time = end - (interval * i);
                    DataTable t    = DossierDB.GetDataForTime(playerName, time);
                    if (table == null)
                    {
                        table = t;
                    }
                    else
                    {
                        table.Merge(t);
                    }
                }
                res = SerializeDossierResult(table, groupType, dataFields, companyFields, clanFields);
            }
            catch (Exception ex)
            {
                res = "[ERROR] " + ex;
            }
            lock (dossierResultLock)
                dossierResult = res;
            //Program.Log(dossierResult);
        }