public RecordType AddRecord(string OName, string OPoint) { byte[] Name = Convert.FromBase64String(OName); byte[] Point = Convert.FromBase64String(OPoint); StreamReader sr = new StreamReader(Server.MapPath("App_Data\rightcolor_private.xml")); string ALL = sr.ReadToEnd(); sr.Close(); RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048); RSA.FromXmlString(ALL); string RealName = System.Text.Encoding.UTF8.GetString(RSA.Decrypt(Name, false)); long RealPoint = long.Parse(System.Text.Encoding.UTF8.GetString(RSA.Decrypt(Point, false))); RecordType AllowInsert = RecordType.None; long ForeverMax = (from inc in Data.Records orderby inc.Point descending select inc.Point).Skip(9).Take(1).SingleOrDefault(); if (RealPoint > ForeverMax) { AllowInsert = RecordType.Forever; goto Insert; } long MonthMax = (from inc in Data.Records where inc.AddDate > DateTime.Now.AddMonths(-1) orderby inc.Point descending select inc.Point).Skip(9).Take(1).SingleOrDefault(); if (RealPoint > MonthMax) { AllowInsert = RecordType.Month; goto Insert; } long WeekMax = (from inc in Data.Records where inc.AddDate > DateTime.Now.AddDays(-7) orderby inc.Point descending select inc.Point).Skip(9).Take(1).SingleOrDefault(); if (RealPoint > WeekMax) { AllowInsert = RecordType.Week; goto Insert; } long DayMax = (from inc in Data.Records where inc.AddDate > DateTime.Now.AddDays(-1) orderby inc.Point descending select inc.Point).Skip(9).Take(1).SingleOrDefault(); if (RealPoint > DayMax) { AllowInsert = RecordType.Day; } Insert: if (AllowInsert != RecordType.None) { Record NewRecord = new Record(); NewRecord.Person = RealName; NewRecord.Point = RealPoint; NewRecord.AddDate = DateTime.Now; Data.Records.InsertOnSubmit(NewRecord); Data.SubmitChanges(); } return AllowInsert; }
partial void DeleteRecord(Record instance);
partial void UpdateRecord(Record instance);
partial void InsertRecord(Record instance);