public IActionResult EntityManagerAPI(string id) { ViewBag.Id = id; namespaceId = id; ViewBag.Summary = SynapseHelpers.GetEntityNameAndNamespaceFromID(id); APIModel aPIModel = new APIModel(); aPIModel.EntityName = SynapseHelpers.GetEntityNameFromID(id); aPIModel.Namespance = SynapseHelpers.GetNamepsaceFromEntityID(id); DataTable dtKey = SynapseHelpers.GetEntityKeyAttributeFromID(id); aPIModel.KeyAttribute = dtKey.Rows[0][1].ToString(); string apiURL = SynapseHelpers.GetAPIURL(); aPIModel.GetList = apiURL + "/GetList" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName; aPIModel.GetObject = apiURL + "/GetObject" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName + "&id={" + aPIModel.KeyAttribute + "}"; aPIModel.GetListByAttribute = apiURL + "/GetListByAttribute" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName + "&synapseattributename={synapseattributename}&attributevalue={attributevalue}"; aPIModel.PostObject = apiURL + "/PostObject" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName; aPIModel.DeleteObject = apiURL + "/DeleteObject" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName + "&id={" + aPIModel.KeyAttribute + "}"; aPIModel.DeleteObjectByAttribute = apiURL + "/DeleteObjectByAttribute" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName + "&synapseattributename={synapseattributename}&attributevalue={attributevalue}"; aPIModel.GetObjectHistory = apiURL + "/GetObjectHistory" + "?synapsenamespace=" + aPIModel.Namespance + "&synapseentityname=" + aPIModel.EntityName + "&id={" + aPIModel.KeyAttribute + "}"; aPIModel.SamplePostJson = SynapseHelpers.GetEntitySampleJSON(id).Rows[0][0].ToString(); return(View(aPIModel)); }
public IActionResult EntityManagerRelationSave(RelationModel model) { if (namespaceId == model.EntityId) { return(Json("You are unable to create a relation to the same entity")); } string sqlValidation = ""; var paramListValidation = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("entityid", namespaceId), new KeyValuePair <string, string>("parententityid", model.EntityId) }; if (model.AttributeId != "0" && model.AttributeId != "") { sqlValidation = "SELECT * FROM entitysettings.entityrelation WHERE entityid = @entityid and parententityid = @parententityid;"; } else { sqlValidation = "SELECT * FROM entitysettings.entityrelation WHERE entityid = @entityid and parententityid = @parententityid and localentityattributeid = @localentityattributeid;"; paramListValidation.Add(new KeyValuePair <string, string>("localentityattributeid", model.AttributeId)); } DataSet ds = DataServices.DataSetFromSQL(sqlValidation, paramListValidation); DataTable dtValidation = ds.Tables[0]; if (dtValidation.Rows.Count > 0) { return(Json("The relation that you are trying to create already exists for this entity")); } string sql = @"SELECT entitysettings.addrelationtoentity( @p_entityid, @p_entityname, @p_synapsenamespaceid, @p_synapsenamespacename, @p_parententityid, @p_parententityname, @p_parentsynapsenamespaceid, @p_parentsynapsenamespacename, @p_attributeid, @p_attributename, CAST(@p_ordinal_position AS integer), @p_entityversionid, @p_username, @p_localentityattributeid, @p_localentityattributename )"; DataTable dt = SynapseHelpers.GetEntityDSFromID(namespaceId); DataTable dtParent = SynapseHelpers.GetEntityDSFromID(model.EntityId); DataTable dtKey = SynapseHelpers.GetEntityKeyAttributeFromID(model.EntityId); string entityName = SynapseHelpers.GetEntityNameFromID(model.EntityId); string localAttributeName = string.Empty; string attributename = dtKey.Rows[0]["attributename"].ToString(); string nextOrdinalPosition = SynapseHelpers.GetNextOrdinalPositionFromID(namespaceId); if (model.AttributeId != "0" && !string.IsNullOrWhiteSpace(model.AttributeId)) { localAttributeName = SynapseHelpers.GetAttributeNameFromAttributeID(model.AttributeId); attributename += "_" + localAttributeName; } var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("p_entityid", namespaceId), new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(namespaceId)), new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_parententityid", model.EntityId), new KeyValuePair <string, string>("p_parententityname", entityName), new KeyValuePair <string, string>("p_parentsynapsenamespaceid", dtParent.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_parentsynapsenamespacename", dtParent.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_attributeid", dtKey.Rows[0]["attributeid"].ToString()), new KeyValuePair <string, string>("p_attributename", attributename), new KeyValuePair <string, string>("p_ordinal_position", nextOrdinalPosition), new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(namespaceId)), new KeyValuePair <string, string>("p_username", HttpContext.Session.GetString(SynapseSession.FullName)), new KeyValuePair <string, string>("p_localentityattributeid", model.AttributeId), new KeyValuePair <string, string>("p_localentityattributename", localAttributeName) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); return(Json(namespaceId)); }
public IActionResult EntityManagerAttributeSave(AttributeModel model) { DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(namespaceId); string dataType = SynapseHelpers.GetDataTypeFromID(model.DataTypeId); string dataTypeDisplay = SynapseHelpers.GetDataTypeDisplayFromID(model.DataTypeId); string nextOrdinalPosition = SynapseHelpers.GetNextOrdinalPositionFromID(namespaceId); string sql = @"SELECT entitysettings.addattributetoentity( @p_entityid, @p_entityname, @p_synapsenamespaceid, @p_synapsenamespacename, @p_username, @p_attributename, @p_attributedescription, @p_datatype, @p_datatypeid, CAST(@p_ordinal_position AS integer), @p_attributedefault, @p_maximumlength, @p_commondisplayname, @p_isnullsetting, @p_entityversionid )"; DataTable dt = SynapseHelpers.GetEntityDSFromID(namespaceId); string maxLength = ""; if (dataTypeDisplay == "Short String") { maxLength = "255"; } if (dataTypeDisplay == "Long String") { maxLength = "1000"; } var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("p_entityid", namespaceId), new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(namespaceId)), new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_username", HttpContext.Session.GetString(SynapseSession.FullName)), new KeyValuePair <string, string>("p_attributename", model.AttributeName), new KeyValuePair <string, string>("p_attributedescription", "Description"), new KeyValuePair <string, string>("p_datatype", dataType), new KeyValuePair <string, string>("p_datatypeid", model.DataTypeId), new KeyValuePair <string, string>("p_ordinal_position", nextOrdinalPosition), new KeyValuePair <string, string>("p_attributedefault", ""), new KeyValuePair <string, string>("p_maximumlength", maxLength), new KeyValuePair <string, string>("p_commondisplayname", ""), new KeyValuePair <string, string>("p_isnullsetting", ""), new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(namespaceId)) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); foreach (DataRow row in dtBVs.Rows) { string baseview_id = row["baseview_id"].ToString(); string sqlRecreate = "SELECT listsettings.recreatebaseview(@baseview_id);"; var paramListRecreate = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("baseview_id", baseview_id) }; DataServices.ExcecuteNonQueryFromSQL(sqlRecreate, paramListRecreate); } return(Json(namespaceId)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = ""; try { id = Request.QueryString["id"].ToString(); } catch { Response.Redirect("Error.aspx"); } if (String.IsNullOrEmpty(id)) { Response.Redirect("Error.aspx"); } this.hdnEntityID.Value = id; try { } catch { } try { this.hdnUserName.Value = Session["userFullName"].ToString(); } catch { } this.lblSummaryType.Text = SynapseHelpers.GetEntityNameAndNamespaceFromID(id); this.hdnNextOrdinalPosition.Value = SynapseHelpers.GetNextOrdinalPositionFromID(id); this.hdnEntityName.Value = SynapseHelpers.GetEntityNameFromID(id); this.hdnNamespace.Value = SynapseHelpers.GetNamepsaceFromEntityID(id); DataTable dtKey = SynapseHelpers.GetEntityKeyAttributeFromID(id); this.hdnKeyAttribute.Value = dtKey.Rows[0][1].ToString(); this.hdnAPIURL.Value = SynapseHelpers.GetAPIURL(); this.hlGetList.Text = this.hdnAPIURL.Value + "/GetList" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value; this.hlGetList.NavigateUrl = this.hlGetList.Text; this.hlGetObject.Text = this.hdnAPIURL.Value + "/GetObject" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value + "&id={" + this.hdnKeyAttribute.Value + "}"; this.hlGetObject.NavigateUrl = this.hlGetObject.Text; this.hlGetListByID.Text = this.hdnAPIURL.Value + "/GetListByAttribute" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value + "&synapseattributename={synapseattributename}&attributevalue={attributevalue}"; this.hlGetListByID.NavigateUrl = this.hlGetListByID.Text; this.hlPostObject.Text = this.hdnAPIURL.Value + "/PostObject" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value; this.hlPostObject.NavigateUrl = this.hlPostObject.Text; this.hlDeleteObject.Text = this.hdnAPIURL.Value + "/DeleteObject" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value + "&id={" + this.hdnKeyAttribute.Value + "}"; this.hlDeleteObject.NavigateUrl = this.hlDeleteObject.Text; this.hlDeleteByAttribute.Text = this.hdnAPIURL.Value + "/DeleteObjectByAttribute" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value + "&synapseattributename={synapseattributename}&attributevalue={attributevalue}"; this.hlDeleteObject.NavigateUrl = this.hlDeleteObject.Text; this.hlGetObjectHistory.Text = this.hdnAPIURL.Value + "/GetObjectHistory" + "?synapsenamespace=" + this.hdnNamespace.Value + "&synapseentityname=" + this.hdnEntityName.Value + "&id={" + this.hdnKeyAttribute.Value + "}"; this.hlGetObjectHistory.NavigateUrl = this.hlGetObjectHistory.Text; this.lblentity1.Text = this.hdnEntityName.Value; this.lblentity2.Text = this.hdnEntityName.Value; this.lblentity3.Text = this.hdnEntityName.Value; this.lblentity4.Text = this.hdnEntityName.Value; this.lblentity5.Text = this.hdnEntityName.Value; this.lblentity6.Text = this.hdnEntityName.Value; this.lblnamespace1.Text = this.hdnNamespace.Value; this.lblnamespace2.Text = this.hdnNamespace.Value; this.lblnamespace3.Text = this.hdnNamespace.Value; this.lblnamespace4.Text = this.hdnNamespace.Value; this.lblnamespace5.Text = this.hdnNamespace.Value; this.lblnamespace6.Text = this.hdnNamespace.Value; this.lblkey1.Text = this.hdnKeyAttribute.Value; this.lblkey2.Text = this.hdnKeyAttribute.Value; this.lblkey3.Text = this.hdnKeyAttribute.Value; this.lblkey4.Text = this.hdnKeyAttribute.Value; this.lblkey5.Text = this.hdnKeyAttribute.Value; this.lblkey6.Text = this.hdnKeyAttribute.Value; this.divPostSample.InnerText = SynapseHelpers.GetEntitySampleJSON(id).Rows[0][0].ToString(); } }
private void CreateNewAttribute() { DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(this.hdnEntityID.Value); this.hdnDataType.Value = SynapseHelpers.GetDataTypeFromID(this.ddlDataType.SelectedValue); string sql = @"SELECT entitysettings.addattributetoentity( @p_entityid, @p_entityname, @p_synapsenamespaceid, @p_synapsenamespacename, @p_username, @p_attributename, @p_attributedescription, @p_datatype, @p_datatypeid, CAST(@p_ordinal_position AS integer), @p_attributedefault, @p_maximumlength, @p_commondisplayname, @p_isnullsetting, @p_entityversionid )"; DataTable dt = SynapseHelpers.GetEntityDSFromID(this.hdnEntityID.Value); string maxLength = ""; if (this.ddlDataType.SelectedItem.Text == "Short String") { maxLength = "255"; } if (this.ddlDataType.SelectedItem.Text == "Long String") { maxLength = "1000"; } var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value), new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(this.hdnEntityID.Value)), new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_username", this.hdnUserName.Value), new KeyValuePair <string, string>("p_attributename", this.txtAttributeName.Text), new KeyValuePair <string, string>("p_attributedescription", "Description"), new KeyValuePair <string, string>("p_datatype", this.hdnDataType.Value), new KeyValuePair <string, string>("p_datatypeid", this.ddlDataType.SelectedValue), new KeyValuePair <string, string>("p_ordinal_position", this.hdnNextOrdinalPosition.Value), new KeyValuePair <string, string>("p_attributedefault", ""), new KeyValuePair <string, string>("p_maximumlength", maxLength), new KeyValuePair <string, string>("p_commondisplayname", ""), new KeyValuePair <string, string>("p_isnullsetting", ""), new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(this.hdnEntityID.Value)) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); ClearAttributesForm(); this.lblSuccess.Text = "Attribute created"; this.lblSuccess.Visible = true; this.hdnNextOrdinalPosition.Value = SynapseHelpers.GetNextOrdinalPositionFromID(this.hdnEntityID.Value); foreach (DataRow row in dtBVs.Rows) { string baseview_id = row["baseview_id"].ToString(); string sqlRecreate = "SELECT listsettings.recreatebaseview(@baseview_id);"; var paramListRecreate = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("baseview_id", baseview_id) }; try { DataServices.ExcecuteNonQueryFromSQL(sqlRecreate, paramListRecreate); } catch (Exception ex) { var a = ex.ToString(); } } BindEntityGrid(); }
private void CreateRelation() { string sql = @"SELECT entitysettings.addrelationtoentity( @p_entityid, @p_entityname, @p_synapsenamespaceid, @p_synapsenamespacename, @p_parententityid, @p_parententityname, @p_parentsynapsenamespaceid, @p_parentsynapsenamespacename, @p_attributeid, @p_attributename, CAST(@p_ordinal_position AS integer), @p_entityversionid, @p_username, @p_localentityattributeid, @p_localentityattributename )"; DataTable dt = SynapseHelpers.GetEntityDSFromID(this.hdnEntityID.Value); DataTable dtParent = SynapseHelpers.GetEntityDSFromID(this.ddlEntity.SelectedValue); DataTable dtKey = SynapseHelpers.GetEntityKeyAttributeFromID(this.ddlEntity.SelectedValue); string attributename = dtKey.Rows[0]["attributename"].ToString(); if (this.ddlLocalAttribute.SelectedIndex > 0) { attributename += "_" + this.ddlLocalAttribute.SelectedItem.Text; } var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value), new KeyValuePair <string, string>("p_entityname", SynapseHelpers.GetEntityNameFromID(this.hdnEntityID.Value)), new KeyValuePair <string, string>("p_synapsenamespaceid", dt.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_synapsenamespacename", dt.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_parententityid", this.ddlEntity.SelectedValue), new KeyValuePair <string, string>("p_parententityname", this.ddlEntity.SelectedItem.Text), new KeyValuePair <string, string>("p_parentsynapsenamespaceid", dtParent.Rows[0]["synapsenamespaceid"].ToString()), new KeyValuePair <string, string>("p_parentsynapsenamespacename", dtParent.Rows[0]["synapsenamespacename"].ToString()), new KeyValuePair <string, string>("p_attributeid", dtKey.Rows[0]["attributeid"].ToString()), new KeyValuePair <string, string>("p_attributename", attributename), new KeyValuePair <string, string>("p_ordinal_position", this.hdnNextOrdinalPosition.Value), new KeyValuePair <string, string>("p_entityversionid", SynapseHelpers.GetCurrentEntityVersionFromID(this.hdnEntityID.Value)), new KeyValuePair <string, string>("p_username", this.hdnUserName.Value), new KeyValuePair <string, string>("p_localentityattributeid", this.ddlLocalAttribute.SelectedValue), new KeyValuePair <string, string>("p_localentityattributename", this.ddlLocalAttribute.SelectedItem.Text) }; DataServices.ExcecuteNonQueryFromSQL(sql, paramList); ClearAttributesForm(); this.hdnNextOrdinalPosition.Value = SynapseHelpers.GetNextOrdinalPositionFromID(this.hdnEntityID.Value); BindEntityGrid(); this.lblSuccess.Text = "Relation created"; this.lblSuccess.Visible = true; }