public async Task <IActionResult> GetList( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "audio")] HttpRequest req, ILogger log) { try { // get the user ID if (!await this.UserAuthenticationService.GetUserIdAsync(req, out var userId, out var responseResult).ConfigureAwait(false)) { return(responseResult); } // list the audio notes var blobs = await this.BlobRepository.ListBlobsInFolderAsync(AudioBlobContainerName, userId).ConfigureAwait(false); var blobSummaries = blobs .Select(b => new GetListItem { Id = b.BlobName.Split('/')[1], Preview = b.Properties.ContainsKey(TranscriptMetadataName) ? b.Properties[TranscriptMetadataName].Truncate(TranscriptPreviewLength) : string.Empty, }) .ToList(); var audioNoteSummaries = new GetListResponse(); audioNoteSummaries.AddRange(blobSummaries); return(new ObjectResult(audioNoteSummaries)); } catch (Exception ex) { log.LogError(ex, UnhandledExceptionError); throw; } }
//public GetListResponse<FtpFailed> GetFtpFailedListByNotificationID(IDRequest request) //{ // try // { // return GenericGetRelated<FtpFailed>("NotificationID", request.ID, false); // } // catch (Exception ex) // { // return ErrorHandler.Handle<GetListResponse<FtpFailed>>(ex); // } //} public GetListResponse<FtpFailed> GetFtpFailedDueList(IDRequest request) { var result = new GetListResponse<FtpFailed>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<FtpFailed>()); object[] args = new object[] { DateTime.UtcNow }; using (IDataReader dr = db.ExecuteDataReader("SPGetFtpFailedDueList", args)) { while (dr.Read()) { result.List.Add(GetFromData<FtpFailed>(dr)); } return result; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<FtpFailed>>(ex); } }
public GetListResponse<Report> GetReportListByReportTypeID(IDRequest request) { Initialize(); var response = new GetListResponse<Report>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Report>()); object[] args = new object[] { request.ID }; using (IDataReader dr = db.ExecuteDataReader("SPGetReportListByReportTypeID", args)) { response.List = new List<Report>(); while (dr.Read()) { var report = GetFromData<Report>(dr); SetAccessInformation(report); response.List.Add(report); } response.Status = true; return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Report>>(ex); } }
public GetListResponse<Contact> GetContactListByParentId(IDRequest request) { try { var response = new GetListResponse<Contact>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Contact>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); int topn = request.Get<int>("TopN", int.MaxValue); int contactType = request.Get<int>("ContactType", 0); Guid parentId = request.Get("ParentId", Guid.Empty); using (IDataReader dr = db.ExecuteDataReader("SPGetContactListByParentId", includeInactive, request.CompanyID, topn, contactType, parentId)) { response.List = new List<Contact>(); while (dr.Read()) { response.List.Add(GetFromData<Contact>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Contact>>(ex); } }
public GetListResponse<BillableFeature> GetBillableFeaturesByCompanyID(IDRequest request) { try { var response = new GetListResponse<BillableFeature>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<BillableFeature>()); object[] args = new object[] { request.ID }; using (IDataReader dr = db.ExecuteDataReader("SPGetBillableFeaturesByCompanyID", args)) { response.List = new List<BillableFeature>(); while (dr.Read()) { response.List.Add(GetFromData<BillableFeature>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<BillableFeature>>(ex); } }
public async Task <IHttpActionResult> GetListAsync([FromUri] int id, [FromUri] int page = 0, [FromUri] int size = 10) { Post post = await UnitOfWork.GetPostRepository().SelectFirstOrDefaultAsync(p => p.Id == id && p.Status == Enums.PostStatus.Published) ?? throw new ActionCannotBeExecutedException(ExceptionMessages.PostNotFound); SelectOptions <Comment> options = new SelectOptions <Comment> { OrderBy = p => p.OrderByDescending(t => t.Id), Take = size, Skip = page * size }; StatusSpecification specification = new StatusSpecification(Enums.CommentStatus.Active); ICommentRepository repo = UnitOfWork.GetCommentRepository(); IEnumerable <Comment> list = await repo.SelectAsync(specification, options); int resultsCount = await repo.CountAsync(specification); Paging paging = new Paging(page: page, count: resultsCount, size: size); GetListResponse response = new GetListResponse(paging) { Items = list.Select(c => new GetListResponseItem { Id = c.Id, UserId = c.UserId, Comment = c.Body, FirstName = c.User.FirstName, Image = c.User.Image }) }; return(Ok(response)); }
public HttpResponseMessage Get() { var response = new GetListResponse<DeclarationDataRow>(); try { var list = declarationDataRepository.GetList(new ListRequest()); response.IsSuccess = true; response.Message = "数据获取成功"; response.Entities = list; return BuildSuccessResult(HttpStatusCode.OK, response); } catch (ValidationError err) { err.Log(); response.IsSuccess = false; response.Message = "登录已过期,请重新登录"; return BuildSuccessResult(HttpStatusCode.Forbidden, response); } catch (Exception ex) { ex.Log(); response.IsSuccess = false; response.Message = "服务器发生异常"; return BuildSuccessResult(HttpStatusCode.InternalServerError, response); } }
public void GetList_Valid() { var jobseekerID = 1; var searchType = ReferralHistoryItemType.All; var request = new GetListRequest { JobseekerId = jobseekerID, SearchType = searchType.GetFlag() }; var response = new GetListResponse { FirstGivenName = "firstname", ListItems = new[] { new ListItem { Type = "A", DisSiteCode = "site" } }, ExecutionResult = new ExecutionResult { Status = ExecuteStatus.Success } }; var outModel = MappingEngine.Map <ReferralHistoryModel>(response); mockUserService.Setup(m => m.Roles).Returns(new[] { "DAD" }); mockMappingEngine.Setup(m => m.Map <ReferralHistoryModel>(response)).Returns(outModel); mockReferralHistoryWcf.Setup(m => m.GetList(It.IsAny <GetListRequest>())).Returns(response); var result = SystemUnderTest().GetList(jobseekerID, searchType); Assert.IsTrue(result.JobseekerID == jobseekerID); Assert.IsTrue(result.JobseekerFirstName == outModel.JobseekerFirstName); Assert.IsTrue(result.List.Count() == outModel.List.Count()); Assert.IsTrue(result.List.First().Site == outModel.List.First().Site); mockReferralHistoryWcf.Verify(m => m.GetList(It.IsAny <GetListRequest>()), Times.Once()); mockMappingEngine.Verify(m => m.Map <ReferralHistoryModel>(response), Times.Once()); }
public GetListResponse<ApplicationFeature> GetApplicationFeatureListByOwnerID(IDRequest request) { try { var response = new GetListResponse<ApplicationFeature>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<ApplicationFeature>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); int topn = request.Get<int>("TopN", int.MaxValue); Guid ownerid = Guid.Empty; request.Get<Guid>("OwnerID", out ownerid); using (IDataReader dr = db.ExecuteDataReader("SPGetApplicationFeatureListByOwnerID", includeInactive, topn, request.CompanyID, ownerid)) { response.List = new List<ApplicationFeature>(); while (dr.Read()) { response.List.Add(GetFromData<ApplicationFeature>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<ApplicationFeature>>(ex); } }
public GetListResponse<SMSPending> GetSMSPendingList(IDRequest request) { var result = new GetListResponse<SMSPending>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SMSPending>()); int numRecords = 100; //process 100 SMS at a time if (request.ContainsKey("NumRecords")) //! IM-2342 int.TryParse(request["NumRecords"], out numRecords); object[] args = new object[] { numRecords }; using (IDataReader dr = db.ExecuteDataReader("SPGetSMSPendingList", args)) { while (dr.Read()) { result.List.Add(GetFromData<SMSPending>(dr)); } return result; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<SMSPending>>(ex); } }
public GetListResponse<NotificationItem> GetNotificationTemplateList(IDRequest request) { try { var response = new GetListResponse<NotificationItem>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<NotificationItem>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); object[] args = new object[] { includeInactive, request.ID }; using (IDataReader dr = db.ExecuteDataReader("SPGetNotificationTemplateList", args)) { response.List = new List<NotificationItem>(); while (dr.Read()) { response.List.Add(GetFromData<NotificationItem>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<NotificationItem>>(ex); } }
//get contact list by type public GetListResponse<Contact> GetContactList(IDRequest request) { var response = new GetListResponse<Contact>(); response.List = new List<Contact>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Contact>()); string spName = "SPGetContactList"; byte type = 0; if (request.ContainsKey("Type")) type = byte.Parse(request["Type"]); int size = 0; if (request.ContainsKey("TopN")) int.TryParse(request["TopN"], out size); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); Guid id = request.ID; var args = new object[] { includeInactive, id, type }; using (IDataReader dr = db.ExecuteDataReader(spName, args)) { while (dr.Read()) response.List.Add(GetFromData<Contact>(dr)); if (size > 0 && response.List.Count > size) { response.List.RemoveRange(size - 1, response.List.Count - size); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Contact>>(ex); } }
public async Task <IHttpActionResult> GetListAsync([FromUri] int page = 0, [FromUri] int size = 10) { SelectOptions <Tourney> options = new SelectOptions <Tourney> { OrderBy = p => p.OrderByDescending(t => t.Id), Take = size, Skip = page * size }; IEnumerable <Tourney> results = await UnitOfWork.GetTourneyRepository().SelectAllAsync(options: options); Paging paging = new Paging(count: results.Count(), page: page, size: size); GetListResponse response = new GetListResponse(paging) { Items = results.Select(t => new GetListItem { Id = t.Id, Name = t.Name, EndDt = t.EndDt, StartDt = t.StartDt }) }; return(Ok(response)); }
private async Task <GetListResponse> ListAudioDetail(string userId = null) { userId ??= this.defaultUserId; Uri getUrl = new Uri($"{this.baseUrl}?userId={userId}"); var getResponse = await HttpClientInstance.GetAsync(getUrl).ConfigureAwait(false); var getResponseContent = await getResponse.Content.ReadAsStringAsync().ConfigureAwait(false); GetListResponse audioNotes = JsonConvert.DeserializeObject <GetListResponse>(getResponseContent); return(audioNotes); }
public List <string> getList() { GetListRequest req = new GetListRequest(); req.user = new User(); req.user.login = conf.Login; req.user.pass = Utils.GetMD5String(conf.Soap_pass); GetListResponse resp = (GetListResponse)Soap.GetList <GetListResponse>(req); if (resp.errorCode != 0) { throw new Exception(resp.errorMessage); } return(resp.list); }
public HttpResponseMessage GetList(int sessionId, int id) { var response = new GetListResponse(); if (_sessionManager.IsActive(sessionId)) { response.Tasks = _taskManager.GetTasks(id); return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { return(Request.CreateResponse(HttpStatusCode.Unauthorized, response)); } }
public void GetListsResponseGeneratesContent() { var response = new GetListResponse { Lists = new List <SkillListMetadata> { new SkillListMetadata { ListId = "shopping_list_list_id", Name = "Alexa shopping list", Version = 1, State = SkillListState.Active, StatusMap = new Dictionary <string, string> { { "active", "url" }, { "completed", "url" } } }, new SkillListMetadata { ListId = "todo_list_list_id", Name = "Alexa to-do list", Version = 1, State = SkillListState.Active, StatusMap = new Dictionary <string, string> { { "active", "url" }, { "completed", "url" } } }, new SkillListMetadata { ListId = "ff097d45-c098-44af-a2e9-7dae032b270b", Name = "test-list-name-veba", Version = 7, State = SkillListState.Active, StatusMap = new Dictionary <string, string> { { "active", "url" }, { "completed", "url" } } } } }; Utility.CompareJson(response, "ListGetListResponse.json"); }
public async Task <IHttpActionResult> GetListAsync([FromUri] MatchStatus?status = null, [FromUri] int page = 0, [FromUri] int size = 10) { IMatchRepository repo = UnitOfWork.GetMatchRepository(); SelectOptions <DAL.Models.Match> options = new SelectOptions <DAL.Models.Match> { OrderBy = p => p.OrderByDescending(t => t.Id), Take = size, Skip = page * size }; StatusSpecification specification = new StatusSpecification(status); IEnumerable <DAL.Models.Match> result = await repo.SelectAsync(specification = specification, options : options); int count = await repo.CountAsync(specification : specification); Paging paging = new Paging(count: count, page: page, size: size); GetListResponse response = new GetListResponse(paging) { Items = result.Select(m => new GetListResponseItem { Id = m.Id, StartDt = m.StartDt, Status = m.Status, Guest = new GetListResponseItemTeam { Id = m.GuestId, City = m.Guest.City, Country = m.Guest.County, Goals = m.Goals.Count(g => g.TeamId == m.GuestId), Name = m.Guest.Name, Logotype = m.Guest.Logotype }, Home = new GetListResponseItemTeam { Id = m.HomeId, City = m.Home.City, Country = m.Home.County, Goals = m.Goals.Count(g => g.TeamId == m.HomeId), Name = m.Home.Name, Logotype = m.Home.Logotype } }) }; return(Ok(response)); }
private GetListResponse MapperToGetListResponse(IEnumerable <CustomerEntity> customers) { GetListResponse _response = new GetListResponse(); var _customersList = new List <GetListResponse.Customer>(); foreach (var item in customers) { _customersList.Add(new GetListResponse.Customer() { Id = item.Id, Name = item.Name, Age = item.Age }); } _response.Customers = _customersList; return(_response); }
public GetListResponse<ApplicationFeatureOwner> GetApplicationFeatureOwnerListByTimeStamp(GetListByTimestampRequest request) { try { var response = new GetListResponse<ApplicationFeatureOwner>(); var service = ImardaProxyManager.Instance.IImardaSecurityProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; response = service.GetApplicationFeatureOwnerListByTimeStamp (request); }); return response; } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<ApplicationFeatureOwner>>(ex); } }
public BusinessMessageResponse DeleteContactRelatedPersons(IDRequest request) { try { var response = new GetListResponse<Contact>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Contact>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); db.ExecuteNonQuery("SPDeleteContactRelatedPersons", includeInactive, request.CompanyID, request.ID); response.Status = true; return response; } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Contact>>(ex); } }
public GetListResponse<NotificationItem> GetNotificationItemList(IDRequest request) { try { var response = new GetListResponse<NotificationItem>(); var service = ImardaProxyManager.Instance.IImardaCRMProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; response = service.GetNotificationItemList(request); }); return response; } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<NotificationItem>>(ex); } }
public GetListResponse<LogonLog> GetTopNLogonLogListBySecurityEntityID(IDRequest request) { var response = new GetListResponse<LogonLog>(); response.List = new List<LogonLog>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<LogonLog>()); int topN = request.Get("TopN", 50); using (IDataReader dr = db.ExecuteDataReader("SPGetTopNLogonLogListBySecurityEntityID", request.ID, topN)) { while (dr.Read()) response.List.Add(GetFromData<LogonLog>(dr)); return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<LogonLog>>(ex); } }
public GetListResponse<SecurityObject> GetAssignedSecurityObjects(IDRequest request) { try { var response = new GetListResponse<SecurityObject>(); var service = ImardaProxyManager.Instance.IImardaSecurityProxy; ChannelInvoker.Invoke(delegate(out IClientChannel channel) { channel = service as IClientChannel; response = service.GetAssignedSecurityObjects(request); RemoveUnownedSecurityObjects(service, request, response); }); return response; } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<SecurityObject>>(ex); } }
public GetListResponse<Scope> GetApiScopeList(IDRequest request) { try { var response = new GetListResponse<Scope>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Scope>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); using (IDataReader dr = db.ExecuteDataReader("SPGetApiScopeList", includeInactive, request.CompanyID)) { response.List = new List<Scope>(); while (dr.Read()) response.List.Add(GetFromData<Scope>(dr)); return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Scope>>(ex); } }
public GetListResponse<Shortcut> GetShortcutList(IDRequest request) { try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Shortcut>()); using (IDataReader dr = db.ExecuteDataReader("SPGetShortCutList", false, request.CompanyID, request.ID)) { var response = new GetListResponse<Shortcut> { List = new List<Shortcut>() }; while (dr.Read()) { response.List.Add(GetFromData<Shortcut>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<Shortcut>>(ex); } }
public async Task <GetListResponse <AllocationData> > GetListAsync() { var listResponse = new GetListResponse <AllocationData>(); try { var uri = new Uri(string.Format(Constants.LoginUrl, string.Empty)); httpClient.MaxResponseContentBufferSize = 25600000000; var response = await httpClient.GetAsync(uri); listResponse = await response.Content.ReadAsAsync <GetListResponse <AllocationData> >(); return(listResponse); } catch (Exception ex) { listResponse.IsSuccess = false; listResponse.Message = "解析数据出现异常"; return(listResponse); } }
public async Task <IHttpActionResult> GetListAsync([FromUri] int page = 0, [FromUri] int size = 10, [FromUri] string searchString = null) { SelectOptions <Post> options = new SelectOptions <Post> { OrderBy = p => p.OrderByDescending(t => t.Id), Take = size, Skip = page * size }; options.Includes.Add(p => p.Dislikes); options.Includes.Add(p => p.Likes); IPostRepository repo = UnitOfWork.GetPostRepository(); ISpecification <Post> specification = (new TitleSpecification(searchString) .Or(new ContentSpecification(searchString))) .And(new StatusSpecification(Enums.PostStatus.Published)); IEnumerable <Post> list = await repo.SelectAsync(options : options, specification : specification); int resultsCount = await repo.CountAsync(specification : specification); Paging paging = new Paging(page: page, count: resultsCount, size: size); GetListResponse response = new GetListResponse(paging) { Items = list.Select(p => new GetListReponseItem { Id = p.Id, Image = p.Items.FirstOrDefault(i => i.Type == Enums.PostItemType.Image).Guid, Intro = p.Items.FirstOrDefault(i => i.Type == Enums.PostItemType.Text).Text, Title = p.Title, Likes = p.Likes.Count, Dislikes = p.Dislikes.Count }) }; return(Ok(response)); }
public GetListResponse<NotificationHistory> GetNotificationHistoryListByNotificationPlanID(IDRequest request) { try { var response = new GetListResponse<NotificationHistory>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<NotificationHistory>()); using (IDataReader dr = db.ExecuteDataReader("SPGetNotificationHistoryListByNotificationPlanID", request.ID)) { response.List = new List<NotificationHistory>(); while (dr.Read()) { response.List.Add(GetFromData<NotificationHistory>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<NotificationHistory>>(ex); } }
public GetListResponse<CustomerCommunicationNode> GetCustomerCommunicationNodes(IDRequest request) { var response = new GetListResponse<CustomerCommunicationNode>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<CustomerCommunicationNode>()); bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); var spName = "SPGetCustomerCommunicationNodes"; using (IDataReader dr = db.ExecuteDataReader(spName, request.CompanyID)) { response.List = new List<CustomerCommunicationNode>(); while (dr.Read()) { response.List.Add(GetFromData<CustomerCommunicationNode>(dr)); } } return response; } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<CustomerCommunicationNode>>(ex); } }
public GetListResponse GetList(GetListRequest request) { GetListResponse response = new GetListResponse(); try { response.AuthenticationRequests = new AuthenticationRequestCap().GetList(); response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); }
public GetListResponse<SecurityObject> GetKnownSecurityObjects(IDRequest request) { var response = new GetListResponse<SecurityObject>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityObject>()); object[] args = new object[] { request.ID }; using (IDataReader dr = db.ExecuteDataReader("SPGetKnownSecurityObjectList", args)) { response.List = new List<SecurityObject>(); while (dr.Read()) { response.List.Add(GetFromData<SecurityObject>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<SecurityObject>>(ex); } }
public GetListResponse<TrackStop> GetTrackStopListsByTrackerId(IDRequest request) { var response = new GetListResponse<TrackStop>(); try { var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Unit>()); var args = new object[] {request.ID}; using (var dr = db.ExecuteDataReader("SPGetTrackStopListsByTrackId", args)) { while (dr.Read()) { var t = GetFromData<TrackStop>(dr); response.List.Add(t); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<TrackStop>>(ex); } }
private void GetPermissions(Guid applicationID, Guid entityID, ref List<SecurityPermission> permissions) { if (permissions != null) { // get the list of all SecurityEntries belong to this entity var response = new GetListResponse<SecurityEntry>(); response.List = new List<SecurityEntry>(); IDRequest entityReq = new IDRequest(entityID, "appid", applicationID); response = GetEntitySecurityEntryList(entityReq); if (response != null && response.List != null) { foreach (SecurityEntry se in response.List) { // get just the securityObjectID and corresponding permissionGranted SecurityPermission permission = new SecurityPermission(); permission.AssignFromEntry(se); if (!permissions.Contains(permission)) { permissions.Add(permission); } } } } }
public GetListResponse<SecurityEntity> GetSecurityEntityListByTimeStamp(GetListByTimestampRequest request) { var response = new GetListResponse<SecurityEntity>(); response.List = new List<SecurityEntity>(); try { response = GenericGetEntityListByTimestamp<SecurityEntity>(request.TimeStamp, request.Cap, true, request.IncludeInactive, request.ID, request.LastRecordID); if (response != null && response.List != null) { Guid applicationID; request.Get<Guid>("appid", out applicationID); foreach (SecurityEntity entity in response.List) { //FILL in permission list entity.PermissionList = GetSecurityPermissionList(applicationID, entity); // fill in the parent id list entity.ImmediateParentsIds = GetEntityRelationships(entity.ID); } } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<SecurityEntity>>(ex); } return response; }
public GetListResponse<SecurityObject> GetSecurityObjectsByApplicationID(IDRequest request) { var response = new GetListResponse<SecurityObject>(); try { Guid applicationID; request.Get<Guid>("appid", out applicationID); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityObject>()); object[] args = new object[] { applicationID }; using (IDataReader dr = db.ExecuteDataReader("SPGetSecurityObjectsByApplicationID", args)) { response.List = new List<SecurityObject>(); while (dr.Read()) { response.List.Add(GetFromData<SecurityObject>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<SecurityObject>>(ex); } }
public GetListResponse<History> GetHistoryExtent(GetFilteredExtentRequest request) { try { var response = new GetListResponse<History>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<History>()); Guid? companyID = request.CompanyID; DateTime? createdAfter = request.ModifiedAfter; DateTime? createdBefore = request.ModifiedBefore; bool? deleted = request.Deleted; bool? active = request.Active; Guid? ownerID = request.OwnerID; int? ownerType = request.OwnerType; var scope = 0; if (request.Scope.HasValue) scope = request.Scope.Value; int startNum = 1; int endNum = Int32.MaxValue; if (request.Offset.HasValue) { startNum = request.Offset.Value; if (startNum < 1) startNum = 1; if (request.Limit.HasValue && request.Limit.Value > 0) endNum = startNum + request.Limit.Value - 1; } var whereClause = ""; var con = ""; //these are 'AND'd together string[] filters = { companyID.HasValue && companyID.Value != Guid.Empty ? string.Format(" [CompanyID] = '{0}' ", companyID.Value.ToString()) : null, createdAfter.HasValue ? string.Format(" [DateCreated] >= '{0}' ", createdAfter.Value.ToString("s")) : null, createdBefore.HasValue ? string.Format(" [DateCreated] <= '{0}' ", createdBefore.Value.ToString("s")) : null, deleted.HasValue ? " [Deleted] = " + (deleted.Value ? '1' : '0') : null, active.HasValue ? " [Active] = " + (active.Value ? '1' : '0') : null, ownerID.HasValue ? string.Format(" [OwnerID] = '{0}' ", ownerID.ToString()) : null, ownerType.HasValue ? string.Format(" [OwnerType] = '{0}' ", ownerType.ToString()) : null, }; var filterClause = new StringBuilder(); con = ""; foreach (var filter in filters) { if (filter != null) { filterClause.Append(con).Append(filter); con = " AND "; } } var conditionClause = new StringBuilder(); con = ""; //add any further conditions these ar OR'd together currently foreach (Condition condition in request.Conditions) { var part = condition.GetSQL(); conditionClause.Append(con).Append(part); con = " OR "; } if (conditionClause.Length > 0) filterClause.Append(string.Format(" OR ( {0} )", conditionClause.ToString())); whereClause = filterClause.ToString(); var sortClause = ""; con = ""; foreach (SortColumn sortColumn in request.SortColumns) { var part = sortColumn.FieldName; sortClause += con + part; if (sortColumn.SortDescending) sortClause += " DESC"; con = ", "; } if (string.IsNullOrEmpty(sortClause)) sortClause = "ID"; //we need some column for the OVER part var query = GetFilteredHistoryExtentSQL(scope, startNum, endNum, whereClause, sortClause); using (IDataReader dr = db.ExecuteDataReader(CommandType.Text, query)) { response.List = new List<History>(); while (dr.Read()) { response.List.Add(GetFromData<History>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<History>>(ex); } }
public GetListResponse<CustomerInfo> GetCustomerInfoList(IDRequest request) { try { var response = new GetListResponse<CustomerInfo>(); var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Company>()); //bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive); //int topn = request.Get<int>("TopN", int.MaxValue); using (IDataReader dr = db.ExecuteDataReader("SPGetCustomerInfo")) //, includeInactive, request.ID)) { response.List = new List<CustomerInfo>(); while (dr.Read()) { response.List.Add(GetFromData<CustomerInfo>(dr)); } return response; } } catch (Exception ex) { return ErrorHandler.Handle<GetListResponse<CustomerInfo>>(ex); } }
/// <summary> /// Gets the status word. /// </summary> /// <param name="listRes">The list res.</param> /// <returns>The statusword used within the total registers.</returns> private static EdlStatusWord? GetStatusWord(GetListResponse listRes) { // find 1.8.0 or 2.8.0 register var energyEntry = listRes.Values.FirstOrDefault( e => e.Name == (ulong)ObisId.EdlEnergyAplusTotal) ?? listRes.Values.FirstOrDefault( e => e.Name == (ulong)ObisId.EdlEnergyAminusTotal); if (energyEntry != null) { return (EdlStatusWord)energyEntry.Status; } return null; }
/// <summary> /// Gets the counter value scaled. /// </summary> /// <param name="listRes">The sml message body of type GetListRes containing the list entries with measurement values.</param> /// <param name="obisEntry">The obisCode of the list entry containing the measurement value.</param> /// <returns> /// The counter value scaled = counterValueUnscaled * 10 pow(scaler). /// </returns> private static MeasurementValue GetCounterValueScaled(GetListResponse listRes, ulong obisEntry, byte[] serverId = null, byte[] publicKey = null) { var energyEntry = listRes.Values.FirstOrDefault( e => e.Name == obisEntry); return energyEntry != null ? GetMeasurementValue(energyEntry, serverId, publicKey) : null; }
public Program(String[] args) { Program.conf = DFSHelper.GetAppConfiguration("configuration.xml"); Logger.loadConfig(); controller = new Controller(); switch (args[0]) { case "-allcerts": // testing crypto etc. testCrypto(); break; case "-infocert": ExCert cert = null; try { cert = controller.GetExCertificate(args[1]); Console.WriteLine("certificate info:"); Console.WriteLine(cert.ToString()); } catch (Exception e) { Console.WriteLine(e.Message); } break; case "-testcert": String sign = null; String base64data = Utils.Base64DecodeToString(Encoding.GetEncoding("UTF-8").GetBytes("somedata"), "UTF-8"); try { sign = controller.Sign(args[1], base64data); if (sign != null) { Console.WriteLine("signing O.K."); } } catch (Exception e) { Console.WriteLine(e.Message); } break; case "-testrestFULLDEBUG": AuthorizeRequest debugReq = new AuthorizeRequest(conf.Login, conf.Api_pass); Console.WriteLine("request body:"); Console.WriteLine(Utils.ToJson(debugReq)); AuthorizeResponse debugResp = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", debugReq); Console.WriteLine("response body:"); Console.WriteLine(Utils.ToJson(debugResp)); if (debugResp != null) { Console.WriteLine("rest O.K."); } break; case "-testrest": AuthorizeResponse response = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", new AuthorizeRequest(conf.Login, conf.Api_pass)); if (response != null) { Console.WriteLine("rest O.K."); } break; case "-testsoap": GetListRequest req = new GetListRequest(); req.user = new User(); req.user.login = conf.Login; req.user.pass = Utils.GetMD5String(conf.Soap_pass); GetListResponse resp = (GetListResponse)Soap.GetList <GetListResponse>(req); if (resp != null) { Console.WriteLine("soap O.K."); } break; } }
private void RemoveUnownedSecurityObjects( ImardaSecurityBusiness.IImardaSecurity service, IDRequest request, GetListResponse<SecurityObject> response) { if (ServiceMessageHelper.IsSuccess(response)) { Guid callerSecurityEntityID; if (request.Get<Guid>("UserID", out callerSecurityEntityID)) { GetListResponse<SecurityObject> resp1 = service.GetKnownSecurityObjects(new IDRequest(callerSecurityEntityID)); ErrorHandler.Check(resp1); if (resp1.List != null) { List<Guid> maxlist = resp1.List.Select(known => known.ID).ToList(); response.List.RemoveAll(so => !maxlist.Contains(so.ID)); } } //Include APIAccessPermission only for companies if (request.Get("Owner", "User") == "User") response.List.Remove(response.List.Find(so => so.ID == APIAccessPermission)); } }