Esempio n. 1
0
 public bool Update(Empresa emp, out Error.Error err)
 {
     Error.Error error = new Error.Error();
     try
     {
         using (DataAccess.ACMEEntities db = new ACMEEntities())
         {
             Empresas objEmpresa = Mapper.MapperEmpresa.MapSingleEmpresaToEntity(emp);
             db.Entry(objEmpresa).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         error.mensaje = "Edición realizada con exito.";
         error.ok      = true;
     }
     catch (Exception e)
     {
         error.ok      = false;
         error.mensaje = "error al editar empresa " + e.Message;
     }
     err = error;
     return(err.ok);
 }
Esempio n. 2
0
 public bool Save(List <Empresa> lst, out Error.Error err)
 {
     Error.Error error = new Error.Error();
     try
     {
         using (DataAccess.ACMEEntities db = new ACMEEntities())
         {
             List <Empresas> em = Mapper.MapperEmpresa.MapEmpresaToEntity_tolist(lst);
             db.Empresas.Add(em[0]);
             db.SaveChanges();
         }
         error.mensaje = "Empresa añadida con exito";
         error.ok      = true;
     }
     catch (Exception e)
     {
         error.ok      = false;
         error.mensaje = "Error al añadir empresa" + e.Message;
     }
     err = error;
     return(error.ok);
 }
Esempio n. 3
0
        public static void LogError(Error.Error error)
        {
            try
            {
                const string ConnectionString = DbServer;

                // Create a MongoClient object by using the connection string
                var client = new MongoClient(ConnectionString);

                //Use the MongoClient to access the server
                var database = client.GetDatabase("mimdb");

                var collection = database.GetCollection <Error.Error>("Error");



                collection.InsertOne(error);
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 4
0
        public static void UpdatePlayer(Player player)
        {
            if (player.Target != null)
            {
                HubContext.getHubContext.Clients.Client(player.HubGuid)
                .addNewMessageToPage("You can't save while fighting");
                return;
            }

            try
            {
                const string ConnectionString = DbServer;

                // Create a MongoClient object by using the connection string
                var client = new MongoClient(ConnectionString);

                //Use the MongoClient to access the server
                var database = client.GetDatabase("mimdb");

                var collection = database.GetCollection <Player>("Player");

                collection.ReplaceOne <Player>(x => x._id == player._id, player);

                HubContext.getHubContext.Clients.Client(player.HubGuid)
                .addNewMessageToPage("The gods take note of your progress");
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Update player"
                };

                Save.LogError(log);
            }
        }
Esempio n. 5
0
        public JsonResult GenerateCode(string key)
        {
            Error.Error error = null;

            WebHTCBackEnd.Models.Events.THC_EventCodeGen objCodeGen = new Models.Events.THC_EventCodeGen();
            DataTable codegenData = objCodeGen.queryEventCodeGenByKey(key, out error);

            string retJson;

            if (error != null)
            {
                retJson = Newtonsoft.Json.JsonConvert.SerializeObject(error);
            }
            else
            {
                //if (codegenData.Rows.Count == 1)
                {
                    string strEventKey  = codegenData.Rows[0]["AE001"].ToString();
                    string strEventName = codegenData.Rows[0]["AE003"].ToString();
                    int    iQRBit       = int.Parse(codegenData.Rows[0]["AE010"].ToString());
                    int    iSerialBit   = int.Parse(codegenData.Rows[0]["AE011"].ToString());
                    int    iLen         = int.Parse(codegenData.Rows[0]["AE018"].ToString());
                    int    iTotalQty    = int.Parse(codegenData.Rows[0]["EQCH007"].ToString());
                    int    iSerial      = int.Parse(codegenData.Rows[0]["AE017"].ToString()) + 1;


                    THC_CodeTypeLib.CodeGenProxy codeProxy = (THC_CodeTypeLib.CodeGenProxy)
                                                             Activator.GetObject(typeof(THC_CodeTypeLib.CodeGenProxy),
                                                                                 "tcp://127.0.0.1:8000/RemoteCodeGen");
                    string strId = codeProxy.CodeGenerate(strEventName, strEventKey, key, iLen, iSerialBit, iQRBit, iTotalQty, iSerial);

                    retJson = string.Format("[{{ \"STATE\" : \"{0}\", \"ID\" : \"{1}\" }}]",
                                            "RUN", strId);
                }
            }

            return(Json(retJson, "application/json", JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public JsonResult UpdateEventData(string event_no)
        {
            var EventNo    = Request.Form["txt_event_no"];
            var EventName  = Request.Form["txt_event_name"];
            var Vender     = Request.Form["txt_vender"];
            var Lunch      = Request.Form["txt_lunch"];
            var StartTime  = Request.Form["txt_start_time"];
            var EndTime    = Request.Form["txt_end_time"];
            var CodeId     = Request.Form["txt_code_id"];
            var CodeNums   = Request.Form["txt_code_nums"];
            var QRBit      = Request.Form["txt_qr_bit"];
            var SerialBit  = Request.Form["txt_serial_bit"];
            var ComBit     = "0";//Request.Form["txt_com_bit"];
            var Production = Request.Form["txt_product"];
            var WebUrl     = Request.Form["txt_web_url"];
            var EventType  = Request.Form["txt_event_type"];
            var Memo       = Request.Form["txt_memo"];
            var Length     = Request.Form["txt_qr_length"];
            var Page       = Request.Form["txt_page"];

            Error.Error error = null;
            WebHTCBackEnd.Models.Events.THC_Event events = new Models.Events.THC_Event();
            events.updateEvent(EventNo, EventName, Vender, Lunch, StartTime, EndTime, CodeId, CodeNums, QRBit,
                               SerialBit, ComBit, Production, WebUrl, EventType, Memo, Length, Page, out error);

            string retJson;

            if (error != null)
            {
                retJson = Newtonsoft.Json.JsonConvert.SerializeObject(error);
            }
            else
            {
                retJson = WebHTCBackEnd.Utility.JsonResponeUtility.ResultOK();
            }

            return(Json(retJson, "application/json", JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
        public static void Show(PlayerSetup.Player player)
        {
            try
            {
                if (player.Effects != null)
                {
                    if (player.Effects.Count > 0)
                    {
                        HubContext.Instance.SendToClient("You are affected by the following affects:", player.HubGuid);

                        foreach (var affect in player.Effects)
                        {
                            HubContext.Instance.SendToClient(affect.Name + " (" + affect.Duration + ") ticks ", player.HubGuid);
                        }
                    }
                    else
                    {
                        HubContext.Instance.SendToClient("You are not affected by anything.", player.HubGuid);
                    }
                }
                else
                {
                    HubContext.Instance.SendToClient("You are not affected by anything.", player.HubGuid);
                }
            }

            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "return name"
                };

                Save.LogError(log);
            }
        }
Esempio n. 8
0
        //select EQC001,EQC002,EQC003,EQC004,EQC005,EC,AEP003,AEP004,AEP005,AEP006,AE003,AE013,AE014
        //from event_qrcode_d as a left join activity_event_prize as b
        //on a.EQC007=b.AEP001 inner join activity_event as c on a.EQC001=c.AE002

        public DataTable getQRRecords(string event_key, out Error.Error error)
        {
            error = null;
            DataTable returnTable = null;
            string    strSQL      = "select AE002,AE003,b.* from activity_event as a inner join export_log as b " +
                                    "on AE001=EPL002 where AE002=@AE002 ";

            try
            {
                dbControl.Open();
                returnTable = dbControl.GetDataTable(strSQL, paraList);
                paraList.Clear();
                if (returnTable.Rows.Count == 0)
                {
                    strSQL = "select AE001 from activity_event where AE002=@AE002";
                    paraList.Add(new SqlParameter("@AE002", event_key));
                    IDataReader dataReader = dbControl.GetReader(strSQL, paraList);
                    dataReader.Read();
                    event_key = dataReader[0].ToString();
                    dataReader.Close();
                }
                else
                {
                    event_key = returnTable.Rows[0]["EPL002"].ToString();
                }
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }
            return(returnTable);
        }
Esempio n. 9
0
 public bool save(FechasBOE fecha, out Error.Error err)
 {
     Error.Error error = new Error.Error();
     try
     {
         using (DataAccess.ACMEEntities db = new ACMEEntities())
         {
             FechasDescargaBOE ent = Mapper.MapperFecha.MapFechaDATOEntity(fecha);
             db.FechasDescargaBOE.Add(ent);
             db.SaveChanges();
         }
         error.ok      = true;
         error.mensaje = "fecha añadida con exito";
     }
     catch (Exception e)
     {
         error.ok      = false;
         error.mensaje = "Error al añadir fecha";
         Console.WriteLine(e.Message);
     }
     err = error;
     return(error.ok);
 }
Esempio n. 10
0
        public bool GetListadoFechas(out List <FechasBOE> lst, out Error.Error err)
        {
            Error.Error      error     = new Error.Error();
            List <FechasBOE> lstResult = new List <FechasBOE>();

            try
            {
                using (DataAccess.ACMEEntities db = new ACMEEntities())
                {
                    lstResult = Mapper.MapperFecha.MapFechaEntityToDA_tolist(db.FechasDescargaBOE.ToList());
                }
                error.mensaje = "Fechas obtenidas con exito";
                error.ok      = true;
            }
            catch (Exception e)
            {
                error.mensaje = "Error al obtener las fechas de descarga del BOE" + e.Message;
                error.ok      = false;
            }
            err = error;
            lst = lstResult;
            return(err.ok);
        }
Esempio n. 11
0
        public JsonResult AllotReward(string key, string event_key, string jobid)
        {
            string jobFile = System.IO.Path.Combine(Server.MapPath("~/codeupload"), jobid + ".txt");

            Error.Error error;
            string      retJson;

            if (!System.IO.File.Exists(jobFile))
            {
                error = new Error.Error();
                error.ErrorMessage = "上傳工作檔案已不存在";
                error.Number       = 102;
                retJson            = Newtonsoft.Json.JsonConvert.SerializeObject(error);
            }
            else
            {
                WebHTCBackEnd.Models.Events.THC_EventReward eventReward = new Models.Events.THC_EventReward();
                List <string> rwdList = eventReward.getRewardArrayByjobId(jobFile, out error);


                if (error != null)
                {
                    retJson = Newtonsoft.Json.JsonConvert.SerializeObject(error);
                }
                else
                {
                    THC_CodeTypeLib.RewardProxy rewardProxy = (THC_CodeTypeLib.RewardProxy)
                                                              Activator.GetObject(typeof(THC_CodeTypeLib.RewardProxy),
                                                                                  "tcp://127.0.0.1:8000/RemoteReward");
                    rewardProxy.RewardAllotForEdenred(key, event_key, rwdList, jobid);
                    retJson = string.Format("[{{ \"STATE\" : \"{0}\" }}]",
                                            "RUN", "OK");
                }
            }

            return(Json(retJson, JsonRequestBehavior.AllowGet));
        }
Esempio n. 12
0
        public static void UpdateRooms()
        {
            var context = HubContext.getHubContext;
            var rooms   = Cache.ReturnRooms();

            if (rooms.Count == 0)
            {
                return;
            }

            try
            {
                foreach (var room in rooms)
                {
                    foreach (var mob in room.mobs.ToList())
                    {
                        UpdateHp(mob, context);
                        UpdateMana(mob, context);
                        UpdateEndurance(mob, context);
                        UpdateAffects(mob, context);
                    }


                    #region add Mobs back


                    if (room.corpses.Count > 0)
                    {
                        // decay corpse

                        foreach (var corpse in room.corpses.ToList())
                        {
                            if (corpse.Type.Equals(Player.PlayerTypes.Player))
                            {
                                continue;
                            }

                            var mobRoomOrigin =
                                rooms.Find(
                                    x =>
                                    x.areaId == corpse.Recall.AreaId && x.area == corpse.Recall.Area &&
                                    x.region == corpse.Recall.Region);
                            var originalArea = World.Areas.ListOfRooms().FirstOrDefault(x =>
                                                                                        x.area == mobRoomOrigin.area && x.areaId == mobRoomOrigin.areaId &&
                                                                                        x.region == mobRoomOrigin.region);

                            if (originalArea != null)
                            {
                                // potential bug with mobs that have the same name but only one carries an item
                                // finding the origianl mob will probbaly match for one but not the other so the
                                // mob with the other item never gets loaded.
                                // potential way round it. random loot drops for mobs that don't have a name and are genric ie. rat
                                // mobs like village idiot have set items
                                var originalMob = originalArea.mobs.Find(x => x.Name == corpse.Name);

                                if (originalMob != null)
                                {
                                    room.items.Remove(room.items.Find(x => x.name.Contains(originalMob.Name)));
                                    room.corpses.Remove(room.corpses.Find(x => x.Name.Equals(originalMob.Name)));

                                    room.mobs.Add(originalMob);
                                }
                            }
                        }
                    }


                    #endregion

                    #region add Items back

                    for (int j = World.Areas.ListOfRooms().Count - 1; j >= 0; j--)
                    {
                        if (World.Areas.ListOfRooms()[j].area == room.area &&
                            World.Areas.ListOfRooms()[j].areaId == room.areaId &&
                            World.Areas.ListOfRooms()[j].region == room.region)
                        {
                            for (int k = World.Areas.ListOfRooms()[j].items.Count - 1; k >= 0; k--)
                            {
                                var itemAlreadyThere =
                                    room.items.Find(x => x.name.Equals(World.Areas.ListOfRooms()[j].items[k].name));

                                if (itemAlreadyThere == null)
                                {
                                    room.items.Add(World.Areas.ListOfRooms()[j].items[k]);
                                }

                                if (itemAlreadyThere?.container == true)
                                {
                                    for (int l = World.Areas.ListOfRooms()[j].items[k].containerItems.Count - 1; l >= 0; l--)
                                    {
                                        var containerItemAlreadyThere =
                                            itemAlreadyThere.containerItems.Find(
                                                x =>
                                                x.name.Equals(
                                                    World.Areas.ListOfRooms()[j].items[k].containerItems[l].name));

                                        if (containerItemAlreadyThere == null)
                                        {
                                            itemAlreadyThere.containerItems.Add(
                                                World.Areas.ListOfRooms()[j].items[k].containerItems[l]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Room update f****d"
                };

                Save.LogError(log);
            }
        }
Esempio n. 13
0
File: Haste.cs Progetto: semtle/MIM
        private static async Task DoHaste(Player attacker, Room room)
        {
            _taskRunnning   = true;
            attacker.Status = Player.PlayerStatus.Busy;


            var hasteAff = new Affect
            {
                Name     = "Haste",
                Duration = attacker.Level + 5,
                AffectLossMessagePlayer = "Your body begins to slow down.",
                AffectLossMessageRoom   = $" begins to slow down."
            };


            await Task.Delay(500);

            try
            {
                if (_target == null)
                {
                    var castingTextAttacker = "You begin to move much faster.";

                    HubContext.SendToClient(castingTextAttacker, attacker.HubGuid);

                    foreach (var character in room.players.ToList())
                    {
                        if (character != attacker)
                        {
                            var roomMessage =
                                $"{Helpers.ReturnName(attacker, character, string.Empty)} starts to blur as they move faster.";

                            HubContext.SendToClient(roomMessage, character.HubGuid);
                        }
                    }


                    if (attacker.Affects == null)
                    {
                        attacker.Affects = new List <Affect> {
                            hasteAff
                        };
                    }
                    else
                    {
                        attacker.Affects.Add(hasteAff);
                    }

                    Score.ReturnScoreUI(attacker);
                }
                else
                {
                    var castingTextAttacker = Helpers.ReturnName(_target, attacker, null) +
                                              " starts to blur as they move faster.";

                    var castingTextDefender = "You begin to move much faster.";

                    HubContext.SendToClient(castingTextAttacker, attacker.HubGuid);
                    HubContext.SendToClient(castingTextDefender, _target.HubGuid);

                    foreach (var character in room.players.ToList())
                    {
                        if (character != attacker || character != _target)
                        {
                            var roomMessage =
                                $"{Helpers.ReturnName(_target, character, string.Empty)} starts to blur as they move faster.";

                            HubContext.SendToClient(roomMessage, character.HubGuid);
                        }
                    }

                    if (_target.Affects == null)
                    {
                        _target.Affects = new List <Affect> {
                            hasteAff
                        };
                    }
                    else
                    {
                        _target.Affects.Add(hasteAff);
                    }

                    Score.ReturnScoreUI(_target);
                }

                Player.SetState(attacker);
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.Message.ToString(),
                    MethodName   = "haste"
                };

                Save.LogError(log);
            }

            _target       = null;
            _taskRunnning = false;
        }
Esempio n. 14
0
        public static void UpdateAffects(PlayerSetup.Player player, IHubContext context)
        {
            try
            {
                if (player?.Affects == null)
                {
                    return;
                }

                foreach (var af in player.Affects.ToList())
                {
                    if (af.Duration == 0 || af.Duration <= 0)
                    {
                        // put in method? or change way we handle invis
                        if (af.Name == "Invis")
                        {
                            player.invis = false;
                        }

                        if (af.Name == "Chill Touch")
                        {
                            player.Equipment.Wielded = "Nothing";
                            var chillTouch = player.Inventory.FirstOrDefault(x => x.name.Equals("Chill Touch"));
                            player.Inventory.Remove(chillTouch);
                        }

                        if (af.AffectLossMessageRoom != null)
                        {
                            HubContext.SendToClient(af.AffectLossMessagePlayer, player.HubGuid);
                        }

                        if (af.AffectLossMessageRoom != null)
                        {
                            var room = Cache.getRoom(player);

                            foreach (var character in room.players.ToList())
                            {
                                if (player != character && character.HubGuid != null)
                                {
                                    HubContext.SendToClient(
                                        Helpers.ReturnName(player, character, string.Empty) + " " +
                                        af.AffectLossMessageRoom, character.HubGuid);
                                }
                            }
                        }

                        player.Affects.Remove(af);
                    }
                    else
                    {
                        af.Duration -= 1;
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Update Affects"
                };

                Save.LogError(log);
            }
        }
Esempio n. 15
0
        public static void UpdateEndurance(PlayerSetup.Player player, IHubContext context)
        {
            try
            {
                if (player == null)
                {
                    return;
                }

                if (player.MovePoints <= player.MaxMovePoints)
                {
                    var die     = new Helpers();
                    var maxGain = player.Dexterity;

                    if (player.Status == Player.PlayerStatus.Fighting)
                    {
                        maxGain = maxGain / 4;
                    }

                    if (player.Status == Player.PlayerStatus.Sleeping)
                    {
                        maxGain = maxGain * 2;
                    }


                    if (player.Status == Player.PlayerStatus.Resting)
                    {
                        maxGain = (maxGain * 2) / 2;
                    }

                    player.MovePoints += die.dice(1, 1, maxGain);

                    if (player.MovePoints > player.MaxMovePoints)
                    {
                        player.MovePoints = player.MaxMovePoints;
                    }


                    if (player.Type == Player.PlayerTypes.Player)
                    {
                        if (player.HubGuid == null)
                        {
                            return;
                        }

                        context.Clients.Client(player.HubGuid)
                        .updateStat(player.MovePoints, player.MaxMovePoints, "endurance");
                    }

                    Score.ReturnScoreUI(player);
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Update endurance"
                };

                Save.LogError(log);
            }
        }
Esempio n. 16
0
        public int updateEventCodeGen(string key, string product_type, string po_number, string serial_number, out Error.Error error)
        {
            error = null;
            int iAffectedCount = -1;

            paraList.Clear();
            string strSQL = "update event_qrcode_h set EQCH004=@EQCH004,EQCH005=@EQCH005,EQCH006=@EQCH006 " +
                            "where EQCH001=@EQCH001";

            paraList.Add(new SqlParameter("@EQCH004", product_type));
            paraList.Add(new SqlParameter("@EQCH005", po_number));
            paraList.Add(new SqlParameter("@EQCH006", serial_number));
            paraList.Add(new SqlParameter("@EQCH001", key));

            try
            {
                dbControl.Open();
                iAffectedCount = dbControl.ExecuteCommad(strSQL, paraList);
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }

            return(iAffectedCount);
        }
Esempio n. 17
0
        public DataTable downloadCode(string event_key, string id, out string activity_name, out string url, out Error.Error error)
        {
            error         = null;
            activity_name = "";
            url           = "";
            DataTable codeTable = null;

            paraList.Clear();

            string strSQL = "select EQC003,EQC004,EQC005 from event_qrcode_d where EQC001=@EQC001 and EQC008=@EQC008 order by EQC002";

            paraList.Add(new SqlParameter("@EQC001", event_key));
            paraList.Add(new SqlParameter("@EQC008", id));

            try
            {
                dbControl.Open();
                codeTable = dbControl.GetDataTable(strSQL, paraList);

                paraList.Clear();
                strSQL = "select AE002,AE014 from activity_event where AE001=@AE001";
                paraList.Add(new SqlParameter("@AE001", event_key));
                IDataReader dataReader = dbControl.GetReader(strSQL, paraList);
                dataReader.Read();
                activity_name = dataReader["AE002"].ToString();
                url           = dataReader["AE014"].ToString();
                dataReader.Close();
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }

            return(codeTable);
        }
Esempio n. 18
0
        public static void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            try
            {
                var Player = Cache.getPlayer(playerId);

                if (Player?.Target != null)
                {
                    SendToClient("You can't quit during combat.", playerId);
                    return;
                }

                var oldRoom = room;

                int playerIndex = room.players.FindIndex(x => x.HubGuid == playerId);


                room.players.RemoveAt(playerIndex);

                Cache.updateRoom(room, oldRoom);

                PlayerSetup.Player playerData = null;
                MIMHub._PlayerCache.TryRemove(playerId, out playerData);

                if (playerData != null)
                {
                    Save.UpdatePlayer(Player);

                    SendToClient("Gods take note of your progress", playerId);
                    SendToClient("See you soon!", playerId);
                    broadcastToRoom(playerData.Name + " has left the realm", room.players, playerId, true);

                    try
                    {
                        HubContext.getHubContext.Clients.Client(playerId).quit();
                    }
                    catch (Exception ex)
                    {
                        var log = new Error.Error
                        {
                            Date         = DateTime.Now,
                            ErrorMessage = ex.InnerException.ToString(),
                            MethodName   = "Quit"
                        };

                        Save.LogError(log);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Quit"
                };

                Save.LogError(log);
            }
        }
Esempio n. 19
0
        public int addNewEventCodeGen(string event_no, string event_name, string gen_datetime, string product_type, string po_number,
                                      string serial_number, string gen_number, string employee, out Error.Error error)
        {
            error = null;
            int iNewId = -1;

            paraList.Clear();

            string strSQL = "select AE001,AE005,AE006,AE007,AE010,AE011,AE018 from activity_event where AE002=@AE002 and AE003=@AE003";

            paraList.Add(new SqlParameter("@AE002", event_no));
            paraList.Add(new SqlParameter("@AE003", event_name));

            try
            {
                bool     bExist     = false;
                bool     bValid     = false;
                string   event_key  = "";
                DateTime datBegin   = new DateTime(1990, 1, 1);
                DateTime datExpired = new DateTime(1990, 1, 1);
                DateTime datNow     = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                dbControl.Open();
                IDataReader dataReader = dbControl.GetReader(strSQL, paraList);
                if (dataReader.Read())
                {
                    bExist    = true;
                    event_key = dataReader["AE001"].ToString();
                    bool.TryParse(dataReader["AE005"].ToString(), out bValid);
                    DateTime.TryParse(dataReader["AE006"].ToString(), out datBegin);
                    DateTime.TryParse(dataReader["AE007"].ToString(), out datExpired);
                }
                dataReader.Close();

                if (!bExist)
                {
                    throw new Exception("Event doest not exist");
                }
                else if (!bValid)
                {
                    throw new Exception("Event is not opened");
                }
                //else if (datNow.Subtract(datBegin).TotalDays < 0)
                //{
                //    throw new Exception("Event Activity not been actived");
                //}
                //else if (datExpired.Subtract(datNow).TotalDays < 0)
                //{
                //    throw new Exception("Event Activity has been closed");
                //}

                paraList.Clear();
                strSQL = "insert into event_qrcode_h (EQCH002,EQCH003,EQCH004,EQCH005,EQCH006,EQCH007,EQCH008) " +
                         "values (@EQCH002,@EQCH003,@EQCH004,@EQCH005,@EQCH006,@EQCH007,@EQCH008);" +
                         "select SCOPE_IDENTITY();";
                paraList.Add(new SqlParameter("@EQCH002", event_key));
                paraList.Add(new SqlParameter("@EQCH003", gen_datetime));
                paraList.Add(new SqlParameter("@EQCH004", product_type));
                paraList.Add(new SqlParameter("@EQCH005", po_number));
                paraList.Add(new SqlParameter("@EQCH006", serial_number));
                paraList.Add(new SqlParameter("@EQCH007", gen_number));
                paraList.Add(new SqlParameter("@EQCH008", employee));
                //paraList.Add(new SqlParameter("@EQCH009", DBNull.Value));

                object objNewId = dbControl.ExecuteScalar(strSQL, paraList);
                iNewId = int.Parse(objNewId.ToString());
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }

            return(iNewId);
        }
Esempio n. 20
0
        public JsonResult NewEventDownload()
        {
            var EventKey  = Request.Form["event_key"];
            var EventName = Request["event_name"];
            var Employee  = Request.Form["txt_employee"];

            Error.Error error = null;
            int         iNewId;
            string      completeTime;

            string fileName    = string.Format("{0}_{1}.txt", EventName, DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"));
            string csvFileName = string.Format("{0}\\{1}",
                                               Server.MapPath("~/exports"),
                                               fileName);

            if (System.IO.File.Exists(csvFileName))
            {
                System.IO.File.Delete(csvFileName);
            }

            WebHTCBackEnd.Models.Events.THC_EventExport objExport = new Models.Events.THC_EventExport();
            DataTable exportTable = objExport.addNewExport(csvFileName, EventKey, Employee, out iNewId, out completeTime, out error);

            string retJson;

            if (error != null)
            {
                retJson = Newtonsoft.Json.JsonConvert.SerializeObject(error);
            }
            else
            {
                //DateTime datCompleteTime = DateTime.Parse(completeTime);
                //string fileName = string.Format("{0}_{1}.csv", EventName, DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"));
                //string csvFileName = string.Format("{0}\\{1}",
                //                      Server.MapPath("~/exports"),
                //                      fileName);

                //EQC001,EQC002,EQC003,EQC004,EQC005,EC,AEP003,AEP004,AEP005,AEP006,AE003,AE013,AE014
                //if (System.IO.File.Exists(csvFileName))
                //{
                //    System.IO.File.Delete(csvFileName);
                //}
                //System.IO.StreamWriter csvWrite = new System.IO.StreamWriter(csvFileName, false, System.Text.Encoding.UTF8);
                //string strLine;
                //foreach (DataRow row in exportTable.Rows)
                //{
                //    //EQC001,EQC002,EQC003,EQC004,EQC005,EC,AEP003,AEP004,AEP005,AEP006,AEP011,AEP012,AEP013,AE002,AE003,AE013,AE014,AE019
                //    strLine = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}",
                //                    row["EQC001"], row["EQC002"], row["EQC003"], row["EQC004"], row["EQC005"],
                //                    row["EC"], row["AEP003"], row["AEP004"], row["AEP005"], row["AEP006"],row["AEP011"],
                //                    row["AEP012"], row["AEP013"], row["AE002"], row["AE003"], row["AE013"], row["AE014"], row["AE019"]);
                //    csvWrite.WriteLine(strLine);
                //}
                //csvWrite.Close();

                retJson = string.Format("[{{ \"NewId\" : {0}, \"DateTime\" : \"{1}\" ,\"FILE\" : \"{2}\" }}]",
                                        iNewId, completeTime, fileName);
            }

            return(Json(retJson, "application/json", JsonRequestBehavior.AllowGet));
        }
Esempio n. 21
0
        public static async Task Intro(PlayerSetup.Player player, Room.Room room, string step, string calledBy)
        {
            try
            {
                var npc = room.mobs.FirstOrDefault(x => x.Name.Equals("Wilhelm"));

                if (string.IsNullOrEmpty(step))
                {
                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name + " says to you \"I don't think we have much further to go " + player.Name + ".\"</span>",
                                            player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient("You hear a twig snap in the distance.", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(npc.Name + " looks at you with a face of terror and dread.", player.HubGuid);

                    await Task.Delay(3000);

                    HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says to you \"did you hear that " + player.Name + ".\"</span>",
                                            player.HubGuid);

                    HubContext.SendToClient("<p class='RoomExits'>[Hint] Type say yes</p>", player.HubGuid);

                    /*
                     *  add quest to player?
                     *
                     *  show dialogue options
                     *  yes / no
                     *  regardless of what is picked proceed to nect step
                     *  if nothing is picked repeat
                     */
                }
                var hasDagger = player.Inventory.FirstOrDefault(x => x.name.Contains("dagger"));
                if (step.Equals("yes", StringComparison.CurrentCultureIgnoreCase) && hasDagger == null)
                {
                    await Task.Delay(1500);

                    HubContext.SendToClient("You look around but see nothing.", player.HubGuid);

                    await Task.Delay(1500);

                    HubContext.SendToClient("Suddenly a Goblin yells AARGH-tttack!!", player.HubGuid);

                    await Task.Delay(3000);

                    HubContext.SendToClient("You hear movement all around you.", player.HubGuid);

                    await Task.Delay(1500);

                    HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says to you \"here take this dagger " + player.Name + ".\"",
                                            player.HubGuid);

                    var weapon = npc.Inventory.FirstOrDefault(x => x.name.Contains("dagger"));

                    if (weapon != null)
                    {
                        player.Inventory.Add(weapon);
                    }


                    HubContext.SendToClient(npc.Name + " gives you a blunt dagger.", player.HubGuid);

                    Score.UpdateUiInventory(player);

                    await Task.Delay(1500);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name +
                                            " says to you \"it's nothing special but it will help you. I believe the way to Ester is all north from here.\"</span>",
                                            player.HubGuid);

                    await Task.Delay(3000);

                    HubContext.SendToClient("You hear movement getting closer.", player.HubGuid);

                    await Task.Delay(3000);

                    HubContext.SendToClient("Suddenly 5 Goblins emerge from the bushes and fan out in a semi circle behind you.",
                                            player.HubGuid);

                    await Task.Delay(3000);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name + " yells \"GO " + player.Name + ", I'll hold them off. RUN! Run now to the North.\"</span>",
                                            player.HubGuid);

                    HubContext.SendToClient(
                        "<p class='RoomExits'>[Hint] Type north or n for short to move north away from the ambush.</p>",
                        player.HubGuid);

                    while (room.players.FirstOrDefault(x => x.Name.Equals(player.Name)) != null)
                    {
                        await Task.Delay(30000);

                        if (room.players.FirstOrDefault(x => x.Name.Equals(player.Name)) != null)
                        {
                            HubContext.SendToClient("<span class='sayColor'>" +
                                                    npc.Name + " yells \"GO\", " + player.Name +
                                                    " \"I'll hold them off. RUN! Run now to the North.\"</span>", player.HubGuid);

                            HubContext.SendToClient(
                                "<p class='RoomExits'>[Hint] Type north or n for short to move north away from the ambush</p>",
                                player.HubGuid);
                        }
                    }
                }

                if (step.Equals("Attack") && calledBy.Equals("mob"))
                {
                    //blah blah
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "willhelm"
                };

                Save.LogError(log);
            }
        }
Esempio n. 22
0
        public void Quit(string playerId, Room.Room room)
        {
            //remove player from room and player cache

            try
            {
                var Player = Cache.getPlayer(playerId);

                if (Player?.Target != null)
                {
                    SendToClient("You can't quit during combat.", playerId);
                    return;
                }

                if (Player != null)
                {
                    using (var db = new LiteDatabase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["database"])))
                    {
                        var col = db.GetCollection <QuitLocation>("QuitLocation");

                        var quitLoc = new QuitLocation
                        {
                            PlayerName = Player.Name,
                            RoomName   = room.title,
                            RoomId     = room.areaId
                        };

                        col.Insert(Guid.NewGuid(), quitLoc);
                    }

                    PlayerManager.RemovePlayerFromRoom(room, Player);

                    Save.SavePlayer(Player);

                    PlayerSetup.Player removedChar = null;

                    MIMHub._PlayerCache.TryRemove(Player.HubGuid, out removedChar);

                    SendToClient("Gods take note of your progress", playerId);
                    SendToClient("See you soon!", playerId);
                    BroadcastToRoom(Player.Name + " has left the realm", room.players, playerId, true);

                    try
                    {
                        _hubContext.Clients.Client(playerId).quit();
                    }
                    catch (Exception ex)
                    {
                        var log = new Error.Error
                        {
                            Date         = DateTime.Now,
                            ErrorMessage = ex.InnerException.ToString(),
                            MethodName   = "Quit"
                        };

                        Save.LogError(log);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Quit"
                };

                Save.LogError(log);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Command list for the game
        /// </summary>
        /// <param name="commandOptions">Everything after the 1st occurance of a space</param>
        /// <param name="commandKey">The string before the 1st occurance of a space</param>
        /// <param name="playerData">Player Data</param>
        /// <param name="room">Current room</param>
        /// <returns>Returns Dictionary of commands</returns>
        public static void Commands(string commandOptions, string commandKey, PlayerSetup.Player playerData, Room.Room room)
        {
            var context = HubContext.Instance;

            switch (commandKey)
            {
            case "north":
                Movement.Move(playerData, room, "North");
                break;

            case "east":
                Movement.Move(playerData, room, "East");
                break;

            case "south":
                Movement.Move(playerData, room, "South");
                break;

            case "west":
                Movement.Move(playerData, room, "West");
                break;

            case "up":
                Movement.Move(playerData, room, "Up");
                break;

            case "down":
                Movement.Move(playerData, room, "Down");
                break;

            case "look":
            case "look at":
            case "l at":
            case "search":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "look");
                break;

            case "l in":
            case "search in":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "look in");
                break;

            case "examine":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "examine");
                break;

            case "touch":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "touch");
                break;

            case "smell":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "smell");
                break;

            case "taste":
                LoadRoom.ReturnRoom(playerData, room, commandOptions, "taste");
                break;

            case "score":
                Score.ReturnScore(playerData);
                break;

            case "inventory":
                Inventory.ReturnInventory(playerData.Inventory, playerData);
                break;

            case "eq":
            case "equip":
            case "equipment":
            case "garb":
                Equipment.ShowEquipment(playerData);
                break;

            case "loot":
            case "get":
            case "take":
                ManipulateObject.GetItem(room, playerData, commandOptions, commandKey, "item");
                break;

            case "plunder":
                ManipulateObject.GetItem(room, playerData, "all " + commandOptions, commandKey, "item");
                break;

            case "drop":
            case "put":
                ManipulateObject.DropItem(room, playerData, commandOptions, commandKey);
                break;

            case "give":
                ManipulateObject.GiveItem(room, playerData, commandOptions, commandKey, "killable");
                break;

            case "save":
                Save.SavePlayer(playerData);
                break;

            case "say":
            case "'":
                Communicate.Say(commandOptions, playerData, room);
                break;

            case "sayto":
            case ">":
                Communicate.SayTo(commandOptions, room, playerData);
                break;

            case "newbie":
                Communicate.NewbieChannel(commandOptions, playerData);
                break;

            case "gossip":
                Communicate.GossipChannel(commandOptions, playerData);
                break;

            case "ooc":
                Communicate.OocChannel(commandOptions, playerData);
                break;

            case "yes":
                Communicate.Say("Yes", playerData, room);
                break;

            case "no":
                Communicate.Say("No", playerData, room);
                break;

            case "yell":
                Communicate.Yell(commandOptions, room, playerData);
                break;

            case "talkto":
                Talk.TalkTo(commandOptions, room, playerData);
                break;

            case "emote":
                Emote.EmoteActionToRoom(commandOptions, playerData);
                break;

            case "use":
            case "wear":
            case "wield":
                Equipment.WearItem(playerData, commandOptions);
                break;

            case "remove":
            case "doff":
            case "unwield":
                Equipment.RemoveItem(playerData, commandOptions);
                break;

            case "hit":
            case "kill":
            case "attack":
                Fight2.PerpareToFight(playerData, room, commandOptions);
                break;

            case "flee":
                Flee.fleeCombat(playerData, room);
                break;

            case "sacrifice":
            case "harvest":
                Harvest.Body(playerData, room, commandOptions);
                break;

            case "peek":
                Peak.DoPeak(context, playerData, room, commandOptions);
                break;

            case "steal":
                Steal.DoSteal(context, playerData, room, commandOptions);
                break;

            case "pick":
                LockPick.DoLockPick(context, playerData, room, commandOptions);
                break;

            case "c magic missile":
            case "cast magic missile":
                MagicMissile.StartMagicMissile(playerData, room, commandOptions);
                break;

            case "c armour":
            case "cast armour":
            case "c armor":
            case "cast armor":
                new Armour().StartArmour(playerData, room, commandOptions);
                break;

            case "c continual light":
            case "cast continual light":
                ContinualLight.StarContinualLight(playerData, room, commandOptions);
                break;

            case "c invis":
            case "cast invis":
                Invis.StartInvis(playerData, room, commandOptions);
                break;

            case "c weaken":
            case "cast weaken":
                Weaken.StartWeaken(playerData, room, commandOptions);
                break;

            case "c chill touch":
            case "cast chill touch":
                ChillTouch.StartChillTouch(playerData, room, commandOptions);
                break;

            case "c fly":
            case "cast fly":
                Fly.StartFly(playerData, room, commandOptions);
                break;

            case "c refresh":
            case "cast refresh":
                Refresh.StartRefresh(playerData, room, commandOptions);
                break;

            case "c faerie fire":
            case "cast faerie fire":
                FaerieFire.StartFaerieFire(playerData, room, commandOptions);
                break;

            case "c teleport":
            case "cast teleport":
                Teleport.StartTeleport(playerData, room);
                break;

            case "c blindness":
            case "cast blindness":
                Blindness.StartBlind(playerData, room, commandOptions);
                break;

            case "c haste":
            case "cast haste":
                Haste.StartHaste(playerData, room, commandOptions);
                break;

            case "c create spring":
            case "cast create spring":
                CreateSpring.StartCreateSpring(playerData, room);
                break;

            case "c shocking grasp":
            case "cast shocking grasp":
                new ShockingGrasp().StartShockingGrasp(playerData, room, commandOptions);
                break;

            case "c cause light":
            case "cast cause light":
                new CauseLight().StartCauseLight(context, playerData, room, commandOptions);
                break;

            case "c cure light":
            case "cast cure light":
                new CureLight().StartCureLight(context, playerData, room, commandOptions);
                break;

            case "c cure blindness":
                new CureBlindness().StartCureBlindness(context, playerData, room, commandOptions);
                break;

            case "c detect invis":
            case "cast detect invis":
                DetectInvis.DoDetectInvis(context, playerData, room);
                break;

            case "forage":
                new Foraging().StartForaging(playerData, room);
                break;

            case "fish":
            case "angle":
            case "line":
            case "trawl":
            case "lure":
                new Fishing().StartFishing(playerData, room);
                break;

            case "reel":
                Fishing.GetFish(playerData, room);
                break;

            case "dirt kick":
                new DirtKick().StartDirtKick(context, playerData, room, commandOptions);
                break;

            case "bash":
                new Bash().StartBash(context, playerData, room, commandOptions);
                break;

            case "shield bash":
                new ShieldBash().StartBash(context, playerData, room, commandOptions);
                break;

            case "punch":
                Punch.StartPunch(playerData, room);
                break;

            case "kick":
                new Kick().StartKick(context, playerData, room, commandOptions);
                break;

            case "spin kick":
                new SpinKick().StartKick(context, playerData, room, commandOptions);
                break;

            case "rescue":
                new Rescue().StartRescue(context, playerData, room, commandOptions);
                break;

            case "lunge":
                new Lunge().StartLunge(context, playerData, room, commandOptions);
                break;

            case "disarm":
                new Disarm().StartDisarm(context, playerData, room);
                break;

            case "backstab":
                new Backstab().StartBackstab(context, playerData, room, commandOptions);
                break;

            case "feint":
                new Feint().StartFeint(context, playerData, room, commandOptions);
                break;

            case "mount":
            case "ride":
                Mount.StartMount(playerData, room, commandOptions);
                break;

            case "dismount":
                Mount.Dismount(playerData, room, commandOptions);
                break;

            case "trip":
                new Trip().StartTrip(context, playerData, room, commandOptions);
                break;

            case "sneak":
                Sneak.DoSneak(context, playerData);
                break;

            case "hide":
                Hide.DoHide(context, playerData);
                break;

            case "lore":
                Lore.DoLore(context, playerData, commandOptions);
                break;

            case "unlock":
                ManipulateObject.UnlockItem(room, playerData, commandOptions, commandKey);
                break;

            case "lock":
                ManipulateObject.LockItem(room, playerData, commandOptions, commandKey);
                break;

            case "close":
            case "shut":
                ManipulateObject.Close(room, playerData, commandOptions, commandKey);
                break;

            case "drink":
                ManipulateObject.Drink(room, playerData, commandOptions, commandKey);
                break;

            case "help":
            case "/help":
            case "?":
            case "commands":
                Help.ShowHelp(commandOptions, playerData);
                break;

            case "time":
            case "clock":
                Update.Time.ShowTime();
                break;

            case "skills":
            case "spells":
            case "skills all":
                ShowSkills.ShowPlayerSkills(playerData, commandOptions);
                break;

            case "practice":
                Trainer.Practice(playerData, room, commandOptions);
                break;

            case "list":
                Shop.listItems(playerData, room);
                break;

            case "buy":
                Shop.buyItems(playerData, room, commandOptions);
                break;

            case "sell":
                Shop.sellItems(playerData, room, commandOptions);
                break;

            case "quest log":
            case "qlog":
                Quest.QuestLog(playerData);
                break;

            case "wake":
                Status.WakePlayer(context, playerData, room);
                break;

            case "sleep":
                Status.SleepPlayer(context, playerData, room);
                break;

            case "rest":
            case "sit":
                Status.RestPlayer(context, playerData, room);
                break;

            case "stand":
                Status.StandPlayer(context, playerData, room);
                break;

            case "greet":
                Greet.GreetMob(playerData, room, commandOptions);
                break;

            case "who":
                Who.Connected(playerData);
                break;

            case "affects":
                Effect.Show(playerData);
                break;

            case "follow":
                Follow.FollowThing(playerData, room, commandOptions);
                break;

            case "nofollow":
                Follow.FollowThing(playerData, room, "noFollow");
                break;

            case "quit":
                HubContext.Instance.Quit(playerData.HubGuid, room);
                break;

            case "craft":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Craft);
                break;

            case "chop":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Chop);
                break;

            case "cook":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Cook);
                break;

            case "brew":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Brew);
                break;

            case "forge":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Forge);
                break;

            case "carve":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Carve);
                break;

            case "knit":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Knitting);
                break;

            case "make":
            case "build":
                Craft.CraftItem(playerData, room, commandOptions, CraftType.Craft);
                break;

            case "show crafts":
            case "craftlist":
                Craft.CraftList(playerData);
                break;

            case "set up camp":
                Camp.SetUpCamp(playerData, room);
                break;

            case "repair":
                Events.Repair.RepairItem(playerData, room, commandOptions);
                break;

            case "/debug":
                PlayerSetup.Player.DebugPlayer(playerData);
                break;

            case "/setGold":
                PlayerSetup.Player.SetGold(playerData, commandOptions);
                break;

            case "/setAc":
                PlayerSetup.Player.SetAC(playerData, commandOptions);
                break;

            case "/map":
                SigmaMap.DrawMap(playerData.HubGuid);     //not what you think it does
                break;

            default:
                HubContext.Instance.SendToClient("Sorry you can't do that. Try help commands or ask on the discord channel.", playerData.HubGuid);
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = commandKey + " " + commandOptions,
                    MethodName   = "Wrong command"
                };

                Save.LogError(log);
                break;
            }
        }
