Ejemplo n.º 1
0
        public override void ExtendedPropertiesDeserialize(System.Xml.XmlNode extendedPropertiesXml)
        {
            base.ExtendedPropertiesDeserialize(extendedPropertiesXml);

            foreach (System.Xml.XmlNode currentPropertyNode in extendedPropertiesXml.SelectNodes("./Property"))
            {
                switch (currentPropertyNode.Attributes["Name"].InnerText)
                {
                case "FormName": FormName = currentPropertyNode.InnerText; break;

                case "FormTypeInt32": formType = (Mercury.Server.Core.Forms.Enumerations.FormType)Convert.ToInt32(currentPropertyNode.InnerText); break;

                case "EntityTypeInt32": entityType = (Mercury.Server.Core.Enumerations.EntityType)Convert.ToInt32(currentPropertyNode.InnerText); break;

                case "EntityObjectId": entityObjectId = Convert.ToInt64(currentPropertyNode.InnerText); break;

                case "Orientation": orientation = (Mercury.Server.Core.Forms.Enumerations.FormControlOrientation)Convert.ToInt32(currentPropertyNode.InnerText); break;

                case "PaperSize": paperSize = (Mercury.Server.Core.Forms.Enumerations.FormControlPaperSize)Convert.ToInt32(currentPropertyNode.InnerText); break;

                case "AllowPrecompileEvents": allowPrecompileEvents = Convert.ToBoolean(currentPropertyNode.InnerText); break;
                }
            }

            return;
        }
Ejemplo n.º 2
0
        public Form(Application applicationReference, Int64 formId)
        {
            this.application = applicationReference;

            InitializeControl();

            formType = Mercury.Server.Core.Forms.Enumerations.FormType.Template;

            if (!LoadFromDatabaseQuickLoad(formId))
            {
                throw new Exception("Unable to load Form from the database for " + formId + ".");
            }

            return;
        }
Ejemplo n.º 3
0
        public Form(Application applicationReference, String formName)
        {
            Application = applicationReference;

            InitializeControl();

            formType = Mercury.Server.Core.Forms.Enumerations.FormType.Template;

            if (!LoadFromDatabase(formName))
            {
                throw new Exception("Unable to load Form from the database for " + formName + ".");
            }

            return;
        }
Ejemplo n.º 4
0
        public Form(Application applicationReference, Int64 forId, Boolean forInstance)
        {
            this.application = applicationReference;

            InitializeControl();


            if (forInstance)
            {
                entityFormId = forId;

                formType = Mercury.Server.Core.Forms.Enumerations.FormType.Instance;


                // NEW FAST METHOD

                if (!LoadFromDatabaseQuickLoadBaseForInstance(forId))
                {
                    throw new Exception("Unable to load Form from the database for " + formId.ToString() + ".");
                }

                // BELOW IS THE OLDER, SLOW METHOD

                //if (!LoadFromDatabaseWithCriteria ("WHERE EntityFormId = '" + forId.ToString () + "'")) {

                //    throw new Exception ("Unable to load Form from the database for " + formId.ToString () + ".");

                //}
            }

            else
            {
                formType = Mercury.Server.Core.Forms.Enumerations.FormType.Template;

                if (!LoadFromDatabaseWithCriteria("WHERE FormId = " + formId.ToString()))
                {
                    throw new Exception("Unable to load Form from the database for " + formId.ToString() + ".");
                }
            }


            return;
        }
