Esempio n. 1
0
 protected void ddlDataType_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.hdnDataType.Value = SynapseHelpers.GetDataTypeFromID(this.ddlDataType.SelectedValue);
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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();
        }