/// <summary> /// Wszystkie taski są uruchamiane w jednym momencie, czyli działanie funkcji trwa 1000 ms, /// a nie 3000. /// </summary> private void SimplaTasksWithWaitAll() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task[] tasks = new Task[3]; tasks[0] = Task.Run(() => { Thread.Sleep(1000); Console.WriteLine("1"); return(1); }); tasks[1] = Task.Run(() => { Thread.Sleep(1000); Console.WriteLine("2"); return(2); }); tasks[2] = Task.Run(() => { Thread.Sleep(1000); Console.WriteLine("3"); return(3); }); Task.WaitAll(tasks); }
private void UsingDelegatesToImprovePerformance() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); MethodInfo trimMethod = typeof(string).GetMethod("Trim", new Type[0]); var trim = (StringToString)Delegate.CreateDelegate(typeof(StringToString), trimMethod); var dtnow = DateTime.UtcNow; Console.WriteLine($"time: {dtnow.TimeOfDay.TotalSeconds} {dtnow.Ticks}"); for (int i = 0; i < 1000000; i++) { trim("test"); } var dtafter = DateTime.UtcNow; Console.WriteLine($"time: {dtafter.TimeOfDay.TotalSeconds} {dtafter.Ticks}"); var resultA = dtafter.TimeOfDay.TotalSeconds - dtnow.TimeOfDay.TotalSeconds; Console.WriteLine($"Result = {resultA}"); Console.WriteLine("Normal for with normal Trim();"); dtnow = DateTime.UtcNow; Console.WriteLine($"time: {dtnow.TimeOfDay.TotalSeconds} {dtnow.Ticks}"); for (int i = 0; i < 1000000; i++) { "trim".Trim(); } dtafter = DateTime.UtcNow; Console.WriteLine($"time: {dtafter.TimeOfDay.TotalSeconds} {dtafter.Ticks}"); var resultB = dtafter.TimeOfDay.TotalSeconds - dtnow.TimeOfDay.TotalSeconds; Console.WriteLine($"Result = {resultB}"); Console.WriteLine($"Difference in times: {resultB - resultA}"); }
void SetTurn() { Mission++; AgreedVotes = Votes = 0; if (Mission < 6) { //Debug.Log("Set Turn"); //Votes = AgreedVotes = 0; TimeTeam = 3; if (CurrentPlayer < TotalPlayers) { CurrentPlayer++; } else { CurrentPlayer = 1; } MissionVotes = new bool[StaticValues.GetMissionPlayersNumber(Mission, TotalPlayers)]; photonView.RPC(StaticValues.SETTURN, PhotonTargets.All, CurrentPlayer); photonView.RPC(StaticValues.SETINFOCANVAS, PhotonTargets.All, Mission, StaticValues.GetMissionPlayersNumber(Mission, TotalPlayers)); } else { photonView.RPC(StaticValues.ENDGAME, PhotonTargets.All, MissionsStats); } }
private void SimpleChildTasks() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task <Int32[]> parent = Task.Run(() => { var results = new Int32[3]; new Task(() => results[0] = 0, TaskCreationOptions.AttachedToParent).Start(); new Task(() => results[1] = 1, TaskCreationOptions.AttachedToParent).Start(); new Task(() => results[2] = 2, TaskCreationOptions.AttachedToParent).Start(); return(results); }); var finalTask = parent.ContinueWith( parentTask => { foreach (var i in parentTask.Result) { Console.WriteLine($"Child task number: {i}"); } } ); finalTask.Wait(); }
protected override void Execute() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Log("Before executing"); base.Execute(); Log("After execution"); }
/// <summary> /// Check External component exist or not /// </summary> /// <param name="pluginHelper">Plugin Helper</param> /// <param name="externalReference">External Reference</param> /// <param name="linkLevel">Policy Link Level</param> public void IsExternalPolicyChildComponentExists(PluginHelper<ClaimHeader> pluginHelper, string externalReference, StaticValues.PolicyLinkLevel linkLevel) { if (string.IsNullOrWhiteSpace(externalReference)) { throw new ArgumentException("External Reference should not be null or empty."); } bool externalComponentExists = false; IUnderwritingService uwService = ObjectFactory.Resolve<IUnderwritingService>(); switch (linkLevel) { case StaticValues.PolicyLinkLevel.Coverage: externalComponentExists = uwService.GetCoverageIDByExternalReference(externalReference) > 0; break; case StaticValues.PolicyLinkLevel.Section: externalComponentExists = uwService.GetSectionIDByExternalReference(externalReference) > 0; break; case StaticValues.PolicyLinkLevel.SectionDetail: externalComponentExists = uwService.GetSectionDetailIDByExternalReference(externalReference) > 0; break; } if (!externalComponentExists) { pluginHelper.AddError(ClaimConstants.POLICY_ATTACHMENT_NOT_ALLOWED); } }
private void SimpleFactory() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task <Int32[]> parent = Task.Run(() => { var result = new Int32[3]; TaskFactory tf = new TaskFactory(TaskCreationOptions.AttachedToParent, TaskContinuationOptions.ExecuteSynchronously); tf.StartNew(() => result[0] = 0); tf.StartNew(() => result[1] = 1); tf.StartNew(() => result[2] = 2); return(result); }); var finalTask = parent.ContinueWith( parentTask => { foreach (int i in parentTask.Result) { Console.WriteLine($"Child Task from TakasFactory number: {i}"); } } ); finalTask.Wait(); }
public void Ok() { if (GameCtrl.SideMenuCtrl.Chosen.Count == StaticValues.GetMissionPlayersNumber(GameCtrl.GetClient().Mission, PhotonNetwork.playerList.Length)) { GameCtrl.TeamVote(); } }
private void WorkingOnIEnumerableMethod_Where() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); var unboundMethod = from m in typeof(Enumerable).GetMethods() where m.Name == "Where" && m.IsGenericMethod let parameters = m.GetParameters() where parameters.Length == 2 let genArg = m.GetGenericArguments().First() let enumerableOfT = typeof(IEnumerable <>).MakeGenericType(genArg) let funcOfBool = typeof(Func <,>).MakeGenericType(genArg, typeof(bool)) where parameters[0].ParameterType == enumerableOfT && parameters[1].ParameterType == funcOfBool select m; Console.WriteLine(unboundMethod); Console.WriteLine(""); Console.WriteLine(unboundMethod.Single()); Console.WriteLine(""); var closedMethod = unboundMethod.Single().MakeGenericMethod(typeof(int)); Console.WriteLine(closedMethod); int[] source = { 3, 4, 5, 6, 7, 8 }; Func <int, bool> predicate = n => n % 2 == 1;//nieparzyste var query = (IEnumerable <int>)closedMethod.Invoke(null, new object[] { source, predicate }); foreach (int element in query) { Console.WriteLine($"{element} |"); } }
private void NazwaKwalifikowanaPodzespolu() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Type t = Type.GetType("System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); t.WriteToScreen(); }
private void GetTypeNameFromStringWithName() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Type t = Assembly.GetExecutingAssembly().GetType("ReflectionTests.UsingTypeOfTests"); t.WriteToScreen(); }
/* * The ContinueWith method has a couple of overloads that you can use to configure when the continuation will run. * This way you can add different continuation methods that will run when an exception happens, the Task is canceled, * or the Task completes successfully. Listing 1-11 shows how to do this. * */ private void SimpleContinueWithSample() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task t = Task.Run(() => { for (int i = 0; i < 100; i++) { Console.Write('*'); } }); t.Wait(); Task <int> t1 = Task.Run(() => { return(43); }); Console.WriteLine("\nThis sample returns a value from Task<int>"); Console.WriteLine($"Result from current Task<int> = {t1.Result}"); Task <int> t2 = Task.Run(() => { return(43); }).ContinueWith((task) => { return(task.Result * 2); }); Console.WriteLine("\nThis sample returns a value from Task<int> with Continuation Task"); Console.WriteLine($"Result from current Task<int> (result * 2) = {t2.Result}"); Console.WriteLine(""); Console.WriteLine(""); }
private void ThrownigAArgumentNullException() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Console.WriteLine("Provide path to file:"); var text = OpenAndParse(Console.ReadLine()); }
private void ContinueWithTaskParameters() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task <int> t = Task.Run(() => { return(42); }); t.ContinueWith((i) => { Console.WriteLine("Canceled"); }, TaskContinuationOptions.OnlyOnCanceled); t.ContinueWith((i) => { Console.WriteLine("Faulted"); }, TaskContinuationOptions.OnlyOnFaulted); var completedTask = t.ContinueWith((i) => { Console.WriteLine("Completed"); }, TaskContinuationOptions.OnlyOnRanToCompletion); completedTask.Wait(); }
private void SpawnObjects() { ShardPresetNumbers = StaticValues.GetShardPresetNumbers(); CloudPresetNumbers = StaticValues.GetCloudPresetNumbers(); CrownPresetNumbers = StaticValues.GetCrownPresetNumbers(); TubePresetNumbers = StaticValues.GetTubePresetNumbers(); maxShards = ShardPresetNumbers.Count; maxClouds = CloudPresetNumbers.Count; maxCrowns = CrownPresetNumbers.Count; maxTubes = TubePresetNumbers.Count; startingCloudsAmount = (int)(maxClouds * 0.75f); startingShardsAmount = (int)(maxShards * 0.75f); startingCrownsAmount = (int)(maxCrowns * 0.75f); startingTubesAmount = (int)(maxTubes * 0.75f); for (int i = 0; i < startingShardsAmount; i++) { StartCoroutine(SpawnParams(shards[ShardPresetNumbers[Random.Range(0, ShardPresetNumbers.Count)] - 1], true)); } for (int i = 0; i < startingTubesAmount; i++) { StartCoroutine(SpawnParams(tubes[TubePresetNumbers[Random.Range(0, TubePresetNumbers.Count)] - 1], true)); } for (int i = 0; i < startingCrownsAmount; i++) { StartCoroutine(SpawnParams(crowns[CrownPresetNumbers[Random.Range(0, CrownPresetNumbers.Count)] - 1], true)); } for (int i = 0; i < startingCloudsAmount; i++) { StartCoroutine(SpawnParams(clouds[CloudPresetNumbers[Random.Range(0, CloudPresetNumbers.Count)] - 1], false)); } StartCoroutine(SpawnParams(logoObject, false)); }
private void CreatingADeadlock() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); object lockA = new object(); object lockB = new object(); var up = Task.Run(() => { Thread.Sleep(1000); lock (lockA) { Thread.Sleep(1000); lock (lockB) Console.WriteLine("Lockad A and B"); } }); lock (lockB) { lock (lockA) { Console.WriteLine("Locked A and B"); } } up.Wait(); }
private void UsingACancellationTokenWithException() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; Task task = Task.Run(() => { while (!token.IsCancellationRequested) { Console.Write("*"); Thread.Sleep(1000); } token.ThrowIfCancellationRequested(); }, token); try { Console.WriteLine("Press enter to stop the task"); Console.ReadLine(); source.Cancel();// zatrzymanie wątku task.Wait(); } catch (AggregateException e) { Console.WriteLine(e.InnerExceptions[0].Message); } }
private void LockingThreads() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); int n = 0; object _lock = new object(); var up = Task.Run(() => { for (int i = 0; i < 1000000; i++) { lock (_lock) n++; } }); for (int i = 0; i < 1000000; i++) { lock (_lock) n--; } up.Wait(); Console.WriteLine(n); }
public Task <Domain.ContaCorrente.ContaCorrente> Obter(ContaModel conta) { if (conta == null) { return(Task.FromResult <Domain.ContaCorrente.ContaCorrente> (null)); } Domain.ContaCorrente.ContaCorrente fakeConta = null; if (StaticValues.ContaCorrenteInterna(conta.Banco)) { // Gerando dados de saldos, limites, status e etc, devido a aplicação não estar persistindo dados fakeConta = new Domain.ContaCorrente.ContaCorrente() { Agencia = conta.Agencia, Conta = conta.Conta, DigitoConta = conta.DigitoConta, DataAbertura = DateTime.Now, Limite = new Random().Next(0, 30000), Saldo = new Random().Next(-5000, 50000), Status = StatusContaCorrente.ATIVA, Tipo = TipoContaCorrente.PESSOA_FISICA }; } return(Task.FromResult <Domain.ContaCorrente.ContaCorrente> (fakeConta)); }
private void CompareAndExchangeAsANonatomicOperation() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Task t1 = Task.Run(() => { if (value == 1) { // Removing the following line will change output //Thread.Sleep(1000); var newValue = 2; var compareTo = value; Interlocked.CompareExchange(ref value, newValue, compareTo); value = 2; } }); Task t2 = Task.Run(() => { var newValue = 3; var compareTo = value; Interlocked.CompareExchange(ref value, newValue, compareTo); }); Task.WaitAll(t1, t2); Console.WriteLine(value); }
private void inicilization() { camer = GameObject.Find("Camera"); place = GameObject.Find("place").gameObject; help2 = GameObject.Find("колода").gameObject; колода = help2.GetComponent <StartCreateCards>(); staticvalues = camer.GetComponent <StaticValues>(); help = help2.GetComponent <move>(); sprites = колода.sprites; placeDeckNext = колода.PlaceDeckNext; placeDeck = колода.PlaceDeck; deck = GameObject.Find("колода").gameObject; deck_next = GameObject.Find("place_deck").gameObject; BackMoveParents = help.BackMoveParents; BackMoveName = help.BackMoveName; BackMoveCurrentParents = help.BackMoveCurrentParents; ChangeBackFace = help.ChangeBackFace; thisCard = help.thisCard; lastPosition = staticvalues.lastPosition; comeBackDeck = staticvalues.comeBackDeck; changeRubashkaDeckCards = staticvalues.changeRubashkaDeckCards; finalPlace1 = колода.finalPlace1; finalPlace2 = колода.finalPlace2; finalPlace3 = колода.finalPlace3; finalPlace4 = колода.finalPlace4; Debug.Log("завершенно"); }
private void UsingBlockingCollection() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); var col = new BlockingCollection <string>(); Task read = Task.Run(() => { while (true) { Console.WriteLine(col.Take()); } }); Task write = Task.Run(() => { while (true) { var s = Console.ReadLine(); if (string.IsNullOrWhiteSpace(s)) { break; } col.Add(s); } }); write.Wait(); }
private void GettingClassMembersInfo() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); MemberInfo[] members = typeof(Walnut).GetMembers(); Console.WriteLine($"Members of class {typeof(Walnut).FullName}"); foreach (MemberInfo member in members) { Console.WriteLine(" "); Console.WriteLine(member); Console.WriteLine(member.MemberType); Console.WriteLine(member.ReflectedType); Console.WriteLine(member.DeclaringType); } Console.WriteLine($"-- Using TypeInfo"); IEnumerable <MemberInfo> membersTI = typeof(Walnut).GetTypeInfo().DeclaredMembers; foreach (MemberInfo member in membersTI) { Console.WriteLine(" "); Console.WriteLine(member); Console.WriteLine(member.MemberType); Console.WriteLine(member.ReflectedType); Console.WriteLine(member.DeclaringType); } Console.WriteLine($"member.ReflectedType zwraca podtyp"); Console.WriteLine($"member.DeclaringType zwraca typ bazowy"); }
public void Multicast() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); Del d = MethodOne; d += MethodTwo; d(); }
private void DownloadTaskTest() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); var result = DownloadContent().Result; Console.WriteLine(result.Substring(0, 1000)); }
public static void policyChange(float[] valueChanges, string[] dicKeys) { for (int i = 0; i < valueChanges.Length; i++) { StaticValues.alterStaticValue(valueChanges[i], dicKeys[i]); } updateSeparatePopValues(); }
public void Raise() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); if (OnChange != null) { OnChange(); } }
private int ReadAndParse() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); var s = Console.ReadLine(); int i = int.Parse(s); return(i); }
private void CovarianceDelegateBasics() { StaticValues.WriteMethodName(MethodBase.GetCurrentMethod()); CovarianceDel del; del = MethodStream; del = MethodString; }
protected void Page_Load(object sender, EventArgs e) { if (StaticValues.GetWowVersion(m_Realm, true) == VF_RealmPlayersDatabase.WowVersionEnum.TBC) { //HtmlControl masterPageBody = (HtmlControl)this.Parent.Page.Master.FindControl("masterPageBody"); //masterPageBody.Style.Add("background-color", "#2c382b"); } }
public async Task <ServiceResult> Transferir(ContaModel ccOrigem, ContaModel ccDestino, decimal valor) { Domain.ContaCorrente.ContaCorrente contaDestino = null; if (valor <= 0) { return(Criticas.Transferencia.ValorInvalido); } var contaOrigem = await this.ContaCorrenteService.Obter(ccOrigem); if (contaOrigem == null) { return(Criticas.ContaCorrente.ContaInvalida); } var contaOrigemAtiva = await this.ContaCorrenteService.ValidarContaAtiva(contaOrigem); if (!contaOrigemAtiva) { return(Criticas.Transferencia.ContaOrigemInvalida); } if (StaticValues.ContaCorrenteInterna(ccDestino.Banco)) { contaDestino = await this.ContaCorrenteService.Obter(ccDestino); if (contaDestino == null) { return(Criticas.ContaCorrente.ContaInvalida); } var contaDestinoAtiva = await this.ContaCorrenteService.ValidarContaAtiva(contaDestino); if (!contaDestinoAtiva) { return(Criticas.Transferencia.ContaDestinoInvalida); } } var debitoResult = await this.ContaCorrenteService.Debitar(contaOrigem, valor); if (!debitoResult.Ok) { return(debitoResult); } if (StaticValues.ContaCorrenteInterna(ccDestino.Banco)) { await this.ContaCorrenteService.Creditar(contaDestino, valor); } else { await this.SPBQueueService.EnviarTransferenciaSPB(ccDestino, valor); } return(ServiceResult.Processado()); }
protected void LoadInvolvements(ITransactionController transactionController, TreeNodeData<ActionKey> node, List<ClaimInvolvementDto> claimInvolvements, List<DtoBase> invToLoad, StaticValues.InternalIOType type) { ClaimHeaderDto headerDto = ((ClaimModel)transactionController.Model).HeaderDto; if (headerDto.ClaimInvolvementLinks != null) { claimInvolvements.ForEach(CI => { var involvementLinkFrom = headerDto.ClaimInvolvementLinks.Where(CIL => ((ClaimInvolvementLinkData)CIL.Data).ClaimInvolvementFromDataId == CI.Data.DataId); involvementLinkFrom.ForEach(y => { var involvement = headerDto.ClaimInvolvements.Where(z => z.Data.DataId == ((ClaimInvolvementLinkData)y.Data).ClaimInvolvementToDataId); invToLoad.AddRange(involvement); }); var involvementLinkTo = headerDto.ClaimInvolvementLinks.Where(CIL => ((ClaimInvolvementLinkData)CIL.Data).ClaimInvolvementToDataId == CI.Data.DataId); involvementLinkTo.ForEach(y => { var involvement = headerDto.ClaimInvolvements.Where(z => z.Data.DataId == ((ClaimInvolvementLinkData)y.Data).ClaimInvolvementFromDataId); invToLoad.AddRange(involvement); }); }); } int invToLoadCount = invToLoad.Distinct().Count(); int count = 0; if (invToLoad.Distinct().Any()) { transactionController.LoadLiteData( Guid.Empty, RetrievalType.WithChildHierarchy, invToLoad.Distinct(), NavigationType.None, null, r => { if (++count == invToLoadCount) { var model = (ClaimModel)transactionController.Model; model.CreateAllInsuredObjectCollection(type); node.IsLoaded = true; } }, true, BusinessDataVariant.Full); } else { node.IsLoaded = true; } }
public IEnumerable<ClaimFinancialAmount> ReadTransactionAmountData(ClaimTransactionHeader claimTransactionHeader, StaticValues.AmountType amountType) { ArgumentCheck.ArgumentNullCheck(claimTransactionHeader, "claimTransactionHeader"); ArgumentCheck.ArgumentNullCheck(amountType, "amountType"); if (_Logger.IsDebugEnabled) { _Logger.Debug(string.Format("ReadTransactionAmountData({0}, {1})", claimTransactionHeader.ClaimTransactionHeaderID, amountType)); } var flattenedTransactions = claimTransactionHeader.ClaimHeader .GetFlattenedTransactionData() .Where(t => t.ClaimTransactionHeaderID == claimTransactionHeader.ClaimTransactionHeaderID); var transactions = from t in flattenedTransactions where t.AmountType == (short)amountType && t.TransactionAmountOriginal != null select CreateClaimFinancialAmount(t); return transactions.ToList(); }
public IEnumerable<ClaimFinancialAmount> ReadClaimDetailAmountData(ClaimDetail claimDetail, bool includeEstimated, StaticValues.AmountType amountType) { ArgumentCheck.ArgumentNullCheck(claimDetail, "claimDetail"); ArgumentCheck.ArgumentNullCheck(amountType, "amountType"); if (_Logger.IsDebugEnabled) { _Logger.Debug(string.Format("ReadClaimDetailAmountData({0}, {1}, {2})", claimDetail.ClaimDetailID, includeEstimated, amountType)); } var flattenedTransactions = claimDetail.ClaimHeader .GetFlattenedTransactionData() .Where(t => t.TransactionGroupIsInProgress && t.ClaimDetailReference == claimDetail.ClaimDetailReference); var amounts = flattenedTransactions.Where(t => t.AmountType == (short)amountType); if (!includeEstimated) amounts = amounts.Where(t => t.ReserveType != (short)StaticValues.ReserveType.Estimated); amounts = amounts.Where(t => t.TransactionAmountOriginal != null); return amounts.Select(t => CreateClaimFinancialAmount(t)); }
public IEnumerable<ClaimFinancialAmount> ReadClaimDetailAmountData(ClaimDetail claimDetail, StaticValues.AmountType amountType) { ArgumentCheck.ArgumentNullCheck(claimDetail, "claimDetail"); ArgumentCheck.ArgumentNullCheck(amountType, "amountType"); if (_Logger.IsDebugEnabled) { _Logger.Debug(string.Format("ReadClaimDetailAmountData({0}, {1})", claimDetail.ClaimDetailID, amountType)); } var flattenedTransactions = claimDetail.ClaimHeader .GetFlattenedTransactionData() .Where(t => t.TransactionGroupIsInProgress && t.ClaimDetailReference == claimDetail.ClaimDetailReference); var amounts = from t in flattenedTransactions where t.AmountType == (short)amountType && t.TransactionAmountOriginal != null select CreateClaimFinancialAmount(t); return amounts.ToList(); }
/// <summary> /// Load historical reserves/payments/recovery reserves/recovery receipts for the specified claim /// </summary> /// <param name="transactionSource">transaction source</param> /// <param name="productClaimDefinition">claim product</param> /// <param name="claimDetailProductMap">claim details used for filtering</param> /// <param name="claimHeader">claim header</param> /// <param name="reserves">resulting reserves</param> /// <param name="payments">resulting payments and recovery receipts</param> /// <param name="recoveryReserves">resulting recovery reserves</param> private static void LoadFinancialAmounts(StaticValues.ClaimTransactionSource transactionSource, ProductClaimDefinition productClaimDefinition, IDictionary<string, ProductClaimDetail> claimDetailProductMap, ClaimHeader claimHeader, ClaimTransactionHeader claimtransactionheader, out IEnumerable<ClaimFinancialAmount> reserves, out IEnumerable<ClaimFinancialAmount> payments, out IEnumerable<ClaimFinancialAmount> recoveryReserves) { var inProgressData = ObjectFactory.Resolve<IInProgressFinancialAmountData>(); var historicalData = ObjectFactory.Resolve<IHistoricalFinancialAmountData>(); var claimHeaderArg = new ClaimHeaderArgument(AmountDataSource.Both, claimHeader, claimtransactionheader); var validClaimDetails = claimDetailProductMap .Where(a => a.Value.ClaimDetailAutomaticDeductibleProcessingMethod == (short)StaticValues.ClaimDetailAutomaticDeductibleProcessingMethod.FromClaimHeader) .Select(a => a.Key); var reserveCalculation = new TotalClaimReserveFinancialCalculation(inProgressData, historicalData); var paymentCalcuation = new TotalClaimPaymentFinancialCalculation(inProgressData, historicalData); var recoveryReceiptCalculation = new TotalClaimReceiptFinancialCalculation(inProgressData, historicalData); var recoveryRerserveCalculation = new TotalClaimRecoveryReserveFinancialCalculation(inProgressData, historicalData); bool includeEstimated = productClaimDefinition.IncurredAmountDerivationMethod == (short)StaticValues.IncurredAmountDerivationMethod.PaymentsReservesincludingEstimated; bool includeRecoveryEstimated = productClaimDefinition.RecoveryIncurredAmountDerivationMethod == (short)StaticValues.RecoveryIncurredAmountDerivationMethod.ReceiptsRecoveryReservesincludingEstimated; reserves = reserveCalculation.ReadLatestClaimReserves(claimHeaderArg, includeEstimated).Where(a => validClaimDetails.Contains(a.ClaimDetailReference)); payments = paymentCalcuation.ReadClaimPayments(claimHeaderArg).Where(a => validClaimDetails.Contains(a.ClaimDetailReference)); payments = payments.Concat(recoveryReceiptCalculation.ReadClaimReceipts(claimHeaderArg).Where(a => validClaimDetails.Contains(a.ClaimDetailReference))); recoveryReserves = recoveryRerserveCalculation.ReadLatestClaimRecoveryReserves(claimHeaderArg, includeRecoveryEstimated).Where(a => validClaimDetails.Contains(a.ClaimDetailReference)); var excludedMovementTypes = ClaimsBusinessLogicHelper.GetExcludedMovementTypesFromAutomaticDeductibleCalculations(); reserves = FilterExcludedMovementTypes(reserves, excludedMovementTypes); recoveryReserves = FilterExcludedMovementTypes(recoveryReserves, excludedMovementTypes); payments = FilterExcludedMovementTypes(payments, excludedMovementTypes); reserves = CreateAmountsForCalculation(reserves); recoveryReserves = CreateAmountsForCalculation(recoveryReserves); payments = CreateAmountsForCalculation(payments); }
/// <summary> /// Process Inactive ClaimDetails /// </summary> /// <param name="claimDetails">Claim Details</param> /// <param name="taskService">Task Service</param> /// <param name="ClaimReference">Claim Reference</param> /// <param name="CustomCode20"> Inactivity ClaimDetail.CustomCode20</param> /// <param name="NameID">Name ID</param> /// <param name="ClaimTransactionSource">Claim Transaction Source</param> private void ProcessInactiveClaimDetails(List<InactivityClaimDetail> claimDetails, ITaskService taskService, string ClaimReference, string CustomCode20, long? NameID, StaticValues.ClaimTransactionSource ClaimTransactionSource) { if (claimDetails == null || claimDetails.Count == 0) { return; } // Get the event type code from the Application Config string inactivityEventTypeCode = string.Empty; if (ClaimTransactionSource == StaticValues.ClaimTransactionSource.Reserve) { inactivityEventTypeCode = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(InactivityReviewEventTypeCode); } else { inactivityEventTypeCode = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(RecoveryInactivityReviewEventTypeCode); } // The number of Inactive Claim Details we are allowed to have in total. int maximumActiveClaims; if (!int.TryParse(CustomCode20, out maximumActiveClaims)) { throw new InvalidOperationException(MessageServiceFactory.GetMessageBody(ClaimConstants.NoMaximumClaimDetailConfigured, claimDetails.First<InactivityClaimDetail>().ClaimHeaderID)); } // if claim detail count is greater than max inactive claim details create claim header event instead if (claimDetails.Count > maximumActiveClaims) { try { this.CreateClaimEvent(ClaimReference, inactivityEventTypeCode, NameID); } catch (Exception ex) { if (_Logger.IsInfoEnabled) { _Logger.Info("Error in processing Inactive Claim Reference : " + ClaimReference); _Logger.Info(ex); } } } else { // Raise an inactivity claim detail event against each claim detail that has been inactive for too long, each of these creating a task. foreach (InactivityClaimDetail claimDetail in claimDetails) { try { this.CreateClaimDetailEvent(ClaimReference, claimDetail.ClaimDetailReference, inactivityEventTypeCode, NameID); } catch (Exception ex) { if (_Logger.IsInfoEnabled) { _Logger.Info("Error in processing Inactive Claim Reference : " + ClaimReference); _Logger.Info(ex); } } } } }
public IEnumerable<ClaimFinancialAmount> ReadUsersClaimPaymentAmountData(ClaimHeader claimHeader, SecurityUser userID, StaticValues.AuthorisationResult authorisationResult, FinancialAmountParticipationFilter filter) { throw new System.NotImplementedException(); }
protected void Initialize(long claimHeaderId, BusinessProcessUsage usage, StaticValues.ClaimStage claimStage, string messageAlias) { if (this.Component == null) { this.Component = this.GetClaimComponent(claimHeaderId, messageAlias); } if (!this.CheckValidClaimsProduct(this.Component as ClaimHeader, (short)claimStage)) { this.InvokeErrorMessage(MessageConstants.INVALID_PRODUCT_CODE); } this.UpdateDataContext(ClaimHeader.ClaimProductVersionID.Value, usage); }
private static void PopulateClaimTransactionDetail(ClaimTransactionDetail claimTransactionDetail, decimal transactionAmount, decimal calcuationSourceAmount, DateTime? reserveDate, short? reserveDaySequence, StaticValues.AmountType amountType) { if (amountType == StaticValues.AmountType.Reserve || amountType == StaticValues.AmountType.RecoveryReserve) { ClaimTransactionGroup claimTransGroup = claimTransactionDetail.ClaimTransactionGroup; ClaimTransactionHeader claimTransHeader = claimTransGroup.ClaimTransactionHeader; var productDefinition = claimTransHeader.GetProductClaimDefinition(); claimTransactionDetail.ReserveDate = reserveDate; transactionAmount = ClaimsBusinessLogicHelper.RoundDecimals(productDefinition.ReserveAmountMaximumNumberOfDecimalPlaces.GetValueOrDefault(0), transactionAmount); calcuationSourceAmount = ClaimsBusinessLogicHelper.RoundDecimals(productDefinition.ReserveAmountMaximumNumberOfDecimalPlaces.GetValueOrDefault(0), calcuationSourceAmount); } claimTransactionDetail.TransactionAmountOriginal = transactionAmount; claimTransactionDetail.CalculationSourceAmountOriginal = calcuationSourceAmount; ClaimsBusinessLogicHelper.CalculateTransactionAmounts(claimTransactionDetail); claimTransactionDetail.ReserveDaySequence = reserveDaySequence; }
public IEnumerable<ClaimFinancialAmount> ReadUsersClaimPaymentAmountData(ClaimHeader claimHeader, SecurityUser userID, StaticValues.AuthorisationResult authorisationResult, FinancialAmountParticipationFilter filter, ClaimTransactionHeader claimTransactionHeader, bool isExcludedFromCurrent = false) { throw new System.NotImplementedException(); }
public IEnumerable<ClaimFinancialAmount> ReadTransactionAmountData(ClaimTransactionHeader claimTransactionHeader, StaticValues.AmountType amountType, FinancialAmountParticipationFilter filter, bool isExcludedFromCurrent = false) { throw new System.NotImplementedException(); }
public IEnumerable<ClaimFinancialAmount> ReadTransactionAmountData(ClaimTransactionHeader claimTransactionHeader, bool includeEstimated, StaticValues.AmountType amountType, FinancialAmountParticipationFilter filter, bool? isIndemnityMovementExcluded, bool? isFeeMovementExcluded, bool? isRecoveryMovementExcluded, bool isExcludedFromCurrent = false) { throw new System.NotImplementedException(); }
public IEnumerable<ClaimFinancialAmount> ReadClaimDetailAmountDataWithReinsurance(ClaimDetail claimDetail, bool includeEstimated, StaticValues.AmountType amountType, FinancialAmountParticipationFilter filter, bool isExcludedFromCurrent = false) { throw new System.NotImplementedException(); }
/// <summary> /// Load historical reserves/payments/recovery reserves/recovery receipts for the specified claim detail /// </summary> /// <param name="transactionSource">transaction source</param> /// <param name="productClaimDefinition">claim product</param> /// <param name="claimDetail">claim detail</param> /// <param name="reserves">resulting reserves</param> /// <param name="payments">resulting payments and recovery receipts</param> /// <param name="recoveryReserves">resulting recovery reserves</param> private static void LoadFinancialAmounts(StaticValues.ClaimTransactionSource transactionSource, ProductClaimDefinition productClaimDefinition, ClaimDetail claimDetail, ClaimTransactionHeader claimtransactionheader, out IEnumerable<ClaimFinancialAmount> reserves, out IEnumerable<ClaimFinancialAmount> payments, out IEnumerable<ClaimFinancialAmount> recoveryReserves) { var inProgressData = ObjectFactory.Resolve<IInProgressFinancialAmountData>(); var historicalData = ObjectFactory.Resolve<IHistoricalFinancialAmountData>(); var claimDetailArg = new ClaimDetailArgument(AmountDataSource.Both, claimDetail, null); var reserveCalculation = new TotalClaimDetailReserveFinancialCalculation(inProgressData, historicalData); var paymentCalcuation = new TotalClaimDetailPaymentFinancialCalculation(inProgressData, historicalData); var recoveryReceiptCalculation = new TotalClaimDetailReceiptFinancialCalculation(inProgressData, historicalData); var recoveryRerserveCalculation = new TotalClaimDetailRecoveryReserveFinancialCalculation(inProgressData, historicalData); bool includeEstimated = productClaimDefinition.RecoveryIncurredAmountDerivationMethod == (short)StaticValues.RecoveryIncurredAmountDerivationMethod.ReceiptsRecoveryReservesincludingEstimated; bool includeRecoveryEstimated = productClaimDefinition.RecoveryIncurredAmountDerivationMethod == (short)StaticValues.RecoveryIncurredAmountDerivationMethod.ReceiptsRecoveryReservesincludingEstimated; reserves = reserveCalculation.ReadLatestClaimDetailReserves(claimDetailArg, includeEstimated); payments = paymentCalcuation.ReadClaimDetailPayments(claimDetailArg); payments = payments.Concat(recoveryReceiptCalculation.ReadClaimDetailReceipt(claimDetailArg)); recoveryReserves = recoveryRerserveCalculation.ReadLatestClaimDetailRecoveryReserves(claimDetailArg, includeRecoveryEstimated); var excludedMovementTypes = ClaimsBusinessLogicHelper.GetExcludedMovementTypesFromAutomaticDeductibleCalculations(); reserves = FilterExcludedMovementTypes(reserves, excludedMovementTypes); recoveryReserves = FilterExcludedMovementTypes(recoveryReserves, excludedMovementTypes); payments = FilterExcludedMovementTypes(payments, excludedMovementTypes); reserves = CreateAmountsForCalculation(reserves); recoveryReserves = CreateAmountsForCalculation(recoveryReserves); payments = CreateAmountsForCalculation(payments); }
/// <summary> /// Add new claim transaction detail for the new deductible. If payment/resere then stored as +ve if recovery reserve stored as -ve /// </summary> /// <param name="claimTransactionGroup">claim transaction group to attach to</param> /// <param name="amountType">amount type</param> /// <param name="deductibleDefinition">deductible definition containing deductible movement type</param> /// <param name="amount">deductible amount</param> /// <param name="latestNonFundedReserve">latest reserve if any</param> /// <returns>Amount s</returns> private static decimal AddClaimTransactionDetails(DateTime transactionDate, ClaimTransactionGroup claimTransactionGroup, StaticValues.AmountType amountType, DeductibleDefinition deductibleDefinition, decimal amount, ClaimFinancialAmount latestNonFundedReserve = null) { decimal convertedAmount; if (claimTransactionGroup.ClaimCurrencyCode != claimTransactionGroup.OriginalCurrencyCode) { convertedAmount = ClaimsBusinessLogicHelper.ConvertCurrencyAmount(claimTransactionGroup.ClaimTransactionHeader, amount, claimTransactionGroup.ClaimCurrencyCode, claimTransactionGroup.OriginalCurrencyCode); } else { convertedAmount = amount; } string fundedMovementType, nonFundedMovementType; if (amountType == StaticValues.AmountType.RecoveryReserve) { convertedAmount = -convertedAmount; fundedMovementType = deductibleDefinition.RecoveryFundedMovementType; nonFundedMovementType = deductibleDefinition.RecoveryNonFundedMovementType; } else { fundedMovementType = deductibleDefinition.FundedMovementType; nonFundedMovementType = deductibleDefinition.NonFundedMovementType; } short? reserveDaySequence = null; if (amountType == StaticValues.AmountType.Reserve || amountType == StaticValues.AmountType.RecoveryReserve) { reserveDaySequence = (short)(latestNonFundedReserve == null ? 10 : latestNonFundedReserve.ReserveDaySequence.GetValueOrDefault(0) + 10); } var claimTransactionDetail = claimTransactionGroup.AddNewClaimTransactionDetail((short)amountType, nonFundedMovementType); PopulateClaimTransactionDetail(claimTransactionDetail, convertedAmount, -Math.Abs(convertedAmount), transactionDate, reserveDaySequence, amountType); List<FlattenedTransaction> flattenedTransactions; if (GlobalClaimWakeUp.MappedTransactionDetails.TryGetValue(claimTransactionGroup.ClaimTransactionHeader.ClaimHeader.ClaimReference, out flattenedTransactions)) { flattenedTransactions.Add(Mapper.Map<ClaimTransactionDetail, FlattenedTransaction>(claimTransactionDetail)); } if (fundedMovementType != null) { claimTransactionDetail = claimTransactionGroup.AddNewClaimTransactionDetail((short)amountType, fundedMovementType); PopulateClaimTransactionDetail(claimTransactionDetail, -convertedAmount, Math.Abs(convertedAmount), transactionDate, reserveDaySequence, amountType); if (GlobalClaimWakeUp.MappedTransactionDetails.TryGetValue(claimTransactionGroup.ClaimTransactionHeader.ClaimHeader.ClaimReference, out flattenedTransactions)) { flattenedTransactions.Add(Mapper.Map<ClaimTransactionDetail, FlattenedTransaction>(claimTransactionDetail)); } } return amount; }
public IEnumerable<ClaimFinancialAmount> ReadUsersClaimPaymentAmountData(ClaimHeader claimHeader, SecurityUser user, StaticValues.AuthorisationResult authorisationResult) { ArgumentCheck.ArgumentNullCheck(claimHeader, "claimHeader"); ArgumentCheck.ArgumentNullCheck(user, "user"); ArgumentCheck.ArgumentNullCheck(authorisationResult, "authorisationResult"); if (_Logger.IsDebugEnabled) { _Logger.Debug(string.Format("ReadUsersClaimPaymentAmountData({0}, {1}, {2})", claimHeader.ClaimHeaderID, user, authorisationResult)); } var flattenedTransactions = claimHeader .GetFlattenedTransactionData() .Where(t => t.TransactionHeaderIsInProgress); var amounts = from t in flattenedTransactions where t.ClaimTransactionSource == (short)StaticValues.ClaimTransactionSource.Payment && !t.IsClaimPaymentCancelled.GetValueOrDefault(false) && t.PaymentAuthorisationStatus == (short)StaticValues.PaymentAuthorisationStatus.PaymentAuthorised && t.AuthorisationLogs.Any(a => a.ActionedByUserID == user.UserID && a.AuthorisationResult == (short)authorisationResult) && t.TransactionAmountOriginal != null select CreateClaimFinancialAmount(t); return amounts.ToList(); }
private static bool IsRecovery(StaticValues.ClaimTransactionSource claimTransactionSource) { return claimTransactionSource == StaticValues.ClaimTransactionSource.RecoveryReceipt || claimTransactionSource == StaticValues.ClaimTransactionSource.RecoveryReserve; }
/// <summary> /// Check if the user can Manually Authorise the payment /// </summary> /// <param name="user">Syatem User</param> /// <param name="checkLog"> Collection of ClaimFinancialAuthorityLimitCheckResult </param> /// <param name="product"> Product Version </param> /// <param name="check"> Claim Financial Authority Check Type </param> /// <param name="header"> Claim mHeader</param> /// <param name="claimTransactionHeader"> Claim Transaction Header </param> /// <returns> True / False</returns> protected bool CanPerformManualCheck(User user, List<ClaimFinancialAuthorityLimitCheckResult> checkLog, ProductVersion product, StaticValues.ClaimFinancialAuthorityCheckType check, ClaimHeader header, ClaimTransactionHeader claimTransactionHeader) { FinancialAuthorityCheckComponents components = new FinancialAuthorityCheckComponents(claimTransactionHeader.ClaimHeader, null, claimTransactionHeader); var claimArgs = new ClaimHeaderArgument(AmountDataSource.Historical, header, claimTransactionHeader); var result = ClaimFinancialAuthorityCheckUtil.PerformUserLimitCheck(user.UserID, product, StaticValues.ClaimFinancialAuthorityLimitType.LimitForManualAuthorisation, check, claimArgs, components,null); checkLog.Add(result); return result == ClaimFinancialAuthorityLimitCheckResult.NullValue || result.IsAuthorised; }
protected void InitializeAmend(long claimHeaderId, BusinessProcessUsage usage, StaticValues.ClaimStage claimStage, string messageAlias) { this.Initialize(claimHeaderId, usage, claimStage, messageAlias); }
/// <summary> /// Check if the user can Manually Authorise the payment /// </summary> /// <param name="user"> System User </param> /// <param name="checkLog"> Collection of Claim Financial Authority Limit Check Result </param> /// <param name="product"> Product Version </param> /// <param name="check"> Enum Claim Financial Authority Check Type</param> /// <param name="claimTransactionHeader">Claim Transaction Header</param> /// <returns> Bool True / False </returns> protected bool CanPerformManualCheck(User user, List<ClaimFinancialAuthorityLimitCheckResult> checkLog, ProductVersion product, StaticValues.ClaimFinancialAuthorityCheckType check, ClaimTransactionHeader claimTransactionHeader) { FinancialAuthorityCheckComponents components = new FinancialAuthorityCheckComponents(claimTransactionHeader.ClaimHeader, null, claimTransactionHeader); var claimTransactionArgs = new ClaimTransactionHeaderArgument(AmountDataSource.Historical, claimTransactionHeader); // Determine if the manual auth is possible. var result = ClaimFinancialAuthorityCheckUtil.PerformUserLimitCheck(user.UserID, product, StaticValues.ClaimFinancialAuthorityLimitType.LimitForManualAuthorisation, check, claimTransactionArgs, components, null); // Add the result to the checklog that was passed in, a list of results of the ClaimFinancialAuthorityChecks checkLog.Add(result); // Return true or false, appropriately return result == ClaimFinancialAuthorityLimitCheckResult.NullValue || result.IsAuthorised; }
private IEnumerable<ClaimNameInvolvementDto> GetNameInvolvemntList(StaticValues.NameInvolvementType type) { //// Get Driver list return this.HeaderDto.ClaimInvolvements .Where(c => c.Data != null && (c.Data as IClaimInvolvementData).ClaimInvolvementType == (short)StaticValues.LinkableComponentType.NameInvolvement).Where(a => a.ClaimNameInvolvements != null) .SelectMany(b => b.ClaimNameInvolvements).Where(a => a.Data != null && (a.Data as IClaimNameInvolvementData).NameInvolvementMaintenanceStatus == (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest && (a.Data as IClaimNameInvolvementData).NameInvolvementType == (short)type).Cast<ClaimNameInvolvementDto>(); }
public IEnumerable<ClaimFinancialAmount> ReadClaimDetailAmountData(ClaimDetail claimDetail, StaticValues.AmountType amountType, FinancialAmountParticipationFilter filter) { throw new System.NotImplementedException(); }