public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;

            try {
                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.PopulationActivityEvent_InsertUpdate ");

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

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

                sqlStatement.Append(((Int32)scheduleType).ToString() + ", ");

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

                sqlStatement.Append(((Int32)scheduleQualifier).ToString() + ", ");

                sqlStatement.Append(((Int32)anchorDate).ToString() + ", ");

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

                sqlStatement.Append(((Int32)performActionDateType).ToString() + ", ");

                sqlStatement.Append(Action.Id.ToString() + ", ");

                sqlStatement.Append("'" + action.ActionParametersXmlSqlParsedString + "', ");

                sqlStatement.Append("'" + action.Description + "', ");

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


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();
            }

            catch (Exception applicationException) {
                application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;

            ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.MemberAuthorizedService_InsertUpdate ");

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

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

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

                sqlStatement.Append("'" + eventDate.ToString("MM/dd/yyyy") + "', ");

                sqlStatement.Append("'" + initialIdentifiedDate.ToString("MM/dd/yyyy") + "', ");

                sqlStatement.Append(Convert.ToInt32(addedManually).ToString() + ", ");

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


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                SetIdentity();


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

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

                application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;


            try {
                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.ConditionCriteriaDemographic_InsertUpdate ");

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

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

                sqlStatement.Append(((Int32)gender).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(useAgeCriteria).ToString() + ", ");

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

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

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

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



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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                SetIdentity();

                success = true;
            }

            catch (Exception applicationException) {
                application.SetLastException(applicationException);
            }

            return(success);
        }
        protected void EntityCorrespondenceBaseConstructor(Application applicationReference, Int64 forEntityId, String forAttention, EntityAddress address, Reference.Correspondence correspondence)
        {
            BaseConstructor(applicationReference);


            entityId = forEntityId;

            attention = forAttention;

            if (address != null)
            {
                entityAddressId = address.Id;

                addressLine1 = address.Line1;

                addressLine2 = address.Line2;

                addressCity = address.City;

                addressState = address.State;

                addressZipCode = address.ZipCode;

                addressZipPlus4 = address.ZipPlus4;

                addressPostalCode = address.PostalCode;
            }

            if (correspondence != null)
            {
                correspondenceId = correspondence.Id;

                correspondenceName = correspondence.Name;

                correspondenceVersion = correspondence.Version;
            }

            readyToSendDate = DateTime.Today;

            sentDate = null;

            receivedDate = null;

            returnedDate = null;


            createAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp();

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

            return;
        }
