コード例 #1
0
        private void CreateNewContent()
        {
            Console.Clear();
            EventContent newContent = new EventContent();

            //Type of event
            Console.WriteLine("Enter the event type (Golf, Bowling, Concert, Sporting event, etc:");
            newContent.TypeOfEvent = Console.ReadLine();

            //Date of event
            Console.WriteLine("Enter the date of the event (01/08/2025:");
            newContent.DateOfEvent = Console.ReadLine();

            //Number of people that will attend
            Console.WriteLine("Enter the number of people that will attend the event");
            string peopleAsString = Console.ReadLine();

            newContent.NumberOfPeopleThatAttend = int.Parse(peopleAsString);

            //Cost per person
            Console.WriteLine("Eneter the cost per person (123.45):");
            string costAsString = Console.ReadLine();

            newContent.CostPerPerson = double.Parse(costAsString);

            //Total cost of event
            Console.WriteLine("Enter the total cost of the event (1234.56)");
            string totalAsString = Console.ReadLine();

            newContent.TotalCostOfEvent = double.Parse(totalAsString);
        }
コード例 #2
0
        //View Existing Content by event
        private void DisplayContentbyEvent()
        {
            Console.Clear();
            //Prompt the user to give me an event
            Console.WriteLine("Enter the name of the event that you would like to see:");

            //Get the users input
            string typeOfEvent = Console.ReadLine();

            //Find the content by that event
            EventContent content = _contentRepo.GetContentByTypeOfEvent(typeOfEvent);

            //Display said content if it isnt't null
            if (content != null)
            {
                Console.WriteLine($"TypeOfEvent: {content.TypeOfEvent}\n " +
                                  $"Date: {content.DateOfEvent}\n" +
                                  $"Number of Attendees {content.NumberOfPeopleThatAttend}\n" +
                                  $"Cost per person {content.CostPerPerson}\n" +
                                  $"Total cost of event {content.TotalCostOfEvent}");
            }
            else
            {
                Console.WriteLine("No content by that event.");
            }
        }
コード例 #3
0
 public PSEventContent(EventContent eventContent)
 {
     Id        = eventContent?.Id;
     Timestamp = eventContent?.Timestamp;
     Action    = eventContent?.Action;
     Target    = new PSTarget(eventContent?.Target);
     Request   = new PSRequest(eventContent?.Request);
     ActorName = eventContent?.Actor?.Name;
     Source    = new PSSource(eventContent?.Source);
 }
コード例 #4
0
        //Seed method
        private void SeedContentList()
        {
            EventContent golf    = new EventContent("Golf", "10/20/2020", 50, 50.00, 2500.00);
            EventContent concert = new EventContent("Concert", "10/25/2020", 20, 120, 2400.00);
            EventContent bowling = new EventContent("Bowling", "11/20/2020", 40, 20, 800.00);

            _contentRepo.AddContentToList(golf);
            _contentRepo.AddContentToList(concert);
            _contentRepo.AddContentToList(bowling);
        }
コード例 #5
0
        //Update Existing Content
        private void UpdateExistingContent()
        {
            //Display all content
            DisplayAllContent();

            //Ask for the event of the content to update
            Console.WriteLine("Enter the event of the content you'd like to update:");

            //Get that event
            string oldEvent = Console.ReadLine();

            //We will build a new object
            EventContent newContent = new EventContent();

            //Type of event
            Console.WriteLine("Enter the event type (Golf, Bowling, Concert, Sporting event, etc:");
            newContent.TypeOfEvent = Console.ReadLine();

            //Date of event
            Console.WriteLine("Enter the date of the event (01/08/2025:");
            newContent.DateOfEvent = Console.ReadLine();

            //Number of people that will attend
            Console.WriteLine("Enter the number of people that will attend the event");
            string peopleAsString = Console.ReadLine();

            newContent.NumberOfPeopleThatAttend = int.Parse(peopleAsString);

            //Cost per person
            Console.WriteLine("Eneter the cost per person (123.45):");
            string costAsString = Console.ReadLine();

            newContent.CostPerPerson = double.Parse(costAsString);

            //Total cost of event
            Console.WriteLine("Enter the total cost of the event (1234.56)");
            string totalAsString = Console.ReadLine();

            newContent.TotalCostOfEvent = double.Parse(totalAsString);

            //Verify the update worked
            bool wasUpdated = _contentRepo.UpdateExistingContent(oldEvent, newContent);

            if (wasUpdated)
            {
                Console.WriteLine("Content sucsessfully updated!");
            }
            else
            {
                Console.WriteLine("Could not update the content.");
            }
        }
コード例 #6
0
        /// <summary>
        /// Adds a set event relative to the context path
        /// </summary>
        public void AddSetEvent(int field, EventContent content)
        {
            if (!EventsEnabled)
            {
                return;
            }
            var e = new EventData {
                Set = content
            };

            AddPath(e.Path, field);
            AddEvent(e);
        }
