public async Task <IActionResult> Index(ResourceParams <GetIndividualPreviewViewModel> resourceParams)
        {
            ViewData["Search"]       = resourceParams.Search;
            ViewData["CurrentSort"]  = resourceParams.Sort;
            ViewData["SortProperty"] = resourceParams.OrderBy;
            ViewData["Sort"]         = resourceParams.Sort == "asc" ? "desc" : "asc";

            var response = new Response <PagedList <GetIndividualPreviewViewModel> >();

            var peopleResult = await _repository.GetEntitiesAsync <Individual>();

            if (!peopleResult.Success)
            {
                response.SetErrorMessages(peopleResult.ErrorMessages);
                return(View(response));
            }

            var peopleEntities = peopleResult.Model;

            if (!string.IsNullOrEmpty(resourceParams.Search))
            {
                peopleEntities = peopleEntities.Where(i => i.FirstName.ToLowerInvariant().Contains(resourceParams.Search) ||
                                                      i.LastName.ToLowerInvariant().Contains(resourceParams.Search) ||
                                                      i.PersonalNumber.ToLowerInvariant().Contains(resourceParams.Search));
            }

            var filteredPeopleViewModels = peopleEntities.GetFilteredData(resourceParams, GetIndividualPreviewViewModel.Projection);

            response.SetSuccess();
            response.SetModel(filteredPeopleViewModels);

            return(View(response));
        }
    public void ReceiveFuel(ResourceParams data)
    {
        switch (data.Type)
        {
        case "LiquidFuel":
            if (data.Amount > 0)
            {
                rb.AddForceAtPosition(
                    //Should make this use something relative to the amount of fuel recived
                    (MassFlowRate * ExhaustVelocity * Throtle / 100) * -transform.forward,
                    transform.position,
                    ForceMode.Force
                    );
                flame.SetActive(true);
            }
            else
            {
                flame.SetActive(false);
            }
            break;

        default:
            Debug.LogError("ReceiveFuel Receives Default");
            break;
        }
    }
        public static PagedList <TViewModel> GetFilteredData <TEntity, TViewModel>
            (this IQueryable <TEntity> entities, ResourceParams <TViewModel> resourceParams, Expression <Func <TEntity, TViewModel> > projection)
            where TEntity : BaseEntity
            where TViewModel : class
        {
            var pageNumber = resourceParams.Page;
            var pageSize   = resourceParams.Size;
            var totalItems = entities.Count();

            var orderProperty = TypeDescriptor.GetProperties(typeof(TEntity)).Find(resourceParams.OrderBy, true);

            if (orderProperty == null)
            {
                resourceParams.OrderBy = nameof(BaseEntity.Id).ToLower();
                orderProperty          = TypeDescriptor.GetProperties(typeof(TEntity)).Find(resourceParams.OrderBy, true);
            }

            if (resourceParams.Sort.ToLower() == "desc")
            {
                entities = entities.OrderByDescending(e => orderProperty.GetValue(e));
            }
            else
            {
                entities = entities.OrderBy(e => orderProperty.GetValue(e));
            }

            var items = entities.Skip(resourceParams.Size * (resourceParams.Page - 1)).Take(resourceParams.Size).Select(projection);

            return(new PagedList <TViewModel>(totalItems, pageNumber, pageSize, items));
        }
        public static bool LoadPackageResource(Assembly sourceAssembly, string resourcePath)
        {
            ResourceParams resourceParams = new ResourceParams();

            resourceParams.UserAssembly = sourceAssembly;
            resourceParams.ResourcePath = resourcePath;
            return(LoadPackageResource(resourceParams, true));
        }
