Exemple #1
0
        partial void ReadStat(Foundation.NSObject sender)
        {
            string res;
            Stat   stat;

            LibraryImport.read_stat_(StatPath.StringValue, out res);
            if (res == null)
            {
                Alert.MessageText = "Не найден файл \"" + StatPath.StringValue + "\".";
                Alert.RunModal();
                return;
            }
            // Директория с загружаемым файлом
            string TmpFileLocDir = Path.GetDirectoryName(StatPath.StringValue);

            try
            {
                stat = new Stat(res, TmpFileLocDir);
            }
            catch (Exception)
            {
                LibraryImport.read_stat_(StatPath.StringValue, out res);
                stat = new Stat(res, TmpFileLocDir);
            }

            //---  Save files  ---//
            string TmpDirPath = StatDir.StatDirPath + stat.GetHashCode();

            Directory.CreateDirectory(TmpDirPath);
            var        creationTime = DateTime.Now;
            FileStream file         = File.Create(TmpDirPath + "/stat.json");

            file.Write(new UTF8Encoding(true).GetBytes(res));
            file.Close();
            foreach (var inter in stat.Info.inter)
            {
                if (!File.Exists(TmpDirPath + '/' + inter.id.pname))
                {
                    try
                    {
                        if (File.Exists(TmpFileLocDir + '/' + inter.id.pname))
                        {
                            File.Copy(TmpFileLocDir + '/' + inter.id.pname,
                                      TmpDirPath + '/' + inter.id.pname);
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Could not copy file '" + inter.id.pname + "'");
                    }
                }
            }
            AddStatToList(stat, creationTime);
        }
Exemple #2
0
        public void Add(Stat stat)
        {
            string res1, res2;
            string json = stat.ToJson();

            for (int i = 0; i < List.Count; ++i)
            {
                LibraryImport.stat_intersect_(List[i].ToJson(), json, out res1, out res2);
                List[i].ChangeJson(res1);
                json = res2;
            }
            stat.ChangeJson(json);
            List.Add(stat);
        }