コード例 #7
0
    public static void HandleNpcTalkEventType(GameSession session, NpcScript npcScript, int eventId)
    {
        ScriptEvent scriptEvent = npcScript.Contents.First().Events.FirstOrDefault(x => x.Id == eventId);

        if (scriptEvent is null)
        {
            return;
        }

        int          indexContent  = Random.Shared.Next(scriptEvent.Contents.Count);
        EventContent eventContents = scriptEvent.Contents[indexContent];

        session.Send(NpcTalkPacket.CustomText(eventContents.Text, eventContents.VoiceId, eventContents.Illustration));
    }
コード例 #8
0
        /// <inheritdoc />
        public override void AddSetEvent(EventPath path, EventContent content)
        {
            if (!_mapContext.EventsEnabled)
            {
                return;
            }
            var e = new EventData {
                Set = content
            };

            e.Path.AddRange(path.Path);

            AddUpdateEvent(e);
        }
コード例 #9
0
        public string GenerateInvoiceContent(EventContent item)
        {
            // I would use Razor templating and css etc if I had time
            var template = @"
<html>
    <head><title>Invoice {0}</title></head>
    <body>
        <h1>Invoice {0}</h1>
        <h3>Status {1}</h2>
        <h3>Created {2}</h2>
    </body>
</html>
";

            return(string.Format(template, item.InvoiceNumber, item.Status, item.CreatedDateUtc));
        }
コード例 #10
0
        public async Task <IActionResult> Create(EventForm form)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                var eventModel = new Event(user);
                _context.Events.Add(eventModel);
                var content = new EventContent(eventModel.Id, form.Title, form.EventDate, eventModel, form.Description, form.Address, form.Phone);
                _context.EventContents.Add(content);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(form));
        }
コード例 #11
0
        public async Task <EventContentDto> CreateAsync(EventContentDto dto)
        {
            var ec = new EventContent
            {
                Name         = dto.Name,
                Description  = dto.Description,
                IsDeleted    = false,
                Content      = dto.Content,
                ContentType  = dto.ContentType,
                CreatedAt    = DateTime.Now,
                LastModified = DateTime.Now,
                Event        = await _unitOfWork.Events.Query.FirstOrDefaultAsync(e => e.Id == dto.EventId),
                Order        = dto.Order
            };

            _unitOfWork.EventContents.Create(ec);
            await _unitOfWork.SaveChangesAsync();

            return(dto);
        }
コード例 #12
0
        // 最新訊息 - 活動寫真 - 最新活動內容
        public ActionResult EventLatestContent(int?ID, int?pagingID)
        {
            if (!ID.HasValue)
            {
                return(RedirectToAction("EventLatest"));
            }
            //======語系取得========
            string langCd = GetLang();
            //======================
            EventLatestRepository repo  = new EventLatestRepository();
            EventContent          model = repo.GetContentByID((int)ID, langCd);

            if (pagingID != null)
            {
                model.PagingID = (int)pagingID;
                var pagFirst = model.Data.PagingList.Where(s => s.ID == (int)pagingID).FirstOrDefault();
                if (pagFirst == null)
                {
                    return(RedirectToAction("EventLatest"));
                }
                pagFirst.Current = "current";
            }
            else
            {
                if (model.Data.PagingList.Count > 0)
                {
                    model.Data.PagingList.First().Current = "current";
                }
            }

            //=瀏覽記錄====================
            DataTable d_log;
            string    err_msg = "";

            DB.Log_Insert(ID.ToString(), "News");
            d_log = DB.Log_List(ref err_msg, ID.ToString(), "News");
            ViewData["log_count"] = d_log.Rows.Count.ToString();
            //============================

            return(View(model));
        }
コード例 #13
0
        /// <summary>
        /// 內容
        /// </summary>
        /// <param name="id"></param>
        /// <param name="lagCode"></param>
        /// <returns></returns>
        public EventContent GetContentByID(int id, string lagCode)
        {
            EventContent result = new EventContent();

            using (var db = new TCGDB(_connectionString))
            {
                var sourceList = db.ACTIVITY
                                 .AsEnumerable()
                                 .Where(s => (string.IsNullOrEmpty(lagCode) ? true : s.LANG_ID == lagCode) &&
                                        s.STATUS != "D")
                                 .OrderByDescending(o => o.SORT)
                                 .OrderByDescending(s => s.C_DATE)
                                 .ToList();

                var source = sourceList.Where(s => s.ID == id).FirstOrDefault();
                if (source == null)
                {
                    throw new Exception("無法取得活動內容,是否已被移除.");
                }

                result.Data = new EventLatestData()
                {
                    ID                = source.ID,
                    Title             = source.C_TITLE,
                    Img               = GetMainImg(source.ID),
                    PagingList        = GetPagingListByID(source.ID),
                    PublishDateString = source.C_DATE.Value.ToString("yyyy-MM-dd"),
                    Remark            = source.C_DESC
                };
                //result.Data.Remark = GetFirstPagingRemark(result.Data.PagingList);
                int dataIndex     = sourceList.IndexOf(source);
                int lastDataIndex = sourceList.Count - 1;
                result.PreviousIDStr = dataIndex == 0 ? "" : sourceList[(dataIndex - 1)].ID.ToString();
                result.NextIDStr     = dataIndex == lastDataIndex ? "" : sourceList[(dataIndex + 1)].ID.ToString();
            }

            return(result);
        }