Exemple #5
0
 public bool CanLoadResource(ResourceParams parameters)
 {
     if (parameters.ResourceType == ResourceType.XHR && parameters.URL.Contains("https://123movies.is/ajax/v2_get_sources"))
     {
         ajaxUrls.Add(parameters.URL);
     }
     return(true);
 }
        public static bool LoadPackageResource(ResourceParams resourceParams, bool throwOnError)
        {
            if (loadedResourcePackages.ContainsKey(resourceParams.ResourcePath))
            {
                return(true);
            }

            Assembly assembly = null;

            assembly = resourceParams.UserAssembly;
            string resourcePath = resourceParams.ResourcePath;

            if (assembly == null)
            {
                assembly = resourceParams.CallingAssembly;

                if (assembly == null)
                {
                    assembly = Assembly.GetCallingAssembly();
                }
            }

            Stream stream = assembly.GetManifestResourceStream(resourcePath);

            if (stream == null)
            {
                assembly = resourceParams.ExecutingAssembly;

                if (assembly == null)
                {
                    assembly = Assembly.GetExecutingAssembly();
                }

                stream = assembly.GetManifestResourceStream(resourcePath);
            }

            if (stream == null)
            {
                if (throwOnError)
                {
                    throw new ArgumentException("Specified resource does not exist in the provided assembly.");
                }

                return(false);
            }

            RadThemePackage package = RadThemePackage.Decompress(stream, typeof(RadThemePackage)) as RadThemePackage;

            if (package == null)
            {
                return(false);
            }

            //remember this location and do not load it again
            loadedResourcePackages[resourceParams.ResourcePath] = null;

            return(LoadPackage(package, throwOnError));
        }
Exemple #7
0
    public bool CanLoadResource(ResourceParams parameters)
    {
        if (parameters.ResourceType == ResourceType.IMAGE)
        {
            Console.WriteLine("image URL: " + parameters.URL);
        }

        return(true);
    }
Exemple #8
0
 public bool CanLoadResource(ResourceParams parameters)
 {
     if (parameters.ResourceType == ResourceType.XHR)
     {
         Debug.WriteLine("Intercepted AJAX request: " + parameters.URL);
         ajaxUrls.Add(parameters.URL);
     }
     return(true);
 }
        /// <summary>
        /// Loads a theme package, stored in the provided embedded resource.
        /// The calling assembly is used to read the manifest resource stream.
        /// </summary>
        /// <param name="resourcePath"></param>
        /// <returns></returns>
        public static bool LoadPackageResource(string resourcePath)
        {
            ResourceParams resourceParams = new ResourceParams();

            resourceParams.CallingAssembly   = Assembly.GetCallingAssembly();
            resourceParams.ExecutingAssembly = Assembly.GetExecutingAssembly();
            resourceParams.ResourcePath      = resourcePath;
            return(LoadPackageResource(resourceParams, true));
        }
 public void Merge(ResourceParams other)
 {
     for (int i = 0; i < other.Count; ++i)
     {
         var key = other.GetKey(i);
         var val = other.GetValue(i);
         AddOrUpdate(key, val);
     }
 }
    public ResourceParams GetResourceParams(int index)
    {
        ResourceParams obj = null;

        if (index >= 0 && index < m_Count)
        {
            obj = m_Vals[index];
        }
        return(obj);
    }
Exemple #12
0
                public bool CanLoadResource(ResourceParams parameters)
                {
                    if (parameters.ResourceType == ResourceType.XHR)
                    {
                        Console.WriteLine("Suppress ajax call - " + parameters.URL);
                        return(false);
                    }

                    return(true);
                }
        public static void RegisterThemeFromStorage(ThemeStorageType storageType, string themeLocation)
        {
            ResourceParams resParams = new ResourceParams();

            resParams.CallingAssembly   = Assembly.GetCallingAssembly();
            resParams.ExecutingAssembly = Assembly.GetExecutingAssembly();
            resParams.ResourcePath      = themeLocation;

            RegisterThemeFromStorage(storageType, resParams);
        }
Exemple #14
0
        public IActionResult GetUsers([FromQuery] ResourceParams resourceParameters)
        {
            var usersCollection = _usersRepository.GetUsers(resourceParameters);

            if (usersCollection == null || usersCollection.Count() == 0)
            {
                return(NotFound("No users were found"));
            }
            return(Ok(_mapper.Map <IEnumerable <UserDto> >(usersCollection)));
        }
    public static bool UpdateModel(string assetPath, ResourceParams param, bool onlySetting)
    {
        ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;

        if (modelImporter == null)
        {
            Debug.LogErrorFormat("no model importer at {0}", assetPath);
            return(false);
        }
        return(UpdateModel(param, modelImporter, onlySetting));
    }
