public bool Create(AppLocale appLocale)
 {
     if (FindByCodeIso(appLocale.Code) != null)
     {
         return(false);
     }
     appLocale.IdAppLocale = GenerateId();
     return(pm.Persist <AppLocale>(appLocale));
 }
Beispiel #2
0
    public string GenerateAcountNumber(AppLocale locale)
    {
        StringBuilder number = new StringBuilder();

        number.Append(locale.Code);
        number.Append(GameManager.FillStringWithChar(GameManager.RandomBetween(0, 99), "0", 2));
        number.Append(GameManager.FillStringWithChar(GameManager.RandomBetween(0, 999999), "0", 6));
        number.Append(GameManager.FillStringWithChar(GameManager.RandomBetween(0, 99999999), "0", 8));
        if (FindByCode(number.ToString()) != null)
        {
            GenerateAcountNumber(locale);
        }
        return(number.ToString());
    }
Beispiel #3
0
        private static string pmGetAppText(AppLocale inLocale, string[] inText)
        {
            string strText = "";

            switch (inLocale)
            {
            case AppLocale.th_TH:
                strText = (inText.Length > 0 ? inText[0] : "");
                break;

            case AppLocale.en_US:
                strText = (inText.Length > 1 ? inText[1] : "");
                break;

            default:
                strText = inText[0];
                break;
            }

            return(strText);
        }
    public void CreateDb()
    {
        // Iniciamos las colecciones
        DB.Inst().NewCollection(_tableAppLocale);
        DB.Inst().NewCollection(_tableAppText);
        DB.Inst().NewCollection(_tableBank);
        DB.Inst().NewCollection(_tableBattle);
        DB.Inst().NewCollection(_tableCity);
        DB.Inst().NewCollection(_tableInventory);
        DB.Inst().NewCollection(_tableItem);
        DB.Inst().NewCollection(_tableMarket);
        DB.Inst().NewCollection(_tablePowerup);
        DB.Inst().NewCollection(_tableProfileAi);
        DB.Inst().NewCollection(_tablePuerto);
        DB.Inst().NewCollection(_tableQuest);
        DB.Inst().NewCollection(_tableResource);
        DB.Inst().NewCollection(_tableReward);
        DB.Inst().NewCollection(_tableScenario);
        DB.Inst().NewCollection(_tableUser);
        DB.Inst().NewCollection(_tableUserGame);
        DB.Inst().NewCollection(_tableVessel);
        DB.Inst().NewCollection(_tableWeapon);

        // Insertamos registros básicos
        AppLocale localeEsp = new AppLocale();

        localeEsp.Code  = "ES";
        localeEsp.Trans = new[] {
            new GenericTrans {
                text = "Español", id_locale = 1
            },
            new GenericTrans {
                text = "Spanish", id_locale = 2
            }
        };
        DbMngr.Inst().AppLocaleController.Create(localeEsp);

        //Barcos
        Vessel ship1 = new Vessel();

        ship1.Code      = "ship_game_s";
        ship1.Health    = 1;
        ship1.Inventory = 1;
        ship1.Weapon    = 1;
        ship1.Trans     = new[] {
            new GenericTrans {
                text = "Barco S", id_locale = 1
            },
            new GenericTrans {
                text = "Ship S", id_locale = 2
            }
        };
        Vessel ship2 = new Vessel();

        ship2.Code      = "ship_game_m";
        ship2.Health    = 0;
        ship2.Inventory = 0;
        ship2.Weapon    = 0;
        ship2.Trans     = new[] {
            new GenericTrans {
                text = "Barco M", id_locale = 1
            },
            new GenericTrans {
                text = "Ship M", id_locale = 2
            }
        };
        Vessel ship3 = new Vessel();

        ship3.Code      = "ship_game_l";
        ship3.Health    = 0;
        ship3.Inventory = 0;
        ship3.Weapon    = 0;
        ship3.Trans     = new[] {
            new GenericTrans {
                text = "Barco L", id_locale = 1
            },
            new GenericTrans {
                text = "Ship L", id_locale = 2
            }
        };
        Vessel ship4 = new Vessel();

        ship4.Code      = "ship_game_xl";
        ship4.Health    = 0;
        ship4.Inventory = 0;
        ship4.Weapon    = 0;
        ship4.Trans     = new[] {
            new GenericTrans {
                text = "Barco XL", id_locale = 1
            },
            new GenericTrans {
                text = "Ship XL", id_locale = 2
            }
        };
        Vessel ship5 = new Vessel();

        ship5.Code      = "ship_game_xxl";
        ship5.Health    = 0;
        ship5.Inventory = 0;
        ship5.Weapon    = 0;
        ship5.Trans     = new[] {
            new GenericTrans {
                text = "Barco XXL", id_locale = 1
            },
            new GenericTrans {
                text = "Ship XXL", id_locale = 2
            }
        };
        DbMngr.Inst().VesselController.Create(ship1);
        DbMngr.Inst().VesselController.Create(ship2);
        DbMngr.Inst().VesselController.Create(ship3);
        DbMngr.Inst().VesselController.Create(ship4);
        DbMngr.Inst().VesselController.Create(ship5);

        //Usuarios
        User u1 = new User();

        u1.Username  = "******";
        u1.Password  = "******";
        u1.Email     = "*****@*****.**";
        u1.Firstname = "Admin";
        u1.RolUser   = Types.RolUsers.Admin;
        User u2 = new User();

        u2.Username  = "******";
        u2.Password  = "******";
        u2.Email     = "*****@*****.**";
        u2.Firstname = "User";
        u2.RolUser   = Types.RolUsers.Admin;
        DbMngr.Inst().UserController.Create(u1);
        DbMngr.Inst().UserController.Create(u2);

        Reward rwd1 = new Reward();

        rwd1.TypeReward = Types.Reward.Gold;
        rwd1.Code       = "first";
        rwd1.Value      = 50d;
        Reward rwd2 = new Reward();

        rwd2.TypeReward = Types.Reward.Exp;
        rwd2.Code       = "second";
        rwd2.Value      = 100d;
        Reward rwd3 = new Reward();

        rwd3.TypeReward = Types.Reward.Vessel;
        rwd3.Code       = "third";
        rwd3.Vessel     = 5;
        Reward rwd4 = new Reward();

        rwd4.TypeReward = Types.Reward.Item;
        rwd4.Code       = "fourth";
        rwd4.Item       = 1;
        DbMngr.Inst().RewardController.Create(rwd1);
        DbMngr.Inst().RewardController.Create(rwd2);
        DbMngr.Inst().RewardController.Create(rwd3);
        DbMngr.Inst().RewardController.Create(rwd4);

        Battle battle = new Battle();

        battle.Code     = "battle1";
        battle.Position = new Coordinates {
            X = 100, Y = 200
        };
        battle.PanelSize = new Coordinates {
            X = 6, Y = 6
        };
        battle.Trans = new[] {
            new GenericTrans {
                text = "Batalla Test", id_locale = 1
            },
            new GenericTrans {
                text = "Test Battle", id_locale = 2
            }
        };
        battle.CpuFog           = false;
        battle.WinBeforeMinTime = false;
        battle.MaxTime          = 100;
        battle.MinTime          = 30;
        battle.MinLevel         = 1;
        battle.AllowedCpuShips  = new List <int> {
            1,
            2,
            3,
            4,
            5
        };
        battle.AllowedUserShips = new List <int> {
            1,
            2,
            3,
            4,
            5
        };
        battle.ProfileCpu = new List <int> {
            1
        };
        Reward rw1 = DbMngr.Inst().RewardController.FindByCode("first");

        battle.Rewards = new List <int> {
            rw1.IdReward
        };
        battle.AllowedPowerups = null;
        DbMngr.Inst().BattleController.Create(battle);

        Quest qst = new Quest();

        qst.Code     = "quest1";
        qst.MinLevel = 1;
        Reward rw2 = DbMngr.Inst().RewardController.FindByCode("second");

        qst.Rewards = new List <int> {
            rw2.IdReward
        };
        qst.Description = new[] {
            new GenericTrans {
                text =
                    "Descripción de la misión. La misión consta de varios objetivos, como conseguir objetos, ciertas batallas, ...",
                id_locale = 1
            },
            new GenericTrans {
                text =
                    "Description of the mission. The mission consists of several objectives, such as getting objects, certain battles, ...",
                id_locale = 2
            }
        };
        qst.Trans = new[] {
            new GenericTrans {
                text = "Misión 1", id_locale = 1
            },
            new GenericTrans {
                text = "Quest 1", id_locale = 2
            }
        };
        DbMngr.Inst().QuestController.Create(qst);

        Market mrkt = new Market();

        mrkt.Code          = "marketgame";
        mrkt.Items         = null;
        mrkt.ItemsPurchase = null;
        DbMngr.Inst().MarketController.Create(mrkt);

        Harbor harbor = new Harbor();

        harbor.Code  = "port_royal";
        harbor.Trans = new[] {
            new GenericTrans {
                text = "Puerto Real", id_locale = 1
            },
            new GenericTrans {
                text = "Port Royal", id_locale = 2
            }
        };
        harbor.PriceGemsRepair = 2;
        harbor.PriceGoldRepair = 1500;
        harbor.TimeGemsRepair  = 100;
        harbor.TimeGoldRepair  = 3600;
        DbMngr.Inst().HarborController.Create(harbor);

        City city = new City();

        city.Code     = "caramelo";
        city.CrewSide = Types.CrewSide.Neutral;
        Market market = DbMngr.Inst().MarketController.FindByCode("marketgame");

        city.IdMarket = market.IdMarket;
        Harbor hbr = DbMngr.Inst().HarborController.FindByCode("port_royal");

        city.IdHarbor = hbr.IdHarbor;
        city.Position = new Coordinates {
            X = 100, Y = 100
        };
        city.Trans = new[] {
            new GenericTrans {
                text = "Ciudad Caramelo", id_locale = 1
            },
            new GenericTrans {
                text = "Candy City", id_locale = 2
            }
        };
        Battle btl = DbMngr.Inst().BattleController.FindByCode("battle1");

        city.Battles = new List <long> {
            btl.IdBattle
        };
        Resource cityResource = DbMngr.Inst().ResourceController.FindByCode("city");

        city.IdResource = cityResource.IdResource;
        Quest quest = DbMngr.Inst().QuestController.FindByCode("quest1");

        city.Quests = new List <long> {
            quest.IdQuest
        };
        DbMngr.Inst().CityController.Create(city);

        Scenario scn = new Scenario();

        scn.Code     = "scenario_inicial";
        scn.MinLevel = 1;
        Resource scnResource = DbMngr.Inst().ResourceController.FindByCode("mapa");

        scn.Resource = scnResource.IdResource;
        scn.Trans    = new[] {
            new GenericTrans {
                text = "Región Egmar", id_locale = 1
            },
            new GenericTrans {
                text = "Egmar region", id_locale = 2
            }
        };
        scn.RandomBattles = new List <Coordinates> {
            new Coordinates {
                X = 200, Y = 300
            },
            new Coordinates {
                X = 300, Y = 350
            }
        };
        Reward rw3 = DbMngr.Inst().RewardController.FindByCode("third");
        Reward rw4 = DbMngr.Inst().RewardController.FindByCode("fourth");

        scn.Rewards = new List <int> {
            rw3.IdReward,
            rw4.IdReward
        };
        City ct = DbMngr.Inst().CityController.FindByCode("caramelo");

        scn.Cities = new List <long> {
            ct.IdCity
        };
        DbMngr.Inst().ScenarioController.Create(scn);

        Bank bank = new Bank();

        bank.Code               = "bankadmin";
        bank.accountNumber      = DbMngr.Inst().BankController.GenerateAcountNumber(localeEsp);
        bank.TimeMoneyReward    = 86400;
        bank.MaxTimeMoneyReward = 86400;

        DbMngr.Inst().BankController.Create(bank);

        UserGame uGame = new UserGame();

        uGame.Code = "ADMINGAME";
        Bank bnk = DbMngr.Inst().BankController.FindByCode("bank_admin");

        uGame.Bank = bnk.IdBank;
        Scenario scnBase = DbMngr.Inst().ScenarioController.FindByCode("scenario_inicial");

        uGame.Scenario = scnBase.IdScenario;
        User usr = DbMngr.Inst().UserController.FindByUserName("admin");

        uGame.User      = usr.IdUser;
        uGame.PlayTime  = 0;
        uGame.UserLevel = 1;
        DbMngr.Inst().UserGameController.Create(uGame);
    }
