public async Task <ActionResult <DataTable> > GetRepoman([FromRoute] string nameRepo, [FromBody] List <ParamRepo> paramRepo)
        {
            Repoman cta = await _context.Repoman.Where(m => m.Namereport == nameRepo).FirstOrDefaultAsync();

            if (cta == null)
            {
                return(NotFound());
            }

            DataTable dt = new DataTable();

            using (SqlConnection connection = new SqlConnection(_context.Database.GetDbConnection().ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(cta.Sentencia, connection))
                {
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.SelectCommand.CommandType = CommandType.Text;
                    //adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                    foreach (ParamRepo item in paramRepo)
                    {
                        adapter.SelectCommand.Parameters.Add(new SqlParameter(item.Parameter.ToString(), item.Value.ToString()));
                    }

                    //adapter.SelectCommand.Parameters.Add(new SqlParameter("@tipo_asi", "DI"));
                    //adapter.SelectCommand.Parameters.Add(new SqlParameter("@asiento", "00000019"));
                    adapter.Fill(dt);
                }
            }

            return(Ok(dt));
        }
Пример #2
0
        public static void SetVacationWorld(bool ignoreHousehold, bool updateSims)
        {
            Common.StringBuilder msg = new Common.StringBuilder("SetVacationWorld" + Common.NewLine);

            try
            {
                ResetWorldType();

                WorldType originalType = GameUtils.GetCurrentWorldType();

                string worldFile = World.GetWorldFileName();

                msg += worldFile + Common.NewLine;

                WorldName currentWorld = WorldName.Undefined;

                msg += "A";

                foreach (KeyValuePair <WorldName, WorldNameData> data in sData)
                {
                    // Do not alter the future world
                    if (data.Key == WorldName.FutureWorld)
                    {
                        continue;
                    }

                    if (data.Value.mWorldFile == worldFile)
                    {
                        currentWorld = data.Key;
                    }
                    else
                    {
                        if (originalType != WorldType.Future)
                        {
                            // Make all other worlds vacation worlds to allow the Core to age the sims while playing home-town
                            GameUtils.WorldNameToType[data.Key] = WorldType.Vacation;
                        }
                        else
                        {
                            // Alter all worlds to *not* allow aging
                            GameUtils.WorldNameToType[data.Key] = WorldType.Base;
                        }
                    }
                }

                if (originalType != WorldType.Future)
                {
                    // handle custom and pre sunlit tides snafu's
                    if (GameUtils.WorldNameToType.ContainsKey(WorldName.UserCreated))
                    {
                        GameUtils.WorldNameToType[WorldName.UserCreated] = WorldType.Vacation;
                    }
                    else
                    {
                        GameUtils.WorldNameToType.Add(WorldName.UserCreated, WorldType.Vacation);
                    }
                }

                msg += "B";

                msg += Common.NewLine + "CurrentWorld: " + currentWorld + Common.NewLine;

                bool adjustBaseBooks = false;

                // Change the books so the base world books can be seen in Traveler worlds or while "Treat As Vacation" is false
                switch (currentWorld)
                {
                case WorldName.China:
                case WorldName.Egypt:
                case WorldName.France:
                    if (!Traveler.Settings.mTreatAsVacation)
                    {
                        adjustBaseBooks = true;
                    }
                    break;

                default:
                    adjustBaseBooks = true;
                    break;
                }

                if ((GameStates.HasTravelData) && (Traveler.Settings.mTreatAsVacation) && ((ignoreHousehold) || (GameStates.TravelHousehold == Household.ActiveHousehold)))
                {
                    switch (currentWorld)
                    {
                    case WorldName.University:
                        GameUtils.WorldNameToType[currentWorld] = WorldType.University;
                        break;

                    case WorldName.FutureWorld:
                        GameUtils.WorldNameToType[currentWorld] = WorldType.Future;
                        break;

                    default:
                        GameUtils.WorldNameToType[currentWorld] = WorldType.Vacation;
                        break;
                    }

                    GameUtils.CheatOverrideCurrentWorld = currentWorld;
                }
                else
                {
                    switch (GameUtils.GetCurrentWorldType())
                    {
                    case WorldType.Vacation:
                    case WorldType.University:
                    case WorldType.Future:
                        GameUtils.WorldNameToType[currentWorld] = WorldType.Base;

                        GameUtils.CheatOverrideCurrentWorld = currentWorld;
                        break;
                    }
                }

                msg += Common.NewLine + "CurrentWorldType: " + GameUtils.GetCurrentWorldType() + Common.NewLine;

                if (sAdjustedStoreItems == null)
                {
                    sAdjustedStoreItems = new List <BookBaseStoreItem>();

                    foreach (List <StoreItem> list in Bookstore.mItemDictionary.Values)
                    {
                        foreach (StoreItem item in list)
                        {
                            BookBaseStoreItem baseItem = item as BookBaseStoreItem;
                            if (baseItem == null)
                            {
                                continue;
                            }

                            if (baseItem.mAllowedWorldTypes == null)
                            {
                                continue;
                            }

                            if (!baseItem.mAllowedWorldTypes.Contains(WorldType.Base))
                            {
                                continue;
                            }

                            if (baseItem.mAllowedWorldTypes.Contains(WorldType.Vacation))
                            {
                                continue;
                            }

                            sAdjustedStoreItems.Add(baseItem);
                        }
                    }
                }

                foreach (BookBaseStoreItem item in sAdjustedStoreItems)
                {
                    if (adjustBaseBooks)
                    {
                        if (!item.mAllowedWorldTypes.Contains(WorldType.Vacation))
                        {
                            item.mAllowedWorldTypes.Add(WorldType.Vacation);
                        }
                    }
                    else
                    {
                        item.mAllowedWorldTypes.Remove(WorldType.Vacation);
                    }
                }

                msg += "C";

                if (PetPoolManager.sPetConfigManager != null)
                {
                    foreach (PetPoolConfig config in PetPoolManager.sPetConfigManager.Values)
                    {
                        if (config == null)
                        {
                            continue;
                        }

                        if (config.mAllowedWorldTypes == null)
                        {
                            config.mAllowedWorldTypes = new List <string>();
                        }

                        config.mAllowedWorldTypes.Remove(WorldType.Vacation.ToString());
                        config.mAllowedWorldTypes.Remove(WorldType.University.ToString());
                        config.mAllowedWorldTypes.Remove(WorldType.Future.ToString());

                        if (!config.mAllowedWorldTypes.Contains(WorldType.Downtown.ToString()))
                        {
                            if (originalType != WorldType.Downtown)
                            {
                                config.mAllowedWorldTypes.Add(WorldType.Vacation.ToString());
                                config.mAllowedWorldTypes.Add(WorldType.University.ToString());
                                config.mAllowedWorldTypes.Add(WorldType.Future.ToString());
                            }
                        }
                        else
                        {
                            config.mAllowedWorldTypes.Add(WorldType.Vacation.ToString());
                            config.mAllowedWorldTypes.Add(WorldType.University.ToString());
                            config.mAllowedWorldTypes.Add(WorldType.Future.ToString());
                        }

                        config.mDisallowedWorldNames = null;
                    }
                }

                msg += "D";

                Navigation navigation = Navigation.Instance;

                if ((navigation != null) && (navigation.mInfoStateButtons.Length >= 2) && (navigation.mInfoStateButtons[1] != null))
                {
                    /*if (GameUtils.IsOnVacation())
                     * {
                     *  navigation.mInfoStateButtons[1].TooltipText = Common.LocalizeEAString("Ui/Caption/Hud/Navigation:OnVacationNoWork");
                     *  navigation.mInfoStateButtons[1].Enabled = false;
                     * }
                     * else*/
                    {
                        navigation.mInfoStateButtons[1].TooltipText = null;
                        navigation.mInfoStateButtons[1].Enabled     = true;
                    }
                }

                msg += "E";

                if (updateSims)
                {
                    currentWorld = GameUtils.GetCurrentWorld();

                    foreach (SimDescription sim in Household.EverySimDescription())
                    {
                        if (sim.Household == null)
                        {
                            continue;
                        }

                        if (sim.Household.IsTravelHousehold)
                        {
                            continue;
                        }

                        if (sim.Household.IsTouristHousehold)
                        {
                            continue;
                        }

                        sim.mHomeWorld = currentWorld;
                    }
                }

                msg += "F";

                // Startup the service manually

                if (SocialWorkerPetPutUp.Instance == null)
                {
                    SocialWorkerPetPutUp.Create();
                }

                if (SocialWorkerPetAdoption.Instance == null)
                {
                    SocialWorkerPetAdoption.Create();
                }

                if (SocialWorkerAdoption.Instance == null)
                {
                    SocialWorkerAdoption.Create();
                }

                if (Babysitter.Instance == null)
                {
                    Babysitter.Create();
                }

                if (Repoman.Instance == null)
                {
                    Repoman.Create();
                }

                if (NewspaperDelivery.Instance == null)
                {
                    NewspaperDelivery.Create();
                }
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }
            finally
            {
                //Common.StackLog(msg);
            }
        }