Exemple #16
0
    public static bool UpdatePrefab(string assetPath, ResourceParams param, bool onlySetting)
    {
        var prefab = AssetDatabase.LoadAssetAtPath <UnityEngine.GameObject>(assetPath);

        if (prefab == null)
        {
            Debug.LogErrorFormat("can't load res at {0}", assetPath);
            return(false);
        }
        return(UpdatePrefab(param, prefab, onlySetting));
    }
    public static bool UpdateTexture(string assetPath, ResourceParams param, bool onlySetting)
    {
        TextureImporter textureImporter = TextureImporter.GetAtPath(assetPath) as TextureImporter;

        if (textureImporter == null)
        {
            Debug.LogErrorFormat("no texture importer at {0}", assetPath);
            return(false);
        }
        UpdateTexture(param, textureImporter, onlySetting);
        return(true);
    }
        public bool CanLoadResource(ResourceParams resourceParams)
        {
            NameValueCollection collections = HttpUtility.ParseQueryString(resourceParams.URL.ToLower());

            switch (filter)
            {
            case FilterType.YOUTUBE:
                if (resourceParams.URL.Contains("videoplayback?source=youtube"))
                {
                    if (collections.GetValues("dur").Length == 1)
                    {
                        duration = Convert.ToInt64(Double.Parse(collections.GetValues("dur")[0]) * 1000.0);
                    }
                    if (collections.GetValues("mime").Length == 1)
                    {
                        if (collections.GetValues("mime")[0].Contains("video"))
                        {
                            videoURL = resourceParams.URL;
                        }

                        if (collections.GetValues("mime")[0].Contains("audio"))
                        {
                            audioURL = resourceParams.URL;
                        }
                    }
                }

                if (resourceParams.ResourceType == ResourceType.PING)
                {
                    if (collections.GetKey(0).Contains("qoe"))
                    {
                        fexp = collections.GetValues("fexp")[0];
                    }
                }

                break;

            case FilterType.M3U8:
                break;

            case FilterType.MEDIA:
                break;

            case FilterType.UNIVERAL:
                break;

            default:
                break;
            }
            return(true);
        }
Exemple #19
0
    private static bool UpdatePrefab(ResourceParams param, UnityEngine.GameObject prefab, bool onlySetting)
    {
        bool rt = ResourceEditUtility.SetParamsToResource("prefabsetparams", param, prefab);

        rt = rt || ResourceEditUtility.ForceSaveAndReimport;
        if (!onlySetting && rt)
        {
            if (ResourceEditUtility.EnableSaveAndReimport)
            {
                EditorUtility.SetDirty(prefab);
            }
        }
        return(true);
    }
        /// <summary>
        /// Regesters theme from a file or resource that contains a xml-serilized Theme object.
        /// The Visual Style Builder application for example is capable of designing and serializing
        /// themes. Theme files generally contain Theme with one or several style sheets each assigned a
        /// registration that defines which RadControl and/or RadElment the style sheet applies.
        /// </summary>
        /// <param name="storageType"></param>
        /// <param name="resourceParams"></param>
        public static void RegisterThemeFromStorage(ThemeStorageType storageType, ResourceParams resourceParams)
        {
            ThemeSource source         = new ThemeSource();
            Assembly    lookUpAssembly = resourceParams.UserAssembly;

            if (lookUpAssembly == null)
            {
                lookUpAssembly = resourceParams.CallingAssembly;
            }

            source.SetCallingAssembly(lookUpAssembly);
            source.StorageType   = storageType;
            source.ThemeLocation = resourceParams.ResourcePath;
            source.ReloadThemeFromStorage();
        }
    private static bool UpdateModel(ResourceParams param, ModelImporter modelImporter, bool onlySetting)
    {
        bool rt = ResourceEditUtility.SetParamsToResource("modelsetparams", param, modelImporter);

        rt = rt || ResourceEditUtility.ForceSaveAndReimport;
        if (!onlySetting && rt)
        {
            if (ResourceEditUtility.EnableSaveAndReimport)
            {
                //modelImporter.SaveAndReimport();
                AssetDatabase.ImportAsset(modelImporter.assetPath);
            }
        }
        return(true);
    }
 public IEnumerable <User> GetUsers(ResourceParams resourceParams)
 {
     try
     {
         var userCollection = _healthContext.Users as IQueryable <User>;
         return(userCollection
                .Skip(resourceParams.PageSize * (resourceParams.PageNumber - 1))
                .Take(resourceParams.PageSize)
                .ToList());
     }
     catch (Exception)
     {
         return(null);
     }
 }
    public void AddOrMerge(string resKey, ResourceParams resParams)
    {
        int ix = m_Keys.IndexOf(resKey);

        if (ix >= 0)
        {
            m_Vals[ix].Merge(resParams);
        }
        else
        {
            m_Keys.Add(resKey);
            m_Vals.Add(resParams);
            ++m_Count;
        }
    }
