public static SqlInt64 GeneratorNext(SqlString code) { if (code.IsNull) { throw new ArgumentException("code"); } CheckSystemLock(); var filename = Path.Combine(GeneratorsDirectory, code.Value + ".xml"); if (!File.Exists(filename)) { throw new Exception("generator not existed"); } long result = 0; using (var f = new FileLock(filename)) { var x = XElement.Parse(f.ReadFile()); var value = Convert.ToInt64(x.Attr("value")); var offset = Convert.ToInt32(x.Attr("offset")); result = value + offset; x.SetAttributeValue("value", result); f.WriteFile(x.ToString()); } return(result); }
public static SqlInt64 GeneratorNext(SqlString code) { if (code.IsNull) { throw new ArgumentException("code"); } CheckSystemLock(); var filename = Path.Combine(GeneratorsDirectory, code.Value + ".xml"); if (!File.Exists(filename)) { throw new IOException("generator not existed"); } long result = 0; using (var f = new FileLock(filename)) { var x = XElement.Parse(f.ReadFile()); var value = Convert.ToInt64(x.Attr("value")); var offset = Convert.ToInt32(x.Attr("offset")); result = value + offset; x.SetAttributeValue("value", result); f.WriteFile(x.ToString()); } return result; }