Ejemplo n.º 5
0
        override public Boolean Save()
        {
#if DEBUG
            DateTime startTime = DateTime.Now;
#endif

            Boolean success = false;

            String schemaName = String.Empty;

            String formControlCriteria = String.Empty;

            String formIdentifier = String.Empty;

            StringBuilder sqlStatement;


            modifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application.Session);


            this.Parent = this;

            if (entityObjectId != 0)
            {
                formType = Mercury.Server.Core.Forms.Enumerations.FormType.Instance;
            }

            switch (formType)
            {
            case Mercury.Server.Core.Forms.Enumerations.FormType.Template:

                formControlCriteria = "FormId = " + formId.ToString();

                formIdentifier = formId.ToString();

                break;

            case Mercury.Server.Core.Forms.Enumerations.FormType.Instance:

            default:

                formControlCriteria = "EntityFormId = " + entityFormId.ToString();

                formIdentifier = entityFormId.ToString();

                break;
            }

            try {
                if (formType == Mercury.Server.Core.Forms.Enumerations.FormType.Template)
                {
                    Int32 existingForm = (Int32)application.EnvironmentDatabase.LookupValue("Form", "COUNT (1) AS CountOf", "FormName = '" + Name + "' AND FormControlId != '" + controlId + "'");

                    if (existingForm != 0)
                    {
                        throw new ApplicationException("Form already exists with the name: " + Name + ".");
                    }
                }



                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC Form_InsertUpdate ");

                sqlStatement.Append(formId.ToString() + ", ");

                if (formType == Mercury.Server.Core.Forms.Enumerations.FormType.Template)
                {
                    sqlStatement.Append("NULL, ");
                }

                else
                {
                    sqlStatement.Append(application.EntityIdGet(entityType, entityObjectId).ToString() + ", ");
                }

                if (formType == Mercury.Server.Core.Forms.Enumerations.FormType.Template)
                {
                    sqlStatement.Append("NULL, ");
                }

                else
                {
                    sqlStatement.Append(entityFormId.ToString() + ", ");
                }

                sqlStatement.Append("'" + base.NameSql + "', '" + base.ControlId.ToString() + "', '" + base.DescriptionSql + "',");

                sqlStatement.Append(((Int32)entityType).ToString() + ", " + entityObjectId.ToString() + ", ");

                sqlStatement.Append("'" + modifiedAccountInfo.SecurityAuthorityNameSql + "', '" + modifiedAccountInfo.UserAccountIdSql + "', '" + modifiedAccountInfo.UserAccountNameSql + "'");

                success = application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString());

                if (!success)
                {
                    throw application.EnvironmentDatabase.LastException;
                }

                if (formId == 0)   // RESET DOCUMENT ID CRITERIA

                {
                    Object identity = application.EnvironmentDatabase.ExecuteScalar("SELECT @@IDENTITY").ToString();

                    if (identity != null)
                    {
                        formId = Int64.Parse(identity.ToString());
                    }
                }

                else if ((entityFormId == 0) && (formType == Mercury.Server.Core.Forms.Enumerations.FormType.Instance))
                {
                    Object identity = application.EnvironmentDatabase.ExecuteScalar("SELECT @@IDENTITY").ToString();

                    if (identity != null)
                    {
                        entityFormId = Int64.Parse(identity.ToString());
                    }

                    createAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(modifiedAccountInfo.SecurityAuthorityName, modifiedAccountInfo.UserAccountId, modifiedAccountInfo.UserAccountName, modifiedAccountInfo.ActionDate);
                }

                sqlStatement = new StringBuilder();

                sqlStatement.Append("DELETE FROM " + ((formType == Mercury.Server.Core.Forms.Enumerations.FormType.Instance) ? "Entity" : String.Empty) + "FormControl ");

                sqlStatement.Append("  WHERE " + ((formType == Mercury.Server.Core.Forms.Enumerations.FormType.Instance) ? "EntityFormId = " + entityFormId.ToString() : "FormId = " + formId.ToString()));

                success = application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString());

                if (!success)
                {
                    throw application.EnvironmentDatabase.LastException;
                }

                success = base.Save();

                if (!success)
                {
                    throw application.LastException;
                }

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);

                return(false);
            }

#if DEBUG
            // System.Diagnostics.Debug.WriteLine ("Form Save from Database Time (SLOW): " + DateTime.Now.Subtract (startTime).TotalMilliseconds.ToString ());

            System.Diagnostics.Debug.WriteLine("Form Save from Database Time (FAST): " + DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString());
#endif

            return(true);
        }