public bool DeleteEnterpriseRole(int roleId)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.RFARoles.FirstOrDefault(obj => obj.RoleID.Equals(roleId));
             if (null == temp)
             {
                 throw new KnownException("该角色不存在");
             }
             var fun      = db.RFAAuthorizations.Where(x => x.RoleID == roleId && !x.Deleted);
             var userrole = db.UserRoles.Where(x => x.RoleID == roleId && !x.Deleted);
             var project  = db.Projects.FirstOrDefault(x => x.Roles.Contains(roleId.ToString()) && !x.Deleted);
             if (0 < userrole.Count() || project != null)
             {
                 throw new KnownException("该角色已被占用,无法删除");
             }
             else
             {
                 db.RFARoles.Remove(temp);
                 foreach (var f in fun)
                 {
                     db.RFAAuthorizations.Attach(f);
                     f.Deleted = true;
                 }
             }
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #2
0
        public bool ClearCache(string userID, string deviceID)
        {
            try
            {
                using (var db = new BCEnterpriseContext())
                {
                    if (!db.SyncStates.Any(o => o.UserID == userID && o.DeviceID == deviceID))
                    {
                        return(true);
                    }
                    db.SyncStates.RemoveRange(db.SyncStates.Where(o => o.UserID == userID && o.DeviceID == deviceID));

                    var temp = db.UserLoginStates.FirstOrDefault(o => o.UserID == userID && o.Device == deviceID);
                    if (null != temp)
                    {
                        LoginLogWrite(db, temp, LoginStatus.Logout, "APP清除缓存");
                        db.UserLoginStates.Remove(temp);
                    }
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void ForceLogout(BCEnterpriseContext db, int roleId, EnterpriseData.Common.LoginStatus status, string description)
        {
            var loginStateList = (from ur in db.UserRoles
                                  where ur.RoleID == roleId && !ur.Deleted
                                  join uls in db.UserLoginStates on ur.UserID equals uls.UserID
                                  select uls).ToList();
            var dbNowTime = ML.BC.EnterpriseData.Model.Extend.DBTimeHelper.DBNowTime(db);

            loginStateList.ForEach(n =>
            {
                var loginLog = new UserLoginLog
                {
                    UserID      = n.UserID,
                    UserName    = n.UserName,
                    IP          = n.LoginIP,
                    Device      = n.Device,
                    Time        = dbNowTime,
                    Description = description,
                    Status      = (int)status
                };
                db.UserLoginLogs.Add(loginLog);
                db.UserLoginStates.Remove(n);
            });
            db.SaveChanges();
        }
 public bool Delete(int ID)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.MaterialTypes.FirstOrDefault(obj => obj.MaterialTypeID.Equals(ID));
             if (null == temp)
             {
                 throw new Exception("该类型不存在");
             }
             var mat = db.KnowledgeBase.FirstOrDefault(x => x.KnowledgeType == ID);
             if (null != mat)
             {
                 throw new Exception("该类型被占用");
             }
             db.MaterialTypes.Remove(temp);
             return(db.SaveChanges() > 0);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool Add(MaterialTypeDto model)
 {
     try
     {
         if (string.IsNullOrEmpty(model.Name))
         {
             throw new KnownException("信息不完善");
         }
         using (var db = new BCEnterpriseContext())
         {
             if (db.MaterialTypes.Any(n => n.Name.Equals(model.Name)))
             {
                 throw new KnownException("已存在该名字");
             }
             var profession = new ML.BC.EnterpriseData.Model.MaterialType()
             {
                 Name      = model.Name,
                 Available = model.Avaliable
             };
             db.MaterialTypes.Add(profession);
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool Delete(int ID)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.MaterialTypes.FirstOrDefault(
                 obj => obj.MaterialTypeID.Equals(ID));
             db.MaterialTypes.Attach(temp);
             db.MaterialTypes.Remove(temp);
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool Update(MaterialTypeDto model)
 {
     try
     {
         if (string.IsNullOrEmpty(model.Name))
         {
             throw new KnownException("信息不完善");
         }
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.MaterialTypes.First(
                 x => x.MaterialTypeID == model.MaterialTypeID);
             if (null == temp)
             {
                 throw new KnownException("没有该记录!");
             }
             temp.Available = model.Avaliable;
             temp.Name      = model.Name;
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #8
0
 public bool UpLoading(KnowlegeDto newFile)
 {
     try
     {
         var mgdb = new MongoDbProvider <KnowledgeBaseFile>();
         using (var db = new BCEnterpriseContext())
         {
             var temp = new KnowledgeBase();
             temp.ID            = newFile.ID;
             temp.Name          = newFile.Name;
             temp.EnterpriseID  = newFile.EnterpriseID;
             temp.Deleted       = newFile.Deleted;
             temp.DocumentSize  = newFile.DocumentSize;
             temp.DocumentType  = (int)newFile.DocumentType;
             temp.KnowledgeType = newFile.KnowledgeType;
             temp.UpdateTime    = newFile.UpdateTime;
             temp.FileGUID      = newFile.FileGUID;
             temp.FileNumber    = newFile.FileNumber;
             temp.FileAllSize   = newFile.FileAllSize;
             db.KnowledgeBase.Add(temp);
             mgdb.SaveFileByStream(newFile.FileStream, newFile.ID, KnowlegeDbName);
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #9
0
 public bool DeleteFile(Guid fileGuid)
 {
     try
     {
         if (null == fileGuid)
         {
             return(false);
         }
         var mgdb = new MongoDbProvider <KnowledgeBaseFile>();
         using (var db = new BCEnterpriseContext())
         {
             var list = db.KnowledgeBase.Where(x => x.FileGUID == fileGuid);
             if (list.Count() > 0)
             {
                 foreach (var file in list)
                 {
                     file.Deleted = true;
                     mgdb.DeleteFileByName(file.ID, KnowlegeDbName);
                 }
             }
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool UpdateEntProperty(EnterprisePropertyDto enterpriseProperty)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.EnterprisePropertys.First(x => x.EnterprisePropertyID == enterpriseProperty.EnterprisePropertyID);
             if (null == temp)
             {
                 throw new KnownException("该对象不存在");
             }
             temp.Available = enterpriseProperty.Available;
             temp.Name      = enterpriseProperty.Name;
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public bool DeleteFrontUserRole(string frontUserID, int roleID)
        {
            try
            {
                if (string.IsNullOrEmpty(frontUserID))
                {
                    throw new KnownException("删除的用户角色不能为空!");
                }
                using (var db = new BCEnterpriseContext())
                {
                    var del = db.UserRoles.FirstOrDefault(
                        obj => obj.UserID == frontUserID && obj.RoleID == roleID);
                    if (null == del)
                    {
                        throw new KnownException("不存在该记录,无法删除!");
                    }

                    //DbEntityEntry<UserRole> entry = db.Entry<UserRole>(frontUserRole);
                    //db.UserRoles.Attach(entry.Entity);
                    //db.UserRoles.Remove(entry.Entity);
                    db.UserRoles.Remove(del);
                    return(0 < db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #12
0
 public bool UpdateEnterpriseProfession(string enterpriseProfessionKey, string enterpriseProfessionName, bool available)
 {
     try
     {
         if (string.IsNullOrEmpty(enterpriseProfessionKey) ||
             string.IsNullOrEmpty(enterpriseProfessionName))
         {
             throw new KnownException("信息不完善");
         }
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.EnterpriseProfessions.First(
                 x => x.EnterpriseProfessionID == enterpriseProfessionKey);
             if (null == temp)
             {
                 throw new KnownException("没有该记录!");
             }
             temp.Available = available;
             temp.Name      = enterpriseProfessionName;
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public bool UpdateFrontUserInfo(FrontUserDto frontUserDto)
        {
            try
            {
                if (null == frontUserDto)
                {
                    throw new KnownException("更新对象不能为空!");
                }
                using (var db = new BCEnterpriseContext())
                {
                    var q = db.FrontUsers.FirstOrDefault(obj => obj.UserID == frontUserDto.UserID);
                    if (null == q)
                    {
                        throw new KnownException("不存在该记录无法更新!");
                    }

                    q.Name       = frontUserDto.Name;
                    q.Mobile     = frontUserDto.Mobile;
                    q.UpdateTime = DateTime.Now;
                    return(0 < db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #14
0
 public int Add(SyncStateDto syncStateDto)
 {
     try
     {
         if (null == syncStateDto)
         {
             throw new KnownException("对象为空,无法添加!");
         }
         if (string.IsNullOrEmpty(syncStateDto.UserID) || string.IsNullOrEmpty(syncStateDto.DeviceID) || syncStateDto.ActionType < 0)
         {
             throw new KnownException("缺少必要信息,无法添加!");
         }
         using (var db = new BCEnterpriseContext())
         {
             syncStateDto.SyncTime = DateTime.Now;
             db.SyncStates.Add(syncStateDto);
             if (0 <= db.SaveChanges())
             {
                 throw new KnownException("添加失败!");
             }
             return(syncStateDto.SyncStateID);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool DeleteFrontUser(string frontUserId)
 {
     try
     {
         if (string.IsNullOrEmpty(frontUserId))
         {
             throw new KnownException("Id不能为空!");
         }
         using (var db = new BCEnterpriseContext())
         {
             var del = db.FrontUsers.FirstOrDefault(x => x.UserID == frontUserId);
             IQueryable <UserRole> delrole;
             if (null != del)
             {
                 delrole = db.UserRoles.Where(x => x.UserID == del.UserID);
                 foreach (var roleuser in delrole)
                 {
                     db.UserRoles.Remove(roleuser);
                 }
                 del.Closed = true;
             }
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #16
0
 public int AddSceneType(SceneTypeDto sceneType)
 {
     try
     {
         if (string.IsNullOrEmpty(sceneType.EnterpriseID))
         {
             throw new KnownException("企业ID不允许为空");
         }
         using (var db = new BCEnterpriseContext())
         {
             SceneType temp = new SceneType()
             {
                 Available    = sceneType.Available,
                 ID           = sceneType.ID,
                 EnterpriseID = sceneType.EnterpriseID,
                 Name         = sceneType.Name,
                 ParentID     = sceneType.ParentID
             };
             db.SceneTypes.Add(temp);
             if (0 < db.SaveChanges())
             {
                 return(temp.ID);
             }
             else
             {
                 return(-1);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #17
0
 public bool UpdateUser(FrontUserDto user)
 {
     try
     {
         if (null == user)
         {
             throw new KnownException("用户信息为空,不能更新!");
         }
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.FrontUsers.First(x => x.UserID == user.UserID);
             if (null == temp)
             {
                 throw new KnownException("该对象不存在");
             }
             if (!string.IsNullOrEmpty(user.Password))
             {
                 temp.Password = CryptoService.MD5Encrypt(user.Password);
             }
             temp.Closed     = user.Closed;
             temp.Mobile     = user.Mobile;
             temp.Name       = user.Name;
             temp.UpdateTime = DateTime.Now;
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #18
0
        private long AddUserLoginState(BCEnterpriseContext db, Account.Dtos.UserLoginStateDto model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("UserLoginStateDto");
            }

            var temp = db.UserLoginStates.FirstOrDefault(m => m.UserID == model.UserID && m.Device == model.Device) ?? new UserLoginState();

            temp.UserID     = model.UserID;
            temp.Device     = model.Device;
            temp.UserName   = model.UserName;
            temp.LoginToken = model.LoginToken;
            temp.LoginIP    = model.LoginIP;
            temp.LoginTime  = DateTime.Now;
            if (temp.UserLoginStateID == 0)
            {
                db.UserLoginStates.Add(temp);
            }
            else
            {
                db.Entry <UserLoginState>(temp).State = System.Data.Entity.EntityState.Modified;
            }
            db.SaveChanges();
            model.UserLoginStateID = temp.UserLoginStateID;

            return(temp.UserLoginStateID);
        }
        public bool SetUserAvatar(string userID, string imageUrl)
        {
            try
            {
                if (string.IsNullOrEmpty(userID) ||
                    string.IsNullOrEmpty(imageUrl))
                {
                    //throw new KnownException("缺少必要信息,无法设置头像!");
                    return(false);
                }
                using (var db = new BCEnterpriseContext())
                {
                    var q = db.FrontUsers.FirstOrDefault(obj => obj.UserID == userID);

                    if (null == q)
                    {
                        //throw new KnownException("用户不存在!");
                        return(false);
                    }
                    q.Picture = imageUrl;
                    return(db.SaveChanges() > 0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #20
0
 public int Add(DepartmentBase department)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             //Department temp = new Department {
             //    ParentID = department.ParentID,
             //    Name = department.Name,
             //    EnterpriseID = department.EnterpriseID,
             //    Description = department.Description,
             //    Available = department.Available,
             //    Deleted = department.Deleted
             //};
             db.Departments.Add(department);
             if (0 >= db.SaveChanges())
             {
                 throw new KnownException("部门添加失败");
             }
             else
             {
                 return(department.ParentID);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #21
0
 private int DeleteDepartment(int departmentId, BCEnterpriseContext db)
 {
     try
     {
         var temp = db.Departments.FirstOrDefault(x => x.DepartmentID == departmentId);
         if (null == temp)
         {
             return(0);
         }
         temp.Deleted = true;
         var list = db.Departments.Where(x => x.ParentID == departmentId).ToList();
         for (int i = 0; i < list.Count(); i++)
         {
             if (0 == DeleteDepartment(list[i].DepartmentID, db))
             {
                 break;
             }
         }
         return(db.SaveChanges());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #22
0
        private bool DeleteChildrenScene(int sceneTypeId, BCEnterpriseContext db)
        {
            var temp = db.SceneTypes.FirstOrDefault(x => x.ID == sceneTypeId);

            if (null == temp)
            {
                return(false);
            }

            var scenetype = db.Scenes.Where(x => x.Type.Contains(sceneTypeId.ToString())).FirstOrDefault();

            if (null == scenetype)
            {
                db.SceneTypes.Remove(temp);
            }
            else
            {
                throw new KnownException("该现场类型已经被引用,无法删除");
            }
            var list = db.SceneTypes.Where(x => x.ParentID == sceneTypeId).ToList();

            for (int i = 0; i < list.Count(); i++)
            {
                if (!DeleteChildrenScene(list[i].ID, db))
                {
                    break;
                }
            }
            return(0 < db.SaveChanges());
        }
Beispiel #23
0
 public bool DeleteEnterpriseProfession(string enterpriseProfessionId)
 {
     try
     {
         if (string.IsNullOrEmpty(enterpriseProfessionId))
         {
             throw new KnownException("输入Id不能为空!");
         }
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.EnterpriseProfessions.FirstOrDefault(
                 obj => obj.EnterpriseProfessionID.Equals(enterpriseProfessionId));
             db.EnterpriseProfessions.Attach(temp);
             db.EnterpriseProfessions.Remove(temp);
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #24
0
 private void LoginLogWrite(BCEnterpriseContext db, UserLoginLog loginLog)
 {
     if (loginLog == null)
     {
         return;
     }
     db.UserLoginLogs.Add(loginLog);
     db.SaveChanges();
 }
 public string AddEnterpriseRole(EnterpriseRoleDto enterpriseRole)
 {
     using (var db = new BCEnterpriseContext())
     {
         if (db.RFARoles.Any(n => n.Name == enterpriseRole.Name && (n.OwnerID ?? "").Equals(enterpriseRole.OwnerID ?? "") && n.RoleID != enterpriseRole.RoleID))
         {
             throw new KnownException("角色名冲突,请更改角色名后重试");
         }
         var temp = db.Enterprises.FirstOrDefault(x => x.EnterpriseID.Equals(enterpriseRole.OwnerID) || string.IsNullOrEmpty(enterpriseRole.OwnerID));
         if (null == temp)
         {
             throw new KnownException("企业ID不合法");
         }
         var role = new ML.BC.EnterpriseData.Model.RFARole
         {
             Name        = enterpriseRole.Name,
             OwnerID     = enterpriseRole.OwnerID,
             Description = enterpriseRole.Description,
             Available   = enterpriseRole.Available
         };
         //  事务处理Authorizations表添加成功和RFARole表添加成功需要同时满足。
         using (TransactionScope transaction = new TransactionScope())
         {
             db.RFARoles.Add(role);
             db.SaveChanges();
             var roleId = db.RFARoles.Where(x => x.OwnerID.Equals(enterpriseRole.OwnerID) && x.Name.Equals(enterpriseRole.Name)).Select(n => n.RoleID);
             if (!string.IsNullOrEmpty(enterpriseRole.FunctionIDs))
             {
                 SetEnterpriseRoleFunction(roleId.First(), enterpriseRole.FunctionIDs);
             }
             if (0 <= db.SaveChanges())
             {
                 transaction.Complete();
                 return(role.Name);
             }
             else
             {
                 throw new KnownException("保存角色功能失败");
             }
         }
     }
 }
        private bool AddSyncState(params SyncStateDto[] syncStateDtos)
        {
            lock (ADDSYNCSTATELOCK)
            {
                try
                {
                    if (null == syncStateDtos || syncStateDtos.Length == 0)
                    {
                        throw new ArgumentNullException("syncStateDtos");
                    }
                    for (int i = 0; i < syncStateDtos.Length; i++)
                    {
                        if (string.IsNullOrEmpty(syncStateDtos[i].UserID) || string.IsNullOrEmpty(syncStateDtos[i].DeviceID) || syncStateDtos[i].ActionType < 0)
                        {
                            throw new KnownException("对象索引:" + i + " 缺少必要信息,无法添加或更新!");
                        }
                    }

                    using (var db = new BCEnterpriseContext())
                    {
                        syncStateDtos.ToList().ForEach(m => m.SyncTime = DateTime.Now);
                        var objs = syncStateDtos.Select(n => new SyncState
                        {
                            SyncStateID = n.SyncStateID,
                            UserID      = n.UserID,
                            DeviceID    = n.DeviceID,
                            ActionType  = n.ActionType,
                            SyncTime    = n.SyncTime
                        }).ToList();

                        List <string> userids     = objs.Select((n) => n.UserID).ToList();
                        List <string> deviceIDs   = objs.Select((n) => n.DeviceID).ToList();
                        List <byte>   actionTypes = objs.Select((n) => n.ActionType).ToList();
                        var           oldlist     = db.SyncStates.Where(m => userids.Contains(m.UserID) && deviceIDs.Contains(m.DeviceID) && actionTypes.Contains(m.ActionType));
                        oldlist.ToList().ForEach(n =>
                        {
                            db.SyncStates.Remove(n);
                        });

                        objs.ForEach(n =>
                        {
                            db.SyncStates.Add(n);
                        });
                        db.SaveChanges();
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Beispiel #27
0
        public bool UpdateUserLoginState(string userId, string lastIP, string Device, string LoginToken)
        {
            try
            {
                if (string.IsNullOrEmpty(userId))
                {
                    throw new ArgumentNullException("userId");
                }
                if (string.IsNullOrEmpty(lastIP))
                {
                    throw new ArgumentNullException("lastIP");
                }

                using (var db = new BCEnterpriseContext())
                {
                    var user = db.FrontUsers.First(n => n.UserID == userId);
                    user.LastDate = DateTime.Now;
                    user.LastIP   = lastIP;
                    db.Entry <FrontUser>(user).State = System.Data.Entity.EntityState.Modified;

                    var updateResult = db.SaveChanges() > 0;

                    var setLoginStateResult = AddUserLoginState(db, new UserLoginStateDto()
                    {
                        Device     = Device,
                        LoginIP    = lastIP,
                        LoginTime  = user.UpdateTime,
                        LoginToken = LoginToken,
                        UserID     = user.UserID,
                        UserName   = user.Name
                    });

                    LoginLogWrite(db, new UserLoginLog
                    {
                        UserID      = user.UserID,
                        UserName    = user.Name,
                        IP          = lastIP,
                        Device      = Device,
                        Time        = user.UpdateTime,
                        Description = string.Empty,
                        Status      = (int)EnterpriseData.Common.LoginStatus.Login
                    });

                    return(updateResult && setLoginStateResult > 0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #28
0
        public bool ConfirmSyncSuccess(string userId, string device, AppSyncActionEnum action, DateTime syncTime)
        {
            lock (CONFIRMSYNCSUCCESSLOCK)
            {
                try
                {
                    using (var db = new BCEnterpriseContext())
                    {
                        var actionList = new List <int>();
                        switch (action)
                        {
                        case AppSyncActionEnum.SyncOrganization:
                            actionList.Add((int)TypeEnum.Department);
                            actionList.Add((int)TypeEnum.User);
                            actionList.Add((int)TypeEnum.Role);
                            break;

                        case AppSyncActionEnum.SyncProjectAndScene:
                            actionList.Add((int)TypeEnum.Project);
                            actionList.Add((int)TypeEnum.Scene);
                            actionList.Add((int)TypeEnum.SceneType);
                            break;

                        case AppSyncActionEnum.SyncSceneData:
                            actionList.Add((int)TypeEnum.SceneData);
                            break;
                        }

                        var syncStates =
                            db.SyncStates.Where(o => o.UserID == userId && o.DeviceID == device &&
                                                actionList.Any(n => n == o.ActionType)).ToList();

                        syncStates.ForEach(n =>
                        {
                            if (n.SyncTime < syncTime)
                            {
                                n.SyncTime = syncTime;
                            }
                        });

                        return(0 < db.SaveChanges());
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 public bool DeleteUserLoginState(string userId)
 {
     try
     {
         using (var db = new BCEnterpriseContext())
         {
             var user = db.UserLoginStates.FirstOrDefault(x => x.UserID.Equals(userId));
             db.UserLoginStates.Remove(user);
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #30
0
        private bool ScanSceneParents(string userID, string sceneID, BCEnterpriseContext db)
        {
            try
            {
                var templist  = GetParentsScenes(sceneID, db);
                var list      = templist.Select(x => x.SceneID).ToList();
                var scenelist = db.ScanLog.Where(x => list.Contains(x.ObjectID) && x.Type == (int)ScanType.Scene && x.UserID.Equals(userID)).Select(n => n.ObjectID).ToList();
                var sc        = new List <string>();
                sc.Add(sceneID);
                if (0 < scenelist.Count())
                {
                    sc = list.Except(scenelist).ToList();
                    sc.Distinct();
                }

                if (1 < sc.Count())
                {
                    foreach (var scene in sc)
                    {
                        var obj = new ScanLog()
                        {
                            UserID   = userID,
                            ObjectID = scene,
                            Type     = (int)ScanType.Scene,
                            Time     = DBTimeHelper.DBNowTime()
                        };
                        db.ScanLog.Add(obj);
                    }
                }
                else
                {
                    var obj = new ScanLog()
                    {
                        UserID   = userID,
                        ObjectID = sceneID,
                        Type     = (int)ScanType.Scene,
                        Time     = DBTimeHelper.DBNowTime()
                    };
                    db.ScanLog.Add(obj);
                }
                return(0 < db.SaveChanges());
            }
            catch (Exception e)
            {
                throw e;
            }
        }