Esempio n. 24
0
        public int addNewEvent(string event_no, string event_name, string vender, string lunch, string start_time,
                               string end_time, string code_id, string code_name, string qr_bit, string serial_bit, string com_bit,
                               string production, string web_url, string event_type, string memo, string length, string page,
                               out Error.Error error)
        {
            error = null;
            int iNewId = -1;

            paraList.Clear();

            string strSQL = "select count(AE002) from activity_event where AE002=@AE002";

            paraList.Add(new SqlParameter("@AE002", event_no));

            try
            {
                dbControl.Open();
                IDataReader dataReader = dbControl.GetReader(strSQL, paraList);
                dataReader.Read();
                int iCount = int.Parse(dataReader[0].ToString());
                dataReader.Close();

                if (iCount > 0)
                {
                    throw new Exception("專案編號重覆 !");
                }

                paraList.Clear();

                strSQL = "insert into activity_event (AE002,AE003,AE004,AE005,AE006,AE007,AE008,AE009,AE010,AE011,AE012,AE013,AE014,AE015,AE016,AE017,AE018,AE019) " +
                         "values (@AE002,@AE003,@AE004,@AE005,@AE006,@AE007,@AE008,@AE009,@AE010,@AE011,@AE012,@AE013,@AE014,@AE015,@AE016,@AE017,@AE018,@AE019);" +
                         "select SCOPE_IDENTITY();";
                paraList.Add(new SqlParameter("@AE002", typeof(string)));
                paraList[0].Value = event_no;
                paraList.Add(new SqlParameter("@AE003", typeof(string)));
                paraList[1].Value = event_name;
                paraList.Add(new SqlParameter("@AE004", typeof(string)));
                paraList[2].Value = vender;
                paraList.Add(new SqlParameter("@AE005", typeof(bool)));
                paraList[3].Value = (lunch == "on" ? true : false);
                paraList.Add(new SqlParameter("@AE006", start_time));
                paraList.Add(new SqlParameter("@AE007", end_time));
                paraList.Add(new SqlParameter("@AE008", code_id));
                paraList.Add(new SqlParameter("@AE009", typeof(int)));
                paraList[7].Value = code_name;
                paraList.Add(new SqlParameter("@AE010", typeof(Int16)));
                paraList[8].Value = qr_bit;
                paraList.Add(new SqlParameter("@AE011", typeof(Int16)));
                paraList[9].Value = serial_bit;
                paraList.Add(new SqlParameter("@AE012", typeof(Int16)));
                paraList[10].Value = com_bit;
                paraList.Add(new SqlParameter("@AE013", production));
                paraList.Add(new SqlParameter("@AE014", web_url));
                paraList.Add(new SqlParameter("@AE015", event_type));
                paraList.Add(new SqlParameter("@AE016", memo));
                paraList.Add(new SqlParameter("@AE017", typeof(int)));
                paraList[15].Value = 0;
                paraList.Add(new SqlParameter("@AE018", typeof(short)));
                paraList[16].Value = length;
                paraList.Add(new SqlParameter("@AE019", typeof(string)));
                paraList[17].Value = page;
                object objNewId = dbControl.ExecuteScalar(strSQL, paraList);
                iNewId = int.Parse(objNewId.ToString());
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }

            return(iNewId);
        }