コード例 #14
0
ファイル: Event.cs プロジェクト: Sharparam/cshrix-bot
 /// <summary>
 /// Initializes a new instance of the <see cref="Event" /> class.
 /// </summary>
 /// <param name="content">The content of the event.</param>
 /// <param name="id">The ID of the event.</param>
 /// <param name="type">The type of the event.</param>
 /// <param name="stateKey">The state key of the event, if any.</param>
 /// <param name="roomId">The ID of the room the event is associated with.</param>
 /// <param name="sender">The ID of the user who sent this event, if any.</param>
 /// <param name="sentAt">The date and time at which the event was sent.</param>
 /// <param name="previousContent">The previous content of the event.</param>
 /// <param name="redacts">The ID of another event to redact.</param>
 /// <param name="unsigned">Optional extra data about the event.</param>
 public Event(
     EventContent content,
     [CanBeNull] string id,
     string type,
     [CanBeNull] string stateKey,
     [CanBeNull] string roomId,
     [CanBeNull] UserId sender,
     DateTimeOffset?sentAt,
     [CanBeNull] EventContent previousContent,
     [CanBeNull] string redacts,
     UnsignedData?unsigned)
 {
     Content         = content;
     Id              = id;
     Type            = type;
     StateKey        = stateKey;
     RoomId          = roomId;
     Sender          = sender;
     SentAt          = sentAt;
     PreviousContent = previousContent;
     Redacts         = redacts;
     Unsigned        = unsigned;
 }
コード例 #15
0
 private void EVSdkWrapper_EventContent(EVContentInfoCli contentInfo)
 {
     WorkerThreadManager.Instance.EVSdkWorkDispatcher.InvokeAsync(() => {
         EventContent?.Invoke(contentInfo);
     });
 }
コード例 #16
0
ファイル: clsSerialIo.cs プロジェクト: wollfman/ToolsManage
        /// <summary>
        /// 更新和记录 继电器 控制设备 运行或关闭
        /// </summary>
        public void DeviceNewAndRecord(int iRoomIndex, EventType eventType, DeviceRunState onOrOff, DeviceRunModel handOrAuto, bool blRecord)
        {
            EventContent eventContent = EventContent.开启;

            if (onOrOff == DeviceRunState.运行)
            {
                eventContent = EventContent.开启;
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.State = DeviceRunState.运行;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.State = DeviceRunState.运行;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.State = DeviceRunState.运行;
                    }
                }
            }
            else if (onOrOff == DeviceRunState.停止)
            {
                eventContent = EventContent.关闭;
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.State = DeviceRunState.停止;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.State = DeviceRunState.停止;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.State = DeviceRunState.停止;
                    }
                }
            }
            if (handOrAuto == DeviceRunModel.手动)
            {
                if (eventType == EventType.烘干)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomHot.TimeHand   = DateTime.Now;
                    }
                }
                else if (eventType == EventType.除湿)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomDehumi.TimeHand   = DateTime.Now;
                    }
                }
                else if (eventType == EventType.新风)
                {
                    lock (clsEnvirControl.listRoom)
                    {
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.HandOrAuto = DeviceRunModel.手动;
                        clsEnvirControl.listRoom[iRoomIndex].roomFan.TimeHand   = DateTime.Now;
                    }
                }
            }
            if (blRecord)
            {
                string strSql = "insert into tb_EnviriEvent (Type,Area,Reason,EventContent,Time)values " +
                                "('" + eventType.ToString() + "','" + clsEnvirControl.listRoom[iRoomIndex].StrName + "','" + handOrAuto.ToString() + "'," +
                                "'" + eventContent.ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                datalogic.SqlComNonQuery(strSql);

                //if (NewEventShowEvent != null)
                //{
                //    string strPoint = strArea;
                //    if (blMoreAir)
                //        strPoint += btAddr.ToString();
                //    if (content == EventContent.设置温度)
                //    {
                //        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString() + btSetTemp.ToString(), "", ""));
                //    }
                //    else
                //    {
                //        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString(), "", ""));
                //    }
                //}
            }
        }
