示例#1
0
        // ==================================================================================
        /// <summary>
        /// This method determines if the page layout has user type.
        /// </summary>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile object</param>
        /// <returns>bool: true if found.</return>
        // ----------------------------------------------------------------------------------
        public bool hasUserType(EdUserProfile UserProfile)
        {
            if (UserTypes == null)
            {
                return(false);
            }
            //
            // Initialise the methods variables and objects.
            //
            string [] arrUserType     = UserProfile.UserType.Split(';');
            string [] arrPageUserType = UserTypes.Split(';');

            foreach (String str1 in arrUserType)
            {
                foreach (String str2 in arrPageUserType)
                {
                    if (str1.ToLower() == str2.ToLower())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        // =====================================================================================
        /// <summary>
        /// This class returns a list of formfield object based on form's Guid
        /// </summary>
        /// <param name="ExportParameters">EvExportParameters object, defining the items to exported.</param>
        /// <param name="UserProfile">EvUserProfile object.</param>
        /// <returns>List of string where each item is row in a CSv output</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving the Formfield list based on form's Guid
        ///
        /// 2. Return the formfield list.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public String exportRecords(
            EvExportParameters ExportParameters,
            Evado.Digital.Model.EdUserProfile UserProfile)
        {
            this.LogMethod("exportRecords method. ");
            this.LogDebug(ExportParameters.getRecordExportParameters( ));
            this.LogDebug("ExportDataSource: " + ExportParameters.ExportDataSource);
            //
            // Initialise the methods objects and variables.
            //
            List <EdRecord> recordList = new List <EdRecord> ( );

            //
            // if the ResultData sourc is not project or common record exit.
            //
            switch (ExportParameters.ExportDataSource)
            {
            case EvExportParameters.ExportDataSources.Project_Record:
            {
                return(this.exportProjectRecords(
                           ExportParameters,
                           UserProfile));
            }

            default:
            {
                return(null);
            }
            }
        }//End getRecordList method.
        // =====================================================================================
        /// <summary>
        /// This class retrieves the Userprofile object based on UserId
        /// </summary>
        /// <param name="UserId">string: a user identifier</param>
        /// <returns>Evado.Digital.Model.EdUserProfile: a user profile object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method to retrieve a userProfile object based on UserId
        ///
        /// 2. Return the UserProfile object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EdUserProfile getItem(string UserId)
        {
            this.LogMethod("getItem");
            this.LogDebug("UserId: " + UserId);
            //
            // Initialise the methods variables and objects.
            //
            Evado.Digital.Model.EdUserProfile userProfile = new Evado.Digital.Model.EdUserProfile( );

            //
            // Retrieve the user object from the database.
            //
            userProfile = this._Dal_UserProfiles.GetItem(UserId);

            this.LogClass(this._Dal_UserProfiles.Log);

            //
            // If the normal userId fails try the Active Directory logon.
            //
            if (userProfile.UserId == String.Empty)
            {
                this.LogDebug("Common Name empty to try AdsID. ");

                userProfile = this._Dal_UserProfiles.GetItemByAdsId(UserId);

                this.LogDebugClass(this._Dal_UserProfiles.Log);
            }

            //
            // Return the user profile.
            //
            return(userProfile);
        }//END getItem method
 public EvReportHtml(
     EdReport report,
     EdUserProfile userProfile)
 {
     this.writeDebugLogMethod("EvReportHtml initialisation method.");
     this._report      = report;
     this._UserProfile = userProfile;
 }
示例#5
0
        // ==================================================================================
        /// <summary>
        /// This method initialises the class
        /// </summary>
        // ----------------------------------------------------------------------------------
        public EvClassParameters(
            EdUserProfile UserProfile,
            int Logginglevel,
            Guid ApplicationGuid)
        {
            this._LoggingLevel = Logginglevel;
            this.AdapterGuid   = ApplicationGuid;
            this.UserProfile   = UserProfile;

            String CustomerGroup = UserProfile.AdsCustomerGroup;
        }//END initialisation method.
        }//END getCategoryList method.

        // =====================================================================================
        /// <summary>
        /// This class obtains an array of selection option based on the selection source code and the parameters.
        /// </summary>
        /// <param name="Project">EvProject: (Mandatory) The selection project object</param>
        /// <param name="selectionType">EvReport.SelectionListTypes: (Mandatory) The selection Report QueryType</param>
        /// <param name="ListParameters">string: (Mandatory) The parameter string</param>
        /// <param name="profile">Evado.Digital.Model.EdUserProfile: (Mandatory) the User profile object</param>
        /// <returns>List of EvOption: a list of options</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Switch the selection QueryType and execute the method for retrieving the selection list.
        ///
        /// 2. Return the selection list
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public List <EvOption> getSelectionList(
            EdReport.SelectionListTypes selectionType,
            string ListParameters,
            Evado.Digital.Model.EdUserProfile profile)
        {
            //
            // Initialise the methods variables and objects.
            //
            List <EvOption> returnList = new List <EvOption> ( );

            this.LogMethod("getSelectionList method ");
            this.LogDebug("selectionType: " + selectionType);
            this.LogDebug("ListParameters: " + ListParameters);

            //
            // Select the ResultData source
            //
            switch (selectionType)
            {
            case EdReport.SelectionListTypes.Status:
            {
                this.LogValue("Status source selected.");

                List <EvOption> tempList = new List <EvOption>();

                //Transforming the ArrayList into a list<EvOption>
                foreach (EvOption option in tempList)
                {
                    returnList.Add(option);
                }

                break;
            }

            case EdReport.SelectionListTypes.Record_State:
            {
                this.LogValue("Record source selected.");
                returnList = EdRecord.getRptRecordStates( );
                break;
            }


            case EdReport.SelectionListTypes.LayoutId:
            {
                this.LogValue("Form source selected.");
                EdRecordLayouts formsBll = new EdRecordLayouts(this.ClassParameters);
                returnList = formsBll.getList(EdRecordTypes.Null, EdRecordObjectStates.Form_Issued, false);
                break;
            }
            }//END Switch

            return(returnList);
        }//END getSelectionList method.
        // =====================================================================================
        /// <summary>
        /// This class updates the user profile in the database.
        /// The update and add process are the same as in each execution the currentMonth objects are
        /// set to superseded and then a new object is inserted to the database.
        /// </summary>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile: a userProfile object</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the UserId or UserCommonName is empty
        ///
        /// 2. Execute the method for deleting items if the commone name is empty.
        ///
        /// 3. Execute the method for adding items if the Uid is not defined
        ///
        /// 4. Else, execute the method to update items.
        ///
        /// 5. Return an event code of method execution.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes saveItem(Evado.Digital.Model.EdUserProfile UserProfile)
        {
            this.FlushLog( );
            this.LogMethod("saveItem");
            this.LogValue("UserId: " + UserProfile.UserId);
            this.LogValue("CommonName: " + UserProfile.CommonName);
            //
            // Initialise the methods variables and objects.
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Check that the user id is valid
            //
            if (UserProfile.UserId == String.Empty)
            {
                this.LogValue("UserId is empty");
                return(EvEventCodes.Identifier_User_Id_Error);
            }

            //
            // If CommonName length is null delete the user.
            //
            if (UserProfile.CommonName == String.Empty)
            {
                this.LogValue("Delete User");
                iReturn = this._Dal_UserProfiles.DeleteItem(UserProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                return(iReturn);
            }

            //
            // Add a new user if the user profile Guid is empty.
            //
            if (UserProfile.Guid == Guid.Empty)
            {
                this.LogValue("Add User");
                iReturn = this._Dal_UserProfiles.AddItem(UserProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                return(iReturn);
            }

            this.LogValue("update User");
            iReturn = this._Dal_UserProfiles.UpdateItem(UserProfile);
            this.LogDebug(this._Dal_UserProfiles.Log);

            return(iReturn);
        }//END saveItem method
        }//END getItem method

        #endregion

        #region Class  update  methods
        // =====================================================================================
        /// <summary>
        /// This class retrieves a user profile with a specific connection String.
        /// </summary>
        /// <param name="ConnectionStringKey">string: the database connection string config key</param>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile object</param>
        /// <returns>EvEventCodes enumeration</returns>
        // -------------------------------------------------------------------------------------
        public EvEventCodes saveItem(
            string ConnectionStringKey,
            Evado.Digital.Model.EdUserProfile UserProfile)
        {
            this.FlushLog( );
            this.LogMethod("saveItem");
            Evado.Digital.Bll.EvStaticSetting.ConnectionStringKey = ConnectionStringKey;

            EvEventCodes userProfile = this.saveItem(UserProfile);


            Evado.Digital.Bll.EvStaticSetting.ResetConnectionString( );
            return(userProfile);
        }
        }//End getRecordList method.

        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region export query record methods

        // =====================================================================================
        /// <summary>
        /// this method exports the project records a list of csv string objects.
        /// </summary>
        /// <param name="ExportParameters">EvExportParameters object, defining the items to exported.</param>
        /// <param name="UserProfile">EvUserProfile object.</param>
        /// <returns>List of string where each item is row in a CSv output</returns>
        // -------------------------------------------------------------------------------------
        private String exportProjectRecords(
            EvExportParameters ExportParameters,
            Evado.Digital.Model.EdUserProfile UserProfile)
        {
            this.LogMethod("exportProjectRecords method. ");

            //
            // Initialise the methods objects and variables.
            //
            List <EdRecord> recordList  = new List <EdRecord> ( );
            EdRecords       formRecords = new EdRecords(this.ClassParameters);

            EdQueryParameters queryParameters = new EdQueryParameters( );

            //
            // Set the start and end date filters.
            //

            queryParameters.States.Add(EdRecordObjectStates.Withdrawn);
            queryParameters.States.Add(EdRecordObjectStates.Draft_Record);

            if (ExportParameters.IncludeDraftRecords == true)
            {
                queryParameters.States.Add(EdRecordObjectStates.Withdrawn);
            }

            queryParameters.NotSelectedState    = true;
            queryParameters.IncludeRecordValues = true;
            queryParameters.IncludeSummary      = false;
            queryParameters.LayoutId            = ExportParameters.LayoutId;

            recordList = formRecords.getRecordList(queryParameters);

            this.LogClass(formRecords.Log);

            string result = this.createExportFile(
                recordList,
                UserProfile,
                ExportParameters.IncludeFreeTextData,
                ExportParameters.IncludeDraftRecords);

            this.LogMethodEnd("exportProjectRecords");
            return(result);
        }//END exportProjectRecords method
        }//END getItem method

        // =====================================================================================
        /// <summary>
        /// This class retrieves the Userprofile object based on Guid
        /// </summary>
        /// <param name="UserProfileGuid">Guid: a userProfile Global unique identifier</param>
        /// <returns>Evado.Digital.Model.EdUserProfile: a user profile object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method to retrieve a userProfile object based on Guid
        ///
        /// 2. Return the UserProfile object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EdUserProfile getItem(Guid UserProfileGuid)
        {
            this.FlushLog( );
            this.LogMethod("getItem");
            this.LogDebug("UserProfileGuid: " + UserProfileGuid);
            //
            // Initialise the methods variables and objects.
            //
            Evado.Digital.Model.EdUserProfile userProfile = new Evado.Digital.Model.EdUserProfile( );

            //
            // Retrieve the user object from the database.
            //
            userProfile = this._Dal_UserProfiles.GetItem(UserProfileGuid);
            this.LogDebugClass(this._Dal_UserProfiles.Log);

            //
            // Return the user profile.
            //
            return(userProfile);
        }//END getItem method
        }//END exportProjectRecords method

        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region export methods

        // =====================================================================================
        /// <summary>
        /// This method creates the content for the common record export file as a CSV file.
        /// </summary>
        /// <param name="FormRecordList">List of EvForm: a list of form objects</param>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile: The user profile.</param>
        /// <param name="IncludeFreeTextData">Boolean: True, if the free text fields are exported.</param>
        /// <param name="IncludeDraftRecords">Boolean: True, if the initialised records are included</param>
        /// <returns>String: an export file string. </returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the form objects list is empty.
        ///
        /// 2. Loop through the form list and the associated form field list.
        ///
        /// 3. Add the formfield list's values to the output string.
        ///
        /// 4. Return the output string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public String createExportFile(
            System.Collections.Generic.List <EdRecord> FormRecordList,
            Evado.Digital.Model.EdUserProfile UserProfile,
            bool IncludeFreeTextData,
            bool IncludeDraftRecords)
        {
            this.LogMethod("createExportFile method ");
            this.LogDebug("IncludeFreeTextData:" + IncludeFreeTextData);
            this.LogDebug("IncludeDraftRecords:" + IncludeDraftRecords);
            try
            {
                //
                // Initialise the methods variables and objects.
                //
                EdRecord headerForm = new EdRecord( );
                System.Text.StringBuilder stCsvData = new System.Text.StringBuilder( );

                //
                // Only process the common records if more than one exists.
                //
                if (FormRecordList.Count == 0)
                {
                    this.LogDebug("FormRecordList count is zero.");
                    this.EventCode = EvEventCodes.Data_Export_Empty_Record_List;

                    this.LogMethodEnd("createExportFile");
                    return(stCsvData.ToString( ));
                }

                //
                // Using the last record get a form header i.e. the latest version.
                //
                headerForm = FormRecordList [(FormRecordList.Count - 1)];

                //
                // Create the report header
                //
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Type: " + EvStatics.getEnumStringValue(headerForm.TypeId)));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("FormId: " + headerForm.LayoutId));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Title: " + headerForm.Title));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm")
                                                                                         + " By " + UserProfile.CommonName));

                this.LogDebug("Form Type: " + headerForm.Design.TypeId);
                this.LogDebug("FormId: " + headerForm.LayoutId);
                this.LogDebug("Form Title: " + headerForm.Title);
                this.LogDebug("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm")
                              + " By " + UserProfile.CommonName);

                //
                // Ouput the ResultData header.
                //
                this._OutputDataColumnCount = this.createExportRecordHeader(headerForm, IncludeFreeTextData);

                //
                // Append the CSV data header row.
                //
                stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnHeader));


                this.LogDebug("Commence export record data.");
                //
                // Iterate through the datagrid processing each letter in the grid
                //
                foreach (EdRecord record in FormRecordList)
                {
                    this._ExportColumnRow = new string [this._OutputDataColumnCount];
                    //
                    // IF the item is a valid record output it.
                    //
                    if (record.State == EdRecordObjectStates.Withdrawn)
                    {
                        this.LogDebug("RecordID: " + record.RecordId + " >> Withdrawn or querid record.");
                        continue;
                    }

                    if (record.State == EdRecordObjectStates.Draft_Record &&
                        IncludeDraftRecords == false)
                    {
                        this.LogDebug("RecordID: " + record.RecordId + " >> Initialised record.");
                        continue;
                    }
                    this.LogDebug("RecordID: " + record.RecordId);
                    this.LogDebug("Field Count: " + record.Fields.Count);

                    //
                    // Output the record left hand static fields.
                    //
                    this._ExportColumnRow [0] = record.RecordId;
                    this._ExportColumnRow [1] = record.stRecordDate;

                    //
                    // Output the record fields
                    //
                    foreach (EdRecordField recordField in record.Fields)
                    {
                        this.LogDebug("FieldId: " + recordField.FieldId);
                        this.LogDebug("field Type: " + recordField.TypeId);
                        this.LogDebug("Field Guid: " + recordField.Guid);
                        this.LogDebug("ItemValue: " + recordField.ItemValue);
                        this.LogDebug("ItemText: " + recordField.ItemText);

                        if (recordField.isReadOnly == true)
                        {
                            continue;
                        }

                        //
                        // Export form field
                        //
                        if (recordField.Guid == Guid.Empty)
                        {
                            continue;
                        }

                        //
                        // select the field type to export.
                        //
                        switch (recordField.TypeId)
                        {
                        case EvDataTypes.Special_Matrix:
                        case EvDataTypes.Table:
                        {
                            this.ExportTableData(recordField);
                            break;
                        }

                        case EvDataTypes.Check_Box_List:
                        {
                            this.ExportCheckBoxData(recordField);
                            break;
                        }

                        default:
                        {
                            this.getExportRecordFieldData(
                                recordField,
                                IncludeFreeTextData);
                            break;
                        }
                        } //END switch statement
                    }     //END field iteration loop.


                    this.LogDebug("Comment.Count: " + record.CommentList.Count);

                    String stComments = String.Empty;
                    foreach (EdFormRecordComment comment in record.CommentList)
                    {
                        stComments += comment.Content
                                      + " by "
                                      + comment.UserCommonName
                                      + " on "
                                      + comment.CommentDate.ToString("dd-MMM-yy HH:mm") + " ";
                    }

                    //
                    // record footer information
                    //
                    this.exportColumnValue(StaticHeaderColumns.Comments, stComments);

                    //
                    // Convert the output row into a CSV row.
                    //
                    stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnRow));
                }//END record list  iteration loop

                this.LogDebug("ExportFile length: " + stCsvData.Length);

                this.LogMethodEnd("createExportFile");

                //
                // Return the new record.
                //
                return(stCsvData.ToString( ));
            } //End Try
            catch (Exception Ex)
            {
                this.EventCode = EvEventCodes.Data_Export_Exception_Event;
                this.LogException(Ex);
            } // End catch.

            this.LogMethodEnd("createExportFile");
            return(String.Empty);
        }//END createExportFile class
示例#12
0
 public EvReportCsv(EdReport report, string separator, EdUserProfile userProfile)
 {
     _report    = report;
     _separator = separator;
 }