当前位置: 首页>>代码示例>>C#>>正文


C# Db.SandBoxDataContext类代码示例

本文整理汇总了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;
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:MalwareManager.cs

示例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);
            }
        }
开发者ID:pande88,项目名称:votchina,代码行数:32,代码来源:UserManager.cs

示例3: GetMachineByName

 public static Machine GetMachineByName(String name)
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return db.Machines.FirstOrDefault(x => x.Name == name);
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:MachineManager.cs

示例4: GetDescription

 public static String GetDescription(Int32 machineState)
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return db.MachinesStates.FirstOrDefault(x => x.State == machineState).Description;
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:MachineManager.cs

示例5: GetNameById

 public static String GetNameById(Int32 id)
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return db.Machines.FirstOrDefault(x => x.Id == id).Name;
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:MachineManager.cs

示例6: LoadSettings

 public static ConnectionSetting LoadSettings()
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return  db.ConnectionSettings.FirstOrDefault();
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:ConnectionManager.cs

示例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();
            }
        }
开发者ID:pande88,项目名称:votchina,代码行数:29,代码来源:ResearchManager.cs

示例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;
 }
开发者ID:pande88,项目名称:votchina,代码行数:7,代码来源:ReportManager.cs

示例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();
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:ReportManager.cs

示例10: GetConnectionStatus

 public static Boolean GetConnectionStatus()
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return db.DatabaseExists();
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:DbManager.cs

示例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;
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:11,代码来源:RegistryManager.cs

示例12: GetDescription

 public static String GetDescription(Int32 malwareClass)
 {
     using (SandBoxDataContext db = new SandBoxDataContext())
     {
         return db.MalwareClasses.FirstOrDefault(x => x.Class == malwareClass).Description;
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:7,代码来源:MalwareManager.cs

示例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;
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:8,代码来源:ProcessManager.cs

示例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;
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:26,代码来源:ReportManager.cs

示例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();
     }
 }
开发者ID:alexkasp,项目名称:monitor,代码行数:9,代码来源:ReportManager.cs


注:本文中的SandBox.Db.SandBoxDataContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。