Esempio n. 25
0
        public DataTable queryEventCodeGenSearch(string event_no, string event_name,
                                                 out string event_key, out string eventno, out string eventname, out string venderno,
                                                 out string vendername, out string[] top10_events, out Error.Error error)
        {
            error        = null;
            top10_events = null;
            event_key    = "";
            eventno      = "";
            eventname    = "";
            venderno     = "";
            vendername   = "";
            paraList.Clear();
            string strAppend = "";

            string strSQL = "select AE001,AE002,AE003,AE004,VM003 from activity_event inner join vender_member " +
                            "on AE004=VM002";

            if (!string.IsNullOrEmpty(event_no))
            {
                strAppend += " and AE002=@AE002";
                paraList.Add(new SqlParameter("@AE002", event_no));
            }
            if (!string.IsNullOrEmpty(event_name))
            {
                strAppend += " and AE003=@AE003";
                paraList.Add(new SqlParameter("@AE003", event_name));
            }
            if (strAppend.Length == 0)
            {
                throw new Exception("No paramters");
            }
            else
            {
                strSQL += " where 1=1" + strAppend;
            }

            DataTable returnTable = null;

            try
            {
                dbControl.Open();
                IDataReader dataReader = dbControl.GetReader(strSQL, paraList);
                if (dataReader.Read())
                {
                    event_key  = dataReader["AE001"].ToString();
                    eventno    = dataReader["AE002"].ToString().Trim();
                    eventname  = dataReader["AE003"].ToString().Trim();
                    venderno   = dataReader["AE004"].ToString().Trim();
                    vendername = dataReader["VM003"].ToString().Trim();
                }
                dataReader.Close();
                if (eventno.Length > 0)
                {
                    paraList.Clear();
                    strSQL = "select a.*,b.PT002 from event_qrcode_h as a left join product_type as b " +
                             "on EQCH004=PT004 " +
                             "where EQCH002=@EQCH002 and PT001=@PT001 " +
                             "order by EQCH001";
                    paraList.Add(new SqlParameter("@EQCH002", event_key));
                    paraList.Add(new SqlParameter("@PT001", THC_Library.Language.LanguageBase.CURRENT_LANGUAGE));
                    returnTable = dbControl.GetDataTable(strSQL, paraList);
                }

                paraList.Clear();
                strSQL = "select top 10 AE002,AE003 from activity_event order by AE001 desc";
                DataTable top10Table = dbControl.GetDataTable(strSQL, paraList);
                top10_events = new string[top10Table.Rows.Count];
                for (int i = 0; i < top10Table.Rows.Count; i++)
                {
                    top10_events[i] = string.Format("{0}-{1}",
                                                    top10Table.Rows[i][0].ToString(),
                                                    top10Table.Rows[i][1].ToString());
                }
            }
            catch (Exception ex)
            {
                error              = new Error.Error();
                error.Number       = 0;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbControl.Close();
            }
            return(returnTable);
        }
 public override void CreateDefaultMap(Error.Error error, Exception exception)
 {
     error.Status = (int)HttpStatusCode.InternalServerError;
     error.Title  = "Woeps";
 }