示例#5
0
        /// <summary>
        /// Make a copy of an existing Work Queue Item Sender directly to and Existing Work Queue Item.
        /// This is a database copy that makes an exact duplicate except for the Work Queue Item Id.
        /// </summary>
        /// <returns>Returns true/false based on success.</returns>
        public Boolean CopyToWorkQueueItem(Int64 destinationWorkQueueItemId)
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            if (destinationWorkQueueItemId == 0)
            {
                return(false);
            }


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

            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.WorkQueueItemSender_CopyToWorkQueueItem ");

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

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

                sqlStatement.Append(ModifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                application.EnvironmentDatabase.CommitTransaction();
            }

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

                success = false;

                application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;


            try {
                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.PopulationCriteriaGeographic_InsertUpdate ");

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

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

                sqlStatement.Append("'" + state + "', ");

                sqlStatement.Append("'" + city + "', ");

                sqlStatement.Append("'" + county + "', ");

                sqlStatement.Append("'" + zipCode + "', ");

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

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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                success = true;
            }

            catch (Exception applicationException) {
                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#7
0
        public Boolean Terminate(DateTime forTerminationDate)
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();



            if (forTerminationDate < EffectiveDate)
            {
                application.SetLastException(new ApplicationException("Permission Denied. Termination Date cannot be set before Effective Date."));

                return(false);
            }


            ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dal.EntityNote_Terminate ");

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

                sqlStatement.Append("'" + forTerminationDate.ToString("MM/dd/yyyy") + "', ");

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

                success = base.application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString(), 0);

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

            catch (Exception applicationException) {
                success = false;

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
示例#8
0
        protected void ProcessLog_StopProcess(String outcome, String exceptionMessage)
        {
            if (base.application == null)
            {
                return;
            }

            String updateStatement = String.Empty;

            Boolean success;

            Mercury.Server.Data.AuthorityAccountStamp accountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                updateStatement = "UPDATE logs.MetricProcess \r\n  SET ";

                updateStatement = updateStatement + "\r\n     EndDate = '" + DateTime.Now.ToString() + "', ";

                updateStatement = updateStatement + "\r\n     Outcome = '" + outcome + "', ";

                updateStatement = updateStatement + "\r\n     Exception = '" + exceptionMessage + "'";

                updateStatement = updateStatement + "\r\n  WHERE ProcessLogId = " + processLogId.ToString();


                success = base.application.EnvironmentDatabase.ExecuteSqlStatement(updateStatement.ToString(), 0);

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

            catch (Exception logException) {
                System.Diagnostics.Trace.WriteLine(logException);

                System.Diagnostics.Trace.Flush();
            }

            return;
        }
示例#9
0
        protected void ProcessStep_StopStep(String outcome, String exceptionMessage)
        {
            String updateStatement = String.Empty;

            Boolean success;

            Mercury.Server.Data.AuthorityAccountStamp accountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                updateStatement = "UPDATE logs.MetricProcessStep \r\n  SET ";

                updateStatement = updateStatement + "\r\n     EndDate = '" + DateTime.Now.ToString() + "', ";

                updateStatement = updateStatement + "\r\n     Outcome = '" + CommonFunctions.SetValueMaxLength(outcome.Replace("'", "''"), 60) + "', ";

                updateStatement = updateStatement + "\r\n     Exception = '" + CommonFunctions.SetValueMaxLength(exceptionMessage.Replace("'", "''"), 999) + "'";

                updateStatement = updateStatement + "\r\n  WHERE ProcessStepId = " + processStepId.ToString();


                success = base.application.EnvironmentDatabase.ExecuteSqlStatement(updateStatement.ToString(), 0);

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

            catch (Exception logException) {
                System.Diagnostics.Trace.WriteLine(updateStatement);

                System.Diagnostics.Trace.WriteLine(logException);

                System.Diagnostics.Trace.Flush();

                base.application.EnvironmentDatabase.RollbackTransaction();
            }

            return;
        }
        override public Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();


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

            try {
                base.application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC EntityCorrespondence_InsertUpdate ");


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

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

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

                sqlStatement.Append("'" + correspondenceName.Replace("'", "''") + "', ");

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


                sqlStatement.Append(IdSqlAllowNull(entityFormId) + ", ");

                sqlStatement.Append(IdSqlAllowNull(relatedEntityId) + ", ");

                sqlStatement.Append("'" + relatedObjectType + "', ");

                sqlStatement.Append(IdSqlAllowNull(relatedObjectId) + ", ");


                sqlStatement.Append("'" + readyToSendDate.ToString("MM/dd/yyyy") + "', ");

                sqlStatement.Append((sentDate.HasValue) ? "'" + sentDate.Value.ToString("MM/dd/yyyy") + "', " : "NULL, ");

                sqlStatement.Append((receivedDate.HasValue) ? "'" + receivedDate.Value.ToString("MM/dd/yyyy") + "', " : "NULL, ");

                sqlStatement.Append((returnedDate.HasValue) ? "'" + returnedDate.Value.ToString("MM/dd/yyyy") + "', " : "NULL, ");


                sqlStatement.Append(((Int32)contactType).ToString() + ", ");

                sqlStatement.Append(IdSqlAllowNull(entityAddressId) + ", ");

                sqlStatement.Append(IdSqlAllowNull(entityContactInformationId) + ", ");

                sqlStatement.Append("'" + attention.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressLine1.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressLine2.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressCity.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressState.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressZipCode.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressZipPlus4.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + addressPostalCode.Replace("'", "''") + "', ");


                sqlStatement.Append("'" + contactFaxNumber.Replace("'", "''") + "', ");

                sqlStatement.Append("'" + contactEmail.Replace("'", "''") + "', ");


                if (String.IsNullOrWhiteSpace(remarks))
                {
                    remarks = String.Empty;
                }

                sqlStatement.Append("'" + remarks.Replace("'", "''") + "', ");


                sqlStatement.Append(GuidSqlAllowNull(automationId) + ", ");

                sqlStatement.Append(((Int32)automationStatus).ToString() + ", ");

                sqlStatement.Append(DateTimeSqlAllowNull(automationDate) + ", ");

                sqlStatement.Append(StringSqlAllowNull(automationException) + ", ");


                sqlStatement.Append("'" + ExtendedPropertiesSql + "', ");

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


                success = base.application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString(), 0);

                if (!success)
                {
                    base.application.SetLastException(base.application.EnvironmentDatabase.LastException);

                    throw base.application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                success = true;

                base.application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                base.application.EnvironmentDatabase.RollbackTransaction();

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
示例#11
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.ContactRegardingManage))
            {
                throw new ApplicationException("Permission Denied.");
            }

            Dictionary <String, String> validationResponse = Validate();

            if (validationResponse.Count != 0)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                }
            }

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

            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.ContactRegarding_InsertUpdate ");


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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");


                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


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

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

                    if (!Int64.TryParse((String)identity, out id))
                    {
                        throw new ApplicationException("Unable to retreive unique id.");
                    }
                }

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = true;

                application.EnvironmentDatabase.CommitTransaction();

                application.InvalidateCache(ObjectType, Id, Name);
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#12
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            Boolean usingTransaction = (application.EnvironmentDatabase.OpenTransactions == 0);


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.CareMeasureManage))
            {
                throw new ApplicationException("Permission Denied [CareMeasureClass.Save].");
            }

            Dictionary <String, String> validationResponse = Validate();

            if (validationResponse.Count != 0)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                }
            }

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

            try {
                if (usingTransaction)
                {
                    application.EnvironmentDatabase.BeginTransaction();
                }


                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("CareMeasureClass_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureClassId", Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureClassName", Name, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureClassDescription", Description, Server.Data.DataTypeConstants.Description);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureDomainId", careMeasureDomainId);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@enabled", Enabled);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@visible", Visible);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery() > 0);


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = true;

                if (usingTransaction)
                {
                    application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (usingTransaction)
                {
                    application.EnvironmentDatabase.RollbackTransaction();
                }

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#13
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String deleteStatement = String.Empty;

            String childIds = String.Empty;


            try {
                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }

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


                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("MemberCaseCarePlanAssessmentCareMeasure_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanAssessmentCareMeasureId", Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanAssessmentId", MemberCaseCarePlanAssessmentId);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureDomainId", CareMeasureDomainId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureClassId", CareMeasureClassId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureId", CareMeasureId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@targetValue", TargetValue);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@componentValue", ComponentScore);



                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery() > 0);


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                #region Save Care Measure Components

                // CREATE LIST OF CHILD IDS

                childIds = String.Empty;

                foreach (MemberCaseCarePlanAssessmentCareMeasureComponent currentAssessmentCareComponent in components)
                {
                    if (currentAssessmentCareComponent.Id != 0)
                    {
                        // if (currentAssessmentCareComponent.ComponentValue != 0) { // ONLY KEEP THOSE ASSIGNED AN ACTUAL VALUE

                        childIds += currentAssessmentCareComponent.Id.ToString() + ", ";

                        // }
                    }
                }

                childIds += "0";

                deleteStatement = "DELETE FROM MemberCaseCarePlanAssessmentCareMeasureComponent WHERE MemberCaseCarePlanAssessmentCareMeasureId = " + Id.ToString() + " AND MemberCaseCarePlanAssessmentCareMeasureComponentId NOT IN (" + childIds + ")";

                success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);  // REMOVE ORPHANED CARE MEASURES (THIS WILL NOT WORK UNLESS YOU REMOVE THE CHILD OBJECTS, TOO

                // TODO: FIX THE DELETE STATEMENT



                foreach (MemberCaseCarePlanAssessmentCareMeasureComponent currentAssessmentCareComponent in components)
                {
                    currentAssessmentCareComponent.MemberCaseCarePlanAssessmentCareMeasureId = Id;

                    currentAssessmentCareComponent.Application = application;

                    // if (currentAssessmentCareComponent.ComponentValue > 0) { // ONLY SAVE THOSE THAT HAVE AN ACTUAL VALUE ASSIGNED

                    success = currentAssessmentCareComponent.Save();

                    if (!success)
                    {
                        application.SetLastException(application.EnvironmentDatabase.LastException);

                        throw application.EnvironmentDatabase.LastException;
                    }

                    // }
                }

                #endregion

                #region Save Care Measure Goals

                // CREATE LIST OF CHILD IDS

                childIds = String.Empty;

                foreach (MemberCaseCarePlanAssessmentCareMeasureGoal currentAssessmentCareGoal in goals)
                {
                    if (currentAssessmentCareGoal.Id != 0)
                    {
                        childIds += currentAssessmentCareGoal.Id.ToString() + ", ";
                    }
                }

                childIds += "0";

                deleteStatement = "DELETE FROM MemberCaseCarePlanAssessmentCareMeasureGoal WHERE MemberCaseCarePlanAssessmentCareMeasureId = " + Id.ToString() + " AND MemberCaseCarePlanAssessmentCareMeasureGoalId NOT IN (" + childIds + ")";

                success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);  // REMOVE ORPHANED CARE MEASURES (THIS WILL NOT WORK UNLESS YOU REMOVE THE CHILD OBJECTS, TOO

                // TODO: FIX THE DELETE STATEMENT



                foreach (MemberCaseCarePlanAssessmentCareMeasureGoal currentAssessmentCareGoal in goals)
                {
                    currentAssessmentCareGoal.MemberCaseCarePlanAssessmentCareMeasureId = Id;

                    currentAssessmentCareGoal.Application = application;

                    success = currentAssessmentCareGoal.Save();

                    if (!success)
                    {
                        application.SetLastException(application.EnvironmentDatabase.LastException);

                        throw application.EnvironmentDatabase.LastException;
                    }
                }

                #endregion


                success = true;
            }

            catch (Exception applicationException) {
                success = false;

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#14
0
        public Boolean Save(Boolean validatePermissions)
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();


            try {
                if ((!application.HasEnvironmentPermission(Server.EnvironmentPermissions.WorkQueueManage)) && (validatePermissions))
                {
                    throw new ApplicationException("Permission Denied");
                }

                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }


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


                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.WorkQueue_InsertUpdate ");


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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");

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


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

                sqlStatement.Append(((Int32)scheduleQualifier).ToString() + ", ");

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

                sqlStatement.Append(((Int32)thresholdQualifier).ToString() + ", ");


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

                sqlStatement.Append(((Int32)initialConstraintQualifier).ToString() + ", ");

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

                sqlStatement.Append(((Int32)initialMilestoneQualifier).ToString() + ", ");


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

                sqlStatement.Append(Convert.ToInt32(getWorkUseGrouping).ToString() + ", ");


                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append("'" + ExtendedPropertiesSql + "', ");

                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM dbo.WorkQueueGetWorkUserView WHERE WorkQueueId = " + Id.ToString());

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


                foreach (WorkQueueGetWorkUserView currentUserView in getWorkUserViews)
                {
                    currentUserView.Application = application;

                    currentUserView.WorkQueueId = Id;

                    currentUserView.Save();
                }


                success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM WorkQueueTeam WHERE WorkQueueId = " + Id.ToString());

                if (success)
                {
                    foreach (WorkQueueTeam currentTeam in workTeams)
                    {
                        currentTeam.WorkQueueId = Id;

                        success = currentTeam.Save(application);

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

                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#15
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.PopulationTypeManage))
            {
                throw new ApplicationException("Permission Denied.");
            }


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

            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.PopulationType_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");


                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


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


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#16
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            Boolean usingTransaction = (application.EnvironmentDatabase.OpenTransactions == 0);


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.ProblemStatementManage))
            {
                throw new ApplicationException("Permission Denied [ProblemSubcategory.Save].");
            }

            Dictionary <String, String> validationResponse = Validate();

            if (validationResponse.Count != 0)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                }
            }

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

            try {
                if (usingTransaction)
                {
                    application.EnvironmentDatabase.BeginTransaction();
                }

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.ProblemSubcategory_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");


                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = true;

                if (usingTransaction)
                {
                    application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (usingTransaction)
                {
                    application.EnvironmentDatabase.RollbackTransaction();
                }

                application.SetLastException(applicationException);
            }

            return(success);
        }
        } // MapDataFields (System.Data.DataRow currentRow)

        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            Boolean usingTransaction = true;


            try {
                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }

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


                if (application.EnvironmentDatabase.OpenTransactions == 0)
                {
                    usingTransaction = true;

                    base.application.EnvironmentDatabase.BeginTransaction();
                }

                // DETERMINE IF THERE ARE ANY OVERLAPPING SEGMENTS

                List <EntityContactInformation> overlappingContactInformationes = application.EntityContactInformationsGetByEntityTypeOverlap(entityId, contactType, contactSequence, effectiveDate, terminationDate, Id);

                if (overlappingContactInformationes.Count > 1)
                {
                    application.TraceWriteLineError(application.TraceSwitchGeneral, "[EntityContactInformation.Save] " + "Entity Id: " + entityId.ToString() + ", Contact Information Type: " + contactType.ToString() + ", Effective Date: " + effectiveDate.ToString("MM/dd/yyyy") + ", Termination Date: " + terminationDate.ToString("MM/dd/yyyy"));

                    throw new ApplicationException("Unable to save due to multiple overlapping contact information.");
                }

                if (overlappingContactInformationes.Count == 1)
                {
                    // TERMINATE OVERLAPPAING SEGMENTS IF POSSIBLE, TERMINATION DATE IS EFFECTIVE DATE -1

                    success = overlappingContactInformationes[0].Terminate(effectiveDate.AddDays(-1));

                    if (!success)
                    {
                        application.TraceWriteLineError(application.TraceSwitchGeneral, "[EntityContactInformation.Save] " + "Entity Id: " + entityId.ToString() + ", Contact Information Type: " + contactType.ToString() + ", Effective Date: " + effectiveDate.ToString("MM/dd/yyyy") + ", Termination Date: " + terminationDate.ToString("MM/dd/yyyy"));

                        throw new ApplicationException("Permission Denied. Unable to terminate previous overlapping contact information.");
                    }
                }


                // ATTEMPT TO SAVE NEW OR UPDATE EXISTING ENTITY ADDRESS

                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                System.Data.SqlClient.SqlCommand sqlCommand = application.EnvironmentDatabase.CreateSqlCommand("dal.EntityContactInformation_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@entityContactInformationId", System.Data.SqlDbType.BigInt));

                sqlCommand.Parameters["@entityContactInformationId"].Value = Id;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@entityId", System.Data.SqlDbType.BigInt));

                sqlCommand.Parameters["@entityId"].Value = entityId;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contactType", System.Data.SqlDbType.Int));

                sqlCommand.Parameters["@contactType"].Value = contactType;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contactSequence", System.Data.SqlDbType.Int));

                sqlCommand.Parameters["@contactSequence"].Value = contactSequence;


                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contactNumber", System.Data.SqlDbType.VarChar, Server.Data.DataTypeConstants.ContactNumber));

                sqlCommand.Parameters["@contactNumber"].Value = number;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contactExtension", System.Data.SqlDbType.VarChar, Server.Data.DataTypeConstants.ContactExtension));

                sqlCommand.Parameters["@contactExtension"].Value = numberExtension;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contactEmail", System.Data.SqlDbType.VarChar, Server.Data.DataTypeConstants.ContactEmail));

                sqlCommand.Parameters["@contactEmail"].Value = email;


                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@effectiveDate", System.Data.SqlDbType.DateTime));

                sqlCommand.Parameters["@effectiveDate"].Value = effectiveDate;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@terminationDate", System.Data.SqlDbType.DateTime));

                sqlCommand.Parameters["@terminationDate"].Value = terminationDate;


                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAuthorityName", System.Data.SqlDbType.VarChar, 60));

                sqlCommand.Parameters["@modifiedAuthorityName"].Value = modifiedAccountInfo.SecurityAuthorityName;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountId", System.Data.SqlDbType.VarChar, 60));

                sqlCommand.Parameters["@modifiedAccountId"].Value = modifiedAccountInfo.UserAccountId;

                sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountName", System.Data.SqlDbType.VarChar, 60));

                sqlCommand.Parameters["@modifiedAccountName"].Value = modifiedAccountInfo.UserAccountName;


                if (sqlCommand.ExecuteNonQuery() != 1)
                {
                    if (application.EnvironmentDatabase.LastException == null)
                    {
                        throw new ApplicationException("Permission Denied. Unable to Save Contact Information.");
                    }

                    base.application.SetLastException(base.application.EnvironmentDatabase.LastException);

                    throw base.application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                success = true;

                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.RollbackTransaction();
                }

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;


            try {
                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.PopulationServiceEvent_InsertUpdate ");

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

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

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

                sqlStatement.Append(IdSqlAllowNull(exclusionServiceId) + ", ");

                sqlStatement.Append(((Int32)anchorDate).ToString() + ", ");

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

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

                sqlStatement.Append(((Int32)scheduleDateQualifier).ToString() + ", ");

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

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

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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();


                String thresholdIds = String.Empty;

                foreach (PopulationServiceEventThreshold currentThreshold in SortedThresholds.Values)
                {
                    currentThreshold.Application = base.application; // RESET APPLICATION REFERENCE FOR DATA TRANSFER OBJECT

                    currentThreshold.PopulationServiceEventId = Id;

                    currentThreshold.PopulationId = populationId;

                    success = currentThreshold.Save();

                    thresholdIds = thresholdIds + currentThreshold.Id.ToString() + ",";

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

                if (success)
                {
                    sqlStatement = new StringBuilder("DELETE FROM PopulationServiceEventThreshold WHERE PopulationServiceEventId = " + Id.ToString());

                    if (thresholdIds.Length != 0)
                    {
                        thresholdIds = thresholdIds.Substring(0, thresholdIds.Length - 1);

                        sqlStatement.Append(" AND PopulationServiceEventThresholdId NOT IN (" + thresholdIds + ")");
                    }

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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                success = true;
            }

            catch (Exception applicationException) {
                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#19
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);
        }
        } // MapDataFields (System.Data.DataRow currentRow)

        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            Boolean usingTransaction = true;


            if (Id != 0)
            {
                return(true);
            }                             // CANNOT MODIFIY EXISTING NOTE CONTENTS


            ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                if (application.EnvironmentDatabase.OpenTransactions == 0)
                {
                    usingTransaction = true;

                    base.application.EnvironmentDatabase.BeginTransaction();
                }

                System.Data.SqlClient.SqlCommand insertCommand = application.EnvironmentDatabase.CreateSqlCommand("dal.EntityNoteContent_Insert");

                insertCommand.CommandType = System.Data.CommandType.StoredProcedure;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@entityNoteId", System.Data.SqlDbType.BigInt));

                insertCommand.Parameters["@entityNoteId"].Value = entityNoteId;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@content", System.Data.SqlDbType.Text));

                insertCommand.Parameters["@content"].Value = content;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAuthorityName", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAuthorityName"].Value = modifiedAccountInfo.SecurityAuthorityName;

                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountId", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAccountId"].Value = modifiedAccountInfo.UserAccountId;

                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountName", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAccountName"].Value = modifiedAccountInfo.UserAccountName;


                if (insertCommand.ExecuteNonQuery() != 1)
                {
                    base.application.SetLastException(base.application.EnvironmentDatabase.LastException);

                    throw base.application.EnvironmentDatabase.LastException;
                }


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

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

                    if (!Int64.TryParse((String)identity, out id))
                    {
                        throw new ApplicationException("Unable to retreive unique id.");
                    }
                }

                success = true;


                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.RollbackTransaction();
                }

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();



            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.CorrespondenceManage))
            {
                throw new ApplicationException("PermissionDenied");
            }



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


            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC Correspondence_InsertUpdate ");


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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");

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

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

                sqlStatement.Append(Convert.ToInt32(storeImage).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append("'" + ExtendedPropertiesSql + "', ");

                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();


                if (success)
                {
                    success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM dbo.CorrespondenceContent WHERE CorrespondenceId = " + Id.ToString());

                    if (success)
                    {
                        if (content == null)
                        {
                            content = new Dictionary <Int32, CorrespondenceContent> ();
                        }

                        Int32 contentIndex = 0;

                        foreach (CorrespondenceContent currentContent in content.Values)
                        {
                            contentIndex = contentIndex + 1;

                            currentContent.Application = application;

                            currentContent.CorrespondenceId = Id;

                            currentContent.ContentSequence = contentIndex;

                            success = currentContent.Save();

                            if (!success)
                            {
                                throw new ApplicationException("Unable to save Correspondence Content.");
                            }
                        }
                    }
                }


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#22
0
        } // MapDataFields (System.Data.DataRow currentRow)

        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();


            ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);

            try {
                base.application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dal.EntityNote_InsertUpdate ");


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

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


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

                sqlStatement.Append(((Int32)relatedEntityType).ToString() + ", ");

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

                sqlStatement.Append("'" + relatedObjectType.Replace("'", "''") + "', ");

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


                sqlStatement.Append(((Int32)importance).ToString() + ", ");

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

                sqlStatement.Append("'" + subject.Replace("'", "''") + "', ");


                sqlStatement.Append("'" + effectiveDate.ToString("MM/dd/yyyy") + "', ");

                sqlStatement.Append("'" + terminationDate.ToString("MM/dd/yyyy") + "', ");


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


                success = base.application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString(), 0);

                if (!success)
                {
                    base.application.SetLastException(base.application.EnvironmentDatabase.LastException);

                    throw base.application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (contents == null)
                {
                    contents = new List <EntityNoteContent> ();
                }

                foreach (EntityNoteContent currentContent in contents)
                {
                    currentContent.Application = application;

                    currentContent.EntityNoteId = Id;

                    success = currentContent.Save();

                    if (!success)
                    {
                        throw new ApplicationException("Unable to Save Entity Note Content.");
                    }
                }

                success = true;

                base.application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                base.application.EnvironmentDatabase.RollbackTransaction();

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
示例#23
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;

            Int32 currentSequence = 0;


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.WorkQueueViewManage))
            {
                throw new ApplicationException("Permission Denied.");
            }

            Dictionary <String, String> validationResponse = Validate();

            if (validationResponse.Count != 0)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                }
            }

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

            try {
                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.WorkQueueView_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");


                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM WorkQueueViewFieldDefinition WHERE WorkQueueViewId = " + Id.ToString(), 0);

                if (!success)
                {
                    throw new ApplicationException("Unable to delete associated Work Queue View Field Definitions.");
                }

                foreach (WorkQueueViewFieldDefinition currentFieldDefinition in fieldDefinitions)
                {
                    sqlStatement = new StringBuilder();

                    sqlStatement.Append("INSERT INTO WorkQueueViewFieldDefinition (WorkQueueViewId, PropertyName, DisplayName, DefaultValue, DataType) VALUES (");

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

                    sqlStatement.Append("'" + currentFieldDefinition.PropertyName.Replace("'", "''") + "', ");

                    sqlStatement.Append("'" + currentFieldDefinition.DisplayName.Replace("'", "''") + "', ");

                    sqlStatement.Append("'" + currentFieldDefinition.DefaultValue.Replace("'", "''") + "', ");

                    sqlStatement.Append(Convert.ToInt32(currentFieldDefinition.DataType).ToString());

                    sqlStatement.Append(")");

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

                    if (!success)
                    {
                        throw new ApplicationException("Unable to insert associated Work Queue View Field Definition.");
                    }
                }



                #region Save Filters

                success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM WorkQueueViewFilterDefinition WHERE WorkQueueViewId = " + Id.ToString(), 0);

                if (!success)
                {
                    throw new ApplicationException("Unable to delete associated Work Queue View Filter Definitions.");
                }

                currentSequence = 0;

                foreach (WorkQueueViewFilterDefinition currentFilterDefinition in filterDefinitions.Values)
                {
                    currentSequence = currentSequence + 1;

                    currentFilterDefinition.Sequence = currentSequence;


                    sqlStatement = new StringBuilder();

                    sqlStatement.Append("INSERT INTO WorkQueueViewFilterDefinition (WorkQueueViewId, Sequence, FieldName, FilterOperator, FilterValue) VALUES (");

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

                    sqlStatement.Append(currentFilterDefinition.Sequence.ToString() + ", ");

                    sqlStatement.Append("'" + currentFilterDefinition.PropertyPath.Replace("'", "''") + "', ");

                    sqlStatement.Append(Convert.ToInt32(currentFilterDefinition.Operator).ToString() + ", ");

                    sqlStatement.Append("'" + currentFilterDefinition.Parameter.Value.ToString().Replace("'", "''") + "'");

                    sqlStatement.Append(")");

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

                    if (!success)
                    {
                        throw new ApplicationException("Unable to insert associated Work Queue View Filter Definition.");
                    }
                }

                #endregion


                #region Save Sorts

                success = application.EnvironmentDatabase.ExecuteSqlStatement("DELETE FROM WorkQueueViewSortDefinition WHERE WorkQueueViewId = " + Id.ToString(), 0);

                if (!success)
                {
                    throw new ApplicationException("Unable to delete associated Work Queue View Sort Definitions.");
                }

                currentSequence = 0;

                foreach (WorkQueueViewSortDefinition currentSortDefinition in sortDefinitions.Values)
                {
                    currentSequence = currentSequence + 1;

                    currentSortDefinition.Sequence = currentSequence;


                    sqlStatement = new StringBuilder();

                    sqlStatement.Append("INSERT INTO WorkQueueViewSortDefinition (WorkQueueViewId, Sequence, FieldName, SortDirection) VALUES (");

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

                    sqlStatement.Append(currentSortDefinition.Sequence.ToString() + ", ");

                    sqlStatement.Append("'" + currentSortDefinition.FieldName.Replace("'", "''") + "', ");

                    sqlStatement.Append(Convert.ToInt32(currentSortDefinition.SortDirection).ToString());

                    sqlStatement.Append(")");

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

                    if (!success)
                    {
                        throw new ApplicationException("Unable to insert associated Work Queue View Sort Definition.");
                    }
                }

                #endregion


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#24
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;


            try {
                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }

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

                application.EnvironmentDatabase.BeginTransaction();


                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("MemberCaseCarePlanAssessment_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanAssessmentId", Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanId", MemberCaseCarePlanId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@assessmentDate", AssessmentDate);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery() > 0);


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                #region Save Care Measures

                // CREATE LIST OF CHILD IDS

                foreach (MemberCaseCarePlanAssessmentCareMeasure currentAssessmentCareMeasure in measures)
                {
                    if (currentAssessmentCareMeasure.Id != 0)
                    {
                        childIds += currentAssessmentCareMeasure.Id.ToString() + ", ";
                    }
                }

                childIds += "0";

                String deleteStatement = "DELETE FROM MemberCaseCarePlanAssessmentCareMeasure WHERE MemberCaseCarePlanAssessmentId = " + Id.ToString() + " AND MemberCaseCarePlanAssessmentCareMeasureId NOT IN (" + childIds + ")";

                success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);  // REMOVE ORPHANED CARE MEASURES (THIS WILL NOT WORK UNLESS YOU REMOVE THE CHILD OBJECTS, TOO

                // TODO: FIX THE DELETE STATEMENT



                foreach (MemberCaseCarePlanAssessmentCareMeasure currentAssessmentCareMeasure in measures)
                {
                    currentAssessmentCareMeasure.MemberCaseCarePlanAssessmentId = Id;

                    currentAssessmentCareMeasure.Application = application;

                    success = currentAssessmentCareMeasure.Save();

                    if (!success)
                    {
                        application.SetLastException(application.EnvironmentDatabase.LastException);

                        throw application.EnvironmentDatabase.LastException;
                    }
                }

                #endregion



                // UPDATE VALUES IN MEMBER CASE CARE PLAN GOALS (SUMMARY INFORMATION)

                sqlCommand = application.EnvironmentDatabase.CreateCommand("MemberCaseCarePlanAssessment_UpdateValues");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@memberCaseCarePlanId", MemberCaseCarePlanId);

                success = (sqlCommand.ExecuteNonQuery() > 0);


                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save () {

            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder ();

            String childIds = String.Empty;


            try {

                Dictionary<String, String> validationResponse = Validate ();

                if (validationResponse.Count != 0) {

                    foreach (String validationKey in validationResponse.Keys) {

                        throw new ApplicationException ("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);

                    }

                }

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


                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand ("MemberCaseCarePlanAssessmentCareMeasureComponent_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@memberCaseCarePlanAssessmentCareMeasureComponentId", Id);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@memberCaseCarePlanAssessmentCareMeasureId", MemberCaseCarePlanAssessmentCareMeasureId);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@careMeasureComponentId", CareMeasureComponentId);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@careMeasureComponentName", Name, Server.Data.DataTypeConstants.Description99);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@careMeasureScaleId", CareMeasureScaleId);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@tag", Tag, Server.Data.DataTypeConstants.UniqueId);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@componentValue", ComponentValue);



                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter (sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery () > 0);


                if (!success) {

                    application.SetLastException (application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;

                }

                SetIdentity ();

                if (!success) {

                    application.SetLastException (application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;

                }

                success = true;

            }

            catch (Exception applicationException) {

                success = false;

                application.SetLastException (applicationException);

            }

            return success;

        }
