public async Task <Resource?> AddResourceAsync(string name, string contentType, byte[] content) { var u = await AccountManager.GetCurrentUserAsync(); if (u is null) { return(null); } var ir = new DbResource { Content = content, Expired = DateTime.MaxValue, Name = name, ContentType = contentType, Uploader = u }; await Db.Resources.AddAsync(ir); await Db.SaveChangesAsync(); return(new Resource { Uploader = u.FriendlyName, Id = ir.Id, Name = name, Size = content.Length }); }
public bool DeleteResource(DbResource res) { string fromType = $"delete from OBI.RESOURCE_TYPE where RESOURCE_TYPE = '{res.ResourceType}'"; string fromKey = $"delete from OBI.RESOURCE_key where RESOURCE_TYPE = '{res.ResourceType}' and RESOURCE_KEY = '{res.ResourceKey}'"; string fromText = $"delete from OBI.RESOURCE_TEXT where RESOURCE_VALUE = '{res.ResourceValue}'" + $"and CULTURE_ID = (select CULTURE_ID from obi.culture where CULTURE_NAME ='{res.CultureCode}')"; bool resultText; try { _connection.Open(); resultText = _connection.DeleteResource(fromText); if (LastResourceWithTheSameResKeyId(res)) { return(resultText && _connection.DeleteResource(fromKey) && _connection.DeleteResource(fromType)); } } catch (Exception e) { Console.WriteLine(e); return(false); } finally { _connection.Close(); } return(resultText); }
private void QryForms() { treeListForm.Nodes.Clear(); DataSet inblk = new DataSet(); inblk.Tables.Add(); inblk.Tables[0].Columns.Add("name"); inblk.Tables[0].Columns.Add("dllname"); inblk.Tables[0].Columns.Add("appname"); inblk.Tables[0].Rows.Add(fgtFormName.Text, "", CConstString.AppName); DataTable dt = DbResource.QueryFormInfo(inblk, CConstString.ConnectName); //outBlock = EI.EITuxedo.CallService("epesformlistinq", inBlock); string formName = ""; string formDesc = ""; for (int i = 0; i < dt.Rows.Count; i++) { formName = dt.Rows[i]["NAME"].ToString(); formDesc = dt.Rows[i]["DESCRIPTION"].ToString(); TreeListNode tnode = this.treeListForm.AppendNode(new object[] { formDesc, formName }, null); tnode.Tag = dt.Rows[i]["ACLID"]; tnode.SelectImageIndex = tnode.ImageIndex = FORMICON; } treeListForm.FocusedNode = null; }
private bool LastResourceWithTheSameResKeyId(DbResource res) { string fromText = "select * from OBI.RESOURCE_TEXT where RESOURCE_KEY_ID = (select RESOURCE_KEY_ID from OBI.RESOURCE_key " + $"where RESOURCE_key = '{res.ResourceKey}' and RESOURCE_type = '{res.ResourceType}')"; DataSet dataSet = _connection.GetResource(fromText); return(dataSet.Tables[0].Rows.Count == 0); }
private int EntryNumber(DbResource res) { string sqlCommand = $"select * from obi.vu_resources where RESOURCE_type = '{res.ResourceType}' " + $"and RESOURCE_KEY = '{res.ResourceKey}' and CULTURE_CODE = '{res.CultureCode}'"; DataSet dataSet = _connection.GetResource(sqlCommand); return(dataSet.Tables[0].Rows.Count); }
public async Task DeleteResourceAsync(long id) { var r = new DbResource { Id = id }; Db.Resources.Attach(r); Db.Resources.Remove(r); await Db.SaveChangesAsync(); }
public bool UpdateResource(DbResource res) { try { _connection.Open(); string sqlCommand = $"SELECT obi.dt_update_resource('{res.ResourceType}', '{res.CultureCode}', '{res.ResourceKey}', '{res.ResourceValue}', 1, 1) AS result FROM dual"; return(_connection.CreateResource(sqlCommand)); } catch (Exception e) { Console.WriteLine(e); throw; } finally { _connection.Close(); } }
/// <summary> /// 查询按钮 /// </summary> private void QueryButton() { layoutControlGroup2.Text = "画面[" + formName + "]按钮"; if (formName == string.Empty) { return; } DataSet inblk = new DataSet(); inblk.Tables.Add(); inblk.Tables[0].Columns.Add("fname"); inblk.Tables[0].Rows.Add(formName); DataTable dt = DbResource.QueryButtonInfo(inblk, CConstString.ConnectName); dt.AcceptChanges(); fgDevGridButtInfo.DataSource = dt; gridViewButtInfo.BestFitColumns(); }
private void QueryForm() { DataSet inblk = new DataSet(); inblk.Tables.Add(); inblk.Tables[0].Columns.Add("name"); inblk.Tables[0].Columns.Add("dllname"); inblk.Tables[0].Columns.Add("appname"); inblk.Tables[0].Rows.Add(fgtFormName.Text, fgtDllName.Text, ""); DataTable dt = DbResource.QueryFormInfo(inblk, CConstString.ConnectName); dt.AcceptChanges(); fgDevGridFormInfo.DataSource = dt; gridViewFormInfo.BestFitColumns(); if (dt != null & dt.Rows.Count > 0) { formName = dt.Rows[0]["name"].ToString(); QueryButton(); } }
public ActionResult <bool> DeleteResource([FromBody] DbResource newResource) { return(_resourceService.DeleteResource(newResource)); }
public ActionResult <bool> UpdateResource([FromBody] DbResource newResource) { var ret = _resourceService.UpdateResource(newResource); return(ret); }
public bool DeleteResource(DbResource newResource) { return(_repository.DeleteResource(newResource)); }
public bool UpdateResource(DbResource newResource) { return(_repository.UpdateResource(newResource)); }
public bool CreateResource(DbResource newResource) { return(_repository.CreateResource(newResource)); }
private bool SaveButtInfo() { DataTable dt = fgDevGridButtInfo.DataSource as DataTable; if (dt == null || dt.Rows.Count < 1) { return(false); } DataTable instable = dt.Clone(); DataTable deltable = dt.GetChanges(DataRowState.Deleted); DataTable updtable = dt.Clone(); DataRow dr = null; for (int rowIndex = 0; rowIndex < gridViewButtInfo.RowCount; ++rowIndex) { if (fgDevGridButtInfo.GetSelectedColumnChecked(rowIndex)) { dr = gridViewButtInfo.GetDataRow(rowIndex); if (dr.RowState == DataRowState.Added) { instable.Rows.Add(dr.ItemArray); } else if (dr.RowState == DataRowState.Modified) { updtable.Rows.Add(dr.ItemArray); } } } DataSet inBlock = new DataSet(); if (instable != null && instable.Rows.Count > 0) { for (int i = 0; i < instable.Rows.Count; i++) { instable.Rows[i]["fname"] = formName; instable.Rows[i]["appname"] = CConstString.AppName; } instable.TableName = "INSERT_BLOCK"; inBlock.Tables.Add(instable); } if (deltable != null && deltable.Rows.Count > 0) { deltable.RejectChanges(); deltable.TableName = "DELETE_BLOCK"; inBlock.Tables.Add(deltable); } if (updtable != null && updtable.Rows.Count > 0) { for (int i = 0; i < updtable.Rows.Count; i++) { updtable.Rows[i]["fname"] = formName; updtable.Rows[i]["appname"] = CConstString.AppName; } updtable.TableName = "UPDATE_BLOCK"; inBlock.Tables.Add(updtable); } if (inBlock.Tables.Count > 0) { string msg = DbResource.SaveButtonInfo(inBlock, CConstString.ConnectName); MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } QueryButton(); return(true); }