/// <summary> /// Ctr. /// </summary> /// <param name="connection">Parent connection</param> /// <param name="inputStream">Incoming data stream from server</param> /// <param name="holders">Array of holder objects that must be disposed when reader is closed</param> public PqlDataReader(PqlDataConnection connection, BufferedReaderStream inputStream, params IDisposable[] holders) { m_protocolUtility = new PqlProtocolUtility(connection, inputStream, holders); try { m_reader = inputStream.MyReader; m_scheme = m_protocolUtility.ReadResponseHeaders(inputStream); if (m_scheme.Fields != null && m_scheme.Fields.Length > 0) { m_currentRow = new RowData(m_scheme.Fields.Select(x => x.DataType).ToArray()); m_state = ReaderState.New; } else { m_state = ReaderState.Closed; } connection.SwitchToFetchingState(); } catch { m_protocolUtility.Dispose(); throw; } }
public string List(int start, int limit) { MessageResponse msg = new MessageResponse(); DataResponse<TMA.MODEL.Entity.AuditEntry> dataResponse = new DataResponse<TMA.MODEL.Entity.AuditEntry>(); try { dataResponse.Result = AuditEntryDao.findAll(start, limit); dataResponse.Total = AuditEntryDao.Count(); return dataResponse.ToJsonString(); } catch (Exception ex) { msg.Message = ConfigManager.ListErrorMessage; msg.Error = ex.ToString(); File.AppendAllText(ConfigManager.LogPath, msg.ToString()); } System.Threading.Thread.Sleep(int.Parse(ConfigManager.TimeForResponseRequest)); return serialize.Serialize(msg); }
public DataResponse<ChartCollectionDTO> GetTop100_V2(string formatID, DateTime chartDate) { DataResponse<ChartCollectionDTO> result = new DataResponse<ChartCollectionDTO>(); result.Data = ChartService.GetHot100(formatID, chartDate); result.Success = true; return result; }
public DataResponse<ChartResponse> GetTop100_V3(string formatID, DateTime chartDate) { DataResponse<ChartResponse> result = new DataResponse<ChartResponse>(); result.Data = Mapper.Map<ChartCollectionDTO, ChartResponse>(ChartService.GetHot100(formatID, chartDate)); result.Success = true; return result; }
public DataResponse<List<RosterStudent>> GetRosterStudents(int userID,int courseID) { var response = new DataResponse<List<RosterStudent>>(); try { response.Data = _lmsRosterRepository.GetRosterStudents(userID,courseID); } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<Course> ShowCourse(int CourseID) { var response = new DataResponse<Course>(); try { response.Data = _lmsCourseRepository.ShowTeacherCourse(CourseID); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<LmsUser>> GetStudents(int UserID) { var response = new DataResponse<List<LmsUser>>(); try { response.Data = _lmsParentRepository.GetStudents(UserID); } catch (Exception ex) { response.Message = ex.Message; } return response; }
//original method //public DataResponse<UserDetailsToEdit> GetUnassignedUserDetails(int UserID) //{ // var response = new LmsUser(); // //try // //{ // response = _lmsUserRepository.GetUnassignedUserDetails(UserID); // // response.Success = true; // //} // //catch (Exception ex) // //{ // // response.Message = "User doesn't exist"; // //} // return response; //} public DataResponse<LmsUser> GetUnassignedUserDetails(int UserID) { var response = new DataResponse<LmsUser>(); try { response.Data = _lmsUserRepository.GetUnassignedUserDetails(UserID); response.Success = true; } catch (Exception ex) { response.Message = "User doesn't exist"; } return response; }
public DataResponse<List<RosterAssignment>> CourseAssignmentGrades(int CourseID) { var response = new DataResponse<List<RosterAssignment>>(); try { response.Data = _lmsStudentCourseRepository.CourseAssignmentGrades(CourseID); response.Success = true; } catch (Exception ex) { response.Message = "No grades available"; } return response; }
public DataResponse<List<TeacherCourses>> GetTeacherCourses(int userID) { var response = new DataResponse<List<TeacherCourses>>(); try { response.Data = _lmsCourseRepository.GetTeacherCourses(userID); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<Course> GetCourseById(int id) { var response = new DataResponse<Course>(); try { response.Data = _courseRepository.GetCourseById(id); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<RosterSearchResult>> RosterUserSearch(RosterStudent student) { var response = new DataResponse<List<RosterSearchResult>>(); try { response.Data = _lmsRosterRepository.RosterUserSearch(student); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<StudentCourse>> GetStudentCourses(int UserID) { var response = new DataResponse<List<StudentCourse>>(); try { response.Data = _lmsStudentCourseRepository.GetStudentCourses(UserID); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<string> GetLogo() { var response = new DataResponse<string>(); try { response.Data = "~/Uploads/" + _repo.GetLogo(); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return response; }
public string Find(int start, int limit, string field, string value) { MessageResponse msg = new MessageResponse(); DataResponse<TMA.MODEL.Entity.Person> dataResponse = new DataResponse<TMA.MODEL.Entity.Person>(); try { dataResponse.Result = PersonsDao.findBy(start, limit, field, value); dataResponse.Total = PersonsDao.Count(field, value); return dataResponse.ToJsonString(); } catch (Exception ex) { msg.Message = ConfigManager.ListErrorMessage; msg.Error = ex.ToString(); } return serialize.Serialize(msg); }
/// <summary> /// Writes data to output stream. /// </summary> public void WriteTo(Stream stream) { var dataResponse = new DataResponse(m_errorCode, m_exception == null ? "Unknown error" : m_exception.Message); if (m_writeBlockHeaderAndStreamEnd) { using (var buffer = new MemoryStream()) { Serializer.SerializeWithLengthPrefix(buffer, dataResponse, PrefixStyle.Base128); var blockSize = checked((Int32) buffer.Length); stream.Write(RowData.BlockHead, 0, RowData.BlockHead.Length); stream.Write(BitConverter.GetBytes(blockSize), 0, sizeof (Int32)); stream.Write(buffer.ToArray(), 0, blockSize); stream.Write(RowData.StreamEnd, 0, RowData.StreamEnd.Length); } } else { Serializer.SerializeWithLengthPrefix(stream, dataResponse, PrefixStyle.Base128); } }
public DataResponse<int> CreateUser(LmsUser user) { var response = new DataResponse<int>(); var validation = Validator.Validate(user); if (!validation.Success) { response.Message = validation.Message; return response; } try { response.Data = _lmsUserRepository.CreateUser(user); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse <EntityNotificationType> Insert(EntityNotificationType entity) { var response = new DataResponse <EntityNotificationType>(); try { base.DBInit(); var model = new Database.LookupNotificationType { Title = entity.Title, NotificationKey = entity.NotificationKey, CreatedBy = entity.CreatedBy, CreatedOn = System.DateTime.UtcNow }; if (base.DBSave(model) > 0) { 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 DataResponse DeleteRegion(string uuid) { DataResponse insertResponse = DataResponse.RESPONSE_ERROR; foreach (IGridDataPlugin plugin in _plugins) { //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); try { //Nice are we not using multiple databases? //MySQLGridData mysqldata = (MySQLGridData)(plugin); //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); insertResponse = plugin.DeleteProfile(uuid); } catch (Exception) { m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name); //MainLog.Instance.Warn("storage", e.ToString()); insertResponse = DataResponse.RESPONSE_ERROR; } } return(insertResponse); }
public IHttpActionResult CreateCountry(CountryModel model) { var response = new DataResponse <EntityCountry>(); if (ModelState.IsValid) { var entityCountry = new EntityCountry(); entityCountry.CountryName = model.CountryName; entityCountry.CountryCode = model.CountryCode; entityCountry.IsActive = model.IsActive; entityCountry.CreatedBy = CurrentUserId; response = repository.Insert(entityCountry); return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
public IActionResult UserInfo([FromBody] object value) { var jo = JToken.Parse(value.ToString()); var id = jo["id"].ToString(); var ten_day_du = jo["ten_day_du"].ToString(); DataResponse res = new DataResponse(); try { res.success = true; if (string.IsNullOrEmpty(ten_day_du)) { res.msg = "Chưa nhập tên đầy đủ"; res.success = false; } if (!res.success) { return(Ok(res)); } if (is_admin || id == user) { res.success = UserRepository.Instance.UserInfo(id, ten_day_du); } if (res.success) { res.msg = "Thay đổi thành công"; } } catch (Exception ex) { res.msg = ex.StackTrace; res.success = false; } return(Ok(res)); }
public override void Handle(object sender, Packet packet) { SCData packetImpl = (SCData)packet; //Log.Info("Receive packet '{0}'.", packetImpl.Id.ToString()); DataResponse dataResponse = (DataResponse)packetImpl.GetExtensionObject(); for (int i = 0; i < dataResponse.Objs.Count; i++) { ObjData objData = dataResponse.Objs[i]; for (int j = 0; j < GameData.g_listAircreaft.Count; j++) { Aircraft aircraft = GameData.g_listAircreaft[j]; if (aircraft.Id == objData.SerialId) { aircraft.m_fixv3RenderPosition = new FixVector3( Fix64.FromRaw(objData.X), Fix64.FromRaw(objData.Y), Fix64.FromRaw(objData.Z)); aircraft.r_isFire = objData.IsFire; } } } }
public DataResponse <string> GetLocalJson([FromBody] DataRequest <Guid> request) { if (request == null) { return(ResponseBase.InvalidInput <DataResponse <string> >("参数错误")); } try { if (!request.IsValid(HostRoot.Instance.UserSet.GetUser, ClientIp, out DataResponse <string> response)) { return(response); } string localJsonFileFullName = SpecialPath.GetMineWorkLocalJsonFileFullName(request.Data); string data = string.Empty; if (File.Exists(localJsonFileFullName)) { data = File.ReadAllText(localJsonFileFullName); } return(DataResponse <string> .Ok(data)); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError <DataResponse <string> >(e.Message)); } }
public async Task <DataResponse <SobremesaDTO> > GetData() { DataResponse <SobremesaDTO> response = new DataResponse <SobremesaDTO>(); if (response.Erros.Count > 0) { response.Sucesso = false; return(response); } try { var teste = await this._context.Sobremesas.ToListAsync(); response.Sucesso = true; response.Data = teste; return(response); } catch (Exception ex) { File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace); throw new Exception("Erro no banco de dados, contate o administrador."); } }
public async Task <ServiceResponse <SeriesResponse> > GetSeriesById(int?characterId) { ServiceResponse <SeriesResponse> serviceResponse = new ServiceResponse <SeriesResponse>(); DataResponse <SeriesResponse> dataResponse = new DataResponse <SeriesResponse>(); try { this.QueryDataId(Convert.ToInt32(characterId)); List <SeriesResponse> seriesResponses = new List <SeriesResponse>(); foreach (var itemSerie in this.series) { SeriesResponse serieResponse = new SeriesResponse(); serieResponse.id = itemSerie.Id; serieResponse.title = itemSerie.Title; serieResponse.description = itemSerie.Description; serieResponse.resourceURI = itemSerie.ResourceUri; serieResponse.modified = Convert.ToString(itemSerie.Modified); serieResponse.startYear = Convert.ToString(itemSerie.StartYear); serieResponse.endYear = Convert.ToString(itemSerie.EndYear); serieResponse.rating = Convert.ToString(itemSerie.Rating); serieResponse.modified = Convert.ToString(itemSerie.Modified); seriesResponses.Add(serieResponse); } dataResponse.Results = seriesResponses; serviceResponse.data = dataResponse; return(serviceResponse); } catch (Exception) { return(serviceResponse); } }
public async Task <DataResponse <BrandDTO> > GetAll() { DataResponse <BrandDTO> response = new DataResponse <BrandDTO>(); try { using (var context = _context) { response.Data = await context.Brands.ToListAsync(); if (response.Data.Count > 0) { response.Success = true; return(response); } response.Errors.Add("Marcas não encontradas"); return(response); } } catch (Exception ex) { throw ex; } }
public DataResponse <EntityDegrees> UpdateDegree(EntityDegrees entity) { var response = new DataResponse <EntityDegrees>(); try { base.DBInit(); #region Prepare model var model = DBEntity.LookupDegrees.FirstOrDefault(a => a.Id == entity.Id); model.DegreeName = entity.DegreeName; model.ShortCode = entity.ShortCode; model.IsActive = entity.IsActive; model.UpdatedOn = entity.UpdatedOn; model.UpdatedBy = entity.UpdatedBy; #endregion if (base.DBSaveUpdate(model) > 0) { return(GetDegreeById(model.Id)); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
/// <summary> /// Retorna uma resposta com os padrões da API /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value"></param> /// <param name="message"></param> /// <param name="typeResult"></param> /// <returns></returns> protected internal static OkObjectResult ApiResponse <T>(T value, string message = "", CustomTypeResultEnum typeResult = CustomTypeResultEnum.Success) { if (message.IsNullOrEmpty()) { if (typeResult == CustomTypeResultEnum.Success || typeResult == CustomTypeResultEnum.Warning) { message = "Ação efetuada com sucesso."; } if (typeResult == CustomTypeResultEnum.Error || typeResult == CustomTypeResultEnum.CriticalError) { message = "Não foi possível efetuar a ação solicitada."; } } var res = new DataResponse <T> { Message = message, Content = value, TypeResult = typeResult }; return(new OkObjectResult(res)); }
public async Task <object> GetAttendance(int id) { try { DataResponse <Attendance> response = await _service.GetByID(id); if (response.HasError()) { return(response); } if (await this.CheckPermissionToReadAttendance(response.Data[0])) { return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public DataResponse <EntityMarketing> GetMarketingById(int MarketingId, int currentUserId, int?currentBusinessId) { var response = new DataResponse <EntityMarketing>(); try { base.DBInit(); var query = DBEntity.MarketingDocuments.Where(a => a.Id == MarketingId).Select(a => new EntityMarketing { Id = a.Id, BusinessId = a.BusinessId, Name = a.Name, Description = a.Description, CategoryId = a.CategoryId, DocumentTypeId = a.DocumentTypeId, CreatedBy = a.CreatedBy, CreatedOn = a.CreatedOn, UpdatedBy = a.UpdatedBy, UpdatedOn = a.UpdatedOn, FilesList = a.MarketingAttachments.Where(c => c.IsActive != false).Select(d => new FilesUploaded { Id = d.Id, FileName = d.FileName }), }); response = GetFirst <EntityMarketing>(query); } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
private async Task <Project> GetOrCreateAsync() { Project project = await FindProject(key : "HR"); if (project == null) { var request = new ProjectRequest { ProjectKey = "HR", Fields = new Dictionary <string, object> { [EntityField.Name] = "Recruiting" } }; MetaResponse createdResponse = await _service.CreateAsync(request); DataResponse <Project> dataResponse = await _service.GetAsync(createdResponse.Meta.Id.Value); project = dataResponse.Data; } return(project); }
public IActionResult IndexCongTy([FromBody] object value, string id) { DataResponse res = new DataResponse(); try { string id_cong_ty = ""; var cong_ty = Newtonsoft.Json.JsonConvert.DeserializeObject <CongTy>(value.ToString()); cong_ty.id_cong_ty = id_cong_ty; cong_ty.id_cong_ty = id; SetMetaData(cong_ty, false); if (string.IsNullOrEmpty(cong_ty.ten_cong_ty)) { res.success = false; res.msg = "Chưa nhập tên công ty"; } else { var cong_ty_tmp = BL.CongTyBL.GetCongTyByName(app_id, cong_ty.ten_cong_ty); if (cong_ty_tmp != null) { res.success = true; res.data = cong_ty_tmp.id_cong_ty; } else { res.success = QLCUNL.BL.CongTyBL.IndexCongTy(cong_ty, out id_cong_ty); res.data = id_cong_ty; } } } catch (Exception ex) { res.msg = ex.Message; res.success = false; } return(Ok(res)); }
public async Task <ServiceResponse <CharacterResponse> > GetCharacterById(int?characterId) { ServiceResponse <CharacterResponse> serviceResponse = new ServiceResponse <CharacterResponse>(); DataResponse <CharacterResponse> dataResponse = new DataResponse <CharacterResponse>(); try { this.QueryDataId(Convert.ToInt32(characterId)); List <CharacterResponse> lCharacters = new List <CharacterResponse>(); foreach (var itemCharacter in characters) { CharacterResponse characterResponse = new CharacterResponse(); characterResponse.Id = itemCharacter.Id; characterResponse.Name = itemCharacter.Name; characterResponse.Description = itemCharacter.Description; characterResponse.Modified = Convert.ToDateTime(itemCharacter.Modified); characterResponse.ResourceURI = itemCharacter.ResourceUri; characterResponse.Comics = AddComics(comics.Where(item => item.Equals(itemCharacter.Id))); characterResponse.Series = AddSeries(series.Where(item => item.Equals(itemCharacter.Id))); characterResponse.Stories = AddStories(stories.Where(item => item.Equals(itemCharacter.Id))); characterResponse.Events = AddEvents(events.Where(item => item.Equals(itemCharacter.Id))); lCharacters.Add(characterResponse); } dataResponse.Results = lCharacters; serviceResponse.data = dataResponse; return(serviceResponse); } catch (Exception) { return(serviceResponse); } }
public IActionResult IndexManyLienHe([FromBody] object value) { DataResponse res = new DataResponse(); List <CongTy> lst = new List <CongTy>(); //lst.Add(new CongTy() { ten_cong_ty = "#Không rõ", lien_he = new List<NguoiLienHe>() { new NguoiLienHe() { chuc_vu = "oong A" } } }); //lst.Add(new CongTy() { ten_cong_ty = "#Không rõ", lien_he = new List<NguoiLienHe>() { new NguoiLienHe() { chuc_vu = "oong B" } } }); try { var list_cong_ty = JsonConvert.DeserializeObject <List <CongTy> >(value.ToString()); foreach (var n in list_cong_ty) { foreach (var item in n.lien_he) { if (!string.IsNullOrEmpty(item.chuc_vu)) { n.thuoc_tinh = new List <int>() { -1 }; SetMetaData(n, false); lst.Add(n); } } } var count = CongTyBL.IndexMany(lst); res.success = count > 0; } catch (Exception ex) { res.msg = ex.Message; res.success = false; } return(Ok(res)); }
public DataResponse <FilmeResultSet> GetFilmesByGenero(int genero) { DataResponse <FilmeResultSet> response = new DataResponse <FilmeResultSet>(); List <FilmeResultSet> filmes = new List <FilmeResultSet>(); if (genero <= 0) { response.Sucesso = false; response.Erros.Add("Gênero deve ser informado."); return(response); } try { using (LocadoraDbContext db = new LocadoraDbContext()) { var data = db.Filmes.Where(f => f.Genero.ID == genero).Join(db.Generos, f => f.Genero.ID, g => g.ID, (f, g) => new FilmeResultSet { ID = f.ID, Nome = f.Nome, Genero = g.Nome, Classificacao = f.Classificacao }).ToList(); foreach (var item in data) { filmes.Add(item); } } response.Sucesso = true; } catch (Exception ex) { response.Erros.Add("Erro no banco de dados, contate o administrador."); response.Sucesso = false; File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace); } response.Data = filmes; return(response); }
public IActionResult UpdateLog([FromBody] List <LogSendMail> value) { DataResponse res = new DataResponse(); try { //var list_cong_ty = JsonConvert.DeserializeObject<List<LogSendMail>>(value.ToString()); //var log = JsonConvert.DeserializeObject<LogSendMail>(value.ToString()); if (value.Count > 0) { foreach (var item in value) { SetMetaData(item, true); res.success = QLCUNL.BL.LogSendMailBL.UpdateStatus(item.Id, item.Status); } } } catch (Exception ex) { res.msg = ex.StackTrace; res.success = false; } return(Ok(res)); }
public DataResponse <List <ClientData> > RefreshClients([FromBody] MinerIdsRequest request) { if (request == null || request.ObjectIds == null) { return(ResponseBase.InvalidInput <DataResponse <List <ClientData> > >("参数错误")); } if (!HostRoot.Instance.HostConfig.IsPull) { return(ResponseBase.InvalidInput <DataResponse <List <ClientData> > >("服务端配置为不支持刷新")); } try { if (!request.IsValid(HostRoot.Instance.UserSet.GetUser, ClientIp, out DataResponse <List <ClientData> > response)) { return(response); } var data = HostRoot.Instance.ClientSet.RefreshClients(request.ObjectIds); return(DataResponse <List <ClientData> > .Ok(data)); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError <DataResponse <List <ClientData> > >(e.Message)); } }
public DataResponse <EntityLeadSource> Insert(EntityLeadSource entity) { var response = new DataResponse <EntityLeadSource>(); try { base.DBInit(); var model = new Database.LookupLeadSource { LeadSource = entity.LeadSource, CreatedBy = entity.CreatedBy, CreatedOn = System.DateTime.UtcNow, IsActive = entity.IsActive }; if (base.DBSave(model) > 0) { 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 IHttpActionResult InsertReportColumnData(EntityReportColumn model) { string[] reservedFields = new string[] { "Id", "BusinessId", "ServiceId", "PatientId", "PatientFirstName", "PatientLastName", "SpecimenCollectionDate", "SpecimenReceivedDate", "ReportedDate", "PracticeId", "PracticeName", "ProviderId", "ProviderFirstName", "ProviderLastName", "ProviderNpi", "RepId", "RepFirstName", "RepLastName", "CreatedOn", "CreatedBy", "UpdatedOn", "UpdatedBy", "OldId", "IsColumnValuesImported", "OldReportId" }; if (reservedFields.Contains(model.ColumnName)) { var error = string.Format("{0} is reserved, please choose another column name", model.ColumnName); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = error })); } var response = new DataResponse <EntityReportColumn>(); if (ModelState.IsValid) { model.UpdatedBy = model.CreatedBy = CurrentUserId; model.BusinessId = CurrentBusinessId.Value; if (model.Id > 0) { response = new RepositoryEnrolledServices().UpdateRportColumn(model); } else { response = new RepositoryEnrolledServices().InsertReportColumn(model); } return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
public override bool Process(Request request, ServerConfig config, out DataResponse dataResponse) { var schema = config.Schemas.FirstOrDefault(s => s.Id == request.Payload.Schema); if (schema != null) { var connection = config.Connections.FirstOrDefault(c => c.Id == schema.Connection); if (connection != null) { var dataAccess = DataFactory.Find(connection); if (dataAccess != null) { var dataList = dataAccess.Process(request, connection, schema); dataResponse = Utils.CreateResponse <DataResponse>(true, request.Tag); dataResponse.Payload = new Payload { Schema = request.Payload.Schema, Data = dataList }; return(true); } } } dataResponse = null; return(true); }
public void ToStringSerialisesAllValues() { DataResponse response = new DataResponse(); response.ErrorMessages.Add(new ErrorMessage("Error 1")); response.ErrorMessages.Add(new ErrorMessage("Error 2")); response.RequestIdentifier = "request"; response.Result = ResponseResult.Success; response.Timestamp = DateTime.Now; response.Data = "new data"; string actual = response.ToString(); string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture, "<dataResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" result=\"{1}\">" + "<error>Error 1</error>" + "<error>Error 2</error>" + "<data>{3}</data>" + "</dataResponse>", response.RequestIdentifier, response.Result, response.Timestamp, response.Data); Assert.AreEqual(expected, actual); }
private string Notify(string response, DataResponse data, JObject input, ILambdaContext context) { string responseUrl = input["ResponseURL"].ToString(); string stackId = input["StackId"].ToString(); string requestId = input["RequestId"].ToString(); string logicalResourceId = input["LogicalResourceId"].ToString(); CloudFormationResponse cf = new CloudFormationResponse(); cf.Status = response; //Values should be either SUCCESS or FAILED cf.PhysicalResourceId = context.LogStreamName; cf.StackId = stackId; cf.RequestId = requestId; cf.LogicalResourceId = logicalResourceId; //This can be the dataset you wish to return cf.Data = data; Console.WriteLine(JObject.FromObject(cf).ToString(Newtonsoft.Json.Formatting.Indented)); var t = PostToS3Async(responseUrl, cf); t.Wait(); return(t.Result.ToString()); }
public async Task <object> GetStudent(int id) { try { DataResponse <Student> response = (await _service.GetByID(id)); if (response.HasError()) { return(response); } if (await CheckPermisionToGetStudent(response.Data[0])) { return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public void GetAllResource(DataRequest request, DataResponse result, DataProvider datasource) { string parent_id = request["P0"]; if (string.IsNullOrEmpty(parent_id)) { parent_id = "0"; } int _isu = 1; int _uid = 0; string _isuser = request["P1"]; string _userid = request["P2"]; if (!string.IsNullOrEmpty(_isuser)) { _isu = int.Parse(_isuser); } if (!string.IsNullOrEmpty(_userid)) { _uid = int.Parse(_userid); } result.Value = ToJson(new SourceOP(request.LogIn).GetAllResource(int.Parse(parent_id), _isu, _uid)); }
public IActionResult ViewAd(string id, string id_tk) { DataResponse res = new DataResponse(); try { var quang_cao = QuangCaoRepository.Instance.GetById(id, new string[] { "ten_hien_thi", "link_dich", "link_hien_thi", "tieu_de_1", "tieu_de_2", "mo_ta_1", "mo_ta_2" }); res.success = quang_cao != null; if (res.success) { res.data = quang_cao; //TEST Tăng view của quảng cáo và của từ khóa /*QuangCaoRepository.Instance.IncreaseView(id); * TuKhoaRepository.Instance.IncreaseView(id_tk);*/ } } catch (Exception ex) { res.msg = ex.Message; res.success = false; } return(Ok(res)); }
public async Task <DataResponse <User> > Authenticate(User user) { DataResponse <User> r = new DataResponse <User>(); try { DataResponse <User> getUserResponse = await _userRepo.GetByEmail(user.Email); if (getUserResponse.HasError()) { return(getUserResponse); } User findedUser = getUserResponse.Data[0]; if (!await new HashUtils().CompareHash(user.Password, findedUser.Password)) { r.Success = false; r.ErrorList.Add("Invalid password"); return(r); } r.Data.Add(findedUser); r.Success = true; return(r); } catch (Exception e) { StringBuilder sb = new StringBuilder(); log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString()); r.Success = false; r.ErrorList.Add("Error on user authentication"); return(r); } }
public IActionResult ChangePassword([FromBody] object value) { DataResponse res = new DataResponse(); try { var user_change_pass = Newtonsoft.Json.JsonConvert.DeserializeObject <User>(value.ToString()); //user_change_pass.id_user = app_id + "_" + user_change_pass.id_user; user_change_pass.id_user = user; SetMetaData(user_change_pass, true); if (!string.IsNullOrEmpty(user_change_pass.password)) { user_change_pass.password = XMedia.XUtil.Encode(user_change_pass.password); user_change_pass.old_password = XMedia.XUtil.Encode(user_change_pass.old_password); } res.success = QLCUNL.BL.UserBL.UpdatePassWord(user_change_pass.id_user, user_change_pass.password, user_change_pass.old_password, out string msg); res.msg = msg; } catch (Exception ex) { res.msg = ex.StackTrace; res.success = false; } return(Ok(res)); }
//public DataResponse<LmsUser> UpdateUserDetails(LmsUser user) public DataResponse<LmsUser> UpdateUserDetails(LMSUserUpdateRequest user) { var response = new DataResponse<LmsUser>(); try { response.Data = _lmsUserRepository.UpdateUserDetails(user); response.Success = true; } catch (Exception ex) { response.Message = "User not updated"; } return response; }
public void Process(ISemanticProcessor proc, IMembrane membrane, DataResponse resp) { byte[] utf8data = resp.Data.ToBase64().to_Utf8(); resp.Context.Response.StatusCode = resp.StatusCode; resp.Context.Response.ContentEncoding = Encoding.UTF8; resp.Context.Response.ContentLength64 = utf8data.Length; resp.Context.Response.OutputStream.Write(utf8data, 0, utf8data.Length); resp.Context.Response.Close(); }
public string Find(int start, int limit, string field, string value) { MessageResponse msg = new MessageResponse(); DataResponse<TMA.MODEL.Entity.Diary> dataResponse = new DataResponse<TMA.MODEL.Entity.Diary>(); try { decimal numberParam; if (decimal.TryParse(value, out numberParam)) { dataResponse.Result = DiariesDao.findBy(start, limit, field, numberParam); dataResponse.Total = DiariesDao.Count(field, numberParam); return dataResponse.ToJsonString(); } else { if (field.Contains("Person")) { if (field.Contains("Company")) { dataResponse.Result = DiariesDao.findCompanyBy(start, limit, field.Split('.')[2], value); dataResponse.Total = DiariesDao.CountCompany(field.Split('.')[2], value); return dataResponse.ToJsonString(); } else { dataResponse.Result = DiariesDao.findPersonBy(start, limit, field.Split('.')[1], value); dataResponse.Total = DiariesDao.CountPerson(field.Split('.')[1], value); return dataResponse.ToJsonString(); } } if (field.Contains("Functionary")) { if (field.Contains("Name")) { dataResponse.Result = DiariesDao.findFunctionaryBy(start, limit, field.Split('.')[2], value); dataResponse.Total = DiariesDao.CountFunctionary(field.Split('.')[2], value); return dataResponse.ToJsonString(); } } else { dataResponse.Result = DiariesDao.findBy(start, limit, field, value); dataResponse.Total = DiariesDao.Count(field, value); return dataResponse.ToJsonString(); } } } catch (Exception ex) { msg.Message = ConfigManager.ListErrorMessage; msg.Error = ex.ToString(); File.AppendAllText(ConfigManager.LogPath, msg.ToString()); } return serialize.Serialize(msg); }
public string List(int start, int limit) { MessageResponse msg = new MessageResponse(); DataResponse<TMA.MODEL.Entity.Diary> dataResponse = new DataResponse<TMA.MODEL.Entity.Diary>(); try { DateTime today = System.DateTime.Today; dataResponse.Result = DiariesDao.findBy(start, limit, "DateDiary", today.ToString("yyyy-MM-dd")); dataResponse.Total = DiariesDao.Count("DateDiary", today.ToString("yyyy-MM-dd")); return dataResponse.ToJsonString(); } catch (Exception ex) { msg.Message = ConfigManager.ListErrorMessage; msg.Error = ex.ToString(); File.AppendAllText(ConfigManager.LogPath, msg.ToString()); } System.Threading.Thread.Sleep(int.Parse(ConfigManager.TimeForResponseRequest)); return serialize.Serialize(msg); }
public DataResponse<List<GradeLevel>> GetAllGradeLevels() { var response = new DataResponse<List<GradeLevel>>(); try { response.Data = _gradeLevelRepository.GetAllGradeLevels(); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<Assignment> GetAssignmentById(int assignmentId) { var response = new DataResponse<Assignment>(); try { response.Data = _assignmentRepository.GetAssignmentById(assignmentId); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } if (response.Data == null) { response.Success = false; response.Message = "That assignment does not exist"; } return response; }
public DataResponse<List<LmsUser>> UserSearch(SearchRequest request) { var response = new DataResponse<List<LmsUser>>(); try { response.Data = _lmsUserRepository.SearchUsers(request); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return response; }
private DataResponse<string> UpdateOverallGrade(int rosterId) { var response = new DataResponse<string>(); try { var results = _assignmentRepository.GetGradedAssignments(rosterId); if (results.Count == 0) { response.Data = null; } else { var avg = results.Average(a => a.Percentage); var newGrade = ConvertPercentToGrade(avg); response.Data = newGrade; _assignmentRepository.UpdateOverallGrade(rosterId, newGrade); } response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<LmsUser>> GetUnassignedUsers() { var response = new DataResponse<List<LmsUser>>(); try { response.Data = _lmsUserRepository.GetUnassignedUsers(); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<LmsUser>> GetStudentsByParentId(int id) { var response = new DataResponse<List<LmsUser>>(); try { response.Data = _lmsUserRepository.GetStudentsByParentId(id).OrderBy(s=>s.FirstName).ToList(); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<LmsUser> GetByAspNetId(string aspNetId) { var response = new DataResponse<LmsUser>(); try { response.Data = _lmsUserRepository.GetUserByAspId(aspNetId); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<ParentStudentInfo>> GetAllStudentInfoByParentId(int id) { var response = new DataResponse<List<ParentStudentInfo>>(); try { var students = _lmsUserRepository.GetStudentsByParentId(id).OrderBy(s => s.FirstName).ToList(); response.Data = new List<ParentStudentInfo>(); foreach (var student in students) { var item = new ParentStudentInfo(); item.Student = student; item.CoursesListItems = _courseRepository.GetCoursesByStudentId(student.UserId); response.Data.Add(item); } response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public DataResponse<List<CourseFront>> GetCoursesByTeacherId(int id) { var response = new DataResponse<List<CourseFront>>(); try { response.Data = _courseRepository.GetCoursesByTeacherId(id); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return response; }