public ServiceResult GetBy(string uuid) { if (string.IsNullOrWhiteSpace(uuid)) { return(ServiceResponse.Error("You must provide a UUID for the Attribute.")); } if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } AttributeManager AttributeManager = new AttributeManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = AttributeManager.Get(uuid); if (res.Code != 200) { return(res); } TMG.Attribute attribute = (TMG.Attribute)res.Result; if (CurrentUser.AccountUUID != attribute.AccountUUID) { return(ServiceResponse.Error("You are not authorized to access this functionality.")); } return(ServiceResponse.OK("", attribute)); }
public ServiceResult Update(TMG.Attribute s) { if (s == null) { return(ServiceResponse.Error("Invalid TMG.Attribute sent to server.")); } AttributeManager AttributeManager = new AttributeManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = AttributeManager.Get(s.UUID); if (res.Code != 200) { return(res); } var dbS = (TMG.Attribute)res.Result; if (dbS.DateCreated == DateTime.MinValue) { dbS.DateCreated = DateTime.Now; } dbS.Deleted = s.Deleted; dbS.Name = s.Name; dbS.Status = s.Status; dbS.SortOrder = s.SortOrder; dbS.Image = s.Image; dbS.ReferenceType = s.ReferenceType; dbS.ReferenceUUID = s.ReferenceUUID; dbS.Value = s.Value; dbS.ValueType = s.ValueType; dbS.SafeName = s.SafeName; dbS.Deleted = s.Deleted; dbS.Active = s.Active; return(AttributeManager.Update(dbS)); }
public ServiceResult SetActiveProfileImageFromAttribute(string attributeUUID) { AttributeManager atm = new AttributeManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = atm.Get(attributeUUID); if (res.Code != 200) { return(res); } var attribute = res.Result as TMG.Attribute; if (attribute.ValueType.EqualsIgnoreCase("ImagePath") == false) { return(ServiceResponse.Error("Attribute is not an image path type.")); } ProfileManager profileManager = new ProfileManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var tmp = profileManager.GetProfile(CurrentUser.UUID, CurrentUser.AccountUUID, true); if (tmp.Code != 200) { return(tmp); } GreenWerx.Models.Membership.Profile profile = (Profile)tmp.Result; profile.Image = attribute.Image; return(ServiceResponse.OK("", profile.Image)); }
public override void OnGUI(Rect area, SerializedProperty property, GUIContent label) { EditorUI.Reset(); if (this.attribute == null) { this.attribute = property.GetObject <Attribute>(); MonoBehaviour script = (MonoBehaviour)property.serializedObject.targetObject; this.isPrefabFile = script.InPrefabFile(); } if (!this.attribute.showInEditor || !this.attribute.isSetup) { this.overallHeight = -2; return; } if (this.isPrefabFile) { return; } this.overallHeight = this.GetBaseHeight(property, label); if (!Attribute.ready && AttributeManager.Get().safeMode) { EditorGUI.ProgressBar(area, AttributeManager.percentLoaded, "Updating"); return; } if (this.access == null) { this.access = new AttributeBoolAccess(); } this.access.Setup(this, area, property, label); }
public ServiceResult SetActiveProfileImageFromAttribute(string attributeUUID) { AttributeManager atm = new AttributeManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = atm.Get(attributeUUID); if (res.Code != 200) { return(res); } var attribute = res.Result as TMG.Attribute; if (attribute == null) { return(ServiceResponse.Error("Attribute was not found.")); } if (attribute.ValueType.EqualsIgnoreCase("ImagePath") == false) { return(ServiceResponse.Error("Attribute is not an image path type.")); } if (_profileMemberManager == null) { _profileMemberManager = new ProfileMemberManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); } var profile = _profileMemberManager.GetMemberProfile(CurrentUser.UUID, CurrentUser.AccountUUID); if (profile == null) { return(ServiceResponse.Error("ProfileMember was not found.")); } profile.Image = attribute.Image; return(ServiceResponse.OK("", profile.Image)); }
public ServiceResult DeleteAttribute(string UUID)//todo bookmark latest test this. { if (string.IsNullOrWhiteSpace(UUID)) { return(ServiceResponse.Error("No id was sent.")); } if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } AttributeManager atm = new AttributeManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = atm.Get(UUID); if (res.Code != 200) { return(res); } var attribute = res.Result as TMG.Attribute; if (attribute.ValueType.EqualsIgnoreCase("ImagePath") == false) { return(atm.Delete(attribute, true)); } string root = System.Web.HttpContext.Current.Server.MapPath("~/Content/Uploads/" + this.CurrentUser.UUID); string fileName = attribute.Image.GetFileNameFromUrl(); //todo get folder and file from attribute.Image => https://localhost:44318/Content/Uploads/8ac0adc1e7154afda15069c822d68d6d/20190226_082504appicon.png string pathToFile = Path.Combine(root, fileName); DocumentManager dm = new DocumentManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); if (dm.DeleteFile(attribute, pathToFile).Code != 200) { return(ServiceResponse.Error("Failed to delete file " + fileName)); } DataFilter filter = this.GetFilter(Request); List <TMG.Attribute> attributes = atm.GetAttributes(this.CurrentUser.AccountUUID, ref filter) .Where(w => w.UUIDType.EqualsIgnoreCase("ImagePath") && w.Value == attribute.UUID && w.Image.Contains(fileName)).ToList(); // Update attributes that are using this image. foreach (TMG.Attribute att in attributes) { // if (am.DeleteSetting(setting.UUID).Code != 200) // return ServiceResponse.Error("Failed to delete image setting for file " + fileName); att.Image = "/assets/img/blankprofile.png"; // todo change image. Monetize? } var res1 = atm.Delete(attribute, true); ProfileManager profileManager = new ProfileManager(Globals.DBConnectionKey, Request.Headers.Authorization?.Parameter); var tmp = profileManager.GetProfile(CurrentUser.UUID, CurrentUser.AccountUUID, true); if (tmp.Code != 200) { return(tmp); } GreenWerx.Models.Membership.Profile profile = (Profile)tmp.Result; if (profile.Image.Contains(fileName)) { profile.Image = "/assets/img/blankprofile.png"; } return(profileManager.UpdateProfile(profile)); }
public static void Select() { Selection.activeObject = AttributeManager.Get(); }
public override void OnGUI(Rect area, SerializedProperty property, GUIContent label) { EditorUI.Reset(); if (this.attribute == null) { this.attribute = property.GetObject <Attribute>(); MonoBehaviour script = (MonoBehaviour)property.serializedObject.targetObject; this.isPrefabFile = script.InPrefabFile(); } if (!this.attribute.showInEditor || !this.attribute.isSetup) { this.overallHeight = -2; return; } if (this.isPrefabFile) { /*this.overallHeight = EditorGUIUtility.singleLineHeight; * //base.OnGUI(area,property,label); * Type utility = ProxyEditor.GetEditorType("ScriptAttributeUtility"); * Type utility = ProxyEditor.GetEditorType("ScriptAttributeUtility"); * SerializedProperty againstProperty = this.property; * var handler = utility.CallMethod("GetHandler",againstProperty); * Debug.Log(handler.GetVariable<PropertyDrawer>("m_PropertyDrawer")); * ProxyEditor.GetVariable<Stack<PropertyDrawer>>("s_DrawerStack").Pop(); * base.OnGUI(area,property,label); * ProxyEditor.GetVariable<Stack<PropertyDrawer>>("s_DrawerStack").Push(this);*/ return; } this.overallHeight = this.GetBaseHeight(property, label); if (!Attribute.ready && AttributeManager.Get().safeMode) { EditorGUI.ProgressBar(area, AttributeManager.percentLoaded, "Updating"); return; } if (this.access == null) { if (this.attribute is AttributeFloat) { this.access = new AttributeAccess <float, AttributeFloat, AttributeFloatData>(); } if (this.attribute is AttributeInt) { this.access = new AttributeAccess <int, AttributeInt, AttributeIntData>(); } if (this.attribute is AttributeString) { this.access = new AttributeAccess <string, AttributeString, AttributeStringData>(); } //if(this.attribute is AttributeBool){this.access = new AttributeAccess<bool,AttributeBool,AttributeBoolData>();} if (this.attribute is AttributeVector3) { this.access = new AttributeAccess <Vector3, AttributeVector3, AttributeVector3Data>(); } if (this.attribute is AttributeGameObject) { this.access = new AttributeAccess <GameObject, AttributeGameObject, AttributeGameObjectData>(); } } if (this.access != null) { this.access.Setup(this, area, property, label); } }