/// <summary> /// Constructor for API Characters. /// </summary> /// <param name="uri">URI of the character</param> /// <param name="result">API Result</param> public UriCharacterEventArgs(Uri uri, APIResult<SerializableAPICharacterSheet> result) { m_uri = uri; m_apiResult = result; m_result = m_apiResult.Result; HasError = m_apiResult.HasError; Error = m_apiResult.ErrorMessage; }
public async Task <APIResult> GetAttachmentByUserId(int userId, string sourceType, string sDate, string eDate) { List <RequestParameter> param = new List <RequestParameter> { new RequestParameter { Name = "userId", Value = userId.ToString() }, new RequestParameter { Name = "sDate", Value = sDate }, new RequestParameter { Name = "eDate", Value = eDate }, new RequestParameter { Name = "sourceType", Value = sourceType } }; APIResult info = await _commonHelper.HttpGet <APIResult>(baseUrl, _config.Get <string>($"{Config.Config.Endpoints_Paths}.GetAttachmentByUserId"), param); return(info); }
/// <summary> /// 修改个人信息 /// </summary> /// <returns></returns> public JsonResult PersonalEdit(string name, int sex, string tel) { var apiResult = new APIResult(); try { PosSalemanBll.PersonalEdit(UserContext.CurrentUser.Id, name, sex, tel); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public JsonResult Edit(PosSaleman model) { var apiResult = new APIResult(); try { PosSalemanBll.AddOrUpdate(model, (UserEntity)UserContext.CurrentUser); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public JsonResult Edit(Cat model) { var apiResult = new APIResult(); try { CatBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } //MessageBox.Show(Json(apiResult).ToString()); return(Json(apiResult)); }
/// <summary> /// 设置设备类型 /// </summary> /// <returns></returns> public APIResult SetMm(MeterTypeVModel mmType) { APIResult rst = new APIResult(); try { DataTable dtFun = this.GetMmFunTypeList(mmType.ModuleTypeId, mmType.ModuleType); bll.SetMm(mmType, dtFun); rst.Code = 0; rst.Msg = ""; rst.Data = this.GetMmList(mmType.ModuleTypeId, ""); } catch (Exception ex) { rst.Code = -1; rst.Msg = ex.Message; FileLog.WriteLog("获取设备类型列表信息错误(GetMmList):" + ex.Message + ex.StackTrace); } return(rst); }
public ActionResult Back(List <MaterialLease> models) { var apiResult = new APIResult(); var user = UserContext.CurrentUser; try { MaterialLeaseBll.Back(models, user.HotelId, user.Id, user.UserName); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public JsonResult Edit(PosConsume model, string detailJson) { var apiResult = new APIResult(); try { model.Details = JsonConvert.DeserializeObject <List <PosConsumeDetail> >(detailJson); PosConsumeBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); apiResult.SeqId = model.Id; } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; } return(Json(apiResult)); }
public JsonResult Edit(RechargeScheme model) { var apiResult = new APIResult(); try { RechargeSchemeBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
/// <summary> /// 转账撤销的保存 /// </summary> /// <returns></returns> public JsonResult ZzCxSave(List <RoomRegYzzHelp> models) { var apiResult = new APIResult(); try { RoomRegZwBll.ZzCxSave(models); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public async Task Invoke(HttpContext httpContext) { try { var ModelState = httpContext.Features; await _next(httpContext); } catch (Exception ex) { httpContext.Response.Clear(); httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError; httpContext.Response.ContentType = "application/json"; APIResult apiResult = APIResultFactory.Build(false, StatusCodes.Status500InternalServerError, Helpers.ErrorMessageEnum.Exception, exceptionMessage: $"({ex.GetType().Name}), {ex.Message}{Environment.NewLine}{ex.StackTrace}"); await httpContext.Response.WriteAsync(JsonConvert.SerializeObject(apiResult)); } }
/// <summary> /// 获取区域下机房,站点个数 /// </summary> /// <param name="areaId">区域ID号</param> /// <returns></returns> public APIResult GetAreaCountInfo(int areaId) { APIResult rst = new APIResult(); try { int sCnt = bll.GetStationCount(areaId); int rCnt = bll.GetRoomCount(areaId); rst.Code = 0; rst.Msg = ""; rst.Data = new { stationCount = sCnt, roomCount = rCnt }; } catch (Exception ex) { rst.Code = -1; rst.Msg = ex.Message; FileLog.WriteLog("获取区域下机房,站点个数错误(GetAreaCountInfo):" + ex.Message + ex.StackTrace); } return(rst); }
public async Task <APIResult <string> > DeleteAsync(int id) { var res = new APIResult <string>(); try { var result = await _ctx.DeleteMany <Article>().Where(whereExpression: p => p.Id == id).ExecuteAsync(); var flag = result > 0; res.Success = true; res.Message = "操作成功."; } catch (Exception ex) { res.StatusCode = 500; res.Message = ex.Message; } return(res); }
public JsonResult Edit(CertificateType model) { var apiResult = new APIResult(); try { CertificateTypeBll.AddOrUpdate(model); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public APIResult <List <MapPlace> > RecentPlaces() { var u = APIRequest.User(HttpContext.Current.Request); List <MapPlace> lst = new List <MapPlace>(); using (var ctx = new MainEntities()) { var linq = ctx.trip_book.Include("trip_request_details").Include("trip_request").Where(a => a.trip_request_details.trip_request.rider_id == u.Entity.id).Select(c => new { place = c.trip_request_details.to_plc, lat = (decimal)c.trip_request_details.to_lat, lng = (decimal)c.trip_request_details.to_lng, }).Distinct().ToList(); linq.ForEach(a => lst.Add(new MapPlace() { city = getCity(a.place), country = getCountry(a.place), governorate = getGov(a.place), lat = a.lat, lng = a.lng, street = getStreet(a.place) })); return(APIResult <List <MapPlace> > .Success(lst)); } }
/// <summary> /// Processes the queried character's EVE mailing lists. /// </summary> /// <param name="result">The result.</param> private void OnCharacterMailingListUpdated(APIResult <SerializableAPIMailingLists> result) { m_mailingListsNextUpdate = result.CachedUntil; // Notify an error occured if (ShouldNotifyError(result, APIMethods.MailingLists)) { EveClient.Notifications.NotifyMailingListsError(this, result); } // If there is no error deserialize the result if (!result.HasError) { EVEMailingLists.Import(result.Result.MailingLists); } // Whether we have the mailing list info or not // import the EVE mail messages ImportEVEMailMessages(); }
/// <summary> /// Processes the queried character's research points. /// </summary> /// <param name="result"></param> private void OnCharacterResearchPointsUpdated(APIResult <SerializableAPIResearch> result) { // Notify an error occured if (ShouldNotifyError(result, APIMethods.ResearchPoints)) { EveClient.Notifications.NotifyResearchPointsError(this, result); } // Quits if there is an error if (result.HasError) { return; } // Import the data m_researchPoints.Import(result.Result.ResearchPoints); // Fires the event regarding research points update EveClient.OnCharacterResearchPointsChanged(this); }
public JsonResult AddOrUpdate(PosConsumeTk model) { var apiResult = new APIResult(); var user = UserContext.CurrentUser; try { PosConsumeTkBll.AddOrUpdate(model, user.Id, user.Name, user.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public JsonResult SetRType(int id, int rtype) { var apiResult = new APIResult(); try { CertificateTypeBll.SetRType(id, rtype); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public virtual async Task <APIResultVM> ReverseDeleteAsync(Guid id, Guid?userId, bool isCommit = true) { try { Guid _userId = userId == null ? Guid.Empty : userId.Value; D entity = await _uow.Repository <D>(_repositoryLogger).GetByIDAysnc(id); if (entity.IsNull()) { return(APIResult.CreateVM(false, id, new List <string>() { ErrorMessages.RecordNotFound })); } if (entity is ITableEntity) { (entity as ITableEntity).UpdateBy = _userId; (entity as ITableEntity).UpdateDT = DateTime.Now; } entity.IsDeleted = false; Repository.Update(entity); if (isCommit) { await CommitAsync(); } return(APIResult.CreateVMWithRec(entity, true, entity.Id)); } catch (Exception e) { _logger.LogError("BaseService.ReverseDeleteAsync", e); return(APIResult.CreateVM(messages: new List <string>() { "An exception occured!" })); } }
public APIResult <bool> SendAddPoints(FidelitySettingsPart setPart, FidelityCustomer customer, FidelityCampaign campaign, string points) { APIResult <bool> result = new APIResult <bool>(); result.success = false; result.data = false; try { List <KeyValuePair <string, string> > kvpList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("place_id", campaign.Id), new KeyValuePair <string, string>("session_id", setPart.AccountID), new KeyValuePair <string, string>("customer_id", customer.Id), new KeyValuePair <string, string>("points", points), }; string responseString = SendRequest(setPart, APIType.merchant, "givePoints", kvpList); if (!string.IsNullOrWhiteSpace(responseString)) { JObject data = JObject.Parse(responseString); result.success = data.Value <bool>("success"); if (result.success) { result.data = true; result.message = "Loyalzoo points added with success."; } else { result.message = data.SelectToken("response").ToString(); } } else { result.message = "no response from Loyalzoo server."; } } catch (Exception ex) { result.message = "exception: " + ex.Message + "."; } return(result); }
public async Task <IActionResult> Get([FromRoute][Required] string id) { try { if (!ModelState.IsValid) { var apiRes = new APIResult() { Success = false, Message = new List <string> { Resources.ErrorValidate_NotValid }, MessageCode = MessageCode.ValidateEntity, Data = ModelState }; return(BadRequest(apiRes)); } var apiResult = await _contractService.GetByIdAsync(id); if (apiResult.Success == true) { return(Ok(apiResult)); } else { return(StatusCode((int)HttpStatusCode.InternalServerError, apiResult)); } } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, new APIResult { MessageCode = MessageCode.Exception, Success = false, Message = new List <string> { Message.Exception }, Data = null })); } }
public static async Task <APIResult> RegisterUser(string email, string password) { APIResult result = new APIResult(); using (var request = new HttpRequestMessage(HttpMethod.Post, $"{URL}/User/Register/")) { var user = new APIUser() { Login = email, Password = password, DefaultTheme = Theme.Light.ToString() }; var json = DataContractSerializer.SerializeObject(user); using (var stringContent = new StringContent(json)) { request.Content = stringContent; httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, CancellationToken.None).ConfigureAwait(false)) { var responseContent = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); StreamReader reader = new StreamReader(responseContent); if (response.StatusCode == HttpStatusCode.OK) { result.Content = DataContractSerializer.DeserializeObject <APIUser>(reader.ReadToEnd()); } else { result.ErrorMessage = DataContractSerializer.DeserializeObject <string>(reader.ReadToEnd()); } } } catch (Exception ex) { result.ErrorMessage = $"The Server is Unavailable. Please, contact with the server administrator. Error occured: {ex.Message}"; } } } return(result); }
public APIResult <string> GetShareUrl(int trip_id, int?booked_id = 0) { using (var ctx = new MainEntities()) { Guid token = Guid.Empty; if (trip_id != 0) { var trip = ctx.trip_share_details.FirstOrDefault(a => a.id == trip_id); if (trip != null) { token = (Guid)trip.guid; } } else if (booked_id != 0) { var trip = ctx.trip_book.Find(booked_id); if (trip != null) { if (trip.trip_request_details != null) { token = (Guid)trip.trip_share_details.guid; } } } else { var trip = Current(); if (trip.data != null) { token = (Guid)trip.data.guid; } } if (token == Guid.Empty || token == null) { return(APIResult <string> .Error(ResponseCode.UserValidationField, "There is no trip to share it!")); } return(APIResult <string> .Success(Settings.Get("site_url") + "/Trip/Tracking/" + token)); } }
private void btnDelete_Click(object sender, EventArgs e) { if (this.gridViewIstab.GetRow(this.gridViewIstab.FocusedRowHandle) == null) { return; } IstabVM istab = this.istab.Where(i => i.Id == (int)this.gridViewIstab.GetRowCellValue(this.gridViewIstab.FocusedRowHandle, this.colId)).FirstOrDefault(); if (istab == null) { return; } if (MessageBox.Show("ลบรหัส \"" + istab.TypCod + "\" ทำต่อหรือไม่?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.splashScreenManager1.ShowWaitForm(); ApiAccessibilities acc = new ApiAccessibilities { API_KEY = this.main_form.config.ApiKey, istab = istab }; APIResult delete = APIClient.DELETE(this.main_form.config.ApiUrl + "Istab/DeleteIstab", acc); if (delete.Success) { this.istab = this.LoadIstabFromServer(); this.bs.ResetBindings(true); this.bs.DataSource = this.istab; this.splashScreenManager1.CloseWaitForm(); } else { this.splashScreenManager1.CloseWaitForm(); if (MessageBox.Show(delete.ErrorMessage.RemoveBeginAndEndQuote(), "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { this.btnDelete.PerformClick(); } } } }
public JsonResult ZrzSave(long ydid, List <RoomYdRoom> roomYdRoomList) { var apiResult = new APIResult(); var user = UserContext.CurrentUser; try { RoomYdBll.ZrzSave(ydid, roomYdRoomList, user.Id, user.Name); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
/// <summary> /// Used when the character list has been queried. /// </summary> /// <param name="result"></param> private void OnCharactersListUpdated(APIResult <SerializableAPICharacters> result) { // Notify on error if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) { return; } EveClient.Notifications.NotifyCharacterListError(this, result); return; } // Invalidates the notification and update EveClient.Notifications.InvalidateAccountError(this); Import(result); m_characterListUpdated = true; }
public JsonResult AddOrUpdate(RoomRegGoods model, List <RoomRegGoodsDetails> details) { var user = UserContext.CurrentUser; var apiResult = new APIResult(); try { RoomRegGoodsBll.AddOrUpdate(model, details, user.Id, user.Name, user.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public DealerVM LoadSingerDealerFromServer(string dealer_id) { APIResult get = APIClient.GET(this.main_form.config.ApiUrl + "Dealers/GetDealerAt", this.main_form.config.ApiKey, "&id=" + dealer_id); if (get.Success) { DealerVM dealer = JsonConvert.DeserializeObject <DealerVM>(get.ReturnValue); return(dealer); } else { if (MessageBox.Show(get.ErrorMessage, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { return(this.LoadSingerDealerFromServer(dealer_id)); } else { return(null); } } }
public void TestRegisterUserNoLowercasePassword() { var blueprintApi = BlueprintAPI.WithBaseUrl(baseUrl); Random random = new Random(); string username = "******" + random.Next(10000); Task.Run(async() => { try { Task <APIResult <UserCredentials, JsonError> > fetchingResponse = blueprintApi.AsyncRegisterUser(username, "FAILURE123"); APIResult <UserCredentials, JsonError> response = await fetchingResponse; // Failure case // If here, exception has not been thrown Assert.Fail(); } catch (InvalidCredentialException e) { // Pass case // Exception correctly thrown } }).GetAwaiter().GetResult(); }
public JsonResult SetZf(RoomYdRoom model) { var apiResult = new APIResult(); var user = UserContext.CurrentUser; try { RoomYdBll.SetZf(model, UserContext.CurrentUser.Id, user.Name); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
/// <summary> /// Constructor. /// </summary> /// <param name="userID"></param> /// <param name="apiKey"></param> /// <param name="serialCharacterList"></param> /// <param name="serialBalanceList"></param> internal AccountCreationEventArgs(long userID, string apiKey, APIResult<SerializableAPIAccountStatus> serialAccountStatus, APIResult<SerializableAPICharacters> serialCharacterList) { m_userID = userID; m_apiKey = apiKey; m_serialAccountStatus = serialAccountStatus; m_serialCharacterList = serialCharacterList; m_keyLevel = CredentialsLevel.Unknown; m_fullKeyError = String.Empty; //Determine the API key level m_keyLevel = Account.GetCredentialsLevel(serialAccountStatus); // On error, retrieve the error message if (m_keyLevel == CredentialsLevel.Unknown) m_fullKeyError = serialAccountStatus.ErrorMessage; // Retrieves the characters list if (m_serialCharacterList.HasError) return; foreach (var serialID in m_serialCharacterList.Result.Characters) { // Look for an existing char ID and update its name var id = EveClient.CharacterIdentities[serialID.ID]; if (id != null) { id.Name = serialID.Name; } else { // Create an identity if necessary id = EveClient.CharacterIdentities.Add(serialID.ID, serialID.Name); } m_identities.Add(id); } }
/// <summary> /// Called when character's skill in training gets updated. /// </summary> /// <param name="result">The result.</param> /// <param name="character">The character's name.</param> private void OnSkillInTrainingUpdated(APIResult<SerializableAPISkillInTraining> result, string characterName) { CCPCharacter ccpCharacter = EveClient.Characters.FirstOrDefault(x => x.Name == characterName) as CCPCharacter; // Return on error if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) return; if (ccpCharacter != null) EveClient.Notifications.NotifySkillInTrainingError(ccpCharacter, result); m_skillInTrainingCache[characterName].State = ResponseState.InError; return; } if (ccpCharacter != null) EveClient.Notifications.InvalidateCharacterAPIError(ccpCharacter); m_skillInTrainingCache[characterName].State = result.Result.SkillInTraining == 1 ? ResponseState.Training : ResponseState.NotTraining; // In the event this becomes a very long running process because of latency // and characters have been removed from the account since they were queried // remove those characters from the cache IEnumerable<KeyValuePair<string, SkillInTrainingResponse>> toRemove = m_skillInTrainingCache.Where(x => !CharacterIdentities.Any(y => y.Name == x.Key)); foreach (var charToRemove in toRemove) { m_skillInTrainingCache.Remove(charToRemove.Key); } // If we did not get response from a character in account yet // or there was an error in any responce, // we are not sure so wait until next time if (m_skillInTrainingCache.Any(x => x.Value.State == ResponseState.Unknown || x.Value.State == ResponseState.InError)) return; // We have successful responces from all characters in account, // so we notify the user and fire the event NotifyAccountNotInTraining(); // Fires the event regarding the account characters skill in training update EveClient.OnAccountCharactersSkillInTrainingUpdated(this); // Reset update pending flag m_updatePending = false; }
/// <summary> /// Called when the account status has been updated. /// </summary> /// <param name="result">The result.</param> private void OnAccountStatusUpdated(APIResult<SerializableAPIAccountStatus> result) { // Return on error if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) return; EveClient.Notifications.NotifyAccountStatusError(this, result); return; } EveClient.Notifications.InvalidateAccountError(this); m_accountCreated = result.Result.CreateDate; m_accountExpirationDate = result.Result.PaidUntil; // Notifies for the account expiration NotifyAccountExpiration(); // Fires the event regarding the account status update EveClient.OnAccountStatusUpdated(this); }
/// <summary> /// Used when the character list has been queried. /// </summary> /// <param name="result"></param> private void OnCharactersListUpdated(APIResult<SerializableAPICharacters> result) { // Notify on error if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) return; EveClient.Notifications.NotifyCharacterListError(this, result); return; } // Invalidates the notification and update EveClient.Notifications.InvalidateAccountError(this); Import(result); m_characterListUpdated = true; }
/// <summary> /// Update when we can update the key level. /// </summary> /// <param name="result"></param> private void OnKeyLevelUpdated(APIResult<SerializableAPIAccountStatus> result) { m_lastKeyLevelUpdate = DateTime.UtcNow; m_keyLevel = GetCredentialsLevel(result); // Notify error if any if (m_keyLevel == CredentialsLevel.Unknown) { EveClient.Notifications.NotifyKeyLevelError(this, result); return; } // Notify characters changed foreach (CharacterIdentity id in CharacterIdentities) { CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter != null) EveClient.OnCharacterChanged(ccpCharacter); } }
/// <summary> /// Processes the queried skill queue information. /// </summary> /// <param name="result"></param> private void OnSkillQueueUpdated(APIResult<SerializableAPISkillQueue> result) { // Notify an error occurred if (ShouldNotifyError(result, APIMethods.SkillQueue)) EveClient.Notifications.NotifySkillQueueError(this, result); // Quits if there is an error if (result.HasError) return; // Import the data m_queue.Import(result.Result.Queue); // Check the account has a character in training m_identity.Account.CharacterInTraining(); // Check the character has room in skill queue if (IsTraining && (SkillQueue.EndTime < DateTime.UtcNow.AddHours(24))) { EveClient.Notifications.NotifySkillQueueRoomAvailable(this); return; } EveClient.Notifications.InvalidateSkillQueueRoomAvailability(this); }
/// <summary> /// Updates the characters list with the given CCP data. /// </summary> /// <param name="result"></param> internal void Import(APIResult<SerializableAPICharacters> result) { if (result.HasError) { ImportIdentities(null); } else { ImportIdentities(result.Result.Characters); } // Fires the event regarding the account character list update EveClient.OnCharacterListChanged(this); }
/// <summary> /// Add the queried jobs to a list. /// </summary> /// <param name="result"></param> /// <param name="jobsAdded"></param> /// <param name="issuedFor"></param> /// <returns>True if jobs get added, false otherwise</returns> private bool AddJobs(APIResult<SerializableAPIIndustryJobs> result, bool jobsAdded, IssuedFor issuedFor) { // Add orders if there isn't an error if (result.HasError) return false; // Check to see if other market // orders have been added before if (!jobsAdded) m_jobs.Clear(); // Add jobs in list result.Result.Jobs.ForEach(x => x.IssuedFor = issuedFor); m_jobs.AddRange(result.Result.Jobs); return true; }
/// <summary> /// Processes the queried character's EVE notifications. /// </summary> /// <param name="result">The result.</param> private void OnCharacterEVENotificationsUpdated(APIResult<SerializableAPINotifications> result) { // Notify an error occured if (ShouldNotifyError(result, APIMethods.Notifications)) EveClient.Notifications.NotifyEVENotificationsError(this, result); // Quits if there is an error if (result.HasError) return; // Import the data m_eveNotifications.Import(result.Result.Notifications); // Notify on new messages if (m_eveNotifications.NewNotifications != 0) EveClient.Notifications.NotifyNewEVENotifications(this, m_eveNotifications.NewNotifications); // Fires the event regarding EVE mail messages update EveClient.OnCharacterEVENotificationsUpdated(this); }
/// <summary> /// Updates this character with the given informations /// </summary> /// <param name="identity"></param> /// <param name="uri"></param> /// <param name="result"></param> internal void Update(CharacterIdentity identity, Uri uri, APIResult<SerializableAPICharacterSheet> result) { m_characterID = identity.CharacterID; m_identity = identity; m_uri = uri; Import(result); }
public APIResult<List<Note>> GetAll() { APIResult<List<Note>> result = new APIResult<List<Note>>(); result.Data = noteController.GetAll(); return result; }
/// <summary> /// Default constructor for new uri characters /// </summary> /// <param name="identity">The identitiy for this character</param> /// <param name="uri">The uri the provided deserialization object was acquired from</param> /// <param name="source">A deserialization object for characters</param> internal UriCharacter(CharacterIdentity identity, Uri uri, APIResult<SerializableAPICharacterSheet> source) : base(identity, Guid.NewGuid()) { m_uri = uri; Import(source); }
/// <summary> /// Called when the query updated. /// </summary> /// <param name="result">The result.</param> private static void OnQueryAPICharacterNameUpdated(APIResult<SerializableAPICharacterName> result) { if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) return; EveClient.Notifications.NotifyCharacterNameError(result); return; } EveClient.Notifications.InvalidateAPIError(); // Deserialize the result Import(result.Result.Entities); }
/// <summary> /// Processed the queried skill queue information. /// </summary> /// <param name="result"></param> private void OnCharacterSheetUpdated(APIResult<SerializableAPICharacterSheet> result) { // Notify an error occurred if (ShouldNotifyError(result, APIMethods.CharacterSheet)) EveClient.Notifications.NotifyCharacterSheetError(this, result); // Quits if there is an error if (result.HasError) return; // Imports the data Import(result); // Check the character has a sufficient clone or send a notification if (Monitored && (m_cloneSkillPoints < SkillPoints)) { EveClient.Notifications.NotifyInsufficientClone(this); return; } EveClient.Notifications.InvalidateInsufficientClone(this); }
/// <summary> /// Updates the account with the informations extracted from the API by <see cref="AccountCreationEventArgs"/>. /// </summary> /// <param name="apiKey"></param> /// <param name="keyLevel"></param> /// <param name="identities"></param> /// <param name="charListQueryResult"></param> internal void UpdateAPIKey(string apiKey, CredentialsLevel keyLevel, IEnumerable<CharacterIdentity> identities, APIResult<SerializableAPICharacters> charListQueryResult, APIResult<SerializableAPIAccountStatus> accountStatusQueryResult) { m_apiKey = apiKey; m_keyLevel = keyLevel; m_charactersListMonitor.UpdateWith(charListQueryResult); m_accountStatusMonitor.UpdateWith(accountStatusQueryResult); // Clear the account for the currently associated identities foreach (CharacterIdentity id in EveClient.CharacterIdentities) { if (id.Account == this) id.Account = null; } // Assign this account to the new identities and create CCP characters foreach (CharacterIdentity id in identities) { // Skip if in the ignore list id.Account = this; if (m_ignoreList.Contains(id)) continue; // Retrieves the ccp character and create one if none CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter == null) { ccpCharacter = new CCPCharacter(id); EveClient.Characters.Add(ccpCharacter, true); ccpCharacter.Monitored = true; } } }
/// <summary> /// Processes the queried character's EVE mailing lists. /// </summary> /// <param name="result">The result.</param> private void OnCharacterMailingListUpdated(APIResult<SerializableAPIMailingLists> result) { m_mailingListsNextUpdate = result.CachedUntil; // Notify an error occured if (ShouldNotifyError(result, APIMethods.MailingLists)) EveClient.Notifications.NotifyMailingListsError(this, result); // If there is no error deserialize the result if (!result.HasError) EVEMailingLists.Import(result.Result.MailingLists); // Whether we have the mailing list info or not // import the EVE mail messages ImportEVEMailMessages(); }
/// <summary> /// Processes the conquerable station list. /// </summary> private static void OnUpdated(APIResult<SerializableAPIConquerableStationList> result) { // Was there an error ? if (result.HasError) { EveClient.Notifications.NotifyConquerableStationListError(result); return; } EveClient.Notifications.InvalidateAPIError(); // Deserialize the list Import(result.Result.Outposts); // Notify the subscribers EveClient.OnConquerableStationListUpdated(); }
/// <summary> /// Gets the credential level from the given result. /// </summary> /// <param name="result"></param> internal static CredentialsLevel GetCredentialsLevel(APIResult<SerializableAPIAccountStatus> result) { // No error ? Then it is a full key if (!result.HasError) return CredentialsLevel.Full; // Error code 200 means it was a limited key if (result.CCPError != null && result.CCPError.IsLimitedKeyError) return CredentialsLevel.Limited; // Another error occurred return CredentialsLevel.Unknown; }
/// <summary> /// Processes the queried EVE mail message mail body. /// </summary> /// <param name="result">The result.</param> private void OnEVEMailBodyDownloaded(APIResult<SerializableAPIMailBodies> result) { m_queryPending = false; // Notify an error occured if (m_ccpCharacter.ShouldNotifyError(result, APIMethods.MailBodies)) EveClient.Notifications.NotifyEVEMailBodiesError(m_ccpCharacter, result); // Quits if there is an error if (result.HasError) return; // If there is an error response on missing IDs inform the user if (!String.IsNullOrEmpty(result.Result.MissingMessageIDs)) result.Result.Bodies.Add( new SerializableMailBodiesListItem { MessageID = long.Parse(result.Result.MissingMessageIDs), MessageText = "The text for this message was reported missing." }); // Quit if for any reason there is no text if (result.Result.Bodies.Count == 0) return; // Import the data EVEMailBody = new EveMailBody(result.Result.Bodies[0]); EveClient.OnCharacterEVEMailBodyDownloaded(m_ccpCharacter); }
/// <summary> /// Processes the queried character's personal market orders. /// </summary> /// <param name="result"></param> /// <remarks>This method is sensitive to which market orders gets queried first</remarks> private void OnCharacterMarketOrdersUpdated(APIResult<SerializableAPIMarketOrders> result) { m_charOrdersUpdated = true; // Notify an error occurred if (ShouldNotifyError(result, APIMethods.MarketOrders)) EveClient.Notifications.NotifyCharacterMarketOrdersError(this, result); // Add orders to list m_charOrdersAdded = AddOrders(result, m_corpOrdersAdded, IssuedFor.Character); // If character is in NPC corporation we switch the corp orders updated flag // to assure the character issued orders gets imported m_corpOrdersUpdated |= !m_corpMarketOrdersMonitor.Enabled; // Import the data if all queried and there are orders to import if (m_corpOrdersUpdated) Import(m_orders); }
/// <summary> /// Occurs when CCP returns new data. /// </summary> /// <param name="result"></param> private void OnMonitorUpdated(APIResult<SerializableAPIServerStatus> result) { // Was there an error ? var lastStatus = m_status; if (result.HasError) { // Checks if EVE Backend Database is temporarily disabled if (result.EVEBackendDatabaseDisabled) return; m_status = ServerStatus.Unknown; EveClient.Notifications.NotifyServerStatusError(result); // Notify subscribers about update EveClient.OnServerStatusUpdated(this, lastStatus, m_status); return; } // Update status and users, notify no more errors m_users = result.Result.Players; m_status = (result.Result.Open ? ServerStatus.Online : ServerStatus.Offline); EveClient.Notifications.InvalidateServerStatusError(); // Notify subscribers about update EveClient.OnServerStatusUpdated(this, lastStatus, m_status); // Send a notification if (lastStatus != m_status) { EveClient.Notifications.NotifyServerStatusChanged(Name, m_status); return; } EveClient.Notifications.InvalidateServerStatusChange(); }
/// <summary> /// Processes the queried character's personal industry jobs. /// </summary> /// <param name="result"></param> /// <remarks>This method is sensitive to which "issued for" jobs gets queried first</remarks> private void OnCharacterJobsUpdated(APIResult<SerializableAPIIndustryJobs> result) { m_charJobsUpdated = true; // Notify an error occurred if (ShouldNotifyError(result, APIMethods.IndustryJobs)) EveClient.Notifications.NotifyCharacterIndustryJobsError(this, result); // Add jobs to list m_charJobsAdded = AddJobs(result, m_corpJobsAdded, IssuedFor.Character); // If character is in NPC corporation we switch the corp jobs updated flag // to assure the character issued jobs gets imported m_corpJobsUpdated |= !m_corpIndustryJobsMonitor.Enabled; // Import the data if all queried and there are jobs to import if (m_corpJobsUpdated && m_jobs.Count != 0) Import(m_jobs); }
/// <summary> /// Processes the queried character's research points. /// </summary> /// <param name="result"></param> private void OnCharacterResearchPointsUpdated(APIResult<SerializableAPIResearch> result) { // Notify an error occured if (ShouldNotifyError(result, APIMethods.ResearchPoints)) EveClient.Notifications.NotifyResearchPointsError(this, result); // Quits if there is an error if (result.HasError) return; // Import the data m_researchPoints.Import(result.Result.ResearchPoints); // Fires the event regarding research points update EveClient.OnCharacterResearchPointsChanged(this); }
/// <summary> /// Processes the queried character's corporation industry jobs. /// </summary> /// <param name="result"></param> /// <remarks>This method is sensitive to which industry jobs gets queried first</remarks> private void OnCorporationJobsUpdated(APIResult<SerializableAPIIndustryJobs> result) { m_corpJobsUpdated = true; // Character is not in NPC corporation if (!IsInNPCCorporation) { // We don't want to be notified about corp roles error if (result.CCPError != null && !result.CCPError.IsJobsRelatedCorpRolesError) { // Notify an error occurred if (ShouldNotifyError(result, APIMethods.CorporationMarketOrders)) EveClient.Notifications.NotifyCorporationIndustryJobsError(this, result); } // Add jobs to list m_corpJobsAdded = AddJobs(result, m_charJobsAdded, IssuedFor.Corporation); } // Import the data if all queried and there are jobs to import if (m_charJobsUpdated && m_jobs.Count != 0) Import(m_jobs); }
/// <summary> /// Imports data from the given character sheet informations /// </summary> /// <param name="serial">The serialized character sheet</param> internal void Import(APIResult<SerializableAPICharacterSheet> serial) { if (serial.HasError) return; Import(serial.Result); EveClient.OnCharacterChanged(this); }
/// <summary> /// Processes the queried character's EVE mail messages. /// </summary> /// <param name="result"></param> private void OnCharacterEVEMailMessagesUpdated(APIResult<SerializableAPIMailMessages> result) { // Notify an error occured if (ShouldNotifyError(result, APIMethods.MailMessages)) EveClient.Notifications.NotifyEVEMailMessagesError(this, result); // Quits if there is an error if (result.HasError) return; m_cachedAPIMailMessagesResult = result.Result; // Each time we import a new batch of EVE mail messages, // query the mailing lists (if it's time to) so that we are always up to date // and import the mail messages after we received the mailing lists if (DateTime.UtcNow > m_mailingListsNextUpdate) { QueryCharacterMailingList(); return; } // Import the EVE mail messages ImportEVEMailMessages(); }