本文整理汇总了C#中SessionNoServer.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# SessionNoServer.Abort方法的具体用法?C# SessionNoServer.Abort怎么用?C# SessionNoServer.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionNoServer
的用法示例。
在下文中一共展示了SessionNoServer.Abort方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static readonly string systemDir = "QuickStart"; // appended to SessionBase.BaseDatabasePath
static int Main(string[] args)
{
using (SessionNoServer session = new SessionNoServer(systemDir))
{
Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
try
{
session.BeginUpdate();
Company company = new Company();
company.Name = "MyCompany";
session.Persist(company);
Employee employee1 = new Employee();
employee1.Employer = company;
employee1.FirstName = "John";
employee1.LastName = "Walter";
session.Persist(employee1);
session.Commit();
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
session.Abort();
}
}
Retrieve();
return 0;
}
示例2: ForgotPasswordLinkButton_Click
protected void ForgotPasswordLinkButton_Click(object sender, EventArgs e)
{
try
{
using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
{
session.BeginRead();
Root root = (Root)session.Open(Root.PlaceInDatabase, 1, 1, false);
if (root == null)
{
ErrorMessage.Text = "The entered email address is not registered with this website";
session.Abort();
return;
}
CustomerContact lookup = new CustomerContact(Email.Text, null);
if (!root.customersByEmail.TryGetKey(lookup, ref lookup))
{
ErrorMessage.Text = "The entered email address is not registered with this website";
session.Abort();
return;
}
session.Commit();
MailMessage message = new MailMessage("[email protected]", Email.Text);
message.Subject = "Your password to VelocityWeb";
message.Body = "Password is: " + lookup.password;
SmtpClient client = new SmtpClient("smtpout.secureserver.net", 80);
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("[email protected]", "xxxx");
client.Credentials = SMTPUserInfo;
client.Send(message);
ErrorMessage.Text = "Email with your password was send to: " + Email.Text;
}
}
catch (System.Exception ex)
{
ErrorMessage.Text = ex.ToString();
}
}
示例3: UnpersistCompareFields
public void UnpersistCompareFields(int bTreeDatabaseNumber)
{
using (SessionNoServer session = new SessionNoServer(systemDir))
{
session.BeginUpdate();
BTreeSet<Person> bTree = (BTreeSet<Person>)session.Open(Oid.Encode((uint)bTreeDatabaseNumber, 1, 1));
BTreeSetIterator<Person> itr = bTree.Iterator();
itr.GoToLast();
itr.Remove();
session.Abort();
session.BeginUpdate();
bTree = (BTreeSet<Person>)session.Open(Oid.Encode((uint)bTreeDatabaseNumber, 1, 1));
bTree.Unpersist(session);
session.Commit();
session.BeginRead();
Database db = session.OpenDatabase((uint)bTreeDatabaseNumber, false);
foreach (Page page in db)
foreach (OptimizedPersistable obj in page)
if (obj.PageNumber > 0)
Assert.Fail("No objects should remain in this database");
session.Commit();
}
}
示例4: LoginButton_Click
protected void LoginButton_Click(object sender, EventArgs e)
{
if (Password.Text.Length == 0)
{
ErrorMessage.Text = "Enter your password.";
return;
}
try
{
using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
{
session.BeginUpdate();
Root velocityDbroot = (Root)session.Open(Root.PlaceInDatabase, 1, 1, false);
if (velocityDbroot == null)
{
ErrorMessage.Text = "The entered email address is not registered with this website";
session.Abort();
return;
}
CustomerContact lookup = new CustomerContact(Email.Text, null);
if (!velocityDbroot.customersByEmail.TryGetKey(lookup, ref lookup))
{
ErrorMessage.Text = "The entered email address is not registered with this website";
session.Abort();
return;
}
if (lookup.password != Password.Text)
{
ErrorMessage.Text = "The entered password does not match the registered password";
session.Abort();
return;
}
session.Commit();
Session["UserName"] = lookup.UserName;
Session["Email"] = Email.Text;
Session["FirstName"] = lookup.FirstName;
Session["LastName"] = lookup.LastName;
FormsAuthentication.RedirectFromLoginPage(Email.Text, false);
}
}
catch (System.Exception ex)
{
ErrorMessage.Text = ex.ToString() + ex.Message;
}
}
示例5: Main
static void Main(string[] args)
{
SessionBase.BaseDatabasePath = @"d:/Databases";
bool dirExist = Directory.Exists(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir));
if (!dirExist)
ImdbImport.ImprortImdb(s_systemDir);
KevinBaconNumbers kevinBaconNumbers = new KevinBaconNumbers();
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
try
{
session.BeginRead();
kevinBaconNumbers.calculateNumbers(session);
kevinBaconNumbers.printResults();
session.Commit();
}
catch (Exception e)
{
session.Abort();
Console.WriteLine(e.ToString());
}
}
}
示例6: ImprortImdb
public static void ImprortImdb(string systemDir)
{
ImdbImport imdbImport = new ImdbImport();
using (SessionNoServer session = new SessionNoServer(systemDir))
{
try
{
session.BeginUpdate();
File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"), true);
ImdbRoot imdbRoot = new ImdbRoot(session);
session.Persist(imdbRoot);
imdbImport.ParseActors(session, imdbRoot);
imdbImport.ParseActresses(session, imdbRoot);
foreach (ActingPerson acting in imdbRoot.ActorSet)
if (!imdbRoot.ActingByNameSet.Add(acting))
Console.WriteLine("Dublicate ActingPerson found (in ActorSet): " + acting.Name);
foreach (ActingPerson acting in imdbRoot.ActressSet)
if (!imdbRoot.ActingByNameSet.Add(acting))
Console.WriteLine("Dublicate ActingPerson found (in ActressSet): " + acting.Name);
session.Commit();
}
catch (Exception e)
{
session.Abort();
Console.WriteLine(e.ToString());
}
}
}
示例7: Create1Vertices
public void Create1Vertices(bool vertexIdSetPerVertexType)
{
DataCache.MaximumMemoryUse = 10000000000; // 10 GB
bool dirExist = Directory.Exists(systemDir);
try
{
if (Directory.Exists(systemDir))
Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
Directory.CreateDirectory(systemDir);
File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
}
catch
{
File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
}
using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true))
{
session.BeginUpdate();
Graph g = new Graph(session, vertexIdSetPerVertexType);
session.Persist(g);
VertexType userType = g.NewVertexType("User");
VertexType otherType = g.NewVertexType("Other");
PropertyType userNamePropertyType = g.NewVertexProperty(userType, "NAME", DataType.String, PropertyKind.Indexed);
VertexType powerUserType = g.NewVertexType("PowerUser", userType);
EdgeType userFriendEdgeType = g.NewEdgeType("Friend", true, userType, userType);
EdgeType userBestFriendEdgeType = g.NewEdgeType("Best Friend", true, userType, userType, userFriendEdgeType);
EdgeType otherEdgeType = g.NewEdgeType("Other", true, userType, userType);
PropertyType bestFriendPropertyType = g.NewEdgeProperty(userFriendEdgeType, "START", DataType.DateTime, PropertyKind.Indexed);
Vertex kinga = userType.NewVertex();
Vertex robin = userType.NewVertex();
Vertex mats = powerUserType.NewVertex();
Vertex chiran = powerUserType.NewVertex();
Vertex other = otherType.NewVertex();
Edge bestFriend = kinga.AddEdge(userBestFriendEdgeType, robin);
Edge otherEdge = kinga.AddEdge(otherEdgeType, robin);
DateTime now = DateTime.UtcNow;
mats.SetProperty("Address", 1);
bestFriend.SetProperty(bestFriendPropertyType, now);
kinga.SetProperty(userNamePropertyType, "Kinga");
if (g.VertexIdSetPerType == false)
mats.SetProperty(userNamePropertyType, "Mats");
else
{
try
{
mats.SetProperty(userNamePropertyType, "Mats");
Assert.Fail("Invalid property for VertexType not handled");
}
catch (Exception)
{
}
}
try
{
other.SetProperty(userNamePropertyType, "Mats");
Assert.Fail("Invalid property for VertexType not handled");
}
catch (Exception)
{
}
try
{
otherEdge.SetProperty(bestFriendPropertyType, now);
Assert.Fail("Invalid property for VertexType not handled");
}
catch (Exception)
{
}
Vertex findMats = userNamePropertyType.GetPropertyVertex("Mats", true);
var list = userNamePropertyType.GetPropertyVertices("Mats", true).ToList();
//Edge findWhen = bestFriendPropertyType.GetPropertyEdge(now);
//var list2 = bestFriendPropertyType.GetPropertyEdges(now);
Console.WriteLine(findMats);
// session.Commit();
// session.BeginRead();
PropertyType adressProperty = g.FindVertexProperty(powerUserType, "Address");
Vertex find1 = adressProperty.GetPropertyVertex(1, true);
session.Abort();
/*session.BeginUpdate();
g.Unpersist(session);
session.Commit();
dirExist = Directory.Exists(systemDir);
try
{
if (Directory.Exists(systemDir))
Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
Directory.CreateDirectory(systemDir);
File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
}
catch
{
File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
}*/
}
using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true))
{
session.BeginUpdate();
//.........这里部分代码省略.........
示例8: Main
//.........这里部分代码省略.........
}
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
session.BeginRead();
Console.WriteLine("Blue Cars");
BTreeSet<Car> bTree = session.Index<Car>("color");
foreach (Car c in (from aCar in bTree where aCar.Color == "Blue" select aCar))
Console.WriteLine(c.ToStringDetails(session));
Console.WriteLine("Cars in fuel efficiency order");
foreach (Car c in session.Index<Car>("litresPer100Kilometers"))
Console.WriteLine(c.ToStringDetails(session));
Console.WriteLine("Vehicles ordered modelYear, brandName, modelName, color");
foreach (Vehicle v in session.Index<Vehicle>())
Console.WriteLine(v.ToStringDetails(session));
session.Commit();
}
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
session.TraceIndexUsage = true;
session.BeginUpdate();
// these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
Car c = (from aCar in session.Index<Car>("color") where aCar.Color == "Blue" select aCar).First();
c.Color = "Green";
session.Commit();
}
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
session.TraceIndexUsage = true;
session.BeginUpdate();
// these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
Car c = (from aCar in session.Index<Car>("color") where aCar.Color == "Green" select aCar).First();
UInt64 id = c.Id;
session.DeleteObject(id);
session.Abort();
session.BeginUpdate();
session.DeleteObject(id);
session.Commit();
}
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
session.TraceIndexUsage = true;
Stopwatch sw = new Stopwatch();
sw.Start();
session.BeginRead();
// these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
Console.WriteLine("Blue Cars");
foreach (Car c in (from aCar in session.Index<Car>("color") where aCar.Color == "Blue" select aCar))
Console.WriteLine(c.ToStringDetails(session));
session.Commit();
sw.Stop();
Console.WriteLine(sw.Elapsed);
}
using (SessionNoServer session = new SessionNoServer(s_systemDir))
{
Stopwatch sw = new Stopwatch();
sw.Start();
session.BeginUpdate();
for (int i = 0; i < 10000; i++)
{ // add some junk to make search harder
car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, i,
odometer, registrationState, registrationPlate + i, insuranceCompany, insurancePolicy);
session.Persist(car);
}
session.Commit();
sw.Stop();
Console.WriteLine(sw.Elapsed);
示例9: RegisterButton_Click
protected void RegisterButton_Click(object sender, EventArgs e)
{
try
{
using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
{
session.BeginUpdate();
CustomerContact customer = new CustomerContact(CompanyName.Text, FirstName.Text, LastName.Text, Email.Text, Address.Text, AddressLine2.Text,
City.Text, ZipCode.Text, State.Text, Country.SelectedItem.Text, Country.SelectedItem.Value, Phone.Text, Fax.Text, MobilePhone.Text,
SkypeName.Text, Website.Text, UserName.Text, Password.Text, HowFoundTextBox.Text, HowFoundRadioButtonList.SelectedIndex, session);
Root root = (Root)session.Open(Root.PlaceInDatabase, 1, 1, false);
CustomerContact lookup;
string user = this.User.Identity.Name;
if (user != null && user.Length > 0)
{
lookup = new CustomerContact(user, null);
root.customersByEmail.TryGetKey(lookup, ref existingCustomer);
}
else
{
lookup = new CustomerContact(customer.email, customer.userName);
if (!root.customersByEmail.TryGetKey(lookup, ref existingCustomer))
root.customersByUserName.TryGetKey(lookup, ref existingCustomer);
}
if (existingCustomer != null)
{
existingCustomer.Update();
if (existingCustomer.email != customer.email)
{
string verifiedEmail = (string)Session["EmailVerificationEmail"];
int emailVerification = (int)Session["EmailVerification"];
if (Request.IsLocal == false)
{
if (emailVerification < 0 || verifiedEmail != customer.email)
{
errors.Text = "Email was not verified for new user registration";
session.Abort();
return;
}
int enteredVerificationNumber;
int.TryParse(EmailVerification.Text, out enteredVerificationNumber);
if (emailVerification != enteredVerificationNumber)
{
errors.Text = "Entered Email Verification number is " + enteredVerificationNumber + " does match the emailed verification number: " + emailVerification;
Session["EmailVerification"] = -1;
session.Abort();
return;
}
}
if (existingCustomer.password != customer.password && user != existingCustomer.email)
{
errors.Text = "Entered Email address already registered";
session.Abort();
return;
}
existingCustomer.priorVerifiedEmailSet.Add(existingCustomer.email);
root.customersByEmail.Remove(existingCustomer);
existingCustomer.email = customer.email;
root.customersByEmail.Add(existingCustomer);
}
if (existingCustomer.userName != customer.userName)
{
lookup = new CustomerContact(user, customer.userName);
if (root.customersByUserName.TryGetKey(lookup, ref lookup))
{
errors.Text = "Entered User Name is already in use";
session.Abort();
return;
}
// remove and add to get correct sorting order
root.customersByUserName.Remove(existingCustomer);
existingCustomer.userName = customer.userName;
root.customersByUserName.Add(existingCustomer);
}
existingCustomer.company = customer.company;
existingCustomer.firstName = customer.firstName;
existingCustomer.lastName = customer.lastName;
existingCustomer.address = customer.address;
existingCustomer.addressLine2 = customer.addressLine2;
existingCustomer.city = customer.city;
existingCustomer.zipCode = customer.zipCode;
existingCustomer.state = customer.state;
existingCustomer.country = Country.SelectedItem.Text;
existingCustomer.countryCode = Country.SelectedItem.Value;
existingCustomer.phone = customer.phone;
existingCustomer.fax = customer.fax;
existingCustomer.mobile = customer.mobile;
existingCustomer.skypeName = customer.skypeName;
existingCustomer.webSite = customer.webSite;
existingCustomer.password = customer.password;
existingCustomer.howFoundOther = customer.howFoundOther;
existingCustomer.howFoundVelocityDb = customer.howFoundVelocityDb;
}
else
{
if (Request.IsLocal == false)
{
int emailVerification = (int)Session["EmailVerification"];
string verifiedEmail = (string)Session["EmailVerificationEmail"];
//.........这里部分代码省略.........
示例10: importEntireWikipedia
static void importEntireWikipedia()
{
const ushort btreeNodeSize = 10000;
Console.WriteLine(DateTime.Now.ToString() + ", start importing Wikipedia text");
//System.Xml.Schema.XmlSchema docSchema;
//using (System.Xml.XmlTextReader schemaReader = new System.Xml.XmlTextReader("c:\\export-0_5.xsd"))
//{
// docSchema = System.Xml.Schema.XmlSchema.Read(schemaReader, ValidationCallBack);
// }
int docCount = 0;
using (SessionNoServer session = new SessionNoServer(s_systemDir, 5000, false, false, CacheEnum.No)) // turn of page and object caching
{
Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
//GCSettings.LatencyMode = GCLatencyMode.Batch;// try to keep the WeakIOptimizedPersistableReference objects around longer
Placement documentPlacement = new Placement(Document.PlaceInDatabase, 1003, 1, 500, 1000, false, false, 1000, false);
Placement contentPlacement = new Placement(Document.PlaceInDatabase, 1, 1, 500, UInt16.MaxValue, false, false, 1, false);
XmlComment xmlComment;
XmlElement xmlElement;
XmlEntity xmlEntity;
XmlText xmlText;
XmlWhitespace xmlWhitespace;
session.BeginUpdate();
File.Copy(s_licenseDbFile, System.IO.Path.Combine(session.SystemDirectory, "4.odb"), true);
// register all database schema classes used by the application in advance to avoid lock conflict later in parallell indexing
session.RegisterClass(typeof(Repository));
session.RegisterClass(typeof(IndexRoot));
session.RegisterClass(typeof(Document));
session.RegisterClass(typeof(Lexicon));
session.RegisterClass(typeof(DocumentText));
session.RegisterClass(typeof(Word));
session.RegisterClass(typeof(WordGlobal));
session.RegisterClass(typeof(WordHit));
session.RegisterClass(typeof(BTreeSet<Document>));
session.RegisterClass(typeof(OidShort));
session.RegisterClass(typeof(BTreeMap<Word, WordHit>));
session.RegisterClass(typeof(HashCodeComparer<Word>));
session.RegisterClass(typeof(BTreeSetOidShort<Word>));
session.RegisterClass(typeof(BTreeMapOidShort<Word, WordHit>));
Database db = session.OpenDatabase(IndexRoot.PlaceInDatabase, false, false);
if (db != null)
{
outputSomeInfo(session);
session.Abort();
return;
}
session.NewDatabase(IndexRoot.PlaceInDatabase, 0, "IndexRoot");
session.NewDatabase(Lexicon.PlaceInDatabase, 0, "Lexicon");
session.NewDatabase(Repository.PlaceInDatabase, 0, "Repository");
for (UInt32 i = 40; i <= 186; i++)
{
session.NewDatabase(i, 512, "Document"); // pre allocate 146 Document databases presized to 512MB each
}
//session.SetTraceDbActivity(Lexicon.PlaceInDatabase);
//session.SetTraceAllDbActivity();
XmlDocument xmlDocument = new XmlDocument("enwiki-latest-pages-articles.xml");
IndexRoot indexRoot = new IndexRoot(btreeNodeSize, session);
indexRoot.Persist(session, indexRoot, true);
Document doc = null;
bool titleElement = false;
bool pageText = false;
UInt32 currentDocumentDatabaseNum = documentPlacement.StartDatabaseNumber;
using (FileStream fs = new FileStream(s_wikipediaXmlFile, FileMode.Open))
{
//using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Decompress)) // if input was a .gz file
{
using (System.Xml.XmlTextReader textReader = new System.Xml.XmlTextReader(fs))
{
while (textReader.Read())
{
System.Xml.XmlNodeType nodeType = textReader.NodeType;
switch (nodeType)
{
case System.Xml.XmlNodeType.Attribute:
break;
case System.Xml.XmlNodeType.CDATA:
break;
case System.Xml.XmlNodeType.Comment:
xmlComment = new XmlComment(textReader.Value, xmlDocument);
break;
case System.Xml.XmlNodeType.Document:
break;
case System.Xml.XmlNodeType.DocumentFragment:
break;
case System.Xml.XmlNodeType.DocumentType:
break;
case System.Xml.XmlNodeType.Element:
xmlElement = new XmlElement(textReader.Prefix, textReader.LocalName, textReader.NamespaceURI, xmlDocument);
if (textReader.LocalName == "title")
titleElement = true;
else if (textReader.LocalName == "text")
pageText = true;
break;
case System.Xml.XmlNodeType.EndElement:
if (textReader.LocalName == "title" && doc != null)
titleElement = false;
else if (textReader.LocalName == "text" && doc != null)
pageText = false;
break;
case System.Xml.XmlNodeType.EndEntity:
break;
//.........这里部分代码省略.........