public async Task AddAssetsType(AssetsTypeInputDto input) { if (await db.AssetsTypes.AnyAsync(m => m.Name == input.AssetsTypeName)) { throw new HttpResponseException(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(new ResponseApi() { Code = EExceptionType.Implement, Message = input.AssetsTypeName + "已存在" })) }); } var assets = new AssetsType() { Id = IdentityManager.NewId(), Name = input.AssetsTypeName, IsDelete = false }; db.AssetsTypes.Add(assets); if (await db.SaveChangesAsync() <= 0) { throw new HttpResponseException(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(new ResponseApi() { Code = EExceptionType.Implement, Message = "添加失败" })) }); } }
/// <summary> /// 页面初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmAssetsTypeCreateLayout_Load(object sender, EventArgs e) { try { AssetsType at = autofacConfig.assTypeService.GetByID(ID); if (isEdit == true) //编辑此分类 { txtID.ReadOnly = true; txtID.Text = at.TYPEID; //分类编号 txtName.Text = at.NAME; //分类名称 txtDate.Text = at.EXPIRYDATE.ToString(); //分类有效日期 if (String.IsNullOrEmpty(at.PARENTTYPEID) == false) //如果有父类,则显示父类信息 { AssetsType parentAt = autofacConfig.assTypeService.GetByID(at.PARENTTYPEID); txtFID.Text = parentAt.TYPEID; //父分类编号 txtFName.Text = parentAt.NAME; //父分类名称 txtFDate.Text = parentAt.EXPIRYDATE.ToString(); //父分类有效日期 } } else if (isCreateSon == true) //创建子分类 { txtFID.Text = at.TYPEID; //父分类编号 txtFName.Text = at.NAME; //父分类名称 txtFDate.Text = at.EXPIRYDATE.ToString(); //父分类有效日期 } } catch (Exception ex) { Form.Toast(ex.Message); } }
/// <summary> /// 更新资产类别 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ReturnInfo UpdateAssetsType(AssetsType entity) { ReturnInfo RInfo = new ReturnInfo(); try { if (String.IsNullOrEmpty(entity.TYPEID)) { throw new Exception("资产类别编号不能为空"); } AssetsType at = _AssetsTypeRepository.GetByID(entity.TYPEID).FirstOrDefault(); if (at == null) { throw new Exception("该分类编号不存在,请检查!"); } at.NAME = entity.NAME; at.EXPIRYDATE = entity.EXPIRYDATE; _unitOfWork.RegisterDirty(at); bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = "更新信息成功!"; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }
/// <summary> /// 数据加载 /// </summary> internal void Bind() { AssetsType assetsType = autofacConfig.assTypeService.GetByID(ID); title1.TitleText = assetsType.NAME; List <AssetsType> assetsTypeList = autofacConfig.assTypeService.GetByLevelAndParentId(2, ID); if (assetsTypeList.Count > 0) { lvSecondLevel.DataSource = assetsTypeList; lvSecondLevel.DataBind(); } foreach (ListViewRow Row in lvSecondLevel.Rows) { frmATFirstLevelLayout Layout = Row.Control as frmATFirstLevelLayout; svEnable svLayout = ((frmATFirstLevelLayout)Row.Control).svRow.RightControl as svEnable; if (Layout.lblNext.BindDataValue.ToString() == "0") { svLayout.btnEnable.Text = "启用"; svLayout.btnEnable.BackColor = System.Drawing.Color.FromArgb(43, 140, 255); Layout.lblName.ForeColor = System.Drawing.Color.FromArgb(230, 230, 230); } } }
public static List <ABAssetsInfo> GetAssetInfoList(AssetsType type) { if (string.IsNullOrEmpty(assetsSearchString)) { if (type == AssetsType.None) { return(s_CurrentAssetsList); } s_TempAssetList.Clear(); foreach (var info in s_CurrentAssetsList) { if (info.type == type) { s_TempAssetList.Add(info); } } } else { s_TempAssetList.Clear(); foreach (var info in s_CurrentAssetsList) { if ((info.type == type || type == AssetsType.None) && info.name.Contains(assetsSearchString)) { s_TempAssetList.Add(info); } } } return(s_TempAssetList); }
/// <summary> /// 删除资产类别 /// </summary> /// <param name="ID"></param> /// <returns></returns> public ReturnInfo DeleteAssetsType(String ID) { ReturnInfo RInfo = new ReturnInfo(); try { if (String.IsNullOrEmpty(ID)) { throw new Exception("资产类别编号不能为空"); } AssetsType at = _AssetsTypeRepository.GetByID(ID).FirstOrDefault(); if (at == null) { throw new Exception("该分类编号不存在,请检查!"); } _unitOfWork.RegisterDeleted(at); bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = "删除成功!"; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }
/// <summary> /// 更改分类启用状态 /// </summary> /// <param name="TypeId"></param> /// <param name="status"></param> /// <returns></returns> public ReturnInfo ChangeEnable(String TypeId, IsEnable status) { ReturnInfo RInfo = new ReturnInfo(); if (String.IsNullOrEmpty(TypeId)) { throw new Exception("分类编号不能为空"); } AssetsType assetsType = _AssetsTypeRepository.GetByID(TypeId).FirstOrDefault(); if (assetsType == null) { throw new Exception("分类编号不存在,请检查!"); } try { assetsType.ISENABLE = (int)status; _unitOfWork.RegisterDirty(assetsType); _unitOfWork.Commit(); RInfo.IsSuccess = true; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }
/// <summary> /// 进行编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void IBEdit_Press(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(ID)) { throw new Exception("请先选择要操作的资产类别"); } AssetsType assetsType = autofacConfig.assTypeService.GetByID(ID); frmLocationRowsButtonLayout frm = new frmLocationRowsButtonLayout(); if (assetsType.ISENABLE == (int)IsEnable.启用) { frm.Enable = true; } else { frm.Enable = false; } frm.ID = ID; DialogOptions Dialog = new DialogOptions { JustifyAlign = LayoutJustifyAlign.FlexEnd, Padding = new Padding(0) }; ShowDialog(frm, Dialog); } catch (Exception ex) { Toast(ex.Message); } }
public static bool IsValidDep(AssetsCategory category, AssetsType type) { if (category == AssetsCategory.UI) { return(false); } return(type == AssetsType.Material || type == AssetsType.Texture || type == AssetsType.Shader || type == AssetsType.Prefab || type == AssetsType.Asset); }
public Asset(AssetsType type, string rootDirectory, string relativePathToAsset, string originalFile = null) { Type = type; RootDirectory = rootDirectory; RelativePathToAsset = relativePathToAsset; FullPathToAsset = Path.Combine(rootDirectory, relativePathToAsset); AssetFileName = Path.GetFileName(relativePathToAsset); OriginalFile = originalFile ?? FullPathToAsset; }
/// <summary> /// 获取资源 /// </summary> /// <param name="prefabName"></param> /// <param name="type"></param> /// <returns></returns> public void LoadAseet(string prefabName, AssetsType type, Action <UnityEngine.Object> func) { GameObject prefab = prefabPool[(int)type].details.TryGet(prefabName); if (prefab == null) { prefab = AddAsset(prefabName, type); } func?.Invoke(prefab); }
protected override void BuildTitle() { var title = AssetsType.GetCnName(); Sheet.CreateRow(NextRowIndex).CreateCell(0).SetCellValue(title); NextRowIndex++; TempRow = Sheet.CreateRow(NextRowIndex); TempRow.CreateCell(0).SetCellValue("单位名称:"); TempRow.CreateCell(1).SetCellValue("测试单位"); NextRowIndex++; }
/// <summary> /// 添加资源 /// </summary> /// <param name="prefabName"></param> /// <param name="type"></param> /// <returns></returns> private GameObject AddAsset(string prefabName, AssetsType type) { string prefabPath = type.ToString() + "/" + prefabName; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab) { prefabPool[(int)type].details.Add(prefabName, prefab); } return(prefab); }
/// <summary> /// 加载获取动态图集图片 /// </summary> /// <param name="spriteName"></param> /// <param name="type"></param> /// <returns></returns> public Sprite LoadAtlasSprite(string spriteName, AssetsType type) { SpriteAtlas atlas; spriteAtlasDic.TryGetValue(AssetsType.ATLAS, out atlas); //如果图集不为空则从图集里面获取对应图片 if (null == atlas) { return(null); } return(atlas.GetSprite(spriteName)); }
internal static string GetResourcePath(AssetsType type) { switch (type) { case AssetsType.Root: return(ASSETS_PATH); case AssetsType.Map: return(Path.Combine(ASSETS_PATH, "Maps")); case AssetsType.Gfx: return(Path.Combine(ASSETS_PATH, "Gfx")); default: return(null); } }
/// <summary> /// This is the constructor for a wrapper around the Vector Resources folder /// </summary> /// <param name="basePath">The path to the root of the Vector file system</param> public Assets(string basePath) { // Load the platform configuration with the patchs to the other parts // Note: this is not present in Cozmo var path = Path.Combine(basePath, "anki/etc/config/platform_config.json"); // Try the Vector first if (File.Exists(path)) { // Mark it as a Vector style assets folder AssetsType = AssetsType.Vector; displayWidth = VectorDisplayWidth; displayHeight = VectorDisplayHeight; // Get the text for the file var text = System.IO.File.ReadAllText(path); // Get it in a convenient form var JSONOptions = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true, IgnoreNullValues = true }; var config = JsonSerializer.Deserialize <Platform_config>(text, JSONOptions); // Construct the cozmoResources patch cozmoResourcesPath = Path.Combine(basePath, config.DataPlatformResourcesPath.Substring(1)); } else { // Mark it as a Cozmo style assets folder AssetsType = AssetsType.Cozmo; displayWidth = CozmoDisplayWidth; displayHeight = CozmoDisplayHeight; // Construct the cozmoResources patch cozmoResourcesPath = Path.Combine(basePath, "assets/cozmo_resources"); } // Load the manifest of features LoadFeatures(Path.Combine(cozmoResourcesPath, "config")); LoadCozmoResources(); }
public static string GetAssetTypeSizeStr(AssetsType type) { if (s_AssetTypeStat.ContainsKey(type)) { if (type == AssetsType.None) { return(s_AssetTypeStat[type].StrInfo(s_TotalAssets)); } else { return(s_AssetTypeStat[type].StrInfo()); } } else { return("--"); } }
/// <summary> /// 获取父资产信息 /// </summary> /// <param name="type"></param> /// <returns></returns> public String GetLevel1TypeID(String type) { AssetsType assetsType = _AssetsTypeRepository.GetByID(type).FirstOrDefault(); if (assetsType.TLEVEL == 1) //没有父资产,说明是一级资产分类 { return(type); } else if (assetsType.TLEVEL == 2) //二级资产 { return(assetsType.PARENTTYPEID); } else //三级资产 { AssetsType AssType = _AssetsTypeRepository.GetByID(assetsType.PARENTTYPEID).FirstOrDefault(); return(assetsType.PARENTTYPEID); } }
/// <summary> /// This is the constructor for a wrapper around the Vector Resources folder /// </summary> /// <param name="basePath">The path to the root of the Vector file system</param> public Assets(string basePath) { // Load the platform configuration with the patchs to the other parts // Note: this is not present in Cozmo var path = Path.Combine(basePath, "anki/etc/config/platform_config.json"); // Try the Vector first if (File.Exists(path)) { // Mark it as a Vector style assets folder AssetsType = AssetsType.Vector; // Make a note of the size of the LCD DisplaySize = new Size(VectorDisplayWidth, VectorDisplayHeight); // Get the text for the file var text = File.ReadAllText(path); // Get it in a convenient form var config = JSONDeserializer.Deserialize <Platform_config>(text); // Construct the cozmoResources patch cozmoResourcesPath = Path.Combine(basePath, config.DataPlatformResourcesPath.Substring(1)); // Load the server's to use LoadServers(Path.Combine(cozmoResourcesPath, "config")); } else { // Mark it as a Cozmo style assets folder AssetsType = AssetsType.Cozmo; // Make a note of the size of the LCD DisplaySize = new Size(CozmoDisplayWidth, CozmoDisplayHeight); // Construct the cozmoResources patch cozmoResourcesPath = Path.Combine(basePath, "assets/cozmo_resources"); } // Load the manifest of features LoadFeatures(Path.Combine(cozmoResourcesPath, "config")); LoadCozmoResources(); }
public ReturnInfo AddAssetsType(AssetsType entity) { ReturnInfo RInfo = new ReturnInfo(); if (String.IsNullOrEmpty(entity.TYPEID)) { throw new Exception("分类编号不能为空"); } if (String.IsNullOrEmpty(entity.NAME)) { throw new Exception("分类名称不能为空"); } if (String.IsNullOrEmpty(entity.EXPIRYDATE.ToString())) { throw new Exception("年限不能为空"); } AssetsType at = _AssetsTypeRepository.GetByID(entity.TYPEID).AsNoTracking().FirstOrDefault(); if (at != null) { throw new Exception("该分类编号已存在!"); } try { entity.EXPIRYDATEUNIT = 1; entity.ISENABLE = 1; _unitOfWork.RegisterNew(entity); bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = "创建成功!"; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }
/// <summary> /// 根据资产类别编号返回资产类别信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public AssetsType GetByID(string ID) { AssetsType at = _AssetsTypeRepository.GetByID(ID).AsNoTracking().FirstOrDefault(); return(at); }
public Asset(AssetsType type, string path) { AssetType = type; PathLocation = path; }
/// <summary> /// 加载单个资源 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="path"></param> /// <returns></returns> public void LoadResAsset(string prefabName, AssetsType type, Action <UObject> func) { mResMgr.LoadAseet(prefabName, type, func); }
private void GUISearchAndAsset() { var searchHeight = 16.8f; var btnWidth = 98; m_SelectedSearchIndex = GUILayout.SelectionGrid(m_SelectedSearchIndex, Styles.searchBtns, 2, GUILayout.Width(btnWidth), GUILayout.Height(searchHeight - 2)); var rect = new Rect(m_Panel.LeftTopRect.x + btnWidth + 1, m_Panel.LeftTopRect.y - searchHeight - 2f, m_Panel.LeftTopRect.width - btnWidth + m_Panel.SplitterWidth, searchHeight); if (m_SelectedSearchIndex == 0) { var newSearch = m_SearchField.OnGUI(rect, ABDatabase.abSearchString); if (ABDatabase.abSearchString != newSearch) { ABDatabase.abSearchString = newSearch; m_ABTree.UpdateInfoList(ABDatabase.GetABInfoList(m_SelectedABType)); Repaint(); } } else { var newSearch = m_SearchField.OnGUI(rect, ABDatabase.assetsSearchString); if (ABDatabase.assetsSearchString != newSearch) { ABDatabase.assetsSearchString = newSearch; m_AssetTree.UpdateInfoList(ABDatabase.GetAssetInfoList(m_SelectedAssetType)); Repaint(); } } var tabLabels = new string[] { "All\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.None), "Material\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Material), "Texture\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Texture), "Prefab\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Prefab), "Shader\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Shader), "Asset\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Asset), "Other\n" + ABDatabase.GetAssetTypeSizeStr(AssetsType.Other), }; var barWidth = m_Panel.RightTopRect.width; var barRect = new Rect(m_Panel.RightTopRect.x, m_Panel.RightTopRect.y - k_AssetsToolbarHeight, m_Panel.RightTopRect.width, k_AssetsToolbarHeight - 0.5f); var selected = (AssetsType)GUI.Toolbar(barRect, (int)m_SelectedAssetType, tabLabels); if (selected != m_SelectedAssetType) { m_SelectedAssetType = selected; m_AssetTree.UpdateInfoList(ABDatabase.GetAssetInfoList(m_SelectedAssetType)); } barWidth = m_Panel.LeftBottomRect.width; barRect = new Rect(m_Panel.LeftBottomRect.x, m_Panel.LeftBottomRect.y - k_DepToolbarHeight, m_Panel.LeftBottomRect.width, k_DepToolbarHeight - 0.5f); var selectedDep = GUI.Toolbar(barRect, m_SelectedDepIndex, new string[] { "Dep", "Ref" }); if (selectedDep != m_SelectedDepIndex) { m_SelectedDepIndex = selectedDep; UpdateDepInfoList(); } }
/// <summary> /// 提交操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Press(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtID.Text)) { throw new Exception("分类编号不能为空"); } if (String.IsNullOrEmpty(txtName.Text)) { throw new Exception("分类名称不能为空"); } if (String.IsNullOrEmpty(txtDate.Text)) { throw new Exception("年限不能为空"); } AssetsType type = autofacConfig.assTypeService.GetByID(txtID.Text); if (type != null) { throw new Exception("该编号已存在"); } if (System.Text.RegularExpressions.Regex.IsMatch(txtDate.Text.Trim(), "^\\d+$") == false) { throw new Exception("年限必须为数字"); } AssetsType at = new AssetsType(); if (isCreate == true || isCreateSon == true) //新建分类 { at.TYPEID = txtID.Text; //分类编号 at.NAME = txtName.Text; //分类名称 at.EXPIRYDATE = Convert.ToInt32(txtDate.Text); //分类有效日期 at.PARENTTYPEID = txtFID.Text; //父分类编号 at.EXPIRYDATEUNIT = 1; //默认为月 at.ISENABLE = 1; //启用 at.CREATEUSER = Client.Session["UserID"].ToString(); if (isCreate == true) { at.TLEVEL = 1; //分类级别 } if (isCreateSon == true) { at.TLEVEL = autofacConfig.assTypeService.GetByID(txtFID.Text).TLEVEL + 1; } ReturnInfo r = autofacConfig.assTypeService.AddAssetsType(at); if (r.IsSuccess == true) { this.Close(); //关闭创建弹出框 this.Form.Toast("创建资产分类成功"); } else { throw new Exception(r.ErrorInfo); } } else if (isEdit == true) //修改分类 { at.TYPEID = txtID.Text; //分类编号 at.NAME = txtName.Text; //分类名称 at.EXPIRYDATE = Convert.ToInt32(txtDate.Text); //分类有效日期 at.PARENTTYPEID = txtFID.Text; //父分类编号 ReturnInfo r = autofacConfig.assTypeService.UpdateAssetsType(at); if (r.IsSuccess == true) { this.Close(); //关闭创建弹出框 this.Form.Toast("资产分类信息修改成功"); } else { throw new Exception(r.ErrorInfo); } } } catch (Exception ex) { Form.Toast(ex.Message); } }
/// <summary> /// 提交操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Press(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtID.Text)) { throw new Exception("分类编号不能为空"); } if (String.IsNullOrEmpty(txtName.Text)) { throw new Exception("分类名称不能为空"); } if (String.IsNullOrEmpty(txtDate.Text)) { throw new Exception("年限不能为空"); } AssetsType at = new AssetsType(); if (isCreate == true || isCreateSon == true) //新建分类 { at.TYPEID = txtID.Text; //分类编号 at.NAME = txtName.Text; //分类名称 at.EXPIRYDATE = Convert.ToInt32(txtDate.Text); //分类有效日期 at.PARENTTYPEID = txtFID.Text; //父分类编号 if (isCreate == true) { at.TLEVEL = 1; //分类级别 } if (isCreateSon == true) { at.TLEVEL = autofacConfig.assTypeService.GetByID(txtFID.Text).TLEVEL + 1; } ReturnInfo r = autofacConfig.assTypeService.AddAssetsType(at); if (r.IsSuccess == true) { this.Close(); //关闭创建弹出框 this.Form.Toast("创建资产分类成功"); //刷新页面数据 ((frmAssetsTypeRows)Form).Bind(); } else { throw new Exception(r.ErrorInfo); } } else if (isEdit == true) //修改分类 { at.TYPEID = txtID.Text; //分类编号 at.NAME = txtName.Text; //分类名称 at.EXPIRYDATE = Convert.ToInt32(txtDate.Text); //分类有效日期 at.PARENTTYPEID = txtFID.Text; //父分类编号 ReturnInfo r = autofacConfig.assTypeService.UpdateAssetsType(at); if (r.IsSuccess == true) { this.Close(); //关闭创建弹出框 this.Form.Toast("资产分类信息修改成功"); //刷新页面数据 ((frmAssetsTypeRows)Form).Bind(); } else { throw new Exception(r.ErrorInfo); } } } catch (Exception ex) { Form.Toast(ex.Message); } }