Example #1
0
        public IActionResult EntityManagerAttributeDelete(string id)
        {
            DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(namespaceId);


            string sql = @"SELECT entitysettings.dropattributefromentity(
                                @p_attributeid,
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_attributeid", id),
                new KeyValuePair <string, string>("p_entityid", 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(RedirectToAction("EntityManagerAttribute", new { id = namespaceId }));
        }
Example #2
0
        protected void btnDropAttribute_Click(object sender, EventArgs e)
        {
            DataTable dtBVs = SynapseHelpers.GetEntityBaseviewsDT(this.hdnEntityID.Value);


            string sql = @"SELECT entitysettings.dropattributefromentity(
                                @p_attributeid,
	                            @p_entityid
                            )";



            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_attributeid", this.hdnAttributeID.Value),
                new KeyValuePair <string, string>("p_entityid", this.hdnEntityID.Value)
            };

            try
            {
                DataServices.ExcecuteNonQueryFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.ToString();
                this.lblError.Visible = true;
                return;
            }


            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)
                {
                    this.lblError.Text    = ex.ToString();
                    this.lblError.Visible = true;
                    return;
                }
            }


            Response.Redirect("EntityManagerAttributes.aspx?action=view&id=" + this.hdnEntityID.Value);
        }
Example #3
0
        public IActionResult EntityManagerView(string id)
        {
            ViewBag.Id  = id;
            namespaceId = id;
            string sql       = "SELECT * FROM entitysettings.v_entitydetailsummary WHERE entityid = @entityid ORDER BY orderby";
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("entityid", id)
            };

            ViewBag.Summary = SynapseHelpers.GetEntityNameAndNamespaceFromID(id);
            DataSet            dsEntityDetail = DataServices.DataSetFromSQL(sql, paramList);
            DataTable          dtBVs          = SynapseHelpers.GetEntityBaseviewsDT(id);
            DetailModel        detailModel    = new DetailModel();
            List <DetailDto>   detailDto      = dsEntityDetail.Tables[0].ToList <DetailDto>();
            List <BaseViewDto> baseViewDto    = dtBVs.ToList <BaseViewDto>();

            detailModel.DetailDto   = detailDto;
            detailModel.BaseViewDto = baseViewDto;
            return(View(detailModel));
        }
Example #4
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));
        }
Example #5
0
        public IActionResult EntityManagerAttributeView(string id)
        {
            namespaceId           = SynapseHelpers.GetEntityIDFromAttributeID(id);
            ViewBag.Id            = namespaceId;
            ViewBag.AttributeId   = id;
            ViewBag.Heading       = SynapseHelpers.GetAttributeNameFromAttributeID(id);
            ViewBag.AttributeName = SynapseHelpers.GetAttributeNameFromAttributeID(id);

            ViewBag.Summary = SynapseHelpers.GetEntityNameAndNamespaceFromID(namespaceId);

            string sql       = "SELECT * FROM entitysettings.v_attributedetailsummary WHERE attributeid = @attributeid ORDER BY orderby";
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("attributeid", id)
            };

            DataSet   ds = DataServices.DataSetFromSQL(sql, paramList);
            DataTable dt = ds.Tables[0];

            ViewBag.Error = "";
            foreach (DataRow drow in dt.Rows)
            {
                string colName = drow["entitydetail"].ToString();
                string colVal  = drow["entitydescription"].ToString();

                if (colName == "Is Key Attribute")
                {
                    if (colVal == "1")
                    {
                        ViewBag.Error = "Drop Attribute button not available as it is not possible to delete a key attribute";
                    }
                }

                if (colName == "Is System Attribute")
                {
                    if (colVal == "1")
                    {
                        ViewBag.Error = "Drop Attribute button not available as it is not possible to delete a system attribute";
                    }
                }

                if (colName == "Is Relation Attribute")
                {
                    if (colVal == "1")
                    {
                        ViewBag.Error = "Drop Attribute button not available as it is not possible to delete a relation attribute from this screen";
                    }
                }
            }


            DataTable          dtBVs       = SynapseHelpers.GetEntityBaseviewsDT(namespaceId);
            Int16              bvCount     = System.Convert.ToInt16(dtBVs.Rows.Count);
            DetailModel        detailModel = new DetailModel();
            List <DetailDto>   detailDto   = dt.ToList <DetailDto>();
            List <BaseViewDto> baseViewDto = dtBVs.ToList <BaseViewDto>();

            detailModel.DetailDto   = detailDto;
            detailModel.BaseViewDto = baseViewDto;
            return(View(detailModel));
        }
Example #6
0
        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);

                BindGrid();

                this.btnDropEntity.Attributes.Add("onclick", "if(confirm('Are you sure that you want to delete this entity? This cannot be undone!!')){return true;} else {return false;};");

                this.btnShowDeleteEntity.Attributes.Add("onclick", "if(confirm('Are you sure that you want to enable the delete functionality?')){alert('Delete enabled'); return true;} else {return false;};");

                DataTable dtBVs   = SynapseHelpers.GetEntityBaseviewsDT(id);
                Int16     bvCount = System.Convert.ToInt16(dtBVs.Rows.Count);
                this.lblDependentBaseviewCount.Text = bvCount.ToString();
                this.lblHasDepencies.Text           = bvCount.ToString();

                if (bvCount > 0)
                {
                    this.pnlHasDepencies.Visible     = true;
                    this.btnShowDeleteEntity.Visible = false;
                }
                else
                {
                    this.pnlHasDepencies.Visible     = false;
                    this.btnShowDeleteEntity.Visible = true;
                }

                this.dgBaseViewDependancies.DataSource = dtBVs;
                this.dgBaseViewDependancies.DataBind();
            }
        }
Example #7
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();
        }