Beispiel #5
0
 public static string GetAppText(AppLocale inLocale, string[] inText)
 {
     return(pmGetAppText(inLocale, inText));
 }
Beispiel #6
0
        public static void SetActiveCorp(DataRow inCorp)
        {
            App.gcCorp            = inCorp["fcSkid"].ToString();
            App.gcCorpName        = inCorp["fcName"].ToString().TrimEnd();
            App.gcCorpName2       = inCorp["fcName2"].ToString().TrimEnd();
            App.gcCorpSaleVATType = (inCorp["fcVatType"].ToString() != string.Empty ? inCorp["fcVatType"].ToString() : "1");
            App.gdStartCorpDate   = Convert.ToDateTime(inCorp["fdCalDate"]);

            BeSmartMRP.Business.Agents.KeepLogAgent.CORPID = inCorp["fcSkid"].ToString();

            System.Data.DataSet dtsCorp = new System.Data.DataSet();
            string strErrorMsg          = "";

            WS.Data.Agents.cDBMSAgent objSQLHelper  = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);
            WS.Data.Agents.cDBMSAgent objSQLHelper2 = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);

            objSQLHelper2.SetPara(new object[] { App.AppUserID });
            if (objSQLHelper2.SQLExec(ref dtsCorp, "QEmplR", "EMPLR", "select * from AppLogin where cRowID = ? ", ref strErrorMsg))
            {
                DataRow dtrEmpl = dtsCorp.Tables["QEmplR"].Rows[0];
                App.mLocale_UI     = UIHelper.AppEnum.GetLocaleEnum(dtrEmpl[QAppLogInInfo.Field.Locale_UI].ToString().TrimEnd());
                App.mLocale_Report = UIHelper.AppEnum.GetLocaleEnum(dtrEmpl[QAppLogInInfo.Field.Locale_Report].ToString().TrimEnd());

                string strLocale = "en-US";
                switch (App.mLocale_UI)
                {
                case AppLocale.th_TH:
                    strLocale = "th-TH";
                    break;

                case AppLocale.en_US:
                    strLocale = "en-US";
                    break;
                }

                pmSetAppCulture(strLocale);
            }

            ActiveCorp.RowID            = inCorp["fcSkid"].ToString();
            ActiveCorp.CorpChar         = inCorp["fcCorpChar"].ToString();
            ActiveCorp.Code             = inCorp["fcCode"].ToString();
            ActiveCorp.Name             = inCorp["fcName"].ToString().TrimEnd();
            ActiveCorp.Name2            = inCorp["fcName2"].ToString().TrimEnd();
            ActiveCorp.StartAppDate     = Convert.ToDateTime(inCorp["fdCalDate"]);
            ActiveCorp.Address1         = inCorp["fcAddr1"].ToString().TrimEnd();
            ActiveCorp.Address2         = inCorp["fcAddr2"].ToString().TrimEnd();
            ActiveCorp.Address12        = inCorp["fcAddr12"].ToString().TrimEnd();
            ActiveCorp.Address22        = inCorp["fcAddr22"].ToString().TrimEnd();
            ActiveCorp.ShowFormulaCompo = (inCorp["fcShowComp"].ToString().TrimEnd() != string.Empty ? inCorp["fcShowComp"].ToString() : "1");
            ActiveCorp.TelNo            = inCorp["fcTel"].ToString().TrimEnd();
            ActiveCorp.FaxNo            = inCorp["fcFax"].ToString().TrimEnd();
            //ActiveCorp.TaxID = inCorp["fcTaxID"].ToString().TrimEnd();
            ActiveCorp.TaxID             = inCorp["FCTRADENO"].ToString().TrimEnd();
            ActiveCorp.SaleVATIsOut      = (inCorp["fcVatIsOut"].ToString() != string.Empty ? inCorp["fcVatIsOut"].ToString() : "Y");
            ActiveCorp.SaleVATType       = (inCorp["fcVatType"].ToString() != string.Empty ? inCorp["fcVatType"].ToString() : "1");
            ActiveCorp.SCtrlStock        = (inCorp["fcCtrlStoc"].ToString().TrimEnd() != string.Empty ? inCorp["fcCtrlStoc"].ToString().TrimEnd() : "1");
            ActiveCorp.CostMethod_Goods  = (inCorp["fcGoodsCos"].ToString().TrimEnd() != string.Empty ? inCorp["fcGoodsCos"].ToString().TrimEnd() : "A");
            ActiveCorp.CostMethod_Rawmat = (inCorp["fcRawCost"].ToString().TrimEnd() != string.Empty ? inCorp["fcRawCost"].ToString().TrimEnd() : "A");

            objSQLHelper.SetPara(new object[1] {
                inCorp["fcSect"].ToString()
            });
            if (objSQLHelper.SQLExec(ref dtsCorp, "QVFLD_Sect", "Sect", "select * from Sect where fcSkid = ? ", ref strErrorMsg))
            {
                App.ActiveCorp.DefaultSectID = dtsCorp.Tables["QVFLD_Sect"].Rows[0]["fcSkid"].ToString();
                objSQLHelper.SetPara(new object[1] {
                    dtsCorp.Tables["QVFLD_Sect"].Rows[0]["fcDept"].ToString()
                });
                if (objSQLHelper.SQLExec(ref dtsCorp, "QVFLD_Dept", "Dept", "select * from Dept where fcSkid = ?", ref strErrorMsg))
                {
                    App.ActiveCorp.DefaultDeptID = dtsCorp.Tables["QVFLD_Dept"].Rows[0]["fcSkid"].ToString();
                }
            }
            objSQLHelper.SetPara(new object[1] {
                inCorp["fcProj"].ToString()
            });
            if (objSQLHelper.SQLExec(ref dtsCorp, "QVFLD_Proj", "Proj", "select * from Proj where fcSkid = ? ", ref strErrorMsg))
            {
                App.ActiveCorp.DefaultProjectID = dtsCorp.Tables["QVFLD_Proj"].Rows[0]["fcSkid"].ToString();
            }

            objSQLHelper.SetPara(new object[1] {
                inCorp["fcJob"].ToString()
            });
            if (objSQLHelper.SQLExec(ref dtsCorp, "QVFLD_Job", "Job", "select * from Job where fcSkid = ? ", ref strErrorMsg))
            {
                App.ActiveCorp.DefaultJobID = dtsCorp.Tables["QVFLD_Job"].Rows[0]["fcSkid"].ToString();
            }

            App.ActiveCorp.MMQtyFormatString = "#,###,###.0000";
            App.ActiveCorp.PriceFormatString = "#,###,###.0000";

            string strQtyPict = inCorp["fcQtyPict"].ToString();

            string[] aText = strQtyPict.Split(".".ToCharArray());

            if (aText.Length > 1)
            {
                App.ActiveCorp.QtyFormatString = AppUtil.StringHelper.ChrTran(aText[0].Trim(), "9", "#") + "." + AppUtil.StringHelper.ChrTran(aText[1].Trim(), "9", "0");
            }
            else
            {
                App.ActiveCorp.QtyFormatString = AppUtil.StringHelper.ChrTran(aText[0].Trim(), "9", "#");
            }

            string strRemark = (Convert.IsDBNull(inCorp["fmMemData"]) ? "" : inCorp["fmMemData"].ToString().TrimEnd());

            strRemark += (Convert.IsDBNull(inCorp["fmMemData2"]) ? "" : inCorp["fmMemData2"].ToString().TrimEnd());

            string strCorpVouCentMode = BizRule.GetMemData(strRemark, "VRM");
            string strCorpVouRunLen   = BizRule.GetMemData(strRemark, "VLN");
            int    intCorpVouRunLen   = 4;

            try
            {
                intCorpVouRunLen = Convert.ToInt32(strCorpVouRunLen);
            }
            catch { }

            //App.ActiveCorp.CorpVouCentMode = (strCorpVouCentMode == "" ? "1" : strCorpVouCentMode);
            //App.ActiveCorp.CorpVouRunLen = (intCorpVouRunLen < 4 ? 4 : intCorpVouRunLen);
        }
 public bool Update(AppLocale appLocale)
 {
     return(pm.Merge <AppLocale>(appLocale));
 }