示例#26
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;


            try {
                if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.CareLevelManage))
                {
                    throw new ApplicationException("Permission Denied.");
                }

                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }

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

                application.EnvironmentDatabase.BeginTransaction();

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.CareLevel_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");


                sqlStatement.Append("'" + ExtendedPropertiesSql + "', ");

                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                foreach (CareLevelActivity currentCareLevelActivity in activities)
                {
                    if (currentCareLevelActivity.Id != 0)
                    {
                        childIds += currentCareLevelActivity.Id.ToString() + ", ";
                    }
                }

                if (!String.IsNullOrWhiteSpace(childIds))    // DELETE ALL REMOVED CHILD IDS FROM DATABASE

                {
                    childIds += "0";

                    String deleteStatement = "DELETE FROM CareLevelActivity WHERE CareLevelId = " + Id.ToString() + " AND CareLevelActivityId NOT IN (" + childIds + ")";

                    success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);
                }

                foreach (CareLevelActivity currentCareLevelActivity in activities)
                {
                    currentCareLevelActivity.CareLevelId = Id;

                    currentCareLevelActivity.Application = application;

                    success = currentCareLevelActivity.Save();

                    if (!success)
                    {
                        application.SetLastException(application.EnvironmentDatabase.LastException);

                        throw application.EnvironmentDatabase.LastException;
                    }
                }


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }
        public Boolean Terminate(DateTime forTerminationDate)
        {
            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            Boolean usingTransaction = true;


            try {
                if (Id == 0)
                {
                    throw new ApplicationException("Permission Denied. Contact Information ID not available.");
                }


                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                if (application.EnvironmentDatabase.OpenTransactions == 0)
                {
                    usingTransaction = true;

                    base.application.EnvironmentDatabase.BeginTransaction();
                }

                System.Data.SqlClient.SqlCommand insertCommand = application.EnvironmentDatabase.CreateSqlCommand("dal.EntityContactInformation_Terminate");

                insertCommand.CommandType = System.Data.CommandType.StoredProcedure;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@entityContactInformationId", System.Data.SqlDbType.BigInt));

                insertCommand.Parameters["@entityContactInformationId"].Value = Id;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@terminationDate", System.Data.SqlDbType.DateTime));

                insertCommand.Parameters["@terminationDate"].Value = forTerminationDate;


                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAuthorityName", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAuthorityName"].Value = modifiedAccountInfo.SecurityAuthorityName;

                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountId", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAccountId"].Value = modifiedAccountInfo.UserAccountId;

                insertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@modifiedAccountName", System.Data.SqlDbType.VarChar, 60));

                insertCommand.Parameters["@modifiedAccountName"].Value = modifiedAccountInfo.UserAccountName;


                if (insertCommand.ExecuteNonQuery() != 1)
                {
                    if (application.EnvironmentDatabase.LastException == null)
                    {
                        throw new ApplicationException("Permission Denied. Unable to Terminate Contact Information.");
                    }

                    base.application.SetLastException(base.application.EnvironmentDatabase.LastException);

                    throw base.application.EnvironmentDatabase.LastException;
                }

                success = true;

                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (usingTransaction)
                {
                    base.application.EnvironmentDatabase.RollbackTransaction();
                }

                base.application.SetLastException(applicationException);
            }

            return(success);
        }
        override public Boolean Save()
        {
            Boolean success = false;

            try {
                ModifiedAccountInfo = new Mercury.Server.Data.AuthorityAccountStamp(application);


                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("PopulationTriggerEvent_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@triggerEventId", Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@populationId", populationId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@eventType", ((Int32)eventType));

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@serviceId", base.IdSqlAllowNullInt64(serviceId));

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@metricType", ((Int32)metricType));

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@metricId", base.IdSqlAllowNullInt64(metricId));

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@metricMinimum", metricMinimum);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@metricMaximum", metricMaximum);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@authorizedServiceId", base.IdSqlAllowNullInt64(authorizedServiceId));

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemStatementId", base.IdSqlAllowNullInt64(problemStatementId));


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@actionId", Action.Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@actionParameters", Action.ActionParametersXml);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@actionDescription", Action.Description, Server.Data.DataTypeConstants.Description99);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery() > 0);


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                success = true;
            }

            catch (Exception applicationException) {
                base.application.SetLastException(applicationException);
            }

            return(success);
        }
        public override Boolean Save()
        {
            Boolean useTransaction = (application.EnvironmentDatabase.OpenTransactions == 0); // NO NESTED TRANSACTIONS

            Boolean success = false;

            StringBuilder sqlStatement = new StringBuilder();

            String childIds = String.Empty;


            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.CareLevelManage))
            {
                throw new ApplicationException("Permission Denied.");
            }

            Dictionary <String, String> validationResponse = Validate();

            if (validationResponse.Count != 0)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                }
            }

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

            try {
                if (useTransaction)
                {
                    application.EnvironmentDatabase.BeginTransaction();
                }

                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.CareLevelActivity_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");

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


                sqlStatement.Append(((Int32)ActivityType).ToString() + ", ");

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

                sqlStatement.Append(((Int32)InitialAnchorDate).ToString() + ", ");

                sqlStatement.Append(((Int32)AnchorDate).ToString() + ", ");


                sqlStatement.Append(((Int32)ScheduleType).ToString() + ", ");

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

                sqlStatement.Append(((Int32)ScheduleQualifier).ToString() + ", ");

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

                sqlStatement.Append(((Int32)ConstraintQualifier).ToString() + ", ");


                sqlStatement.Append(((Int32)PerformActionDate).ToString() + ", ");

                if (Action == null)
                {
                    sqlStatement.Append("NULL, NULL, NULL, ");
                }

                else
                {
                    sqlStatement.Append(Action.Id.ToString() + ", ");

                    sqlStatement.Append("'" + Action.ActionParametersXmlSqlParsedString + "', ");

                    sqlStatement.Append("'" + Action.Description + "', ");
                }


                sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                String deleteStatement = "DELETE FROM CareLevelActivityThreshold WHERE CareLevelActivityId = " + Id.ToString();

                success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);


                foreach (Activity.ActivityThreshold currentThreshold in Thresholds)
                {
                    currentThreshold.ActivityId = Id;

                    currentThreshold.Application = application;


                    sqlStatement = new StringBuilder();

                    sqlStatement.Append("EXEC dbo.CareLevelActivityThreshold_InsertUpdate ");

                    sqlStatement.Append(currentThreshold.Id.ToString() + ", ");

                    sqlStatement.Append("'" + currentThreshold.Name.Replace("'", "''") + "', ");

                    sqlStatement.Append("'" + currentThreshold.Description.Replace("'", "''") + "', ");

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


                    sqlStatement.Append(currentThreshold.RelativeDateValue.ToString() + ", ");

                    sqlStatement.Append(((Int32)currentThreshold.RelativeDateQualifier).ToString() + ", ");

                    sqlStatement.Append(((Int32)currentThreshold.Status).ToString() + ", ");


                    if (Action == null)
                    {
                        sqlStatement.Append("NULL, NULL, NULL, ");
                    }

                    else
                    {
                        sqlStatement.Append(Action.Id.ToString() + ", ");

                        sqlStatement.Append("'" + Action.ActionParametersXmlSqlParsedString + "', ");

                        sqlStatement.Append("'" + Action.Description + "', ");
                    }


                    sqlStatement.Append(modifiedAccountInfo.AccountInfoSql);


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

                    if (!success)
                    {
                        application.SetLastException(application.EnvironmentDatabase.LastException);

                        throw application.EnvironmentDatabase.LastException;
                    }

                    currentThreshold.SetIdentity();
                }


                success = true;

                if (useTransaction)
                {
                    application.EnvironmentDatabase.CommitTransaction();
                }
            }

            catch (Exception applicationException) {
                success = false;

                if (useTransaction)
                {
                    application.EnvironmentDatabase.RollbackTransaction();
                }

                application.SetLastException(applicationException);
            }

            return(success);
        }
