Пример #1
0
 public bool Contains(BaseResource resource)
 {
     return(Input.Contains(resource) ||
            Output.Contains(resource) ||
            Control.Contains(resource) ||
            Mechanism.Contains(resource));
 }
Пример #2
0
        public ActionResult Delete(int Id)
        {
            try
            {
                var dbObj = db.ServiceSettings.FirstOrDefault(ln => ln.ID == Id);

                if (!User.IsInRole("Admin"))
                {
                    if (!Utils.ServiceUtils.IsServiceOwner(dbObj.ID, User.Identity.Name))
                    {
                        return(Json(new { Result = "ERROR", Message = BaseResource.Get("NoPermission") }));
                    }
                }

                db.StripeSettings.RemoveRange(dbObj.StripeSettings);

                db.ServiceSettings.Remove(dbObj);
                db.SaveChanges();
                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
 public async Task <bool> UpdateAsync(BaseResource resource)
 {
     using (var connection = ConnectionConfig.Instance.GetConnection())
     {
         return(await connection.UpdateAsync(resource, new { Id = resource.Id }, ConfigSettings.BaseResourceTable) > 0);
     }
 }
 public async Task <bool> AddAsync(BaseResource resource)
 {
     using (var connection = ConnectionConfig.Instance.GetConnection())
     {
         return(await connection.InsertAsync(resource, ConfigSettings.BaseResourceTable) > 0);
     }
 }
Пример #5
0
    private void InteractWithWorldObject(RaycastHit hit, InteractorComponent interactorComp, InventoryComponent inventoryComp)
    {
        switch (hit.transform.gameObject.GetComponentInParent <CollectibleComponent>().baseCollectible)
        {
        case BaseResource t:
            //    GatherResource(t, inventoryComp);
            break;

        default:
            break;
        }

        BaseResource resourceComp = hit.transform.gameObject.GetComponentInParent <CollectibleComponent>().baseCollectible;

        if (resourceComp != null)
        {
            // GatherResource(resourceComp, inventoryComp);
        }

        CartComponent transComp = hit.transform.GetComponent <CartComponent>();

        if (transComp != null)
        {
            interactorComp.interactMode        = InteractMode.Object;
            interactorComp.isInteracting       = true;
            interactorComp.currentInteractable = transComp;
            //if(player.go.GetComponent<InventoryComponent>().InventoryBag.Count > 0)
            //{
            //    transComp.gameObject.GetComponent<InventoryComponent>().TransferItemsFromTo(
            //        player.go.GetComponent<InventoryComponent>(),
            //        transComp.gameObject.GetComponent<InventoryComponent>(), true);
            //}
        }
    }
Пример #6
0
        protected void  Initialize(string viewName)
        {
            ShowOrButton = true;
            InitializeComponent();
            InitialName           = string.Empty;
            resourceTypesLink.Tag = resourceTypesLink.Text = ChooseResTypeDialog.AllResTypesRepresentation;
            _editHeading.Text     = InitialName = viewName ?? string.Empty;
            FormTitleString       = "name of a view";
            _referenceTopic       = "organizing\\organizing_using_views.html#newmanual";

            linkedWsps = Core.ResourceStore.EmptyResourceList;
            if (Core.WorkspaceManager.GetAllWorkspaces().Count > 1)
            {
                if (BaseResource != null)
                {
                    linkedWsps = BaseResource.GetLinksOfType(null, "InWorkspace");
                }

                checkInWsps.Checked = buttonChooseWsps.Enabled = textWsps.Enabled = (linkedWsps.Count > 0);
                if (checkInWsps.Checked)
                {
                    PrintSelectedWsps(linkedWsps);
                }
            }
        }
Пример #7
0
        public static MvcHtmlString Get_SortSelector_Orders()
        {
            string res = @"
            <div class=\'ui-field-contain\'>
            <label for='sort-select-orders'>" + BaseResource.Get("SortSelect") + @" </label>
            <select name='sort-select-orders' id='sort-select-orders' multiple='multiple' data-native-menu='false'>
                <option>" + BaseResource.Get("SortSelectChoose") + @"</option>
                <option value='CreationDate ASC'>CreationDate ASC</option>
                <option value='CreationDate DSC'>CreationDate DSC</option>
                <option value='CustomerUser ASC'>CustomerUser ASC</option>
                <option value='CustomerUser DSC'>CustomerUser DSC</option>
                <option value='StoreUser ASC'>StoreUser ASC</option>
                <option value='StoreUser DSC'>StoreUser DSC</option>
                <option value='OrderState ASC'>OrderState ASC</option>
                <option value='OrderState DSC'>OrderState DSC</option>
                <option value='ShippingState ASC'>ShippingState ASC</option>
                <option value='ShippingState DSC'>ShippingState DSC</option>
                <option value='PaymentState ASC'>PaymentState ASC</option>
                <option value='PaymentState DSC'>PaymentState DSC</option>
            </select>
            </div>";

            res += @"<script>
                $('#sort-select-orders').bind( 'change', function(event, ui) {
                        OrdersSortSelectionChanged(event,ui);
                });</script>";

            return(new MvcHtmlString(res));
        }
Пример #8
0
        public void ChangeUIData()
        {
            if (manager.listResult != null)
            {
                List <BlockListData> uiDataList = new List <BlockListData>();

                if (manager.totalCount > 0)
                {
                    Debug.Log("data len=" + manager.listResult.Count);

                    for (int i = 0; i < manager.listResult.Count; i++)
                    {
                        BaseResource res = manager.listResult[i];

                        BlockListData data = new BlockListData();
                        data.name = res.name;
                        data.data = res;
                        for (int j = 0; j < res.thumbnails.Length; j++)
                        {
                            if (res.thumbnails[j] != null)
                            {
                                data.icon = ImageHelper.GetImageUrl("http://" + manager.serverHost, res.thumbnails[j]);
                                break;
                            }
                        }

                        uiDataList.Add(data);
                    }
                }

                ui.SetData(uiDataList, manager.curPage, manager.totalCount);
            }
        }
Пример #9
0
        public static MvcHtmlString Get_FilterSelector_Products()
        {
            string res = @"
            <fieldset>
            <label for='filter-select-products'>" + BaseResource.Get("FilterSelect") + @"</label>
            <select name='filter-select-products' id='filter-select-products'>
                <option>" + BaseResource.Get("FilterSelectChoose") + @"</option>
                <option value='PartNumber'>PartNumber</option>
                <option value='ProductName'>ProductName</option>
                <option value='Description'>Description</option>
                <option value='Owner'>Owner</option>
                <option value='Price'>Price</option>
            </select>
            
                <label for='orderfilterinput'>" + BaseResource.Get("FilterInput") + @"</label>
                <input type='text' name='orderfilterinput' id='orderfilterinput'>
            ";

            res += @"<input type='button' class='ui-button ui-widget ui-corner-all' onclick='filtersearchbuttonclicked()' value='" + BaseResource.Get("BtnFilterSearch") + "'></input>";

            res += "</fieldset>";

            res += @"<script>
                    $(function() {
                       //  $('#filter-select-products').selectmenu();
                    });
                    </script>";


            return(new MvcHtmlString(res));
        }
Пример #10
0
        public JsonResult RolesCreate(ViewModels.RoleViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") }));
            }

            try
            {
                var rcreateres = _roleManager.Create(new IdentityRole()
                {
                    Name = model.Name
                });
                if (rcreateres.Succeeded)
                {
                    var newrole = _roleManager.FindByName(model.Name);
                    return(Json(new { Result = "OK", Record = new ViewModels.RoleViewModel()
                                      {
                                          Id = newrole.Id, Name = newrole.Name
                                      } }));
                }
                else
                {
                    return(Json(new { Result = "ERROR", Message = rcreateres.Errors.First().ToString() }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Пример #11
0
        public JsonResult Create(LocalizationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") }));
            }

            var toCreate = new Models.LocalizationModel()
            {
                Key               = model.Key,
                Value             = model.Value,
                Culture           = model.Culture,
                LastModDate       = DateTime.Now,
                ModUser           = User.Identity.Name,
                TranslationStatus = Enums.EnumTranslationStatus.Undefined,
                WasHit            = false
            };

            try
            {
                var dbobj = localizationRepository.Create(toCreate, User.Identity.Name);
                db.SaveChanges();
                return(Json(new { Result = "OK", Record = dbobj.ToLocalizationViewModel() }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
        public JsonResult Update(PredefinedMinerClientViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidData") }));
            }


            try
            {
                var dbObj = db.PredefinedMinerClients.FirstOrDefault(ln => ln.Id == model.Id);
                if (dbObj == null)
                {
                    return(Json(new { Result = "ERROR", Message = BaseResource.Get("InvalidPredefMinerClientId") }));
                }

                if (db.PredefinedMinerClients.Any(ln => ln.ClientId == model.ClientId))
                {
                    return(Json(new { Result = "ERROR", Message = BaseResource.Get("PredefClientAlreadyExists") }));
                }

                dbObj.ClientId  = model.ClientId;
                dbObj.ScriptUrl = model.ScriptUrl;
                db.SaveChanges();

                return(Json(new { Result = "OK", Message = "data saved.." }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Пример #13
0
        public void OnClickResource(BlockListData data)
        {
            BaseResource res = data.data as BaseResource;

            if (cbClickResource != null)
            {
                cbClickResource(res);
            }
        }
Пример #14
0
        public override async Task <object> Fetch()
        {
            var u = new Uri(uri);

            using (var stream = await SearchAction.Action(u, new SearchQuery(this)))
            {
                return(BaseResource.FromStream(u, stream));
            }
        }
Пример #15
0
 /// <summary>
 /// Instantiates an OrgRoom object
 /// </summary>
 /// <param name="Name">User controlled Room Name</param>
 /// <param name="Room">Type of BaseRoom object to determine base stats</param>
 /// <param name="Augmentations">List of BaseRoom_Augmentations to apply to the base room</param>
 /// <param name="Notes">User controlled room notes</param>
 /// <param name="ActiveResource">Resource this room is currently generating</param>
 public OrgRoom(String Name, BaseRoom Room, List<BaseRoom_Augmentation> Augmentations, String Notes, BaseResource ActiveResource)
 {
     this.Name = Name;
     this.Room = Room;
     this.Augmentations.Clear();
     this.Augmentations.AddRange(Augmentations);
     this.Notes = Notes;
     this.ActiveResource = ActiveResource;
 }
Пример #16
0
 public override void Remove(BaseResource resource)
 {
     switch (resource.GetType().ToString())
     {
     case "PatientResource":
         var patjson = (PatientResource)resource;
         this._patientResource.DeleteOne(rs => rs.id == patjson.id);
         break;
     }
 }
Пример #17
0
    /// <summary>
    /// 点击一个资源的回调
    /// </summary>
    /// <param name="res"></param>
    private void OnSelect(BaseResource res)
    {
        Asset asset = res as Asset;

        // 显示Loading状态
        storageUI.ShowLoading();

        // 下载资源,传入回调
        storageManager.DownloadAsset(asset, OnDownloadAssetFinish);
    }
Пример #18
0
 public override void Update(string id, BaseResource resource)
 {
     switch (resource.GetType().ToString())
     {
     case "PatientResource":
         var patjson = (PatientResource)resource;
         this._patientResource.ReplaceOne(rs => rs.id == id, patjson);
         break;
     }
 }
Пример #19
0
        public async static Task <FileSize> Action(Uri uri, Action <BaseResource, List <BaseResource> > lambda)
        {
            var parent = uri.LocateParent();

            var stream = await Request.Get(parent, new Types.Queries.BaseQuery());

            var content  = BaseResource.FromStream(uri, stream);
            var resource = content.Find(r => (r.GetUri().Equals(uri)));

            return(await resource.GetSize(lambda));
        }
Пример #20
0
        private void CreateBaseResource(string typeName, FileInfo info)
        {
            string       fromRoot     = info.FullName.Remove(0, parent.FullName.Length + 1);
            var          typeResource = typeList[typeName];
            var          version      = typeResource.GetSerializationVersion();
            BaseResource resource     = new BaseResource();

            resource.SetFileName(fromRoot);
            resource.SetEntryVersion(version);
            AddResource(typeName, BuildResourceTreeNode(resource.GetFileName(), resource));
        }
Пример #21
0
    public override void OnEpisodeBegin()
    {
        base.OnEpisodeBegin();

        if (!Goal.IsComplete)
        {
            CurrentState = AgentStateType.Idle;
        }

        resource = null;
    }
Пример #22
0
        private DesignerItem CreateItem(BaseResource resource, int size)
        {
            DesignerItem item = new DesignerItem(resource.Name, resource.DesignerID);

            item.Width          = size;
            item.Height         = size;
            item.BoundLogicItem = resource;
            item.dispName       = resource.Name;
            item.Tag            = resource.Name;

            return(item);
        }
Пример #23
0
    private void TakeResource()
    {
        if (!HasResource)
        {
            resource = Target.TakeResource();

            if (resource is object)
            {
                InternalStepCount = 0;
            }
        }
    }
Пример #24
0
        public static bool OnEntity(Entity entity)
        {
            var ent = BaseNetworkable.Get(entity.baseNetworkable.uid);

            if (ent != null)
            {
                ent.OnEntityUpdate(entity);
                return(ent.OnEntity(entity));
            }
            var prefabId = entity.baseNetworkable.prefabID;

            if (prefabId == (UInt32)EPrefabUID.BasePlayer)
            {
                ent = new BasePlayer();
            }
            else if (prefabId == (UInt32)EPrefabUID.OreBonus)
            {
                ent = new OreBonus();
            }
            else if (entity.resource != null && Database.IsOreResource(prefabId))
            {
                ent = new OreResource();
            }
            else if (entity.heldEntity != null)
            {
                ent = new BaseHeldEntity();
            }
            else if (OpCodes.IsStorage(entity.baseNetworkable.prefabID))
            {
                ent = new StorageContainer();
            }
            else if (Database.IsCollectible(prefabId))
            {
                ent = new CollectibleEntity();
            }
            else if (Database.IsBaseResource(prefabId))
            {
                ent = new BaseResource();
            }
            else if (entity.worldItem != null && Database.IsComponent(entity.worldItem.item.itemid))
            {
                //new WorldItem();
            }

            if (ent == null)
            {
                return(false);
            }
            ent.OnEntityCreate(entity);
            return(ent.OnEntity(entity));
        }
Пример #25
0
 public bool DoesItemExist(BaseResource itemToSearchFor)
 {
     for (int i = 0; i < InventoryBag.Count; i++)
     {
         //if (InventoryBag[i] != null)
         //{
         if (InventoryBag[i].itemType.baseCollectible.GetName() == itemToSearchFor.GetName())
         {
             return(true);
         }
         //     }
     }
     return(false);
 }
Пример #26
0
    private void TakeResource()
    {
        if (isAtResource && !HasResource)
        {
            resource = Target.GetResource();

            if (resource is object)
            {
                internalStepCount = 0;
                AddReward(0.1f);
                Debug.Log($"Current Reward: {GetCumulativeReward()}");
            }
        }
    }
Пример #27
0
        //public override List<BaseResource> Get() => this._patientResource.Find(rs => true).ToList();

        //public override BaseResource Get(string id) => this._resource.Find<BaseResource>(rs => rs.id == id).FirstOrDefault();

        public override BaseResource Create(BaseResource resource)
        {
            switch (resource.GetType().Name)
            {
            case "PatientResource":
                var patjson = (PatientResource)resource;
                this._patientResource.InsertOne(patjson);
                break;

            default:
                break;
            }
            return(resource);
        }
Пример #28
0
        static void CheckCommonStaticPropertiesOfResource(BaseResource resource)
        {
            Assert.DoesNotThrow(() =>
            {
                dynamic o = resource;
                Assert.True(o.Id.Equals(resource.Id));
            });

            Assert.DoesNotThrow(() =>
            {
                dynamic o = resource;
                Assert.True(o.Title.Equals(resource.Title));
            });
        }
Пример #29
0
        public static async Task <bool> AddRbacAccess(this BaseResource csmResource, string objectId)
        {
            try
            {
                //Disable RBAC access temporarily
                //if (csmResource.SubscriptionType == SubscriptionType.VSCodeLinux)
                return(false);

                var rbacRole = csmResource.SubscriptionType == SubscriptionType.MonitoringTools || csmResource is ServerFarm || csmResource is ResourceGroup
                ? _readerRole
                : _contributorRole;
                // add rbac contributor
                // after adding a user, CSM can't find the user for a while
                // pulling on the Graph GET doesn't work because that would return 200 while CSM still doesn't recognize the new user
                for (var i = 0; i < 30; i++)
                {
                    var csmResponse = await GetClient(csmResource.SubscriptionType).HttpInvoke(HttpMethod.Put,
                                                                                               new Uri(string.Concat(ArmUriTemplates.CsmRootUrl, csmResource.CsmId, "/providers/Microsoft.Authorization/RoleAssignments/", Guid.NewGuid().ToString(), "?api-version=", ArmUriTemplates.RbacApiVersion)),
                                                                                               new
                    {
                        properties = new
                        {
                            roleDefinitionId = string.Concat("/subscriptions/", csmResource.SubscriptionId, "/providers/Microsoft.Authorization/roleDefinitions/", rbacRole),
                            principalId      = objectId
                        }
                    });

                    SimpleTrace.Diagnostics.Verbose(AnalyticsEvents.AssignRbacResult, csmResponse.StatusCode);
                    if (csmResponse.StatusCode == HttpStatusCode.BadRequest)
                    {
                        await Task.Delay(1000);
                    }
                    else
                    {
                        await csmResponse.EnsureSuccessStatusCodeWithFullError();

                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                SimpleTrace.Diagnostics.Error(e, AnalyticsEvents.ErrorInAddRbacUser);
            }

            SimpleTrace.Diagnostics.Verbose(AnalyticsEvents.FailedToAddRbacAccess);
            return(false);
        }
Пример #30
0
    /// <summary>
    /// Changes the completed routine to the routine that follows it
    /// </summary>
    void AutoChangeState(bool switchResource = true)
    {
        // Ignore when dead or game over
        if (LevelController.Instance.IsGameOver || IsDead)
        {
            return;
        }

        if (Strikes > totalStrikes)
        {
            SheepManager.Instance.SheepDied(this);
            return;
        }

        switch (state)
        {
        // Done Walking: Consume Resource
        case State.Walking:
            if (curResource.ResourceType == Resource.Rest)
            {
                SwitchCoroutine(RestingRoutine());
            }
            else
            {
                SwitchCoroutine(ConsumeResourceRoutine(curResource));
            }
            break;

        // Done consuming resource: Fetch the next one
        // To add varierity, rest areas are chosen at random
        case State.Resting:
        case State.Eating:
        case State.Drinking:
        case State.Idling:
        case State.Recovering:

            // Pursue the current resource - just target a new one
            if (switchResource)
            {
                SwitchToNextResource();
            }

            curResource = GetAvailableResource(curResourceType);
            SwitchCoroutine(WalkRoutine());
            break;
        }
    }
Пример #31
0
        public JsonResult ProductImportStart(int importConfigId)
        {
            var user = userRepository.GetUser(User.Identity.Name);

            Utils.ProgressDialogUtils.Show("productImport", BaseResource.Get("ProductImportDialogTitle"), BaseResource.Get("ProductImportStarted"), 1, user.SignalRConnections);


            var config = db.ProductImportConfigurations.FirstOrDefault(ln => ln.Id == importConfigId);

            if (config == null)
            {
                Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ImportConfigNotFound"), 0, user.SignalRConnections);
                return(Json(new { Success = false, Message = "config not found.." }));
            }

            if (!User.IsInRole("Admin") && config.Owner.ID != user.Id)
            {
                Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("ImportNotOwnerOfConfig"), 0, user.SignalRConnections);
                return(Json(new { Success = false, Message = "no permission to load this config..." }));
            }

            var importer = Factories.ProductImportFactory.GetProductImportImplementation(Enums.EnumImportType.GoogleProductXML);

            Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("Cleaning"), 0, user.SignalRConnections);
            var prodsToRemove = db.ProductTmpImport.Where(ln => ln.Owner.ID == user.Id).ToList();

            db.ProductTmpImport.RemoveRange(prodsToRemove);
            //int rctr = 0;
            //foreach(var ritem in prodsToRemove)
            //{
            //    rctr++;
            //    Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("CleaningItem") + " (" + rctr + " / " + toCleanCount + ")", Utils.ProductUtils.calc_percent(rctr, toCleanCount), user.SignalRConnections);
            //    db.ProductTmpImport.Remove(ritem);
            //}
            db.SaveChanges();

            if (importer.ImportSource(config.Source, config.Owner.ID, user.SignalRConnections))
            {
                Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("MessageProductImportFinished"), 100, user.SignalRConnections);
                return(Json(new { Success = true, Message = "import completed.." }));
            }
            else
            {
                Utils.ProgressDialogUtils.Update("productImport", BaseResource.Get("MessageProductImportError"), 0, user.SignalRConnections);
                return(Json(new { Success = false, Message = "import failed.." }));
            }
        }
Пример #32
0
        static void CheckCommonStaticPropertiesOfResource(BaseResource resource)
        {
            Assert.DoesNotThrow(() =>
            {
                dynamic o = resource;
                Assert.True(o.Id.Equals(resource.Id));
            });

            Assert.DoesNotThrow(() =>
            {
                dynamic o = resource;
                Assert.True(o.Title.Equals(resource.Title));
            });

        }
Пример #33
0
 public UserDataModel(BaseResource resource)
 {
     this.storageContext = resource.StorageContext;
     this.currentUser = resource.CurrentUser;
 }
Пример #34
0
 /// <summary>
 /// Infrastructure. Initializes a new instance of the
 /// <see cref= "ConfigurationSetting"/> class.
 /// </summary>
 /// <param name="resource">
 /// An object representing a configuration setting.
 /// </param>
 internal ConfigurationSetting(BaseResource resource)
 {
     this.Object = resource.Object;
 }