Exemple #24
0
    public void ReceiveFuel(ResourceParams data)
    {
        switch (data.Type)
        {
        case "LiquidFuel":
            if (data.Amount >= 0)
            {
                LiquidFuel += data.Amount;
            }
            break;

        default:
            Debug.LogError("ReceiveFuel Recives Default");
            break;
        }
    }
    public bool TryGetResourceParams(string res, out ResourceParams val)
    {
        bool ret = false;
        int  ix  = m_Keys.IndexOf(res);

        if (ix >= 0)
        {
            val = m_Vals[ix];
            ret = true;
        }
        else
        {
            val = null;
        }
        return(ret);
    }
Exemple #26
0
    public static bool UpdateDB(string assetPath, UnityEngine.GameObject prefab)
    {
        ResourceParams param;
        string         guid = AssetDatabase.AssetPathToGUID(assetPath);

        if (!DBInstance.Data.TryGetResourceParams(guid, out param))
        {
            param          = new ResourceParams();
            param.Resource = assetPath;
            DBInstance.Data.AddOrMerge(guid, param);
        }
        else
        {
        }
        bool rt = ResourceEditUtility.GetParamsFromResource("prefabgetparams", param, prefab);

        return(rt);
    }
    public static bool UpdateDB(string assetPath, ModelImporter modelImporter)
    {
        ResourceParams param;
        string         guid = AssetDatabase.AssetPathToGUID(assetPath);

        if (!DBInstance.Data.TryGetResourceParams(guid, out param))
        {
            param          = new ResourceParams();
            param.Resource = assetPath;
            DBInstance.Data.AddOrMerge(guid, param);
        }
        else
        {
        }
        bool rt = ResourceEditUtility.GetParamsFromResource("modelgetparams", param, modelImporter);

        return(rt);
    }
Exemple #28
0
        bool ResourceHandler.CanLoadResource(ResourceParams parameters)
        {
            if (parameters.ResourceType == ResourceType.IMAGE || parameters.URL.StartsWith("file://"))
            {
                return(true);
            }

            if (parameters.ResourceType == ResourceType.MAIN_FRAME)
            {
                try {
                    var componentModel = _serviceProvider?.GetService(typeof(SComponentModel)) as IComponentModel;
                    Assumes.Present(componentModel);
                    componentModel.GetService <IIdeService>().Navigate(parameters.URL);
                }
                catch (Exception ex) {
                    Log.Error(ex, "CanLoadResource");
                }
            }

            return(false);
        }
