Ejemplo n.º 1
0
        /// <summary>
        /// Get List of Things.
        /// </summary>
        /// <param name="searchFor">Search text as per the 'Title' field.</param>
        /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param>
        /// <param name="pageNumber">Page Number.</param>
        /// <param name="pageSize">Items count per page.</param>
        /// <param name="loadParents">Enable or Disable loading the Parents objects.</param>
        /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param>
        /// <returns></returns>
        public APIThingResponseModels.GetThingsList GetThingsList(string searchFor, long?locationID, bool loadThingEnds, bool loadEndpoints, bool loadLocation, bool loadThingExtensionValues, int pageNumber, int pageSize)
        {
            APIThingResponseModels.GetThingsList result = new APIThingResponseModels.GetThingsList();

            IPagedList <Thing> thingsPL = uof_Repositories.repoThings.GetPagedList(searchFor, locationID, pageNumber, pageSize);

            List <Thing> things = thingsPL.ToList();

            List <APIThing> listAPIThings = new List <APIThing>();

            foreach (Thing thing in things)
            {
                APIThing apiThing = TypesMapper.APIThingAdapter.fromThing(thing, loadLocation, loadThingEnds, loadThingEnds, loadThingExtensionValues);
                listAPIThings.Add(apiThing);
            }
            result.Things = listAPIThings;


            PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel();

            pagingInfo.CurrentPage  = thingsPL.PageNumber;
            pagingInfo.ItemsPerPage = thingsPL.PageSize;
            pagingInfo.ItemsCount   = thingsPL.TotalItemCount;
            pagingInfo.PagesCount   = thingsPL.PageCount;
            result.PagingInfo       = pagingInfo;
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get Things list that have warnings Only.
        /// </summary>
        /// <param name="pageNumber">Page Number.</param>
        /// <param name="pageSize">Items count per page.</param>
        /// <param name="loadParents">Enable or Disable loading the Parents objects.</param>
        /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param>
        /// <param name="locationID">The requested Location to validate it's own things for a warnings</param>
        /// <returns>List of Locations that have one warning or more.</returns>
        public List <APIThing> GetThingsWithWarnings(int pageNumber, int pageSize, bool loadParents, bool loadChilds, long locationID)
        {
            List <APIThing> apiThings = new List <APIThing>();
            List <Thing>    things    = db.Things
                                        .Where(t =>
                                               t.LinkThingsLocations.Any(
                                                   lt =>
                                                   (lt.LocationID == locationID || (locationID == null || locationID == 0)) &&
                                                   lt.Thing.Endpoints.Any(
                                                       e => e.IsNumericOnly == true &&
                                                       (e.LastIONumericValue >= e.HighRange || e.LastIONumericValue <= e.LowRange)
                                                       )
                                                   )
                                               )
                                        .OrderBy(o => o.Title)
                                        .Skip((pageNumber - 1) * pageSize)
                                        .Take(pageSize).ToList();

            foreach (Thing item in things)
            {
                APIThing apiThing = TypesMapper.APIThingAdapter.fromThing(item, loadParents, loadChilds);
                apiThings.Add(apiThing);
            }
            return(apiThings);
        }
Ejemplo n.º 3
0
        public static APILocation fromLocation(Location sourceLocation, bool loadViews, bool loadThings)
        {
            APILocation result = new APILocation();

            result.GUID       = sourceLocation.GUID;
            result.IconID     = sourceLocation.IconID;
            result.ID         = sourceLocation.ID;
            result.isActive   = sourceLocation.isActive;
            result.LatitudeX  = sourceLocation.LatitudeX;
            result.LongitudeY = sourceLocation.LongitudeY;
            result.Status     = sourceLocation.Status;
            result.Title      = sourceLocation.Title;

            #region Parents
            #region LocationViews
            if (loadViews)
            {
                List <APILocationView> apiLocationViews = new List <APILocationView>();
                foreach (LocationView locationView in sourceLocation.locationViews)
                {
                    APILocationView apiLocationView = TypesMapper.APILocationViewAdapter.fromLocationView(locationView, false);
                    apiLocationViews.Add(apiLocationView);
                }
                result.LocationViews = apiLocationViews;
            }
            #endregion


            #endregion

            #region Childs
            if (loadThings)
            {
                #region Things
                List <APIThing> apiThings = new List <APIThing>();
                foreach (Thing thing in sourceLocation.Things)
                {
                    APIThing apiThing = TypesMapper.APIThingAdapter.fromThing(thing, false, false, false, false);
                    apiThings.Add(apiThing);
                }
                result.Things = apiThings;
                #endregion
            }
            result.ThingsCount = sourceLocation.Things.Count;



            #endregion

            return(result);
        }
Ejemplo n.º 4
0
        private void AddMapBtn_Click(object sender, RoutedEventArgs e)
        {
            AddMapWindow window = new AddMapWindow();

            window.ShowDialog();
            if (window.isOk)
            {
                int mode = 0;
                switch (window.ModeBox.Text)
                {
                case "Standard":
                    mode = 0;
                    break;

                case "Mania":
                    mode = 1;
                    break;

                case "Taiko":
                    mode = 2;
                    break;

                case "Catch":
                    mode = 3;
                    break;
                }
                MapInfo info = APIThing.GetMapInfo(window.UrlBox.Text, mode);

                string[] mapValues = new string[sqlLib.TableColumnCount(sqlLib.mapsTab)];
                mapValues[sqlLib.mapId]         = string.Empty;
                mapValues[sqlLib.mapIdInPool]   = CheckMapNumbersByMod(window.ModBox.Text);
                mapValues[sqlLib.mapMapper]     = info.creator;
                mapValues[sqlLib.mapArtist]     = info.artist;
                mapValues[sqlLib.mapTitle]      = info.title;
                mapValues[sqlLib.mapDifficulty] = info.version;
                mapValues[sqlLib.mapStars]      = info.difficultyrating;
                mapValues[sqlLib.mapLenght]     = info.total_length;
                mapValues[sqlLib.mapBpm]        = info.bpm;
                mapValues[sqlLib.mapMod]        = window.ModBox.Text;
                mapValues[sqlLib.mapMappool]    = sqlLib.GetColumnData(sqlLib.mappoolsTab, "mappoolId", "WHERE mappoolName = " + sqlLib.CheckString(PoolBox.Text))[0];

                string query = sqlLib.InsertDataQuery(mapValues, sqlLib.mapsTab);
                sqlLib.RunQuery(query);
                Refresh();
            }
        }
Ejemplo n.º 5
0
        public static APIThing fromThing(Thing sourceThing)
        {
            APIThing result = new APIThing();

            result.ID             = sourceThing.ID;
            result.Title          = sourceThing.Title;
            result.ThingsCategory = TypesMapper.APIThingCategoryAdapter.fromThingCategory(sourceThing.ThingCategory);
            result.UTC_Diff       = sourceThing.UTC_Diff;

            List <APIEndPoint> apiEnds = new List <APIEndPoint>();

            foreach (Endpoint end in sourceThing.Endpoints)
            {
                APIEndPoint apiEnd = new APIEndPoint();
                apiEnd = TypesMapper.APIEndPointAdapter.fromEndpoint(end);
                apiEnds.Add(apiEnd);
            }
            result.EndPoints = apiEnds;

            return(result);
        }
Ejemplo n.º 6
0
        public static APIThing fromThing(Thing sourceThing, bool loadParents, bool loadChilds)
        {
            APIThing result = new APIThing();

            result.ID       = sourceThing.ID;
            result.Title    = sourceThing.Title;
            result.UTC_Diff = sourceThing.UTC_Diff;

            #region Load Master Types
            result.ThingsType = TypesMapper.APIThingsTypeAdapter.fromThingsType(sourceThing.ThingCategory);

            #endregion

            #region Parents
            if (loadParents)
            {
                #region Locations
                List <APILocation> apiLocations = new List <APILocation>();
                List <Location>    locations    = db.Locations.Where(l => l.LinkThingsLocations.Any(ll => ll.LocationID == l.ID)).ToList();
                foreach (Location location in locations)
                {
                    APILocation apiLocation = TypesMapper.APILocationAdapter.fromLocation(location, false, false);
                    apiLocations.Add(apiLocation);
                }
                result.Locations = apiLocations;
                #endregion
            }

            #endregion

            #region Load Childs
            if (loadChilds)
            {
                #region EndPoints
                List <APIEndPoint> apiEndPoints = new List <APIEndPoint>();
                foreach (Endpoint endpoint in sourceThing.Endpoints)
                {
                    APIEndPoint apiEndpoint = TypesMapper.APIEndPointAdapter.fromEndpoint(endpoint, false, false);
                    apiEndPoints.Add(apiEndpoint);
                }
                result.EndPoints = apiEndPoints;
                #endregion

                #region ThingEnds
                List <APIThingEnd> apiThingEnds = new List <APIThingEnd>();
                foreach (ThingEnd thingEnd in sourceThing.ThingEnds)
                {
                    APIThingEnd apiThingEnd = TypesMapper.APIThingEndAdapter.fromThingEnd(thingEnd, false, false);
                    apiThingEnds.Add(apiThingEnd);
                }
                result.ThingEnds = apiThingEnds;
                #endregion

                #region APIThingExtensionValues
                List <APIThingExtensionValue> apiThingExtensionValues = new List <APIThingExtensionValue>();
                foreach (ThingExtensionValue thingExtensionValue in sourceThing.ThingExtensionValues)
                {
                    APIThingExtensionValue apiThingExtensionValue = TypesMapper.APIThingExtensionValueAdapter.fromThingExtensionValue(thingExtensionValue, true, false);
                    apiThingExtensionValues.Add(apiThingExtensionValue);
                }
                result.APIThingExtensionValues = apiThingExtensionValues;
                #endregion
            }

            result.ThingEndsCount = sourceThing.ThingEnds.Count;
            #endregion


            List <APIEndPoint> apiEnds = new List <APIEndPoint>();
            //foreach(Endpoint end in sourceThing.Endpoints)
            //{
            //    APIEndPoint apiEnd = new APIEndPoint();
            //    apiEnd = TypesMapper.APIEndPointAdapter.fromEndpoint(end);
            //    apiEnds.Add(apiEnd);
            //}
            //result.EndPoints = apiEnds;

            return(result);
        }