Esempio n. 27
0
        public static async Task AwakeningRescue(PlayerSetup.Player player, Room.Room room, string step, string calledBy)
        {
            //give player quest
            var findLance = new Quest()
            {
                Id          = 3,
                Name        = "Find and greet Lance",
                Description =
                    "Mortem has asked me to go find Lance the village elder who can be found in the main square, From the temple leave south and follow the hill path in to town." +
                    "<p class='RoomExits'>[Hint] Type greet lance to greet the Elder once you have found him</p>",
                QuestGiver   = "Mortem",
                QuestFindMob = Lance.VillageElderLance().Name,
                Type         = Quest.QuestType.FindMob,
                RewardXp     = 250,
                QuestHint    = "<h5>Hint:</h5><p>Lance is here, type greet Lance to interact with him.</p>",
                QuestTrigger = Lance.VillageElderLance().Name,
                RewardDialog = new DialogTree()
                {
                    Message       = "Yes I am Lance, well met $playerName",
                    ShowIfOnQuest = "Find and greet Lance"
                }
            };

            try
            {
                //to stop task firing twice
                if (player.QuestLog.FirstOrDefault(x => x.Name.Equals("Find and greet Lance")) != null)
                {
                    return;
                }

                var npc = room.mobs.FirstOrDefault(x => x.Name.Equals("Mortem"));

                if (npc == null)
                {
                    return;
                }

                if (step.Equals("wake", StringComparison.CurrentCultureIgnoreCase))
                {
                    //remove player from tutorial room
                    var oldRoom = Cache.ReturnRooms()
                                  .FirstOrDefault(
                        x => x.area.Equals("Tutorial") && x.areaId.Equals(1) && x.region.Equals("Tutorial"));

                    if (oldRoom != null && oldRoom.players.Contains(player))
                    {
                        PlayerManager.RemovePlayerFromRoom(oldRoom, player);
                    }


                    HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says \"Ah you are awake!\"</span>", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name + " says \"You were in a bad way when we found you, I didn't think you would wake.\"</span>",
                                            player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(npc.Name + " gets a pair of trousers, a plain top and hands them to you.",
                                            player.HubGuid);

                    player.Inventory.Add(ClothingBody.PlainTop());
                    player.Inventory.Add(ClothingLegs.PlainTrousers());

                    Score.UpdateUiInventory(player);

                    await Task.Delay(2000);

                    HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says \"Wear them, you can't walk around naked I am afraid.\"</span>",
                                            player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(
                        "<p class='RoomExits'>[Hint] To view items you are carrying type Inventory or i for short</p>",
                        player.HubGuid);

                    HubContext.SendToClient(npc.Name + " smiles at you.", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(
                        "<p class='RoomExits'>[Hint] Type wear trousers and wear shirt or alternatively wear all</p>",
                        player.HubGuid);
                }

                if (step != null && step.Contains("plain"))
                {
                    if (player.QuestLog.FirstOrDefault(x => x.Name.Equals("Find and greet Lance")) != null)
                    {
                        return;
                    }



                    if (player.Equipment.Body.Equals(ClothingBody.PlainTop().name) &&
                        !player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name))
                    {
                        HubContext.SendToClient("<span class='sayColor'>" +
                                                npc.Name + " says \"It fits well, don't forget to wear the trousers too.\"</span>",
                                                player.HubGuid);

                        await Task.Delay(2000);

                        return;
                    }

                    if (player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name) &&
                        !player.Equipment.Body.Equals(ClothingBody.PlainTop().name))
                    {
                        HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says \"It fits well, don't forget to wear the top too.\"</span>",
                                                player.HubGuid);

                        await Task.Delay(2000);

                        return;
                    }

                    if (player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name) &&
                        player.Equipment.Body.Equals(ClothingBody.PlainTop().name))
                    {
                        HubContext.SendToClient("<span class='sayColor'>" +
                                                npc.Name +
                                                " says \"Excellent, I have one request for you and that is to speak to Lance the Elder of the village.\"</span>",
                                                player.HubGuid);

                        HubContext.SendToClient("<span class='sayColor'>" +
                                                npc.Name +
                                                " says \"He wants to know if you remember anything about the attack that may help him? We have been raided a few times of late.\"</span>",
                                                player.HubGuid);

                        HubContext.SendToClient("<span class='sayColor'>" +
                                                npc.Name +
                                                " says \"You will found him in the Square of Anker just leave south and follow the hill path in to town you can't miss the Square.\"</span>",
                                                player.HubGuid);



                        player.QuestLog.Add(findLance);



                        HubContext.SendToClient(
                            "<span class='questColor'>New Quest added: <br />Find and greet Lance. <br />Type qlog to be reminded about quest information.</span>",
                            player.HubGuid);


                        HubContext.SendToClient(
                            npc.Name +
                            " waves to you, may Tyr bless you.",
                            player.HubGuid);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "mortem"
                };

                Save.LogError(log);
            }
        }