Exemple #29
0
    public void SendFuel(ResourceParams data)
    {
        switch (data.Type)
        {
        case "LiquidFuel":
            if (LiquidFuel - data.Amount > 0)
            {
                LiquidFuel -= data.Amount;
                data.Sender.SendMessage("ReceiveFuel", data);
            }
            else if (LiquidFuel >= 0)
            {
                data.Amount = LiquidFuel;
                LiquidFuel  = 0;
                data.Sender.SendMessage("ReceiveFuel", data);
            }
            break;

        default:
            Debug.LogError("SendFuel Recives Default");
            break;
        }
    }
    public override void OnInspectorGUI()
    {
        bool saveDB = false;

        toDel.Clear();
        ModelImporterParamsDB db = target as ModelImporterParamsDB;
        int count = db.Data.Count;

        if (count == 0)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(EMPTY);
            GUILayout.EndHorizontal();
        }
        else
        {
            for (int i = 0; i < count; ++i)
            {
                string         guid  = db.Data.GetResourceKey(i);
                string         path  = AssetDatabase.GUIDToAssetPath(guid);
                ResourceParams param = db.Data.GetResourceParams(i);
                bool           valid = !string.IsNullOrEmpty(path) && param != null;
                if (!valid)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(VALID);
                    if (GUILayout.Button(DELETE))
                    {
                        toDel.Add(guid);
                        saveDB = true;
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    if (foldout.Count < i + 1)
                    {
                        foldout.Add(false);
                    }
                    var pathArr = path.Split('/');
                    if (EditorGUILayout.Foldout(foldout[i], i + ":" + pathArr[pathArr.Length - 1].ToString()))
                    {
                        foldout[i] = true;
                        for (int ix = 0; ix < param.Count; ++ix)
                        {
                            var key = param.GetKey(ix);
                            var val = param.GetValue(ix);
                            GUILayout.BeginHorizontal();
                            GUILayout.Label(string.Format("{0}:{1}", key, val));
                            GUILayout.EndHorizontal();
                        }

                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button(SELECT))
                        {
                            var asset = AssetDatabase.LoadMainAssetAtPath(path);
                            if (asset == null)
                            {
                                if (EditorUtility.DisplayDialog(NOT_FOUND_TITLE, string.Format(NOT_FOUND_CONTEXT, path), OK, NO))
                                {
                                    toDel.Add(guid);
                                    saveDB = true;
                                }
                            }
                            else
                            {
                                Selection.activeObject = asset;
                            }
                        }
                        if (GUILayout.Button(UPDATERES))
                        {
                            var importer = AssetImporter.GetAtPath(path) as ModelImporter;
                            if (null != importer)
                            {
                                ModelImporterParamsDB.UpdateModel(path, importer, false);
                                AssetDatabase.ImportAsset(path);
                            }
                        }
                        if (GUILayout.Button(UPDATEDB))
                        {
                            var importer = AssetImporter.GetAtPath(path) as ModelImporter;
                            if (null != importer)
                            {
                                ModelImporterParamsDB.UpdateDB(path, importer);
                                saveDB = true;
                            }
                        }
                        if (GUILayout.Button(DELETE))
                        {
                            toDel.Add(guid);
                            saveDB = true;
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        foldout[i] = false;
                    }
                }
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(ModelImporterParamsDB.SYNC_ALL))
            {
                ResourceEditUtility.ResetResourceParamsCalculator();
                ModelImporterParamsDB.UpdateAllModels();
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.BeginHorizontal();
        objToAdd = EditorGUILayout.ObjectField(objToAdd, typeof(UnityEngine.GameObject), false);
        if (GUILayout.Button(ADD) && null != objToAdd)
        {
            var path     = AssetDatabase.GetAssetPath(objToAdd);
            var importer = AssetImporter.GetAtPath(path) as ModelImporter;
            if (null != importer)
            {
                ModelImporterParamsDB.UpdateDB(path, importer);
                saveDB = true;
            }
        }
        GUILayout.EndHorizontal();

        foreach (var del in toDel)
        {
            db.Data.Remove(del);
        }

        if (saveDB)
        {
            EditorUtility.SetDirty(target);
            AssetDatabase.SaveAssets();
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button(ModelImporterParamsDB.IMPORT))
        {
            string file = EditorUtility.OpenFilePanel(ModelImporterParamsDB.IMPORT_DIALOG, string.Empty, "json");
            if (!string.IsNullOrEmpty(file))
            {
                ModelImporterParamsDB.Import(file);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(ModelImporterParamsDB.EXPORT))
        {
            string file = EditorUtility.SaveFilePanel(ModelImporterParamsDB.EXPORT_DIALOG, string.Empty, "modeldata", "json");
            if (!string.IsNullOrEmpty(file))
            {
                ModelImporterParamsDB.Export(file);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(ModelImporterParamsDB.FETCH))
        {
            ModelImporterParamsDB.Fetch();
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(ModelImporterParamsDB.COMMIT))
        {
            ModelImporterParamsDB.Commit();
        }
        GUILayout.EndHorizontal();
    }