Exemple #1
0
 public DirItem adjustItem(string text) {
   var res = Items.FirstOrDefault(i => i.text == text);
   if (res != null) {
     var mp3Exists = File.Exists(fileName(res, false));
     if (mp3Exists && res.version == 0) res.version = 1;
     else if (!mp3Exists && res.version != 0) res.version = 0;
     return res;
   }
   Reset();
   var freeDir = Items.GroupBy(i => i.dirId).OrderBy(g => g.Key).FirstOrDefault(g => g.Count() < 300);
   int dirId; int fileId;
   if (freeDir == null) { dirId = Items.Select(i => i.dirId).DefaultIfEmpty(-1).Max() + 1; fileId = 0; }
   else { dirId = freeDir.Key; fileId = freeDir.Select(f => f.fileId).Max() + 1; }
   Items.Add(res = new DirItem() { text = text, dirId = dirId, fileId = fileId });
   var itemFn = fileName(res, true); //string.Format(@"{0}\{1}\{2}.xml", Path.GetDirectoryName(selfPath), res2.dirId, res2.fileId);
   LowUtils.AdjustFileDir(itemFn); XmlUtils.ObjectToFile(itemFn, res);
   return res;
 }
Exemple #2
0
 public string fileName(DirItem it, bool isXml) {
   return string.Format(@"{0}\{1}\{2}.{3}", Path.GetDirectoryName(selfPath), it.dirId, it.fileId, isXml ? "xml" : "mp3");
 }
Exemple #3
0
 public string url(DirItem it) {
   return string.Format("{0};{1}/{2}/{3}", 1 /*(int)schools.dictTypes.ttsUrl*/, lang, it.dirId, it.fileId);
 }