public bool SaveFiles(List <string> FilesList, int MarketingId, bool isEdit, int CurrentUserId) { try { base.DBInit(); foreach (var fileName in FilesList) { var attachmentModel = new Database.MarketingAttachment { FileName = fileName, MarketingId = MarketingId, CreatedBy = CurrentUserId, CreatedOn = System.DateTime.UtcNow }; EntityAdd <Database.MarketingAttachment>(attachmentModel); } if (DBEntity.SaveChanges() <= 0) { return(false); } } catch (Exception ex) { ex.Log(); return(false); } finally { base.DBClose(); } return(true); }
/// <summary> /// 新增台架 /// </summary> /// <param name="panrentFid"></param> /// <param name="dbEntity"></param> /// <param name="idMapping"></param> private void AddKggDBEntity(long panrentFid, DBEntity dbEntity, Dictionary <long, ExpandsData> idMapping) { var newObject_n = dbEntity.Clone() as ElectronBase; var newIds = idMapping.SingleOrDefault(o => o.Key == newObject_n.G3E_FID); if (newObject_n.G3E_FNO == 199) { if (newObject_n.GetType().Name.Equals("Gg_pd_gnwzmc_n")) { UpdateGnwzSstj(panrentFid, newIds.Value.newG3e_fid); } } if (newObject_n.GetType().Name.Equals("Common_n")) { ClearCommon(newObject_n); } if (newObject_n.GetType().Name.Equals("Gg_gz_tj_n")) { if (newObject_n.HasAttribute("GNWZ_FID")) { newObject_n.SetValue("GNWZ_FID", panrentFid.ToString()); } } newObject_n.G3E_ID = newIds.Value.newG3e_id; newObject_n.G3E_FID = newIds.Value.newG3e_fid; newObject_n.EntityState = EntityState.Insert; newObject_n.SetValue("LTT_ID", (decimal)MapConfig.Instance.LTTID); DBManager.Instance.Insert(newObject_n); }
public ActionResult Save(EmpresaEntity entity) { try { var result = new DBEntity(); if (entity.IdEmpresa.HasValue) { result = IApp.empresaService.Actualizar(entity); TempData["msg"] = "Se actualizo el registro con exito!"; } else { result = IApp.empresaService.Insertar(entity); TempData["msg"] = "Se inserto el registro con exito!"; } if (result.CodeError != 0) { throw new Exception(result.MsgError); } return(RedirectToAction("index")); } catch (Exception ex) { return(Content(ex.Message)); } }
public ActionResult Save(ClienteInformacionAdministrativaEntity entity) { try { var result = new DBEntity(); if (entity.IdClienteInformacionAdmin.HasValue) { result = IApp.clienteinformacionadministrativaService.Actualizar(entity); TempData["msg"] = "Se Actualizo el registro con exito!"; } else { result = IApp.clienteinformacionadministrativaService.Insertar(entity); TempData["msg"] = "Se agrego el registro con exito!"; } if (result.CodeError != 0) { throw new Exception(result.MsgError); } return(RedirectToAction("Index")); } catch (Exception ex) { return(Content(ex.Message)); } }
/// <summary> /// Check if the logged in user is supervisor or not /// </summary> public int CheckSupervisor(int companyId, int userId) { int showTopLevel = 0; try { using (DBEntity context = new DBEntity()) { //check whether the user has access to the company UserCompany userCompany = (from uc in context.UserCompany where uc.CompanyId == companyId && uc.IsEnabled && uc.Status == 1 && uc.UserId == userId select uc).FirstOrDefault(); if (userCompany != null) { PermissionManager permissionManager = new PermissionManager(Convert.ToInt64(userCompany.ReportsPerms)); if (permissionManager.Contains(ReportPerms.ShowDashBoardTopLevel)) { showTopLevel = 1; } } } return(showTopLevel); } catch (Exception checkSupervisorException) { LambdaLogger.Log(checkSupervisorException.ToString()); return(showTopLevel); } }
//删除坐标,图形界面同步删除节点 public void deleDataRow() { if (tunnels[gridView1.FocusedRowHandle].HandleValue < 0) { gridView1.DeleteRow(gridView1.FocusedRowHandle); } else { gridView1.DeleteRow(gridView1.FocusedRowHandle); gridControl.RefreshDataSource(); Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc); DBEntity entity = dbControl.FindOne(Query.EQ("HandleValue", tunnels[gridView1.FocusedRowHandle].HandleValue)); DBTunnel newTunnel = entity as DBTunnel; newTunnel.BasePoints.Clear(); foreach (var t in tunnels) { if (t.HandleValue == tunnels[gridView1.FocusedRowHandle].HandleValue) { newTunnel.BasePoints.Add(new DBVertice(t.X, t.Y, t.Z)); } } dbControl.Update(newTunnel, this); } }
private void btnRegisterTopic_Click(object sender, EventArgs e) { var idTeam = dgvTeams.Rows[dgvTeams.CurrentCell.RowIndex].Cells["ID"].Value; if (idTeam == null) { MessageBox.Show("Vui lòng chọn Nhóm đăng ký!"); return; } var conn = new SqlConnection(DBEntity.GetConnection()); conn.Open(); var cmd = new SqlCommand("StudentRegisterTeam", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@idStudent", _idStudent); cmd.Parameters.AddWithValue("@idTeam", idTeam); cmd.Parameters.AddWithValue("@idTopical", cbbTopic.SelectedValue); cmd.Parameters.Add("@Result", SqlDbType.Int).Direction = ParameterDirection.Output; int count = cmd.ExecuteNonQuery(); int returnValue = int.Parse(cmd.Parameters["@Result"].Value.ToString()); //int returnValue = (int)cmd.Parameters["@RETURN_VALUE"].Value; if (returnValue > 0) { MessageBox.Show("Đăng ký nhóm thành công!", "Thông báo"); LoadStudentTeams(); } else { MessageBox.Show("Đăng ký nhóm thất bại. Mã lỗi (" + returnValue + ")", "Thông báo"); } }
public DataResponse <bool> DeleteDegree(int id) { var response = new DataResponse <bool>(); try { base.DBInit(); var model = DBEntity.LookupDegrees.Find(id); DBEntity.LookupDegrees.Remove(model); if (DBEntity.SaveChanges() > 0) { response.Message = "Success"; response.Status = DataResponseStatus.OK; response.Model = true; } } catch (Exception ex) { ex.Log(); response.Message = "Error, There are some related item in database, please delete those first"; response.Model = false; } finally { base.DBClose(); } return(response); }
private DBEntity ConstructEntity(DataRow row, Type type) { DBEntity entity = Activator.CreateInstance(type) as DBEntity; bool hasGemetry = false; foreach (var property in type.GetProperties()) { if (IsNonColumn(property)) { continue; } if (property.Name == GeometryQuery.GeometryField) { hasGemetry = true; } else //if (HasColumn(reader, property)) { try { var value = row[property.Name];//GetValue(reader, property); property.SetValue(entity, value, null); } catch (Exception ex) { } } } if (hasGemetry) { MakeGeometry(entity); } return(entity); }
public DataResponse <EntityMarketing> Update(EntityMarketing entity) { var response = new DataResponse <EntityMarketing>(); try { base.DBInit(); var model = DBEntity.MarketingDocuments.FirstOrDefault(a => a.Id == entity.Id); model.Name = entity.Name; model.Description = entity.Description; model.DocumentTypeId = entity.DocumentTypeId; model.CategoryId = entity.CategoryId; model.UpdatedBy = entity.CurrentUserId; model.UpdatedOn = System.DateTime.UtcNow; if (DBEntity.SaveChanges() > 0) { return(GetMarketingById(model.Id, entity.CurrentUserId, entity.BusinessId)); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
private void modify(Func <DBVertice, bool> handler) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc); DBEntity entity = dbControl.FindOne (Query.EQ("HandleValue", this._handleValue)); if (entity == null) { return; } bool changed = false; if (entity.Type == "Tunnel") { DBTunnel tunnel = entity as DBTunnel; changed = handler(tunnel.BasePoints[this._index]); } else if (entity.Type == "TunnelNode") { DBNode node = entity as DBNode; changed = handler(node.Position); } if (changed) { dbControl.Update(entity, Project.Instance.GetActivePropCtl(doc)); } }
private DBEntity ConstructEntityRaw(DbDataReader reader, Type type) { DBEntity entity = Activator.CreateInstance(type) as DBEntity; bool hasGemetry = false; foreach (var property in type.GetProperties()) { if (IsNonColumn(property)) { continue; } if (property.Name == GeometryQuery.GeometryField) { hasGemetry = true; } else if (HasColumn(reader, property)) { var value = GetValue(reader, property); property.SetValue(entity, value, null); } } if (hasGemetry) { MakeGeometry(entity); } return(entity); }
public DataResponse <bool> DeleteReportColumnLookup(int id) { var response = new DataResponse <bool>(); try { base.DBInit(); LookupServiceColumn reportColumn = DBEntity.LookupServiceColumns.Find(id); try { DBEntity.LookupServiceColumns.Remove(reportColumn); if (DBEntity.SaveChanges() > 0) { response.Status = DataResponseStatus.OK; response.Message = "Successfully Deleted."; response.Model = true; } } catch (DbUpdateException ex) { response.Status = DataResponseStatus.InternalServerError; response.Message = "There are some releted item in database, please delete those first."; response.Model = false; } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
public DataResponse SetDefaultService(ServiceToggle entity) { var response = new DataResponse <bool?>(); try { base.DBInit(); var lookupEnrolledServices = DBEntity.LookupEnrolledServices.Where(a => a.BusinessId == entity.BusinessId).ToList(); var model = lookupEnrolledServices.FirstOrDefault(a => a.Id == entity.ServiceId); if (entity.Status == true) { lookupEnrolledServices.ForEach(a => a.Status = false); } model.Status = entity.Status; DBEntity.SaveChanges(); } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
private void Initialize(IAppSetting configuration) { if (!string.IsNullOrEmpty(configuration.Connection)) { this.context = new DBEntity(configuration.Connection); } }
public DataResponse <bool> DeleteFile(int FileId) { var response = new DataResponse <bool>(); try { base.DBInit(); var model = DBEntity.MarketingAttachments.FirstOrDefault(a => a.Id == FileId); if (model != null) { model.IsActive = false; } if (DBEntity.SaveChanges() > 0) { response.Model = true; } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
public DataResponse <EntityRepGroups> Insert(EntityRepGroups entity) { var response = new DataResponse <EntityRepGroups>(); try { base.DBInit(); var model = new Database.RepGroup { BusinessId = entity.BusinessId, RepGroupName = entity.RepGroupName, Description = entity.Description, CreatedBy = entity.CreatedBy, CreatedOn = entity.CreatedOn, IsActive = true, //SalesDirectorId = entity.SalesDirectorId, }; if (base.DBSave(model) > 0) { if (entity.SalesDirectorIds != null && entity.SalesDirectorIds.Count() > 0) { foreach (var item in entity.SalesDirectorIds) { DBEntity.RepgroupManagerMappers.Add(new RepgroupManagerMapper { RepGroupId = model.Id, ManagerId = item, UserRole = (int)RepgroupUserType.Director, CreatedBy = entity.CreatedBy, CreatedOn = entity.CreatedOn }); DBEntity.SaveChanges(); } } if (entity.RepGroupManagerIds != null && entity.RepGroupManagerIds.Count() > 0) { foreach (var item in entity.RepGroupManagerIds) { DBEntity.RepgroupManagerMappers.Add(new RepgroupManagerMapper { RepGroupId = model.Id, ManagerId = item, UserRole = (int)RepgroupUserType.Manager, CreatedBy = entity.CreatedBy, CreatedOn = entity.CreatedOn }); DBEntity.SaveChanges(); } } entity.Id = model.Id; response.CreateResponse(entity, DataResponseStatus.OK); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
public void GetAllNumData() { using (var _db = new DBEntity()) { var _Nums = _db.Digits.ToList(); Assert.IsNotNull(_Nums); } }
/// <summary> Создаёт новый объект и сохраняет его в Хранилище Данных </summary> public DBObject CreateDBObject(DBEntity entity) { id ID = this.GetID(entity); DBObject Result = DBObject.GetEmpty(entity, ID); this.AddDBObject(Result); return(Result); }
public void GetAllPropertyData() { using (var _db = new DBEntity()) { var _Properties = _db.Features.ToList(); Assert.IsNotNull(_Properties); } }
public virtual bool Create(T entity) { using (DBEntity db = new DBEntity()) { db.CreateObjectSet <T>().AddObject(entity); return(db.SaveChanges() > 0); } }
public IEnumerable <UserBrowseViewModel> GetUserBrowse(int roleId) { using (DBEntity db = new DBEntity()) { //ToList立即执行,否则会出错:The ObjectContext instance has been disposed and can no longer be used for operations that require a connection return(db.GetUserBrowse(roleId).ToList()); } }
public void Update(DBEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } UpdateRaw(entity); }
/// <summary> /// 从当前项目的litedb中找到对象 /// </summary> /// <param name="handleValue">要找到对象的句柄数值</param> /// <returns></returns> public static DBEntity GetEntityFromDB(long handleValue) { Document doc = Application.DocumentManager.MdiActiveDocument; DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc); DBEntity dbEntity = dbControl.FindOne(LiteDB.Query.EQ("HandleValue", handleValue)); return(dbEntity); }
public DataResponse <EntityDepartments> Update(EntityDepartments entity) { var response = new DataResponse <EntityDepartments>(); try { base.DBInit(); #region Prepare model var model = DBEntity.Departments.FirstOrDefault(a => a.Id == entity.Id); model.DepartmentName = entity.DepartmentName; model.Description = entity.Description; model.IsActive = entity.IsActive; model.UpdatedOn = entity.UpdatedOn; model.UpdatedBy = entity.UpdatedBy; #endregion if (base.DBSaveUpdate(model) > 0) { IEnumerable <DepartmentPrivilege> departmentPrivilege = DBEntity.DepartmentPrivileges.Where(a => a.DepartmentId == model.Id).ToList(); if (departmentPrivilege.Count() > 0) { DBEntity.DepartmentPrivileges.RemoveRange(departmentPrivilege); DBEntity.SaveChanges(); } if (entity.DepartmentPrivilegeIds != null && entity.DepartmentPrivilegeIds.Count() > 0) { foreach (var item in entity.DepartmentPrivilegeIds) { DBEntity.DepartmentPrivileges.Add(new DepartmentPrivilege { DepartmentId = model.Id, PrivilegeId = item, CreatedBy = model.CreatedBy, CreatedOn = model.CreatedOn, UpdatedBy = entity.UpdatedBy, UpdatedOn = entity.UpdatedOn }); DBEntity.SaveChanges(); } } return(GetDepartmentById(model.Id)); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
/// <summary> /// 获取只更更改坐标的设备 /// </summary> /// <param name="dbEntity"></param> /// <param name="pointFidList"></param> private void GetGraphG3eFID(DBEntity dbEntity, ICollection <long> pointFidList) { var fid = dbEntity.GetValue <long>("G3E_FID"); if (!pointFidList.Contains(fid)) { pointFidList.Add(fid); } }
public IEnumerable <UserViewModel> GetSearchPagingUserView(IEnumerable <UserViewModel> entities, int pageIndex, int pageSize) { using (DBEntity db = new DBEntity()) { return(entities.Skip((pageIndex - 1) * pageSize) .Take(pageSize) .ToList()); } }
public virtual IEnumerable <T> GetSearchPagingInfo(IEnumerable <T> entities, int pageIndex, int pageSize) { using (DBEntity db = new DBEntity()) { return(entities.Skip((pageIndex - 1) * pageSize) .Take(pageSize) .ToList()); } }
public virtual IEnumerable <T> GetPagingInfo(int pageSize) { using (DBEntity db = new DBEntity()) { return(db.CreateObjectSet <T>() .Take(pageSize) .ToList()); } }
public void AddEntity(DBEntity entity) { Entities.Add(entity); if (IgnoreIndex) { return; } AddToIndex(entity); }
public static void ToSaveEntity(RoleEditViewModel viewModel) { using (DBEntity db = new DBEntity()) { Role role = db.Role.GetEntity(m => m.ID == viewModel.ID); role.Name = viewModel.Name; role.Remark = viewModel.Remark; role.IsEnable = int.Parse(viewModel.IsEnable) == 1 ? true : false; db.SaveChanges(); } }
private ResponseMessageNews Approval_PaymentRequest_News(DBEntity.User u, string fromUserName) { ResponseMessageNews news = new ResponseMessageNews(); Article art = new Article(); //art.Description = "您有" + _praSvc.GetPaymentRequestApprovalsByName(u.LoginName).Count + "个要审批的付款申请,点击进入审批列表"; art.Title = "上海益润微信公众号审批中心 - 待审付款申请"; art.PicUrl = "http://180.169.11.53/senlan2.weixin/images/approval.jpg"; art.Url = "http://180.169.11.53/senlan2.weixin/pages/approval_paymentrequest.html?openid=" + fromUserName; news.Articles.Add(art); return news; }