Esempio n. 28
0
 private void IncializarVariables()
 {
     serv = new BusinnesLogic.Metodos();
     lblmensajetab1.Text = string.Empty;
     error = new Error.Error();
 }
Esempio n. 29
0
        public static void ParseCommand(string input, PlayerSetup.Player playerData, Room.Room room = null)
        {
            if (string.IsNullOrEmpty(input.Trim()))
            {
                HubContext.SendToClient("You need to enter a command, type help if you need it.", playerData.HubGuid);
                return;
            }

            //testing
            string enteredCommand = input;

            string[] commands   = enteredCommand.Split(' ');
            string   commandKey = commands[0];


            string commandOptions = string.Empty;

            // testing



            if (commands.Length >= 2)
            {
                if ((commands[1].Equals("in", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("at", StringComparison.InvariantCultureIgnoreCase)))
                {
                    commandKey     = commands[0] + " " + commands[1];
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim();
                }
                else if (commandKey.Equals("c", StringComparison.InvariantCultureIgnoreCase) || commandKey.Equals("cast", StringComparison.InvariantCultureIgnoreCase) && commands.Length > 1)
                {
                    commandKey = commands[0] + " " + commands[1];

                    commandOptions =
                        enteredCommand.Substring(enteredCommand.IndexOf(commands[0], StringComparison.Ordinal)).Trim();
                }
                else
                {
                    commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(' ', 1)).Trim();
                }
            }

            //TODO: do this only once
            var command = Command.Commands(commandOptions, commandKey, playerData, room);

            var fire = command.FirstOrDefault(x => x.Key.StartsWith(commandKey, StringComparison.InvariantCultureIgnoreCase));

            if (fire.Value != null)
            {
                fire.Value();
            }
            else
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = commandOptions + " " + commandKey,
                    MethodName   = "Wrong command"
                };

                Save.LogError(log);

                HubContext.SendToClient("Sorry you can't do that.", playerData.HubGuid);
            }

            playerData.LastCommandTime = DateTime.UtcNow;

            Score.UpdateUiPrompt(playerData);
        }
