public bool DumpMetaParamsExist(string dumpFileName, int param, int tarif) { DumpMeta dm = new DumpMeta(); if (GetDumpMeta(dumpFileName, ref dm) && dm.paramList != null && dm.paramList.Count > 0) { for (int i = 0; i < dm.paramList.Count; i++) { string tmp = dm.paramList[i]; if (tmp == param + metaPairSeparator + tarif) return true; } } return false; }
public bool GetDumpMeta(string dumpFileName, ref DumpMeta dumpMeta) { string metaFileName = ""; ReplaceExtensionInFileName(dumpFileName, ".xml", ref metaFileName); FileStream metaFileStream = null; try { metaFileStream = new FileStream(metaFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read); dumpMeta = (DumpMeta)formatter.Deserialize(metaFileStream); metaFileStream.Close(); return true; } catch (Exception ex) { if (metaFileStream != null) metaFileStream.Close(); return false; } }
public bool DumpMetaAppendParams(string dumpFileName, int param, int tarif) { DumpMeta dm = new DumpMeta(); if (GetDumpMeta(dumpFileName, ref dm) && dm.paramList != null && dm.paramList.Count > 0) { for (int i = 0; i < dm.paramList.Count; i++) { string tmp = dm.paramList[i]; if (tmp == param + metaPairSeparator + tarif) return true; } dm.paramList.Add(param + metaPairSeparator + tarif); return SetDumpMeta(dumpFileName, dm); } else { dm.paramList = new List<string>(); dm.paramList.Add(param + metaPairSeparator + tarif); return SetDumpMeta(dumpFileName, dm); } return false; }