private static MethodDefinition BootstrapMethodTo(AssemblyDefinition whichAssToReplaceIn, MethodDefinition definitionOldMethod, TypeDefinition definitionTypeReturn, MethodDefinition delegateToMethod) { ModuleDefinition main = whichAssToReplaceIn.MainModule; definitionOldMethod.Name = $"{definitionOldMethod.Name}BackupCall"; //Create new method and use it instead var definitionNewMethod = new MethodDefinition( "CreateNew", MethodAttributes.Public | MethodAttributes.Static, definitionOldMethod.ReturnType); definitionNewMethod.Parameters.Add( definitionOldMethod.Parameters[0]); definitionTypeReturn.Methods.Add(definitionNewMethod); { var processor = definitionNewMethod.Body.GetILProcessor(); processor.Body.Instructions.Clear(); processor.Emit(OpCodes.Ldarg_0); processor.Emit(OpCodes.Call, main.ImportReference(delegateToMethod)); processor.Emit(OpCodes.Ret); } CallHelper.ReplaceCall(definitionOldMethod, definitionNewMethod, whichAssToReplaceIn); return(definitionNewMethod); }
private void btnCall_Click(object sender, EventArgs e) { if (this.callHelper == null || !this.callHelper.IsCallEstablished) { if (!this.parent.SocketHelper.InititateCallConnection()) { MessageBox.Show("An error ocurred while trying to establish your call. Please try again.", "Error establishing call", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.btnCall.Image = Resources.EndCallIcon; this.toolTipInfo.SetToolTip(btnCall, "End call"); this.callHelper = new CallHelper(); this.callHelper.DataAvailable += callHelper_DataAvailable; callHelper.EstablishCall(); } else { this.callHelper.CloseCall(); this.btnCall.Image = Resources.CallIcon; this.toolTipInfo.SetToolTip(btnCall, "Initiate call"); } }
Button_Compare[] button;//buttons array public source() { InitializeComponent(); button = new Button_Compare[] { firstbutton, secondbutton, thirdbutton }; helper = new CallHelper(Motion); r = new Random(); }
private void CastError(GameClient client) { client.LastCastedSpell = null; client.LastCastTarget = null; client.IsCurrentlyCasting = false; CallHelper.Reset(); }
internal static void SpellBegin(object sender, Packet e) { var client = Collections.AttachedClients[(int)sender]; client.IsCurrentlyCasting = true; CallHelper.Reset(); CasterHelper.Reset(); }
public void BillCurrentMonth() { var monthlyPlan = MockData.MonthlyPayment; var monthlyPlanRemainingAmount = 0.0; var callsForProcessing = MockData.CallsMade; double totalPrice = 0.0; double localCallsTotalPrice = 0.0; double externalCallsTotalPrice = 0.0; CallHelper helperInstance = new CallHelper(); helperInstance.ProcessCalls(ref callsForProcessing); MonthlyBill bill = new MonthlyBill(callsForProcessing, monthlyPlan); var processedCalls = callsForProcessing.OrderBy(c => c.TimeCalled).ToList(); //Debug order //var processedCalls = callsForProcessing; totalPrice = processedCalls.Sum(s => s.Cost); localCallsTotalPrice = processedCalls.Where(c => c.CallType == CallType.Local || c.CallType == CallType.LocalPrime).Sum(c => c.Cost); externalCallsTotalPrice = processedCalls.Where(c => c.CallType == CallType.National || c.CallType == CallType.International).Sum(c => c.Cost); monthlyPlanRemainingAmount = monthlyPlan.Amount - totalPrice; Console.WriteLine("Abono mensual: $" + monthlyPlan.Amount); Console.WriteLine("Detalle de consumos del mes (por fecha):"); Console.WriteLine("Tipo de llamada | Destino | Costo por Minuto | Horario de llamado | Duración (en minutos) | Costo total por llamada"); //Print recipe foreach (var call in processedCalls) { Console.Write(call.CallType.ToString() + " | "); Console.Write(call.Destination.Name + " | "); Console.Write("$" + call.Destination.Cost.ToString() + " | "); Console.Write(call.TimeCalled.DayOfWeek + ", " + call.TimeCalled.ToString() + " | "); Console.Write(call.DurationInMinutes.ToString() + " | "); Console.Write("$" + call.Cost.ToString()); Console.WriteLine(); } Console.WriteLine("Consumo en llamadas Locales: $" + localCallsTotalPrice); Console.WriteLine("Consumo en llamadas Nacionales/Internacionales: $" + externalCallsTotalPrice); Console.WriteLine("Costo total en consumo mensual: $" + totalPrice); Console.WriteLine("Crédito restante en el plan mensual: $" + monthlyPlanRemainingAmount); Console.WriteLine("Presione cualquier tecla para salir..."); Console.ReadKey(); }
public CallResult <IList <ImageInfo> > GetMainImageFromUrl(string url, IWebPageParser pageParser, out long downloadedSize) { downloadedSize = 0; var html = String.Empty; try { /* * <div id="imgTagWrapperId" class="imgTagWrapper" style="height: 801.299px;"> * * <img alt="Sara's Prints Little Girls' Short Sleeve Nightie, Red/Pink Chevron, 2" * src="http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY879_.jpg" * data-old-hires="http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UL1500_.jpg" * class="a-dynamic-image a-stretch-vertical" id="landingImage" * data-a-dynamic-image="{"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY606_.jpg":[405,606],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY879_.jpg":[587,879],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY741_.jpg":[495,741],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY445_.jpg":[297,445],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY500_.jpg":[334,500],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY679_.jpg":[453,679],"http://ecx.images-amazon.com/images/I/81YDdI2Rk0L._UY550_.jpg":[367,550]}" style="max-height: 801px; max-width: 587px;"> * * </div> */ var htmlResult = _htmlScraper.GetHtml(url, ProxyUseTypes.Amazon, (proxy, status, content) => { return(status == HttpStatusCode.OK && pageParser.ValidateHtml(content)); }); if (htmlResult.IsSuccess) { html = htmlResult.Data; downloadedSize = html.Length; return(pageParser.GetLargeImages(html)); } else { CallHelper.ThrowIfFail(htmlResult); } } catch (Exception ex) { _log.Error("Parsing html page issue, url=" + url, ex); _log.Info("HTML: " + html); return(new CallResult <IList <ImageInfo> >() { Status = CallStatus.Fail, Exception = ex, }); } return(new CallResult <IList <ImageInfo> >() { Status = CallStatus.Fail }); }
private void AlreadyCursed(GameClient client, Match match) { client.IsCurrentlyCasting = false; if (client.LastCastTarget == null || client.LastCastedSpell == null) { return; } string value = match.Groups[1].Value; if (!string.IsNullOrWhiteSpace(value)) { SetIsCursed(client, value); } CallHelper.Reset(); }
internal static void EquipmentUpdated(object sender, Packet e) { var client = Collections.AttachedClients[(int)sender]; var slot = e.ReadByte(); e.ReadInt16(); e.ReadByte(); var name = e.ReadString8(); if (slot == 1) { if (Collections.BaseStaffs.ContainsKey(name)) { client.EquippedWeaponId = Collections.BaseStaffs[name].Id; client.EquippedWeapon = name; client.LastEquipmentUpdate = DateTime.Now; Console.WriteLine(client.EquippedWeaponId); } CallHelper.Reset(); } }
private void AlreadyCasted(GameClient client) { client.IsCurrentlyCasting = false; if (client.LastCastTarget == null || client.LastCastedSpell == null) { return; } #region curse if (client.LastCastedSpell.Name.StartsWith("ard cradh")) { SetIsCursed(client, "ard cradh"); } #endregion #region fas if (client.LastCastedSpell.Name.StartsWith("mor fas nadur")) { SetIsFas(client, "mor fas nadur"); } #endregion CallHelper.Reset(); }
private void InternalOpenBrowser(object sender, EventArgs e) { CallHelper.OpenBrowser(releasePageURL); }
private void bttHomepage_Click(object sender, EventArgs e) { CallHelper.OpenBrowser(navigationURL); Close(); }
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) { CallHelper.OpenBrowser(e.LinkText); }
private void toolStripFeedback_Click(object sender, EventArgs e) { CallHelper.SendFeedback(this); }
private void txtDescription_LinkClicked(object sender, LinkClickedEventArgs e) { CallHelper.OpenBrowser(e.LinkText); }
public override void Instrument(AnankeContext ananke, AssemblyDefinition ass) { var main = ass.MainModule; AssemblyDefinition attachment = AssemblyDefinition.ReadAssembly("Ananke.Attachment.Core.dll"); //TODO: Deduplicate code //SoLInventoryItemHandlerBypass { var bootstrapMethod = attachment.MainModule.Types.First(t => t.Name == "SoLInventoryItemHandlerBypass") .Methods .First(m => m.IsStatic && m.Name == "GetNewItemByItemType"); var inventoryItemHandlerTypedef = main.Types.First(t => t.Name == "InventoryItemHandler"); var getNewItemByItemTypeMethoddef = inventoryItemHandlerTypedef.Methods.First(m => m.Name == "GetNewItemByItemType"); getNewItemByItemTypeMethoddef.Name = "GetNewItemByItemTypeAnankeBackupCall"; var getNewItemByItemTypeMethoddefExternationProbe = new MethodDefinition( "GetNewItemByItemType", MethodAttributes.Public | MethodAttributes.Static, getNewItemByItemTypeMethoddef.ReturnType); getNewItemByItemTypeMethoddefExternationProbe.Parameters.Add( getNewItemByItemTypeMethoddef.Parameters[0]); inventoryItemHandlerTypedef.Methods.Add(getNewItemByItemTypeMethoddefExternationProbe); { var processor = getNewItemByItemTypeMethoddefExternationProbe.Body.GetILProcessor(); processor.Body.Instructions.Clear(); processor.Emit(OpCodes.Ldarg_0); processor.Emit(OpCodes.Call, main.ImportReference(bootstrapMethod)); processor.Emit(OpCodes.Ret); } CallHelper.ReplaceCall(getNewItemByItemTypeMethoddef, getNewItemByItemTypeMethoddefExternationProbe, ass); } //SoLStaticLivingEntityInlineRegistryBypass { var bootstrapMethod = attachment.MainModule.Types .First(t => t.Name == "SoLStaticLivingEntityInlineRegistryBypass").Methods.First(m => m.IsStatic && m.Name == "GetNewLivingEntityByStaticPrefabType"); var definitionTypeReturn = main.Types.First(t => t.Name == "LivingEntity"); var definitionTypeEnumerator = main.Types.First(t => t.Name == "LivingEntityType"); var definitionOldMethod = definitionTypeReturn.Methods.First(m => m.Name == "CreateNew" && m.Parameters[0].ParameterType == definitionTypeEnumerator); BootstrapMethodTo(ass, definitionOldMethod, definitionTypeReturn, bootstrapMethod); var bootstrapNameToTypeMethod = attachment.MainModule.Types .First(t => t.Name == "SoLStaticLivingEntityInlineRegistryBypass").Methods.First(m => m.IsStatic && m.Name == "GetNewLivingEntityTypeByName"); var definitionNameToTypeOldMethod = definitionTypeReturn.Methods.First(m => m.Name == "GetLivingEntityTypeByName"); BootstrapMethodTo(ass, definitionNameToTypeOldMethod, definitionTypeReturn, bootstrapNameToTypeMethod); } /* * TODO PRODUCTION CRITICAL: * OVERRIDE GetNewStaticPrefabByName as well otherwise * Workshop(yes, it is at least partially is in the game) support * and multiplayer will break. */ //SoLStaticPrefabBypass { var bootstrapMethod = attachment.MainModule.Types.First(t => t.Name == "SoLStaticPrefabInlineRegistryBypass") .Methods .First(m => m.IsStatic && m.Name == "GetNewStaticPrefabByStaticPrefabType"); var inventoryItemHandlerTypedef = main.Types.First(t => t.Name == "StaticPrefab"); var getNewItemByItemTypeMethoddef = inventoryItemHandlerTypedef.Methods.First(m => m.Name == "GetNewStaticPrefabByStaticPrefabType"); getNewItemByItemTypeMethoddef.Name = "GetNewStaticPrefabByStaticPrefabTypeAnankeBackupCall"; var getNewItemByItemTypeMethoddefExternationProbe = new MethodDefinition( "GetNewStaticPrefabByStaticPrefabType", MethodAttributes.Public | MethodAttributes.Static, getNewItemByItemTypeMethoddef.ReturnType); getNewItemByItemTypeMethoddefExternationProbe.Parameters.Add( getNewItemByItemTypeMethoddef.Parameters[0]); inventoryItemHandlerTypedef.Methods.Add(getNewItemByItemTypeMethoddefExternationProbe); { var processor = getNewItemByItemTypeMethoddefExternationProbe.Body.GetILProcessor(); processor.Body.Instructions.Clear(); processor.Emit(OpCodes.Ldarg_0); processor.Emit(OpCodes.Call, main.ImportReference(bootstrapMethod)); processor.Emit(OpCodes.Ret); } CallHelper.ReplaceCall(getNewItemByItemTypeMethoddef, getNewItemByItemTypeMethoddefExternationProbe, ass); } //Phase hook OnAfterInitialRecipesWereLoaded { var delegatorMethod = attachment.MainModule.Types.First(t => t.Name == "SoLPhaseDelegator").Methods .First(m => m.IsStatic && m.Name == "OnAfterInitialRecipesWereLoaded"); var solClass = main.Types.FirstOrDefault(t => t.Name == "SpaceGame"); var solClassLoadContentMethod = solClass.Methods.FirstOrDefault(m => m.Name == "LoadContent"); var solClassLoadContentMethodIL = solClassLoadContentMethod.Body.GetILProcessor(); var ilcodeCall = solClassLoadContentMethodIL.Create(OpCodes.Call, main.ImportReference(delegatorMethod)); solClassLoadContentMethodIL.InsertAfter( solClassLoadContentMethodIL.Body.Instructions.First(i => i.OpCode == OpCodes.Call && ((MethodReference)i.Operand).Name.Contains("GetRecipes")).Next,//We pick a call and step after result assignment ilcodeCall ); } }
/// <summary> /// Actions performed when "Submit feature request" menu clicked. /// </summary> private static void ExecuteFeature(object sender, EventArgs e) { CallHelper.OpenBrowser(SharedStrings.About_Feature); }
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index) { CallHelper.DecompileCall(true, this, Buf, OwnerStub, Index); }
private void CastedSpell(GameClient client, Match match) { client.IsCurrentlyCasting = false; if (client.LastCastTarget == null || client.LastCastedSpell == null) { return; } string value = match.Groups[1].Value; switch (value) { #region fas case "beag fas nadur": SetIsFas(client, value); break; case "fas nadur": SetIsFas(client, value); break; case "mor fas nadur": SetIsFas(client, value); break; case "ard fas nadur": SetIsFas(client, value); break; #endregion #region curse case "beag cradh": SetIsCursed(client, value); break; case "cradh": SetIsCursed(client, value); break; case "mor cradh": SetIsCursed(client, value); break; case "ard cradh": SetIsCursed(client, value); break; case "Dark Seal": SetIsCursed(client, value); break; case "Darker Seal": SetIsCursed(client, value); break; #endregion #region aite case "beag naomh aite": case "naomh aite": case "mor naomh aite": case "ard naomh aite": #endregion #region Ao case "ao beag cradh": if (client.Attributes.Serial == client.LastCastTarget.Serial) { client.Attributes.HasBC = false; } break; case "ao cradh": if (client.Attributes.Serial == client.LastCastTarget.Serial) { client.Attributes.HasCradh = false; } break; case "ao mor cradh": if (client.Attributes.Serial == client.LastCastTarget.Serial) { client.Attributes.HasMorCradh = false; } break; case "ao ard cradh": if (client.Attributes.Serial == client.LastCastTarget.Serial) { client.Attributes.HasArdCradh = false; } break; #endregion default: break; } CallHelper.Reset(); }
public void SendEmail(IUnitOfWork db, ILogService log, IEmailService emailService, IQuantityManager quantityManager, DateTime when, long?by) { CallResult <Exception> result; if (AppSettings.IsDemo) { result = CallResult <Exception> .Success(null); } else { result = emailService.SendEmail(this, CallSource.UI, by); } CallHelper.ThrowIfFail(result); Order order = null; switch (this.EmailType) { case EmailTypes.RequestFeedback: db.Orders.UpdateRequestedFeedback(this.OrderNumber); break; case EmailTypes.AddressVerify: db.Orders.UpdateRequestedAddressVerify(this.OrderNumber); break; case EmailTypes.LostPackage: break; case EmailTypes.LostPackage2: break; case EmailTypes.UndeliverableAsAddressed: break; case EmailTypes.ExchangeInstructions: if (ExchangeItems != null) { var exchangeToItems = ExchangeItems.Where(i => i.InputQuantity > 0).ToList(); if (exchangeToItems.Any()) { var model = new QuantityOperationDTO() { Type = (int)QuantityOperationType.ExchangeOnHold, OrderId = this.OrderNumber, Comment = "Sent Exchange Instruction", QuantityChanges = exchangeToItems.Select(i => new QuantityChangeDTO() { Quantity = i.InputQuantity, StyleId = i.ExchangeStyleId ?? 0, StyleItemId = i.ExchangeStyleItemId ?? 0, StyleString = i.ExchangeStyleString, ExpiredOn = when.AddDays(14), Tag = "Exchanged from: " + i.StyleString + ", styleItemId: " + i.StyleItemId, }).ToList(), }; quantityManager.AddQuantityOperation(db, model, when, by); } foreach (var item in ExchangeItems) { log.Info("Exchange item, from styleId=" + item.StyleId + " styleItemId=" + item.StyleItemId + " --- to styleId=" + item.ExchangeStyleId + ", styleItemId=" + item.ExchangeStyleItemId + ", quantity=" + item.InputQuantity); //TODO: save into DB } } break; } if (!String.IsNullOrEmpty(NewComment)) { AddOrderComment(db, OrderNumber, NewComment, when, by); } var emailNotifyType = EmailNotifyHelper.GetEmailNotifyFrom(this.EmailType); db.OrderEmailNotifies.Add(new OrderEmailNotify() { OrderNumber = this.OrderNumber, Reason = "User emailed, webpage", Type = (int)emailNotifyType, CreateDate = when, CreatedBy = by }); db.Commit(); if (ReplyToEmailId.HasValue) { var email = db.Emails.Get(ReplyToEmailId.Value); if (email != null) { email.ResponseStatus = (int)EmailResponseStatusEnum.Sent; db.Commit(); log.Info("Mark as responsed (as reply), emailId=" + email.Id); } } if (!String.IsNullOrEmpty(this.OrderNumber)) { var orderEmails = db.Emails.GetAllByOrderId(this.OrderNumber) .Where(e => e.FolderType == (int)EmailFolders.Inbox && ((String.IsNullOrEmpty(e.AnswerMessageID) && e.ResponseStatus == (int)EmailResponseStatusEnum.None) || e.ResponseStatus == (int)EmailResponseStatusEnum.ResponsePromised)) .ToList(); foreach (var email in orderEmails) { var dbEmail = db.Emails.Get(email.Id); dbEmail.ResponseStatus = (int)EmailResponseStatusEnum.Sent; log.Info("Mark as responsed (by orderNumber), emailId=" + email.Id); } db.Commit(); } }
private void CastMissed(GameClient client) { CallHelper.Reset(); }
/// <summary> /// Actions performed when "Visit homepage" menu clicked. /// </summary> private static void ExecuteVisit(object sender, EventArgs e) { CallHelper.OpenBrowser(SharedStrings.About_Hopemage); }
private void GmPorted(GameClient client) { client.Paused = true; CallHelper.Reset(); }
public static string HttpPost(this string url, Dictionary <string, object> postParams, HttpPostCfg httpCfg = null) { if (string.IsNullOrWhiteSpace(url)) { throw new FException("url不能为空"); } if (postParams == null || !postParams.Any()) { throw new FException("postParams不能为空"); } if (httpCfg == null) { httpCfg = CreateDefaultHttpPostCfg(); } else if (httpCfg.ReTryCount <= 0) { httpCfg.ReTryCount = 1;//至少执行一次 } var restRequest = new RestRequest(Method.POST); restRequest.Timeout = 10 * 1000;//连接超时设置为10秒 restRequest.AddHeader("Accept", "*/*"); string contentType = GetContentType(httpCfg.ContentType); restRequest.AddHeader("Content-Type", contentType); if (httpCfg.ContentType == ContentType.Json) { restRequest.AddJsonBody(postParams); } else if (httpCfg.ContentType == ContentType.Text) { string queryString = postParams.GetUrlParams(); restRequest.AddParameter(contentType, queryString, ParameterType.RequestBody); } else if (httpCfg.ContentType == ContentType.Form) { foreach (var param in postParams) { restRequest.AddParameter(param.Key, param.Value); } } //如果是网络连接异常,那么重试 IRestResponse restResponse = null; CallHelper.ReTryRun(reTryCount: httpCfg.ReTryCount, reTryAction: () => { restResponse = new RestClient(url).ExecuteAsync(restRequest).Result; bool hasNetWorkError = restResponse.ErrorException is System.Net.WebException; bool isReTrySuc = !hasNetWorkError; return(isReTrySuc); }, remark: "HttpPost"); //响应状态码是否表示成功 OK(200) if (!restResponse.IsSuccessful) { var errSb = new StringBuilder(); errSb.AppendLine($"{url}接口异常"); errSb.AppendLine($"Content:{restResponse.Content}"); errSb.AppendLine($"StatusCode:{restResponse.StatusCode}"); errSb.AppendLine($"ResponseStatus:{restResponse.ResponseStatus}"); errSb.AppendLine($"ErrorMessage:{restResponse.ErrorMessage}"); throw new Exception(errSb.ToString(), restResponse.ErrorException); } return(restResponse.Content); }
private void LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CallHelper.OpenBrowser(SharedStrings.About_Releases); }