コード例 #17
0
ファイル: frmEnvirState.cs プロジェクト: wollfman/ToolsManage
        private void sbtnAirSet_Click(object sender, EventArgs e)
        {
            string strOnOff = cbbAirOnOff.Text;
            string strMode  = cbbModel.Text;
            string strTemp  = tbAirTemp.Text;

            if (string.IsNullOrEmpty(strOnOff))
            {
                MessageUtil.ShowError("空调启停不可为空!");
                return;
            }
            if (string.IsNullOrEmpty(strMode))
            {
                MessageUtil.ShowError("空调模式不可为空!");
                return;
            }
            if (string.IsNullOrEmpty(strTemp))
            {
                MessageUtil.ShowError("空调设置温度不可为空!");
                return;
            }

            sbtnAirSet.Enabled       = false;
            clsEnvirControl.blAskAir = false;
            iAirClick = 30;
            Thread.Sleep(600);

            #region  空调控制

            DeviceRunState state = DeviceRunState.停止;
            EventContent   OnOff = EventContent.关闭;
            if (cbbAirOnOff.Text == DeviceRunState.停止.ToString())
            {
                OnOff = EventContent.关闭;
                state = DeviceRunState.停止;
            }
            else if (cbbAirOnOff.Text == DeviceRunState.运行.ToString())
            {
                OnOff = EventContent.开启;
                state = DeviceRunState.运行;
            }

            AirRunModel  airRunModel = AirRunModel.制冷;
            EventContent model       = EventContent.设置制冷;
            if (cbbModel.Text == AirRunModel.制冷.ToString())
            {
                airRunModel = AirRunModel.制冷;
                model       = EventContent.设置制冷;
            }
            else if (cbbModel.Text == AirRunModel.制热.ToString())
            {
                airRunModel = AirRunModel.制热;
                model       = EventContent.设置制热;
            }
            byte bTemp = Convert.ToByte(tbAirTemp.Text);

            string strArea   = clsEnvirControl.listRoom[iIndex].StrName;
            bool   blMoreAir = false;//是否 为 一个房间多台空调
            if (clsEnvirControl.listRoom[iIndex].listAir.Count > 1)
            {
                blMoreAir = true;
            }
            for (int iIndexAir = 0; iIndexAir < clsEnvirControl.listRoom[iIndex].listAir.Count; iIndexAir++)//房间内的 所有空调
            {
                #region  启停

                if (clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].State != state)
                {
                    AirFactoryType factory = clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].AirType;
                    byte           addr    = (byte)clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].IntAddr;
                    bool           blRet   = serialAir.AirControl(factory, addr, OnOff, 26, strArea, DeviceRunModel.手动, blMoreAir, IsWait.OnlyWait);
                    if (blRet)
                    {
                        lock (clsEnvirControl.listRoom)
                        {
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].State      = state;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].HandOrAuto = DeviceRunModel.手动;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].TimeHand   = DateTime.Now;
                        }
                    }
                    else
                    {
                        MessageUtil.ShowTips(addr.ToString() + "#空调启停设置失败!");
                        iAirClick = 0;
                        clsEnvirControl.blAskAir = true;
                        sbtnAirSet.Enabled       = true;
                        return;
                    }
                }

                #endregion

                #region  模式

                if (clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].Model != airRunModel)
                {
                    AirFactoryType factory = clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].AirType;
                    byte           addr    = (byte)clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].IntAddr;
                    bool           blRet   = serialAir.AirControl(factory, addr, model, 26, strArea, DeviceRunModel.自动, blMoreAir, IsWait.OnlyWait);
                    if (blRet)
                    {
                        lock (clsEnvirControl.listRoom)
                        {
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].Model      = airRunModel;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].HandOrAuto = DeviceRunModel.手动;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].TimeHand   = DateTime.Now;
                        }
                    }
                    else
                    {
                        MessageUtil.ShowTips(addr.ToString() + "# 空调模式设置失败!");
                        iAirClick = 0;
                        clsEnvirControl.blAskAir = true;
                        sbtnAirSet.Enabled       = true;
                        return;
                    }
                }

                #endregion

                #region  温度

                if (clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].IntTempSet != bTemp)
                {
                    AirFactoryType factory = clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].AirType;
                    byte           addr    = (byte)clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].IntAddr;
                    bool           blRet   = serialAir.AirControl(factory, addr, EventContent.设置温度, bTemp, strArea, DeviceRunModel.自动, blMoreAir, IsWait.OnlyWait);
                    if (blRet)
                    {
                        lock (clsEnvirControl.listRoom)
                        {
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].IntTempSet = clsEnvirSet.intSetTempCool;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].HandOrAuto = DeviceRunModel.手动;
                            clsEnvirControl.listRoom[iIndex].listAir[iIndexAir].TimeHand   = DateTime.Now;
                        }
                    }
                    else
                    {
                        MessageUtil.ShowTips(addr.ToString() + "# 空调温度设置失败!");
                        iAirClick = 0;
                        clsEnvirControl.blAskAir = true;
                        sbtnAirSet.Enabled       = true;
                        return;
                    }
                }


                #endregion
            }
            #endregion
            iAirClick = 0;
            clsEnvirControl.blAskAir = true;
            sbtnAirSet.Enabled       = true;
        }
