Esempio n. 1
0
        protected void btnCreateNewEntity_Click(object sender, EventArgs e)
        {
            string tmpViewName = Guid.NewGuid().ToString("N");
            //Check if we can create a temporary view using the supplied SQL Statement
            string sqlCreate       = "CREATE VIEW baseviewcore." + this.lblNamespaceName.Text + "_" + this.txtEntityName.Text + " AS " + this.txtSQL.Text + ";";
            var    paramListCreate = new List <KeyValuePair <string, string> >()
            {
            };

            try
            {
                DataServices.executeSQLStatement(sqlCreate, paramListCreate);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = "Error creating view: " + ex.ToString();
                this.lblError.Visible = true;
                return;
            }

            string sql = "SELECT listsettings.createbaseview(@p_baseviewnamespaceid, @p_baseviewnamespace, @p_baseviewname, @p_baseviewdescription, @p_baseviewsqlstatement, @p_username);";

            var paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_baseviewnamespaceid", this.hdnNamespaceID.Value),
                new KeyValuePair <string, string>("p_baseviewnamespace", SynapseHelpers.GetBaseviewNamespaceNameFromID(this.hdnNamespaceID.Value)),
                new KeyValuePair <string, string>("p_baseviewname", this.txtEntityName.Text),
                new KeyValuePair <string, string>("p_baseviewdescription", this.txtEntityComments.Text),
                new KeyValuePair <string, string>("p_baseviewsqlstatement", this.txtSQL.Text),
                new KeyValuePair <string, string>("p_username", this.hdnUserName.Value)
            };


            DataSet ds = new DataSet();

            try
            {
                ds = DataServices.DataSetFromSQL(sql, paramList);
            }
            catch (Exception ex)
            {
                this.lblError.Text    = "Error creating view: " + System.Environment.NewLine + ex.ToString();
                this.lblError.Visible = true;
                return;
            }



            DataTable dt = ds.Tables[0];

            string newGuid = "";

            try
            {
                newGuid = dt.Rows[0][0].ToString();
            }
            catch { }

            Response.Redirect("BaseviewManagerView.aspx?id=" + newGuid);
        }
Esempio n. 2
0
        public IActionResult BaseViewManagerNew(string id)
        {
            namespaceId = id;
            BaseViewModel model = new BaseViewModel();

            model.BaseviewNamespaceName = SynapseHelpers.GetBaseviewNamespaceNameFromID(namespaceId);
            return(View(model));
        }
Esempio n. 3
0
        public IActionResult BaseViewManagerNewSave(BaseViewModel model, string command)
        {
            if (command == "Validate")
            {
                string tmpViewName = Guid.NewGuid().ToString("N");
                //Check if we can create a temporary view using the supplied SQL Statement
                string sqlTempCreate       = "CREATE VIEW baseviewtemp." + model.BaseviewNamespaceName + "_" + tmpViewName + " AS " + model.BaseviewSQL + ";";
                var    paramTempListCreate = new List <KeyValuePair <string, string> >()
                {
                };

                try
                {
                    DataServices.executeSQLStatement(sqlTempCreate, paramTempListCreate);
                }
                catch (Exception ex)
                {
                    return(Json("Error creating view: " + ex.ToString()));
                }
                return(Json("OK"));
            }

            string sqlCreate       = "CREATE VIEW baseviewcore." + model.BaseviewNamespaceName + "_" + model.BaseviewName + " AS " + model.BaseviewSQL + ";";
            var    paramListCreate = new List <KeyValuePair <string, string> >()
            {
            };

            DataServices.executeSQLStatement(sqlCreate, paramListCreate);
            string sql       = "SELECT listsettings.createbaseview(@p_baseviewnamespaceid, @p_baseviewnamespace, @p_baseviewname, @p_baseviewdescription, @p_baseviewsqlstatement, @p_username);";
            var    paramList = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("p_baseviewnamespaceid", namespaceId),
                new KeyValuePair <string, string>("p_baseviewnamespace", SynapseHelpers.GetBaseviewNamespaceNameFromID(namespaceId)),
                new KeyValuePair <string, string>("p_baseviewname", model.BaseviewName),
                new KeyValuePair <string, string>("p_baseviewdescription", model.BaseviewDesc == null ? "" : model.BaseviewDesc),
                new KeyValuePair <string, string>("p_baseviewsqlstatement", model.BaseviewSQL),
                new KeyValuePair <string, string>("p_username", HttpContext.Session.GetString(SynapseSession.FullName))
            };
            DataSet   ds      = DataServices.DataSetFromSQL(sql, paramList);
            DataTable dt      = ds.Tables[0];
            string    newGuid = dt.Rows[0][0].ToString();

            return(Json(newGuid));
        }
Esempio n. 4
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.hdnNamespaceID.Value = id;

                string local = "";
                try
                {
                    local = Request.QueryString["local"].ToString();
                }
                catch
                {
                }

                this.hdnLocalNamespaceID.Value = local;



                string name = "";
                try
                {
                    name = SynapseHelpers.GetBaseviewNamespaceNameFromID(id);
                }
                catch { }

                try
                {
                    this.hdnUserName.Value = Session["userFullName"].ToString();
                }
                catch { }

                if (String.IsNullOrEmpty(name))
                {
                    Response.Redirect("Error.aspx");
                }

                this.lblNamespaceName.Text = name;

                this.lblError.Text              = string.Empty;
                this.lblError.Visible           = false;
                this.lblSuccess.Visible         = false;
                this.btnCreateNewEntity.Visible = false;
                this.btnCancel.Visible          = false;
            }
        }