Esempio n. 30
0
File: Fight2.cs Progetto: semtle/MIM
        private static async Task HitTarget(Player attacker, Player defender, Room room, int delay)
        {
            try
            {
                while (attacker.HitPoints > 0 && defender.HitPoints > 0)
                {
                    //check still here
                    Player target = FindValidTarget(room, defender.Name, attacker);


                    if (target == null)
                    {
                        HubContext.SendToClient("No one here by that name", attacker.HubGuid);
                        return;
                    }

                    bool canAttack = CanAttack(attacker, defender);

                    if (canAttack)
                    {
                        bool alive = IsAlive(attacker, defender);



                        if (alive && attacker.Status != Player.PlayerStatus.Busy)
                        {
                            await Task.Delay(delay);

                            double offense = Offense(attacker);
                            double evasion = Evasion(defender);

                            double toHit  = (offense / evasion) * 100;
                            int    chance = D100();

                            Player checkAttackerAgainAfterDelay = FindValidTarget(room, defender.Name, attacker);
                            Player checkDefenderAgainAfterDelay = FindValidTarget(room, attacker.Name, defender);

                            if (checkAttackerAgainAfterDelay == null || checkDefenderAgainAfterDelay == null)
                            {
                                //Fixes bug where fleeing you would still get hit and hit back while in another room.
                                return;
                            }

                            ShowAttack(attacker, defender, room, toHit, chance, null);


                            if (attacker.Type == Player.PlayerTypes.Player)
                            {
                                Score.UpdateUiPrompt(attacker);
                            }
                            if (defender.Type == Player.PlayerTypes.Player)
                            {
                                Score.UpdateUiPrompt(defender);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "fight"
                };

                Save.LogError(log);
            }
        }