コード例 #18
0
ファイル: clsSerialAir.cs プロジェクト: wollfman/ToolsManage
        ///// <summary>
        ///// 新告警显示 事件
        ///// </summary>
        //public event NewEventShowEventHandler NewAlarmShowEvent;

        #endregion

        /// <summary>
        /// 空调控制 及SQL 存储
        /// </summary>
        public bool AirControl(AirFactoryType factory, byte btAddr, EventContent content, byte btSetTemp, string strArea, DeviceRunModel runMode, bool blMoreAir, IsWait isWait)
        {
            bool   blRet      = false;
            string strContent = content.ToString();

            #region  大金 空调控制

            if (factory == AirFactoryType.大金)
            {
                if (content == EventContent.开启 || content == EventContent.关闭)
                {
                    if (content == EventContent.开启)
                    {
                        blRet = DjAirControl(btAddr, DjControlType.开关, (byte)DjOnOff.开启, isWait);
                    }
                    else if (content == EventContent.关闭)
                    {
                        blRet = DjAirControl(btAddr, DjControlType.开关, (byte)DjOnOff.关闭, isWait);
                    }
                }
                else if (content == EventContent.设置制冷 || content == EventContent.设置制热 || content == EventContent.设置除湿)
                {
                    if (content == EventContent.设置制冷)
                    {
                        blRet = DjAirControl(btAddr, DjControlType.模式, (byte)DjModel.制冷, isWait);
                    }
                    else if (content == EventContent.设置制热)
                    {
                        blRet = DjAirControl(btAddr, DjControlType.模式, (byte)DjModel.制热, isWait);
                    }
                    else if (content == EventContent.设置除湿)
                    {
                    }
                }
                else if (content == EventContent.设置温度)
                {
                    blRet      = DjAirControl(btAddr, DjControlType.温度, btSetTemp, isWait);
                    strContent = content.ToString() + btSetTemp.ToString();
                }
            }

            #endregion

            #region  其他 空调控制

            else if (factory == AirFactoryType.其他)
            {
                if (content == EventContent.开启 || content == EventContent.关闭)
                {
                    if (content == EventContent.开启)
                    {
                        blRet = OtherAirControl(btAddr, OtherAirControlType.开关, (byte)OtherAirOnOff.开启, isWait);
                    }
                    else if (content == EventContent.关闭)
                    {
                        blRet = OtherAirControl(btAddr, OtherAirControlType.开关, (byte)OtherAirOnOff.关闭, isWait);
                    }
                }
                else if (content == EventContent.设置制冷 || content == EventContent.设置制热 || content == EventContent.设置除湿)
                {
                    if (content == EventContent.设置制冷)
                    {
                        blRet = OtherAirControl(btAddr, OtherAirControlType.模式, (byte)OtherAirModelType.制冷, isWait);
                    }
                    else if (content == EventContent.设置制热)
                    {
                        blRet = OtherAirControl(btAddr, OtherAirControlType.模式, (byte)OtherAirModelType.制热, isWait);
                    }
                    else if (content == EventContent.设置除湿)
                    {
                    }
                }
                else if (content == EventContent.设置温度)
                {
                    blRet      = OtherAirControl(btAddr, OtherAirControlType.温度, btSetTemp, isWait);
                    strContent = content.ToString() + btSetTemp.ToString();
                }
            }

            #endregion

            if (blRet)
            {
                commonCls.NewEnvirEventRecord(EventType.空调, strArea, runMode, strContent);

                if (NewEventShowEvent != null)
                {
                    string strPoint = strArea + " ";
                    if (blMoreAir)
                    {
                        strPoint += btAddr.ToString();
                        strPoint += "#空调";
                    }

                    if (content == EventContent.设置温度)
                    {
                        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString() + btSetTemp.ToString(), "", "", DateTime.Now));
                    }
                    else
                    {
                        NewEventShowEvent(new NewEventEventArgs(EventType.空调, strPoint, content.ToString(), "", "", DateTime.Now));
                    }
                }
            }

            return(blRet);
        }
コード例 #19
0
 /// <summary>
 /// Returns the data for the specified EventContent
 /// </summary>
 public abstract T GetItem(EventContent data);
