Exemple #1
0
        /// <summary>
        /// Open logs and group to cargo, and return.
        /// </summary>
        /// <param name="openDir">Principal, PublicLogSavepath</param>
        /// <param name="logCargoFilter"></param>
        /// <param name="logDatFilter"></param>
        /// <returns></returns>
        public List <DataCargo> OpenPublicDataCargo(string openDir, OpenFileFilter logCargoFilter, OpenFileFilter logDatFilter)
        {
            var logCargos = new List <DataCargo>();

            string[] cargoDirs = Directory.GetDirectories(openDir, logCargoFilter.ToString(), SearchOption.TopDirectoryOnly);
            var      bs        = new JsonSaves();

            foreach (var cargoDir in cargoDirs)
            {
                string[] logs = Directory.GetFiles(cargoDir, $"{logDatFilter.ToString()}{FileEndChar.DataLog}.dat", SearchOption.TopDirectoryOnly);

                if (logs.Length <= 0)
                {
                    continue;
                }

                DataCargo lc = new DataCargo();

                foreach (var logfile in logs) //Get each logs in cargo(cargo = folder, log = .dat) only for this
                {
                    var log = bs.TransferToObject <Data>(logfile);
                    if (log != default)
                    {
                        lc.Load(log);
                    }
                }

                lc.Lock();
                logCargos.Add(lc);
            }
            return(logCargos);
        }
Exemple #2
0
        public List <Cargo.Cargo> OpenPrivatesFiles(CargoType type, OpenFileFilter cargoFilter)
        {
            List <Cargo.Cargo> cargos = new List <Cargo.Cargo>();
            var bs       = new JsonSaves();
            var cargoDir = GetPrivateSavepath(type);

            if (Directory.Exists(cargoDir))
            {
                //get all files in cargoFilter.ToString() which end char is Cargo(=privates)
                string[] dats = Directory.GetFiles(cargoDir, $"{cargoFilter.ToString()}*{FileEndChar.Cargo}.dat", SearchOption.TopDirectoryOnly);

                foreach (var dat in dats)
                {
                    var val = bs.TransferToObject <Cargo.Cargo>(dat);
                    if (val == null)
                    {
                        continue;
                    }
                    cargos.Add(val);
                }
            }
            return(cargos);
        }