private int GetScreeningTime(EventPackage eventPackage, IEnumerable <EventTest> eventTests) { int screeningTime = 0; if (eventPackage != null) { screeningTime += eventPackage.Package.ScreeningTime; } if (!eventTests.IsNullOrEmpty()) { screeningTime += eventTests.Sum(et => et.Test.ScreeningTime); } if (eventPackage != null || (eventTests != null && eventTests.Any())) { var eventId = eventPackage != null ? eventPackage.EventId : eventTests.First().EventId; var eventData = _eventRepository.GetById(eventId); if (eventData.IsDynamicScheduling && screeningTime == 0) { screeningTime = MinimumScreeningTime; } if (eventPackage != null && eventData.IsDynamicScheduling && eventData.IsPackageTimeOnly) { screeningTime = eventPackage.Package.ScreeningTime > 0 ? eventPackage.Package.ScreeningTime : MinimumScreeningTime; } } return(screeningTime); }
public HttpResponseMessage UpdateEventPackage(EventPackage updateRecord) { try { if (updateRecord == null) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } // Update the EventPackage record in the Azure SQL DB: int eventPackageResult = _eventPackageWorker.UpdateCreate(updateRecord); if (eventPackageResult > 0) { return(new HttpResponseMessage(HttpStatusCode.OK)); } // Existed already: else if (eventPackageResult == 0) { return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception e) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
public void HandleEvent(EventPackage package) { LoggerHelper.Write(string.Format("params: {0}", package?.ToString())); IDispacher dispacher; switch (package.Tag) { case EventTag.TASK: dispacher = ServiceProvider.Instance.Get <ITaskDispacher>(); break; case EventTag.ERROR: dispacher = ServiceProvider.Instance.Get <IErrorDispacher>(); break; default: dispacher = ServiceProvider.Instance.Get <IDispacher>(); break; } dynamic _ctx = new ExpandoObject(); _ctx.Payload = package.Payload; _ctx.CTSource = new CancellationTokenSource(); dispacher.Dispach(_ctx); }
public void CalculateBuff() { mBuffInfoList.Clear(); EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; //cooperation int num = userPackage.GetManorPersonNumber(); if (num >= 2) { NBuffInfo buff = new NBuffInfo(); buff.type = NBuffType.Cooperation; buff.configID = num; mBuffInfoList.Add(buff); } //world event var infoList = eventPackage.GetCurEventList(); foreach (var info in infoList) { NBuffInfo buff = new NBuffInfo(); buff.type = NBuffType.WorldEvent; buff.configID = info.configID; mBuffInfoList.Add(buff); } }
// 接收AbstractXiepPackage包 public static AbstractXiepPackage ReceivePackage(NetworkStream ns) { String xml = ReceiveXml(ns); if (String.IsNullOrEmpty(xml)) { return(null); } AbstractXiepPackage rtnPackage = null; XmlTreeNode treeNode = XmlTreeNode.FromXml(xml); String packageName = treeNode.Key; if (packageName.Equals("RequestPackage")) { rtnPackage = new RequestPackage(); } else if (packageName.Equals("ResponsePackage")) { rtnPackage = new ResponsePackage(); } else if (packageName.Equals("EventPackage")) { rtnPackage = new EventPackage(); } else { return(null); } rtnPackage.SetRootPackage(treeNode); return(rtnPackage); }
public IEnumerable <CustomerReceiptItem> CreateReceiptItems(Order order, EventPackage package, IEnumerable <EventTest> tests, IEnumerable <OrderedPair <long, long> > orderItemIdTestIdPair, IEnumerable <OrderedPair <long, string> > products) { var items = new List <CustomerReceiptItem>(); order.OrderDetails. Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess). ToList().ForEach(od => { if (od.DetailType == OrderItemType.EventPackageItem) { items.AddRange(CreateEventPackageRecieptItems(package.Package.Tests, od)); } else if (od.DetailType == OrderItemType.EventTestItem) { var test = tests.Where(p => p.Id == od.OrderItem.ItemId).Select(p => p.Test). SingleOrDefault(); items.Add(CreateEventTestRecieptItems(test, od)); } else if (od.DetailType == OrderItemType.ProductItem) { items.Add(CreateProductinRecieptItems(products, od)); } }); return(items); }
public EventCustomerOrderSummaryModel GetEventCustomerOrderSummaryModel(TempCart tempCart, OrderPlaceEditModel orderPlaceEditModel, SourceCodeApplyEditModel sourceCodeModel) { if (tempCart == null) { return(new EventCustomerOrderSummaryModel()); } Event theEvent = null; Host eventHost = null; if (tempCart.EventId.HasValue) { theEvent = _eventRepository.GetById(tempCart.EventId.Value); eventHost = _hostRepository.GetHostForEvent(tempCart.EventId.Value); } EventSchedulingSlot appointment = null; if (tempCart.AppointmentId.HasValue) { appointment = _slotRepository.GetbyId(tempCart.AppointmentId.Value); } EventPackage eventPackage = null; if (orderPlaceEditModel.SelectedPackageId > 0) { eventPackage = _eventPackageRepository.GetById(orderPlaceEditModel.SelectedPackageId); } IEnumerable <EventTest> eventTests = null; if (orderPlaceEditModel.SelectedTestIds != null && orderPlaceEditModel.SelectedTestIds.Count() > 0) { eventTests = _eventTestRepository.GetbyIds(orderPlaceEditModel.SelectedTestIds); } IEnumerable <ElectronicProduct> products = null; if (orderPlaceEditModel.SelectedProductIds != null && orderPlaceEditModel.SelectedProductIds.Count() > 0) { products = _productRepository.GetByIds(orderPlaceEditModel.SelectedProductIds); } ShippingOption shippingOption = null; if (orderPlaceEditModel.SelectedShippingOptionId > 0) { shippingOption = _shippingOptionRepository.GetById(orderPlaceEditModel.SelectedShippingOptionId); } Order order = null; if (tempCart.IsCompleted) { order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value); } return(_eventCustomerSummaryModelFactory.Create(theEvent, eventHost, appointment, eventPackage, eventTests, products, shippingOption, sourceCodeModel, order, tempCart.ShippingId)); }
void xsServer_ClientConnected(object sender, ClientConnectedArgs e) { var dict = new Dictionary <string, string>(); EventPackage eventPackage = new EventPackage("Welcome"); eventPackage.AddArgument("NowTime", DateTime.Now.ToString()); e.setEventPackage(eventPackage); }
void OnGetWorldEvent(NetMsgDef msg) { TSCGetWorldEvent res = TSCGetWorldEvent.ParseFrom(msg.mBtsData); EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; eventPackage.SetHistoryEvent(res); InitView(); RefreshItemInfo(); }
//get item history price public void CalculateGraphInfo(int configID, long startTime, long curTime) { mGraphInfoList.Clear(); EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; ItemPackage itemPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage; ITEM_RES itemConfig = itemPackage.GetItemDataByConfigID(configID); List <NWorldEventInfo> eventList = eventPackage.GetHistoryEventList(); string itemKeyName = itemConfig.KeyName; itemKeyName = char.ToUpper(itemKeyName[0]) + itemKeyName.Substring(1).ToLower(); //reflection System.Type type = System.Type.GetType("com.nkm.framework.resource.data." + "WORLD_EVENTS"); PropertyInfo itemPriceProperty = type.GetProperty(itemKeyName); PropertyInfo itemHasProperty = type.GetProperty("Has" + itemKeyName); NGraphNode preNode = null; NGraphNode node = null; //add start node node = new NGraphNode(); node.price = (double)itemConfig.GoldConv / 1000d; node.time = startTime; mGraphInfoList.Add(node); for (int i = 0; i < eventList.Count; i++) { NWorldEventInfo info = eventList[i]; WORLD_EVENTS eventConfig = eventPackage.GetEventConfigDataByConfigID(info.configID); bool isHas = (bool)itemHasProperty.GetValue(eventConfig, null); if (!isHas) { continue; } double priceArgs = System.Convert.ToDouble(itemPriceProperty.GetValue(eventConfig, null)) / 100; if (info.happenTime <= startTime) { node = mGraphInfoList[0]; node.price *= priceArgs; } else { preNode = mGraphInfoList[mGraphInfoList.Count - 1]; node = new NGraphNode(); if (info.isHappen) { node.price = preNode.price * priceArgs; } else { node.price = preNode.price / priceArgs; } mGraphInfoList.Add(node); } } }
public override void PackageRecieve(EventPackage package, MessageInfo info) { lock (networkIncomingEnqueueSyncObj) { if (RecieverListener != null) { networkPackageQueue.Enqueue(() => { RecieverListener.RecievePackage(package, info); }); } } }
private void btnBroadcastNotice_Click(object sender, EventArgs e) { var eventPackage = new EventPackage(txtNotice.Text.Trim()); foreach (var socket in xsServer.ConnectedClientList) { xsServer.SendEvent(new NetworkStream(socket), eventPackage); } txtNotice.Clear(); }
protected override void Awake() { base.Awake(); iconSprite = transform.Find("icon").GetComponent <UISprite>(); dynamicPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Dynamic) as DynamicPackage; eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; UIEventListener listener = transform.Find("icon").GetComponent <UIEventListener>(); listener.onPress = OnPress; }
/// <summary> /// 发送事件 /// </summary> /// <param name="package"></param> private void SendEvent(EventPackage package) { List <EventHandleDel> list = null; if (m_EventDic.TryGetValue(package.eventType, out list)) { foreach (var item in list) { item(package); } } }
private void OnApplicationFocus(bool focus) { if (!focus) { AppSoftClosed = DateTime.UtcNow; PublishAllEvents(); } else { TimeSpentSoftClosed = (DateTime.UtcNow - GameLaunchTime).Seconds; EventPackage sendPackage = new EventPackage("App_Focused", this, false, ApplicationVersion + " :app_focused"); } }
public int GetScreeningTime(long eventPackageId, IEnumerable <long> eventTestIds) { EventPackage eventPackage = null; if (eventPackageId > 0) { eventPackage = _eventPackageRepository.GetById(eventPackageId); } var eventTests = eventTestIds.IsNullOrEmpty() ? null : _eventTestRepository.GetbyIds(eventTestIds); return(GetScreeningTime(eventPackage, eventTests)); }
protected override void DataChanged(Subscription subscription, DataChangedEventArgs args) { foreach (var change in args.DataChanges) { NodeData nodeData = (NodeData)change.MonitoredItem.UserData; EventVqt @event = new EventVqt(); @event.FillWith(nodeData, change); var package = new EventPackage(@event, plantCode, Constants.RealTime, null); outBuffer.Post(package); } }
private PackageModel GetEventPackage(EventPackage eventPackage) { return(new PackageModel { EventPackageId = eventPackage.Id, Description = eventPackage.Description, Price = eventPackage.Price, PackageName = eventPackage.Package.Name, PackageId = eventPackage.Package.Id, TestItems = GetTestModels(eventPackage.Tests) }); }
//接收服务器响应线程函数 private void receiveResponseThreadFunction() { try { while (true) { //接收请求包 AbstractXiepPackage recvPackage = XiepIoHelper.ReceivePackage(_networkStream); if (recvPackage == null) { throw new IOException("获取数据包失败。"); } //如果是响应数据包 if (recvPackage is ResponsePackage) { ResponsePackage responsePackage = (ResponsePackage)recvPackage; String requestId = responsePackage.RequestId; lock (_mapRequestResponse) { if (_mapRequestResponse.ContainsKey(requestId)) { _mapRequestResponse.Remove(requestId); _mapRequestResponse.Add(requestId, responsePackage); } } } //如果是事件数据包 else if (recvPackage is EventPackage) { EventPackage eventPackage = (EventPackage)recvPackage; //触发收到服务器事件的事件 if (ServerEventCame != null) { ServerEventCame.BeginInvoke(this, new XiepClientEventArgs(eventPackage), new AsyncCallback(delegate(IAsyncResult iar) { }), null); } } } } catch { _networkStream = null; _socket = null; //触发与服务器连接断开事件 if (ServerDisconnected != null) { //ServerDisconnected.BeginInvoke(this, new System.EventArgs(), new AsyncCallback(delegate(IAsyncResult iar) { }), this); ServerDisconnected.Invoke(this, new System.EventArgs()); } } }
public async Task <bool> Handle(AddEventPackageCommand request, CancellationToken cancellationToken) { var _newPackage = new EventPackage { Code = request.PackageDetails.Code, Description = request.PackageDetails.Description, RatePerHead = request.PackageDetails.RatePerHead, Name = request.PackageDetails.Name }; dbContext.EventPackages.Add(_newPackage); await dbContext.SaveChangesAsync(); return(true); }
public void PlaceOrderPersistsOrderWithOneItemSpecified() { IOrderController orderController = new OrderController(); var eventPackage = new EventPackage(3730) { Price = 139.95m, PackageId = 57, EventId = 940 }; orderController.AddItem(eventPackage, 1, 0, 0); orderController.PlaceOrder(OrderType.Retail, 0); // TODO: Test that this actually occurred. }
public int GetScreeningTime(Order order) { var eventPackageOrderItem = order.OrderDetails.SingleOrDefault(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.DetailType == OrderItemType.EventPackageItem); EventPackage eventPackage = null; if (eventPackageOrderItem != null) { var eventPackageId = eventPackageOrderItem.OrderItem.ItemId; eventPackage = _eventPackageRepository.GetById(eventPackageId); } var eventTestIds = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.DetailType == OrderItemType.EventTestItem).Select(od => od.OrderItem.ItemId).ToArray(); var eventTests = eventTestIds.Any() ? _eventTestRepository.GetbyIds(eventTestIds) : null; return(GetScreeningTime(eventPackage, eventTests)); }
private bool DispatchEncryptedMessage(Peer toPassTo, LidgrenTransferPacket packet, NetDeliveryMethod method) { if (!toPassTo.EncryptionRegister.HasKey(packet.EncryptionMethodByte)) { ClassLogger.LogError("Failed to decrypt packet. Client requested unregistered method: " + packet.EncryptionMethodByte); return(false); } try { switch (packet.OperationType) { case Packet.OperationType.Event: EventPackage ep = this.GeneratePackage <EventPackage>(packet, toPassTo.EncryptionRegister[packet.EncryptionMethodByte]); if (ep != null) { toPassTo.PackageRecieve(ep, new MessageInfo(packet, method)); } return(true); case Packet.OperationType.Request: RequestPackage rqp = this.GeneratePackage <RequestPackage>(packet, toPassTo.EncryptionRegister[packet.EncryptionMethodByte]); if (rqp != null) { toPassTo.PackageRecieve(rqp, new MessageInfo(packet, method)); } return(true); case Packet.OperationType.Response: ResponsePackage rp = this.GeneratePackage <ResponsePackage>(packet, toPassTo.EncryptionRegister[packet.EncryptionMethodByte]); if (rp != null) { toPassTo.PackageRecieve(rp, new MessageInfo(packet, method)); } return(true); default: return(false); } } catch (LoggableException e) { ClassLogger.LogError(e.Message + e.InnerException != null ? " Inner: " + e.InnerException : ""); return(false); } }
private bool Dispatch(Peer toPassTo, IPackage packet, NetDeliveryMethod method) { try { //TODO: Refactor switch ((Packet.OperationType)packet.OperationType) { case Packet.OperationType.Event: EventPackage ePackage = GeneratePackage <EventPackage>(packet); if (ePackage != null) { toPassTo.PackageRecieve(ePackage, new MessageInfo(method)); } return(true); case Packet.OperationType.Request: //ClassLogger.LogDebug("Hit request"); RequestPackage rqPackage = GeneratePackage <RequestPackage>(packet); if (rqPackage != null) { //ClassLogger.LogDebug("About to call peer method"); toPassTo.PackageRecieve(rqPackage, new MessageInfo(method)); } return(true); case Packet.OperationType.Response: ResponsePackage rPackage = GeneratePackage <ResponsePackage>(packet); if (rPackage != null) { toPassTo.PackageRecieve(rPackage, new MessageInfo(method)); } return(true); default: return(false); } } catch (LoggableException e) { ClassLogger.LogError(e.Message + e.InnerException != null ? " Inner: " + e.InnerException : ""); return(false); } }
/// <summary> /// Used when an event is raised and the event needs to be published to the analytics server instantly /// </summary> /// <param name="package">Event package we are sending</param> public static void PublishEvent(EventPackage package) { var result = UnityEngine.Analytics.AnalyticsEvent.Custom(ApplicationVersion + ":" + package.EventName, package.Data); if (result != UnityEngine.Analytics.AnalyticsResult.Ok) { UnityEngine.Debug.LogError(package.EventName + " Failed: " + result.ToString()); Log.Write(package.EventName + " Failed: " + result.ToString()); } #if (UNITY_EDITOR || UNITY_EDITOR_OSX) if (Application.isEditor) { //var sendName = ApplicationVersion + ":" + package.EventName + "(" + result.ToString() + ")"; //package.EventName = sendName; EventValidator.RecieveEvent(package, result); //ConvertToJSON(package); } #endif }
public void CalculateVisibleEvent() { EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; var curEventList = eventPackage.GetCurEventList(); foreach (NWorldEventInfo info in curEventList) { mVisibleEventList.Add(info); } var futureList = eventPackage.GetFutureEventList(); foreach (NWorldEventInfo info in futureList) { if (eventPackage.IsVisible(info)) { mVisibleEventList.Add(info); } } }
private IEnumerator EventsSend(float cooldownBeforeSend) { var waitInterval = new WaitForSeconds(cooldownBeforeSend); while (true) { yield return(waitInterval); var list = _storageEvents.GetEvents(); if (list.Count < 0) { continue; } var id = _storageSendingEvents.StoreEvent(list); EventPackage pkg = new EventPackage { events = list }; var evStr = JsonConvert.SerializeObject(pkg); CoroutineManager.Instance.StartCoroutine(PostEvents(id, evStr, OnSuccess, OnError)); } }
internal static void UpdateEventPackage(EventPackage eventPackage, PaymentContext context) { // get all the Tickets, Products and Sponsorships associated with the Event Package var tickets = context.Ticket.Where(t => t.EventPackageId == eventPackage.EventPackageId); Console.WriteLine("Found " + tickets.Count() + " Tickets associated with the Event Package"); var products = context.Product.Where(p => p.EventPackageId == eventPackage.EventPackageId); Console.WriteLine("Found " + products.Count() + " Products associated with the Event Package"); var sponsorships = context.Sponsorship.Where(s => s.EventPackageId == eventPackage.EventPackageId); Console.WriteLine("Found " + sponsorships.Count() + " Sponsorships associated with the Event Package"); decimal ticketNonReceiptable = 0; decimal productNonReceiptable = 0; decimal sponsorshipNonpReceiptable = 0; decimal totalNonReceiptable = 0; var eventPackageTotalAmount = eventPackage.Amount; ticketNonReceiptable = tickets.Sum(t => t.AmountNonreceiptable ?? 0); productNonReceiptable = products.Sum(p => p.AmountNonreceiptable ?? 0); sponsorshipNonpReceiptable = sponsorships.Sum(s => s.AmountNonreceiptable ?? 0); Console.WriteLine("Sum of Ticket Amount Non-Receipetable: " + ticketNonReceiptable); Console.WriteLine("Sum of Product Amount ReceiNon-Receipetablepted: " + productNonReceiptable); Console.WriteLine("Sum of Sponsorship Amount Non-Receipetable: " + sponsorshipNonpReceiptable); totalNonReceiptable = ticketNonReceiptable + productNonReceiptable + sponsorshipNonpReceiptable; Console.WriteLine("Total Amount Non-Receipetable:" + totalNonReceiptable); eventPackage.AmountNonReceiptable = totalNonReceiptable; eventPackage.AmountReceipted = eventPackageTotalAmount - totalNonReceiptable; eventPackage.SyncDate = null; context.Update(eventPackage); context.SaveChanges(); Console.WriteLine("Updated Event Package: " + eventPackage.EventPackageId); }
private void RemoveTestsAlreadyInPackage(List <long> selectedTestIds, long eventId, EventPackage eventPackage) { var package = eventPackage != null ? eventPackage.Package : null; if (package != null && !selectedTestIds.IsNullOrEmpty()) { var packageTestIds = package.Tests.Select(t => t.Id); selectedTestIds.RemoveAll(t => packageTestIds.Contains(t)); } }
public EventCustomerOrderSummaryModel GetEventCustomerOrderSummaryModel(TempCart tempCart, SourceCodeApplyEditModel sourceCodeModel = null) { if (tempCart == null) { return(new EventCustomerOrderSummaryModel()); } Event theEvent = null; Host eventHost = null; if (tempCart.EventId.HasValue) { theEvent = _eventRepository.GetById(tempCart.EventId.Value); eventHost = _hostRepository.GetHostForEvent(tempCart.EventId.Value); } EventSchedulingSlot appointment = null; if (tempCart.AppointmentId.HasValue) { appointment = _slotRepository.GetbyId(tempCart.AppointmentId.Value); } EventPackage eventPackage = null; if (tempCart.EventPackageId.HasValue) { eventPackage = _eventPackageRepository.GetById(tempCart.EventPackageId.Value); } IEnumerable <EventTest> eventTests = null; var testIds = new List <long>(); if (!string.IsNullOrEmpty(tempCart.TestId)) { string[] testIdStrings = tempCart.TestId.Split(new[] { ',' }); foreach (var testIdString in testIdStrings) { int i = 0; if (int.TryParse(testIdString, out i)) { testIds.Add(i); } } } if (testIds.Count > 0) { eventTests = _eventTestRepository.GetbyIds(testIds); } IEnumerable <ElectronicProduct> products = null; var productIds = new List <long>(); if (!string.IsNullOrEmpty(tempCart.ProductId)) { string[] productIdStrings = tempCart.ProductId.Split(new[] { ',' }); foreach (var productIdIdString in productIdStrings) { int i = 0; if (int.TryParse(productIdIdString, out i)) { productIds.Add(i); } } } if (productIds.Count > 0) { products = _productRepository.GetByIds(productIds); } ShippingOption shippingOption = null; if (tempCart.ShippingId.HasValue && tempCart.ShippingId.Value > 0) { shippingOption = _shippingOptionRepository.GetById(tempCart.ShippingId.Value); } SourceCodeApplyEditModel applySourceCodemodel = sourceCodeModel ?? GetSourceCodeApplied(tempCart); Order order = null; if (tempCart.IsCompleted) { order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value); } return(_eventCustomerSummaryModelFactory.Create(theEvent, eventHost, appointment, eventPackage, eventTests, products, shippingOption, applySourceCodemodel, order, tempCart.ShippingId)); }