コード例 #20
0
        /// <summary>
        /// Fills the database with default data.
        /// </summary>
        /// <param name="context">The dbcontext to use.</param>
        /// <returns>The task representing the operation.</returns>
        public static async Task FillWithDefaultAsync(this UnderSeaDatabaseContext context)
        {
            // Effects, Buildings, researches
            // áramlásirányító
            var popIn = new Effect {
                Name = KnownValues.PopulationIncrease, Value = 50
            };
            var cp = new Effect {
                Name = KnownValues.CoralProductionIncrease, Value = 200
            };
            var currentController = new BuildingType {
                CostPearl = 1000, CostCoral = 0, BuildTime = 5, MaxCount = -1
            };

            // zátonyvár
            var bsIn = new Effect {
                Name = KnownValues.BarrackSpaceIncrease, Value = 200
            };
            var reefCastle = new BuildingType {
                CostPearl = 1000, CostCoral = 0, BuildTime = 5, MaxCount = -1
            };

            // Iszaptraktor
            var harvMod1 = new Effect {
                Name = KnownValues.HarvestModifier, Value = 0.1
            };
            var mudT = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Iszapkombájn
            var harvMod2 = new Effect {
                Name = KnownValues.HarvestModifier, Value = 0.15
            };
            var mudC = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // korallfal
            var defMod1 = new Effect {
                Name = KnownValues.UnitDefenseModifier, Value = 0.2
            };
            var wall = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Szonárágyú
            var attMod1 = new Effect {
                Name = KnownValues.UnitAttackModifier, Value = 0.2
            };
            var canon = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Harcművészet
            var combModA = new Effect {
                Name = KnownValues.UnitAttackModifier, Value = 0.1
            };
            var combModD = new Effect {
                Name = KnownValues.UnitDefenseModifier, Value = 0.1
            };
            var martialArts = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Alchemy
            var taxMod1 = new Effect {
                Name = KnownValues.TaxationModifier, Value = 0.3
            };
            var alchemy = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };


            // Add effects, buildings, researches
            context.Effects.AddRange(popIn, cp, bsIn, harvMod1, harvMod2,
                                     defMod1, attMod1, combModA, combModD, taxMod1);
            context.BuildingTypes.AddRange(currentController, reefCastle);
            context.ResearchTypes.AddRange(mudT, mudC, wall, canon, martialArts, alchemy);
            await context.SaveChangesAsync();


            // Add effects to buildings and researches
            context.BuildingEffects.AddRange(
                new BuildingEffect {
                Building = currentController, Effect = popIn
            },
                new BuildingEffect {
                Building = currentController, Effect = cp
            },
                new BuildingEffect {
                Building = reefCastle, Effect = bsIn
            });

            context.ResearchEffects.AddRange(
                new ResearchEffect {
                Research = mudT, Effect = harvMod1
            },
                new ResearchEffect {
                Research = mudC, Effect = harvMod2
            },
                new ResearchEffect {
                Research = wall, Effect = defMod1
            },
                new ResearchEffect {
                Research = canon, Effect = attMod1
            },
                new ResearchEffect {
                Research = martialArts, Effect = combModA
            },
                new ResearchEffect {
                Research = martialArts, Effect = combModD
            },
                new ResearchEffect {
                Research = alchemy, Effect = taxMod1
            });
            await context.SaveChangesAsync();


            // Add units
            // rohamfóka
            var seal = new UnitType
            {
                AttackPower = 6, DefensePower = 2, CostPearl = 50, CostCoral = 0, MaintenancePearl = 1, MaintenanceCoral = 1
            };
            // csatacsikó
            var pony = new UnitType
            {
                AttackPower = 2, DefensePower = 6, CostPearl = 50, CostCoral = 0, MaintenancePearl = 1, MaintenanceCoral = 1
            };
            // lézercápa
            var lazor = new UnitType
            {
                AttackPower = 5, DefensePower = 5, CostPearl = 100, CostCoral = 0, MaintenancePearl = 3, MaintenanceCoral = 2
            };
            // hadvezér
            var leader = new LeaderType
            {
                AttackPower = 0, DefensePower = 0, CostPearl = 400, CostCoral = 0, MaintenancePearl = 4, MaintenanceCoral = 2
            };

            context.UnitTypes.AddRange(seal, pony, lazor, leader);
            await context.SaveChangesAsync();


            // Add events
            var plague        = new RandomEvent();
            var removeCurrent = new Effect
            {
                TargetId = currentController.Id, Name = KnownValues.AddBuildingEffect, Value = -1
            };

            var fire         = new RandomEvent();
            var removeCastle = new Effect
            {
                TargetId = reefCastle.Id, Name = KnownValues.AddBuildingEffect, Value = -1
            };

            var mine     = new RandomEvent();
            var addPearl = new Effect
            {
                Value = 1000, Name = KnownValues.PearlProductionIncrease
            };

            var goodHarvest = new RandomEvent();
            var extraCoral  = new Effect
            {
                Name = KnownValues.BuildingProductionIncrease, Value = 50
            };

            var badHarvest = new RandomEvent();
            var lessCoral  = new Effect
            {
                Name = KnownValues.BuildingProductionIncrease, Value = -50
            };

            var contentPopulation = new RandomEvent();
            var addCurrent        = new Effect
            {
                Name = KnownValues.AddBuildingEffect, TargetId = currentController.Id, Value = 1
            };
            var discontentPopulation = new RandomEvent();

            var contentSoldiers = new RandomEvent();
            var addAttack       = new Effect
            {
                Name = KnownValues.IncreaseUnitAttack, Value = 1
            };

            var discontentSoldiers = new RandomEvent();
            var removeAttack       = new Effect
            {
                Name = KnownValues.IncreaseUnitAttack, Value = -1
            };

            await context.SaveChangesAsync();

            // Add event effects
            context.EventEffects.AddRange(
                new EventEffect {
                Effect = removeCurrent, Event = plague
            },
                new EventEffect {
                Effect = removeCastle, Event = fire
            },
                new EventEffect {
                Effect = addPearl, Event = mine
            },
                new EventEffect {
                Effect = extraCoral, Event = goodHarvest
            },
                new EventEffect {
                Effect = lessCoral, Event = badHarvest
            },
                new EventEffect {
                Effect = addCurrent, Event = contentPopulation
            },
                new EventEffect {
                Effect = removeCurrent, Event = discontentPopulation
            },
                new EventEffect {
                Effect = addAttack, Event = contentSoldiers
            },
                new EventEffect {
                Effect = removeAttack, Event = discontentSoldiers
            }
                );
            await context.SaveChangesAsync();


            // Add contents
            var currentCont = new BuildingContent
            {
                Parent       = currentController,
                Name         = "Áramlásirányító",
                Description  = "+50 lakos, 200 korall / kör",
                ImageUrl     = "images/static/buildings/aramlasiranyito-lg.png",
                IconImageUrl = "images/static/buildings/aramlasiranyito-icon.png"
            };

            var reefCastCont = new BuildingContent
            {
                Parent       = reefCastle,
                Name         = "Zátonyvár",
                Description  = "+200 szállás",
                ImageUrl     = "images/static/buildings/zatonyvar-lg.png",
                IconImageUrl = "images/static/buildings/zatonyvar-icon.png"
            };

            context.BuildingContents.AddRange(currentCont, reefCastCont);

            var sealCont = new UnitContent
            {
                Parent       = seal,
                Name         = "Rohamfóka",
                Description  = "Jól támad de rosszul véd",
                ImageUrl     = "images/static/units/rohamfoka.svg",
                IconImageUrl = "images/static/units/rohamfoka.svg"
            };
            var ponyCont = new UnitContent
            {
                Parent       = pony,
                Name         = "Csatacsikó",
                Description  = "Jól véd de rosszul támad",
                ImageUrl     = "images/static/units/csatacsiko.svg",
                IconImageUrl = "images/static/units/csatacsiko.svg"
            };
            var lazorCont = new UnitContent
            {
                Parent       = lazor,
                Name         = "Lézercápa",
                Description  = "lazers man",
                ImageUrl     = "images/static/units/lezercapa.svg",
                IconImageUrl = "images/static/units/lezercapa.svg"
            };
            var leaderCont = new UnitContent
            {
                Parent      = leader,
                Name        = "Parancsnok",
                Description = "Támadást csak parancsnok tud vezetni",
            };

            context.UnitContents.AddRange(sealCont, ponyCont, lazorCont, leaderCont);

            var mudTCont = new ResearchContent
            {
                Parent       = mudT,
                Name         = "Iszap traktor",
                Description  = "Iszapozza a korallt (amitől amúgy IRL meghalna, korall nem növény nem kell neki föld), +10% korall termelés",
                ImageUrl     = "images/static/researches/iszaptraktor-lg.png",
                IconImageUrl = "images/static/researches/iszaptraktor-sm.png"
            };
            var mudCCont = new ResearchContent
            {
                Parent       = mudC,
                Name         = "Iszap kombájn",
                Description  = "Nagyon iszapozza a korallt, +15% korall termelés",
                ImageUrl     = "images/static/researches/iszapkombajn-lg.png",
                IconImageUrl = "images/static/researches/iszapkombajn-sm.png"
            };
            var defCont = new ResearchContent
            {
                Parent       = wall,
                Name         = "Korallfal",
                Description  = "Fal, korallból. +20% védekezés",
                ImageUrl     = "images/static/buildings/korallfal.svg",
                IconImageUrl = "images/static/buildings/korallfal.svg"
            };
            var attCont = new ResearchContent
            {
                Parent       = canon,
                Name         = "Szonárágyú",
                Description  = "Mint a denevér, echo-lokáció. +20% támadás",
                ImageUrl     = "images/static/researches/szonaragyu-lg.png",
                IconImageUrl = "images/static/researches/szonaragyu-sm.png"
            };
            var cCont = new ResearchContent
            {
                Parent       = martialArts,
                Name         = "Vízalatti harcművészetek",
                Description  = "\"A különbség a lehetetlen és a lehetséges között az egyén akarata.\", +10% védekezés és támadás",
                ImageUrl     = "images/static/buildings/vizalatti-harcmuveszetek.svg",
                IconImageUrl = "images/static/buildings/vizalatti-harcmuveszetek.svg"
            };
            var taxCont = new ResearchContent
            {
                Parent       = alchemy,
                Name         = "Alkímia",
                Description  = "A népesség pénzt csinál, +30% adó bevétel",
                ImageUrl     = "images/static/buildings/alkimia.svg",
                IconImageUrl = "images/static/buildings/alkimia.svg"
            };

            context.ResearchContents.AddRange(mudTCont, mudCCont, defCont, attCont, cCont, taxCont);

            var plagueCont = new EventContent
            {
                Parent      = plague,
                Name        = "Pestis",
                Description = "Az országodban kitört a pestis, elveszítesz 50 embert és egy áramlásirányítót.",
                FlavourText = "Hozzátok a halottakat!"
            };
            var fireCont = new EventContent
            {
                Parent      = fire,
                Name        = "Víz alatti tűz",
                Description = "Az országodban tűz ütött ki és leégett egy zátonyvár.",
                FlavourText = "Tűz víz alatt? Micsoda?!"
            };
            var mineCont = new EventContent
            {
                Parent      = mine,
                Name        = "Aranybánya",
                Description = "Az embereid felfedeztek egy új aranybányát, kapsz 1000 bónusz aranyat.",
                FlavourText = "Nagyon fényes"
            };
            var goodhvCont = new EventContent
            {
                Parent      = goodHarvest,
                Name        = "Jó termés",
                Description = "Minden áramlásirányító +50 korallt ad ebben a körben.",
                FlavourText = "A termés egy stabil ország alapja"
            };
            var badhvCont = new EventContent
            {
                Parent      = badHarvest,
                Name        = "Rossz termés",
                Description = "Minden áramlásirányító -50 korallt ad ebben a körben.",
                FlavourText = "A király lakomázik, a paraszt éhezik"
            };
            var contPopCont = new EventContent
            {
                Parent      = contentPopulation,
                Name        = "Elégedett emberek",
                Description = "Az országodban elégedettek az emberek, ezért extra 50 ember költözött be és építettek maguknak egy áramlásirányítót.",
                FlavourText = "Nő a nép, nő a felelősség"
            };
            var discontPopCont = new EventContent
            {
                Parent      = discontentPopulation,
                Name        = "Elégedetlen emberek",
                Description = "Az országodban elégedetlenek az emberek, ezért 50 ember elköltözött és az áramlásirányítójukat lerombolták.",
                FlavourText = "A paraszt elmegy, pusztítást hagy maga után"
            };
            var contSolCont = new EventContent
            {
                Parent      = contentSoldiers,
                Name        = "Elégedett katonák",
                Description = "Katonáid elégedettek ebben a körben, minden katona támadása nő eggyel.",
                FlavourText = "Elégedett katona motivált katona"
            };
            var disconSolCont = new EventContent
            {
                Parent      = discontentSoldiers,
                Name        = "Elégedetlen katonák",
                Description = "Katonáid elégedetlenek ebben a körben, minden katona támadása csökken eggyel.",
                FlavourText = "Elsőnek a morál, utána a hűség"
            };

            context.EventContents.AddRange(plagueCont, mineCont, fireCont, goodhvCont, badhvCont,
                                           contPopCont, contSolCont, disconSolCont, discontPopCont);
            await context.SaveChangesAsync();


            // globals
            context.GlobalValues.Add(new GlobalValue
            {
                BaseTaxation              = 25,
                Round                     = 1,
                StartingBarrackSpace      = 0,
                StartingCorals            = 2000,
                StartingPearls            = 2000,
                StartingPopulation        = 0,
                LootPercentage            = 0.5,
                UnitLossOnLostBatle       = 0.1,
                RandomEventChance         = 0.1,
                RandomEventGraceTimer     = 10,
                ScoreBuildingMultiplier   = 50,
                ScoreResearchMultiplier   = 100,
                ScorePopulationMultiplier = 1,
                ScoreUnitMultiplier       = 5,
                FirstStartingBuilding     = reefCastle,
                SecondStartingBuilding    = currentController,
                RandomAttackModifier      = 0.1
            });
            await context.SaveChangesAsync();
        }