コード例 #1
0
        public override void MapDataFields(System.Data.DataRow currentRow)
        {
            base.MapDataFields(currentRow);

            String selectStatement;

            Int32 currentSequence = 0;


            selectStatement = "SELECT * FROM WorkQueueViewFieldDefinition WHERE WorkQueueViewId = " + Id.ToString();

            foreach (System.Data.DataRow currentField in application.EnvironmentDatabase.SelectDataTable(selectStatement, 0).Rows)
            {
                WorkQueueViewFieldDefinition fieldDefinition = new WorkQueueViewFieldDefinition();

                fieldDefinition.MapDataFields(currentField);

                fieldDefinitions.Add(fieldDefinition);
            }

            // LOAD FILTER DEFINITIONS

            selectStatement = "SELECT * FROM WorkQueueViewFilterDefinition WHERE WorkQueueViewId = " + Id.ToString() + " ORDER BY Sequence";

            currentSequence = 0;

            foreach (System.Data.DataRow currentFilter in application.EnvironmentDatabase.SelectDataTable(selectStatement, 0).Rows)
            {
                currentSequence = currentSequence + 1;

                WorkQueueViewFilterDefinition filterDefinition = new WorkQueueViewFilterDefinition();

                filterDefinition.MapDataFields(currentFilter);

                filterDefinition.Sequence = currentSequence;

                filterDefinitions.Add(currentSequence, filterDefinition);
            }

            // LOAD SORT DEFINITIONS

            selectStatement = "SELECT * FROM WorkQueueViewSortDefinition WHERE WorkQueueViewId = " + Id.ToString() + " ORDER BY Sequence";

            currentSequence = 0;

            foreach (System.Data.DataRow currentSort in application.EnvironmentDatabase.SelectDataTable(selectStatement, 0).Rows)
            {
                currentSequence = currentSequence + 1;

                WorkQueueViewSortDefinition sortDefinition = new WorkQueueViewSortDefinition();

                sortDefinition.MapDataFields(currentSort);

                sortDefinition.Sequence = currentSequence;

                sortDefinitions.Add(currentSequence, sortDefinition);
            }

            return;
        }
コード例 #2
0
        //public override List<Mercury.Server.Services.Responses.ConfigurationImportResponse> XmlImport (System.Xml.XmlNode objectNode) {

        //    List<Mercury.Server.Services.Responses.ConfigurationImportResponse> response = new List<Mercury.Server.Services.Responses.ConfigurationImportResponse> ();

        //    Services.Responses.ConfigurationImportResponse importResponse = new Mercury.Server.Services.Responses.ConfigurationImportResponse ();


        //    importResponse.ObjectType = objectNode.Name;

        //    importResponse.ObjectName = objectNode.Attributes["Name"].InnerText;

        //    importResponse.Success = true;


        //    if (importResponse.ObjectType == "WorkQueueView") {

        //        foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes) {

        //            switch (currentNode.Name) {

        //                case "Properties":

        //                    foreach (System.Xml.XmlNode currentProperty in currentNode.ChildNodes) {

        //                        switch (currentProperty.Attributes["Name"].InnerText) {

        //                            case "WorkQueueViewName": workQueueViewName = currentProperty.InnerText; break;

        //                            case "Description": description = currentProperty.InnerText; break;

        //                            case "Enabled": enabled = Convert.ToBoolean (currentProperty.InnerText); break;

        //                            case "Visible": visible = Convert.ToBoolean (currentProperty.InnerText); break;

        //                        }

        //                    }

        //                    break;

        //            }

        //        }

        //        importResponse.Success = Save ();

        //        importResponse.Id = Id;

        //        if (!importResponse.Success) { importResponse.SetException (base.application.LastException); }

        //    }

        //    else { importResponse.SetException (new ApplicationException ("Invalid Object Type Parsed as WorkQueueView.")); }

        //    response.Add (importResponse);

        //    return response;

        //}

        #endregion


        #region Validation Functions

        public Dictionary <String, String> ValidateFieldDefinition(WorkQueueViewFieldDefinition fieldDefinition)
        {
            Dictionary <String, String> validationResponse = new Dictionary <String, String> ();


            fieldDefinition.DisplayName = fieldDefinition.DisplayName.Trim();

            fieldDefinition.PropertyName = fieldDefinition.PropertyName.Trim();


            if (String.IsNullOrEmpty(fieldDefinition.DisplayName.Trim()))
            {
                validationResponse.Add("Display Name", "Empty or Null.");
            }

            if (String.IsNullOrEmpty(fieldDefinition.PropertyName.Trim()))
            {
                validationResponse.Add("Property Name", "Empty or Null.");
            }



            System.Text.RegularExpressions.Regex expressionSpecialCharacters;

            String excludedCharacters = String.Empty;

            excludedCharacters = excludedCharacters + @"\\|/|\.|,|'|~|`|!|@|#|\$|%|\^|&|\*|\(|\)|\-|\+|\=|\{|\}|\[|\]|:|;|\?|<|>";

            expressionSpecialCharacters = new System.Text.RegularExpressions.Regex(excludedCharacters);

            if (expressionSpecialCharacters.IsMatch(fieldDefinition.DisplayName))
            {
                validationResponse.Add("Display Name", "Special Characters not allowed.");
            }


            foreach (WorkQueueViewFieldDefinition currentFieldDefinition in fieldDefinitions)
            {
                if (currentFieldDefinition != fieldDefinition)
                {
                    if (currentFieldDefinition.DisplayName == fieldDefinition.DisplayName)
                    {
                        validationResponse.Add("Display Name", "Duplicate.");
                    }

                    if (currentFieldDefinition.PropertyName == fieldDefinition.PropertyName)
                    {
                        validationResponse.Add("Property Name", "Duplicate.");
                    }
                }
            }

            if (WellKnownFields.ContainsKey(fieldDefinition.DisplayName))
            {
                if (!validationResponse.ContainsKey("Display Name"))
                {
                    validationResponse.Add("Display Name", "Reserved Name not allowed.");
                }
            }

            return(validationResponse);
        }