本文整理汇总了C#中SandBox.Db.SandBoxDataContext类的典型用法代码示例。如果您正苦于以下问题:C# SandBoxDataContext类的具体用法?C# SandBoxDataContext怎么用?C# SandBoxDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SandBoxDataContext类属于SandBox.Db命名空间,在下文中一共展示了SandBoxDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPathById
public static String GetPathById(Int32 id)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.Malwares.FirstOrDefault(x => x.Id == id).Path;
}
}
示例2: CreateUser
//**********************************************************
//* Создание пользователя
//**********************************************************
public static MembershipUser CreateUser(String username, String password, Int32 roleId)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
var users = UserManager.GetUsers();
if (Enumerable.Any(users, us => us.Login == username)) return null;
User user = new User
{
Login = username,
Password = password,
PasswordSalt = CreateSalt(),
CreatedDate = DateTime.Now,
LastLoginDate = DateTime.Now
};
user.Password = CreatePasswordHash(password, user.PasswordSalt);
db.Users.InsertOnSubmit(user);
db.SubmitChanges();
var usr = db.Users.FirstOrDefault(x => x.Login == username);
if (usr == null) return null;
UsersInRole userInRole = new UsersInRole {UserId = usr.UserId, RoleId = roleId};
db.UsersInRoles.InsertOnSubmit(userInRole);
db.SubmitChanges();
return GetUser(username);
}
}
示例3: GetMachineByName
public static Machine GetMachineByName(String name)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.Machines.FirstOrDefault(x => x.Name == name);
}
}
示例4: GetDescription
public static String GetDescription(Int32 machineState)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.MachinesStates.FirstOrDefault(x => x.State == machineState).Description;
}
}
示例5: GetNameById
public static String GetNameById(Int32 id)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.Machines.FirstOrDefault(x => x.Id == id).Name;
}
}
示例6: LoadSettings
public static ConnectionSetting LoadSettings()
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.ConnectionSettings.FirstOrDefault();
}
}
示例7: AddResearch
//**********************************************************
//* Добавление нового исследования, возвращает researchId
//**********************************************************
public static Int32 AddResearch(Int32 userId, Int32 mlwrId, Int32 vmId, Int32 researchVmData, Int32 duration, String name = "")
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Research research = new Research
{
UserId = userId,
MlwrId = mlwrId,
VmId = vmId,
ResearchVmData = researchVmData,
State = (Int32)ResearchState.READY,
CreatedDate = DateTime.Now,
Duration = duration,
ResearchName = name,
TrafficFileReady = (Int32)TrafficFileReady.NOACTION
};
db.Researches.InsertOnSubmit(research);
db.SubmitChanges();
var researches = from r in db.Researches
where r.UserId == userId
select r.Id;
return researches.Max();
}
}
示例8: GetEvtSignif
public static int GetEvtSignif(events evt)
{
var db = new SandBoxDataContext();
var dofe = db.DirectoryOfEvents.FirstOrDefault<DirectoryOfEvents>(x => ((x.dest == evt.dest) && (x.module == evt.module)
&& ([email protected] == [email protected])&&(x.who==evt.who)));
return dofe == null ? -1 : dofe.significance;
}
示例9: DeleteDirectorysOfEvent
public static void DeleteDirectorysOfEvent(long id)
{
var db = new SandBoxDataContext();
var dofe = db.DirectoryOfEvents.FirstOrDefault<DirectoryOfEvents>(x => x.Id == id);
if(dofe!=null) db.DirectoryOfEvents.DeleteOnSubmit(dofe);
db.SubmitChanges();
}
示例10: GetConnectionStatus
public static Boolean GetConnectionStatus()
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.DatabaseExists();
}
}
示例11: GetRegistry
/// <summary>
/// Получение всей таблицы с запиями регистра
/// </summary>
/// <returns></returns>
public static IQueryable<RegTest> GetRegistry()
{
var db = new SandBoxDataContext();
IQueryable<RegTest> res = from r in db.RegTest
select r;
return res;
}
示例12: GetDescription
public static String GetDescription(Int32 malwareClass)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
return db.MalwareClasses.FirstOrDefault(x => x.Class == malwareClass).Description;
}
}
示例13: GetProcessesTableView
public static IQueryable<Proc> GetProcessesTableView()
{
var db = new SandBoxDataContext();
var results = from proc in db.Proc
orderby proc.procName
select proc;
return results;
}
示例14: GetEventsDescrByModule
//public static IQueryable<string> GetEventsDescrByModule(string moduleDesctiption)
//{
// var db = new SandBoxDataContext();
// int modId = -1;
// var mod = db.EventsModulesDescriptions.FirstOrDefault<EventsModulesDescriptions>(x => x.Description == moduleDesctiption);
// if (mod != null)
// {
// modId = mod.EventModuleID;
// }
// if (modId != -1)
// {
// return from ev in db.ModulesVsEvents
// where ev.Module == modId
// select ResearchManager. GetEvtEvtDescription( ev.Event);
// }
// return null;
//}
public static IQueryable GetEventsDescrByModule(string moduleDesctiption)
{
var db = new SandBoxDataContext();
return from ed in db.EventsEventDescriptions
join mve in db.ModulesVsEvents on ed.EventID equals mve.Event
join md in db.EventsModulesDescriptions on mve.Module equals md.EventModuleID
where md.Description == moduleDesctiption
select ed;
}
示例15: AddReport
public static void AddReport(Int32 researchId, Int32 modId, Int32 actionId, String obj, String target, String additional="")
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Report report = new Report { ResearchId = researchId, ModuleId = modId, ActionId = actionId, Object = obj, Target = target, TIme = DateTime.Now, Additional = additional};
db.Reports.InsertOnSubmit(report);
db.SubmitChanges();
}
}