示例#30
0
        public override Boolean Save()
        {
            Boolean success = false;

            StringBuilder sqlStatement;

            String criteriaIds;

            if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.ConditionManage))
            {
                throw new ApplicationException("Permission Denied");
            }


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


            try {
                application.EnvironmentDatabase.BeginTransaction();



                conditionClassId = application.ConditionClassGetIdByName(conditionClassName);

                if (conditionClassId == 0)
                {
                    ConditionClass conditionClass = new ConditionClass(application);

                    conditionClass.Name = conditionClassName;

                    conditionClass.Description = conditionClassName;

                    conditionClass.Enabled = true;

                    conditionClass.Visible = true;

                    conditionClass.Save();

                    conditionClassId = conditionClass.Id;
                }


                sqlStatement = new StringBuilder();

                sqlStatement.Append("EXEC dbo.Condition_InsertUpdate ");

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

                sqlStatement.Append("'" + NameSql + "', ");

                sqlStatement.Append("'" + DescriptionSql + "', ");

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

                sqlStatement.Append(Convert.ToInt32(Enabled).ToString() + ", ");

                sqlStatement.Append(Convert.ToInt32(Visible).ToString() + ", ");


                //sqlStatement.Append (IdSqlAllowNull (OnBeforeMembershipAddWorkflowId) + ", ");

                //sqlStatement.Append (events["OnMembershipAdd"].Id.ToString () + ", ");

                //sqlStatement.Append ("'" + events["OnMembershipAdd"].ActionParametersXmlSqlParsedString + "', ");

                //sqlStatement.Append ("'" + events["OnMembershipAdd"].Description + "', ");


                //sqlStatement.Append (IdSqlAllowNull (OnBeforeMembershipTerminateWorkflowId) + ", ");

                //sqlStatement.Append (events["OnMembershipTerminate"].Id.ToString () + ", ");

                //sqlStatement.Append ("'" + events["OnMembershipTerminate"].ActionParametersXmlSqlParsedString + "', ");

                //sqlStatement.Append ("'" + events["OnMembershipTerminate"].Description + "', ");


                sqlStatement.Append("'" + ExtendedPropertiesSql + "', ");

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


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

                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                SetIdentity();


                #region Demographic Criteria

                if (success)
                {
                    criteriaIds = String.Empty;

                    foreach (ConditionCriteria.ConditionCriteriaDemographic currentCriteria in demographicCriteria)
                    {
                        currentCriteria.ConditionId = id;

                        success = success && currentCriteria.Save(application);

                        criteriaIds = criteriaIds + currentCriteria.Id.ToString() + ",";

                        if (!success)
                        {
                            break;
                        }
                    }

                    if (success)
                    {
                        sqlStatement = new StringBuilder("DELETE FROM ConditionCriteriaDemographic WHERE ConditionId = " + id.ToString());

                        if (criteriaIds.Length != 0)
                        {
                            criteriaIds = criteriaIds.Substring(0, criteriaIds.Length - 1);

                            sqlStatement.Append(" AND ConditionCriteriaDemographicId NOT IN (" + criteriaIds + ")");
                        }

                        success = application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString(), 0);
                    }
                }

                #endregion


                #region Event Criteria

                if (success)
                {
                    criteriaIds = String.Empty;

                    foreach (ConditionCriteria.ConditionCriteriaEvent currentCriteria in eventCriteria)
                    {
                        currentCriteria.ConditionId = id;

                        success = success && currentCriteria.Save(application);

                        criteriaIds = criteriaIds + currentCriteria.Id.ToString() + ",";

                        if (!success)
                        {
                            break;
                        }
                    }

                    if (success)
                    {
                        sqlStatement = new StringBuilder("DELETE FROM ConditionCriteriaEvent WHERE ConditionId = " + id.ToString());

                        if (criteriaIds.Length != 0)
                        {
                            criteriaIds = criteriaIds.Substring(0, criteriaIds.Length - 1);

                            sqlStatement.Append(" AND ConditionCriteriaEventId NOT IN (" + criteriaIds + ")");
                        }

                        success = application.EnvironmentDatabase.ExecuteSqlStatement(sqlStatement.ToString(), 0);
                    }
                }

                #endregion


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }


                success = true;

                application.EnvironmentDatabase.CommitTransaction();
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }