//Add Data From Linked Tables for Display
        public void EditForDisplay(ClientTelephony clientTelephony)
        {
            //Hierarchy
            if (clientTelephony.HierarchyType == "ClientTopUnit")
            {
                ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
                ClientTopUnit           clientTopUnit           = clientTopUnitRepository.GetClientTopUnit(clientTelephony.HierarchyItem);
                if (clientTopUnit != null)
                {
                    clientTelephony.HierarchyName = clientTopUnit.ClientTopUnitName;
                }
            }
            else if (clientTelephony.HierarchyType == "ClientSubUnit")
            {
                ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                ClientSubUnit           clientSubUnit           = clientSubUnitRepository.GetClientSubUnit(clientTelephony.HierarchyItem);
                if (clientSubUnit != null)
                {
                    clientTelephony.HierarchyName = clientSubUnit.ClientSubUnitName;
                }
            }

            //MainNumberFlag
            clientTelephony.MainNumberFlagNullable = (clientTelephony.MainNumberFlag == true) ? true : false;
        }
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(ClientProfileGroup clientProfileGroup)
        {
            //Set Hierarchy if ClientTopUnit
            ClientProfileGroupClientTopUnit clientProfileGroupClientTopUnit = clientProfileGroup.ClientProfileGroupClientTopUnits.SingleOrDefault();

            if (clientProfileGroupClientTopUnit != null)
            {
                ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
                ClientTopUnit           clientTopUnit           = new ClientTopUnit();
                clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientProfileGroupClientTopUnit.ClientTopUnitGuid);
                if (clientTopUnit != null)
                {
                    clientProfileGroup.HierarchyItem = clientTopUnit.ClientTopUnitName;
                    clientProfileGroup.HierarchyCode = clientTopUnit.ClientTopUnitGuid;
                    clientProfileGroup.HierarchyType = "ClientTopUnit";
                }
            }

            //Set Hierarchy if ClientSubUnit
            ClientProfileGroupClientSubUnit clientProfileGroupClientSubUnit = clientProfileGroup.ClientProfileGroupClientSubUnits.SingleOrDefault();

            if (clientProfileGroupClientSubUnit != null)
            {
                ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                ClientSubUnit           clientSubUnit           = new ClientSubUnit();
                clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientProfileGroupClientSubUnit.ClientSubUnitGuid);
                if (clientSubUnit != null)
                {
                    clientProfileGroup.HierarchyItem = clientSubUnit.ClientSubUnitName;
                    clientProfileGroup.HierarchyCode = clientSubUnit.ClientSubUnitGuid;
                    clientProfileGroup.HierarchyType = "ClientSubUnit";
                }
            }
        }
Beispiel #3
0
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(PriceTrackingHandlingFeeGroup group)
        {
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            List <fnDesktopDataAdmin_SelectPriceTrackingHandlingFeeGroupHierarchy_v1Result> hierarchy = new List <fnDesktopDataAdmin_SelectPriceTrackingHandlingFeeGroupHierarchy_v1Result>();

            hierarchy = GetGroupHierarchy(group.PriceTrackingHandlingFeeGroupId);
            group.PriceTrackingHandlingFeeGroupName = Regex.Replace(group.PriceTrackingHandlingFeeGroupName, @"[^\w\-()*]", "-");

            if (hierarchy.Count > 0)
            {
                group.HierarchyType = hierarchy[0].HierarchyType;
                group.HierarchyCode = hierarchy[0].HierarchyCode.ToString();
                group.HierarchyItem = hierarchy[0].HierarchyName.Trim();

                if (hierarchy[0].HierarchyType == "ClientSubUnitTravelerType")
                {
                    group.ClientSubUnitGuid = hierarchy[0].HierarchyCode.ToString();
                    group.ClientSubUnitName = hierarchy[0].HierarchyName.Trim();
                    group.TravelerTypeGuid  = hierarchy[0].TravelerTypeGuid;
                    group.TravelerTypeName  = hierarchy[0].TravelerTypeName.Trim();
                    if (!string.IsNullOrEmpty(group.ClientSubUnitGuid))
                    {
                        ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                        ClientSubUnit           clientSubUnit           = clientSubUnitRepository.GetClientSubUnit(group.ClientSubUnitGuid);
                        if (clientSubUnit != null && clientSubUnit.ClientTopUnit != null)
                        {
                            group.ClientTopUnitName = clientSubUnit.ClientTopUnit.ClientTopUnitName;
                        }
                    }
                }

                if (hierarchy[0].HierarchyType == "ClientSubUnit" || hierarchy[0].HierarchyType == "TravelerType")
                {
                    if (hierarchy[0].ClientTopUnitName != null)
                    {
                        group.ClientTopUnitName = hierarchy[0].ClientTopUnitName.Trim();
                    }
                }

                if (hierarchy[0].HierarchyType == "ClientAccount")
                {
                    group.SourceSystemCode = hierarchy[0].SourceSystemCode;
                }
            }

            if (hierarchy.Count > 1)
            {
                group.IsMultipleHierarchy = true;
                group.HierarchyType       = "Multiple";
                group.HierarchyItem       = "Multiple";
                group.HierarchyCode       = "Multiple";
            }
            else
            {
                group.IsMultipleHierarchy = false;
            }
        }
Beispiel #4
0
        //Add Data From Linked Tables for Display
        public void EditForDisplay(ClientSubUnitClientAccount clientSubUnitClientAccount)
        {
            ClientAccountRepository clientAccountRepository = new ClientAccountRepository();
            ClientAccount           clientAccount           = new ClientAccount();

            clientAccount = clientAccountRepository.GetClientAccount(clientSubUnitClientAccount.ClientAccountNumber, clientSubUnitClientAccount.SourceSystemCode);
            if (clientAccount != null)
            {
                clientSubUnitClientAccount.ClientAccountName = clientAccount.ClientAccountName;
            }

            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
            ClientSubUnit           clientSubUnit           = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitClientAccount.ClientSubUnitGuid);
            if (clientSubUnit != null)
            {
                clientSubUnitClientAccount.ClientSubUnitName = clientSubUnit.ClientSubUnitName;
            }

            ConfidenceLevelForLoadRepository confidenceLevelForLoadRepository = new ConfidenceLevelForLoadRepository();
            ConfidenceLevelForLoad           confidenceLevelForLoad           = new ConfidenceLevelForLoad();

            if (clientSubUnitClientAccount.ConfidenceLevelForLoadId != null)
            {
                int confidenceLevelForLoadId = (int)clientSubUnitClientAccount.ConfidenceLevelForLoadId;
                confidenceLevelForLoad = confidenceLevelForLoadRepository.GetConfidenceLevelForLoad(confidenceLevelForLoadId);
                if (confidenceLevelForLoad != null)
                {
                    clientSubUnitClientAccount.ConfidenceLevelForLoadDescription = confidenceLevelForLoad.ConfidenceLevelForLoadDescription;
                }
            }

            LineOfBusinessRepository lineOfBusinessRepository = new LineOfBusinessRepository();
            LineOfBusiness           lineOfBusiness           = new LineOfBusiness();

            if (clientSubUnitClientAccount.ClientAccountLineOfBusinessId != null)
            {
                int lineOfBusinessId = (int)clientSubUnitClientAccount.ClientAccountLineOfBusinessId;
                lineOfBusiness = lineOfBusinessRepository.GetLineOfBusiness(lineOfBusinessId);
                if (lineOfBusiness != null)
                {
                    clientSubUnitClientAccount.LineOfBusiness = lineOfBusiness;
                }
            }
        }
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(PointOfSaleFeeLoad pointOfSaleFeeLoad)
        {
            //ClientTopUnit
            if (pointOfSaleFeeLoad.ClientTopUnitGuid != null)
            {
                ClientTopUnitRepository ClientTopUnitRepository = new ClientTopUnitRepository();
                ClientTopUnit           clientTopUnit           = ClientTopUnitRepository.GetClientTopUnit(pointOfSaleFeeLoad.ClientTopUnitGuid);
                if (clientTopUnit != null)
                {
                    pointOfSaleFeeLoad.ClientTopUnitName = clientTopUnit.ClientTopUnitName;
                }
            }

            //ClientSubUnit
            if (pointOfSaleFeeLoad.ClientSubUnitGuid != null)
            {
                ClientSubUnitRepository ClientSubUnitRepository = new ClientSubUnitRepository();
                ClientSubUnit           clientSubUnit           = ClientSubUnitRepository.GetClientSubUnit(pointOfSaleFeeLoad.ClientSubUnitGuid);
                if (clientSubUnit != null)
                {
                    pointOfSaleFeeLoad.ClientSubUnitName = clientSubUnit.ClientSubUnitName;
                }
            }

            //TravelerType
            if (pointOfSaleFeeLoad.TravelerTypeGuid != null)
            {
                TravelerTypeRepository TravelerTypeRepository = new TravelerTypeRepository();
                TravelerType           TravelerType           = TravelerTypeRepository.GetTravelerType(pointOfSaleFeeLoad.TravelerTypeGuid);
                if (TravelerType != null)
                {
                    pointOfSaleFeeLoad.TravelerTypeName = TravelerType.TravelerTypeName;
                }
            }

            //Product
            if (pointOfSaleFeeLoad.ProductId > 0)
            {
                ProductRepository productRepository = new ProductRepository();
                Product           product           = productRepository.GetProduct(pointOfSaleFeeLoad.ProductId);
                if (product != null)
                {
                    pointOfSaleFeeLoad.Product = product;
                }
            }
        }
Beispiel #6
0
        //Get All PseudoCityOrOfficeMaintenance ClientSubUnits
        public List <ClientSubUnit> GetAllPseudoCityOrOfficeMaintenanceClientSubUnits(int pseudoCityOrOfficeMaintenanceId)
        {
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();

            List <ClientSubUnit> clientSubUnits = new List <ClientSubUnit>();

            List <PseudoCityOrOfficeMaintenanceClientSubUnit> pseudoCityOrOfficeMaintenanceClientSubUnits = db.PseudoCityOrOfficeMaintenanceClientSubUnits.Where(x => x.PseudoCityOrOfficeMaintenanceId == pseudoCityOrOfficeMaintenanceId).ToList();

            foreach (PseudoCityOrOfficeMaintenanceClientSubUnit pseudoCityOrOfficeMaintenanceClientSubUnit in pseudoCityOrOfficeMaintenanceClientSubUnits)
            {
                ClientSubUnit clientSubUnit = clientSubUnitRepository.GetClientSubUnit(pseudoCityOrOfficeMaintenanceClientSubUnit.ClientSubUnitGuid);
                if (clientSubUnit != null)
                {
                    clientSubUnits.Add(clientSubUnit);
                }
            }

            return(clientSubUnits);
        }
        //Get one Commissionable Route Group
        public ClientTopUnitMatrixDPCode GetGroup(string hierarchyCode, string hierarchyType)
        {
            ClientTopUnitMatrixDPCode clientTopUnitMatrixDPCode = new ClientTopUnitMatrixDPCode();

            if (hierarchyType == "ClientSubUnit")
            {
                MatrixDPCodeByClientSubUnit matrixDPCodeByClientSubUnit = db.MatrixDPCodeByClientSubUnits.SingleOrDefault(c => c.ClientSubUnitGuid == hierarchyCode);
                if (matrixDPCodeByClientSubUnit != null)
                {
                    clientTopUnitMatrixDPCode.HierarchyType = hierarchyType;
                    clientTopUnitMatrixDPCode.HierarchyCode = matrixDPCodeByClientSubUnit.ClientSubUnitGuid;
                    clientTopUnitMatrixDPCode.MatrixDPCode  = matrixDPCodeByClientSubUnit.MatrixDPCode;
                    clientTopUnitMatrixDPCode.VersionNumber = matrixDPCodeByClientSubUnit.VersionNumber;

                    ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                    ClientSubUnit           clientSubUnit           = clientSubUnitRepository.GetClientSubUnit(matrixDPCodeByClientSubUnit.ClientSubUnitGuid);
                    if (clientSubUnit != null)
                    {
                        clientTopUnitMatrixDPCode.HierarchyItem = clientSubUnit.ClientSubUnitName;
                    }
                }
            }
            else
            {
                MatrixDPCodeByTravelerType matrixDPCodeByTravelerType = db.MatrixDPCodeByTravelerTypes.SingleOrDefault(c => c.TravelerTypeGuid == hierarchyCode);
                if (matrixDPCodeByTravelerType != null)
                {
                    clientTopUnitMatrixDPCode.HierarchyType = hierarchyType;
                    clientTopUnitMatrixDPCode.HierarchyCode = matrixDPCodeByTravelerType.TravelerTypeGuid;
                    clientTopUnitMatrixDPCode.MatrixDPCode  = matrixDPCodeByTravelerType.MatrixDPCode;
                    clientTopUnitMatrixDPCode.VersionNumber = matrixDPCodeByTravelerType.VersionNumber;

                    TravelerTypeRepository travelerTypeRepository = new TravelerTypeRepository();
                    TravelerType           travelerType           = travelerTypeRepository.GetTravelerType(matrixDPCodeByTravelerType.TravelerTypeGuid);
                    if (travelerType != null)
                    {
                        clientTopUnitMatrixDPCode.HierarchyItem = travelerType.TravelerTypeName;
                    }
                }
            }
            return(clientTopUnitMatrixDPCode);
        }
Beispiel #8
0
        //Add Data From Linked Tables for Display
        public void EditForDisplay(ClientSubUnitTeam clientSubUnitTeam)
        {
            ClientSubUnitRepository clientSubUnitTeamRepository = new ClientSubUnitRepository();
            ClientSubUnit           clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitTeamRepository.GetClientSubUnit(clientSubUnitTeam.ClientSubUnitGuid);
            if (clientSubUnit != null)
            {
                clientSubUnitTeam.ClientSubUnitName = clientSubUnit.ClientSubUnitName;
            }

            TeamRepository teamRepository = new TeamRepository();
            Team           team           = new Team();

            team = teamRepository.GetTeam(clientSubUnitTeam.TeamId);
            if (team != null)
            {
                clientSubUnitTeam.TeamName = team.TeamName;
            }
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ClientSubUnitCreateProfileAdvice clientSubUnitCreateProfileAdvice)
        {
            //Add LanguageName
            if (clientSubUnitCreateProfileAdvice.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(clientSubUnitCreateProfileAdvice.LanguageCode);
                if (language != null)
                {
                    clientSubUnitCreateProfileAdvice.LanguageName = language.LanguageName;
                }
            }

            //Add ClientSubUnitName
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
            ClientSubUnit           clientSubUnit           = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitCreateProfileAdvice.ClientSubUnitGuid);
            clientSubUnitCreateProfileAdvice.ClientSubUnitDisplayName = clientSubUnit.ClientSubUnitDisplayName;
        }
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(ChatFAQResponseGroup group)
        {
            group.ChatFAQResponseGroupName = Regex.Replace(group.ChatFAQResponseGroupName, @"[^\w\-()*]", "-");

            //Hierarchy
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            List <fnDesktopDataAdmin_SelectChatFAQResponseGroupHierarchy_v1Result> hierarchy = GetGroupHierarchy(group.ChatFAQResponseGroupId);

            if (hierarchy.Count > 0)
            {
                if (hierarchy.Count == 1)
                {
                    HierarchyGroup hierarchyGroup = hierarchyRepository.GetHierarchyGroup(
                        hierarchy[0].HierarchyType ?? "",
                        hierarchy[0].HierarchyCode ?? "",
                        hierarchy[0].HierarchyName ?? "",
                        hierarchy[0].TravelerTypeGuid ?? "",
                        hierarchy[0].TravelerTypeName ?? "",
                        hierarchy[0].SourceSystemCode ?? ""
                        );

                    if (hierarchyGroup != null)
                    {
                        group.HierarchyType     = hierarchyGroup.HierarchyType;
                        group.HierarchyCode     = hierarchyGroup.HierarchyCode;
                        group.HierarchyItem     = hierarchyGroup.HierarchyItem;
                        group.ClientSubUnitGuid = hierarchyGroup.ClientSubUnitGuid;
                        group.ClientSubUnitName = hierarchyGroup.ClientSubUnitName;
                        group.TravelerTypeGuid  = hierarchyGroup.TravelerTypeGuid;
                        group.TravelerTypeName  = hierarchyGroup.TravelerTypeName;
                        group.ClientTopUnitName = hierarchyGroup.ClientTopUnitName;
                        group.SourceSystemCode  = hierarchyGroup.SourceSystemCode;
                    }
                }
                else
                {
                    List <MultipleHierarchyDefinition> multipleHierarchies = new List <MultipleHierarchyDefinition>();
                    foreach (fnDesktopDataAdmin_SelectChatFAQResponseGroupHierarchy_v1Result item in hierarchy)
                    {
                        multipleHierarchies.Add(new MultipleHierarchyDefinition()
                        {
                            HierarchyType    = item.HierarchyType,
                            HierarchyItem    = item.HierarchyName,
                            HierarchyCode    = item.HierarchyCode,
                            TravelerTypeGuid = item.TravelerTypeGuid,
                            SourceSystemCode = item.SourceSystemCode
                        });
                    }
                    group.ClientSubUnitsHierarchy = hierarchyRepository.GetClientSubUnitHierarchies(multipleHierarchies);

                    ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                    group.ClientTopUnitName = clientSubUnitRepository.GetClientSubUnitClientTopUnitName(group.ClientSubUnitsHierarchy.First().ClientSubUnitGuid);
                }
            }

            if (hierarchy.Count > 1)
            {
                group.IsMultipleHierarchy = true;
                group.HierarchyType       = "Multiple";
                group.HierarchyItem       = "Multiple";
                group.HierarchyCode       = "Multiple";
            }
            else
            {
                group.IsMultipleHierarchy = false;
            }
        }
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(PolicyGroup group)
        {
            //Trip Types
            TripTypeRepository tripTypeRepository = new TripTypeRepository();
            TripType           tripType           = new TripType();

            tripType = tripTypeRepository.GetTripType(group.TripTypeId);
            if (tripType != null)
            {
                group.TripType = tripType.TripTypeDescription;
            }

            //Meetings
            if (group.MeetingID != null)
            {
                int meetingID = Int32.Parse(group.MeetingID.ToString());
                MeetingRepository meetingRepository = new MeetingRepository();
                Meeting           meeting           = meetingRepository.GetGroup(meetingID);
                if (meeting != null)
                {
                    group.Meeting = meeting;
                }
            }

            group.PolicyGroupName = Regex.Replace(group.PolicyGroupName, @"[^\w\-()*]", "-");

            //Hierarchy
            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            List <fnDesktopDataAdmin_SelectPolicyGroupHierarchy_v1Result> hierarchy = GetGroupHierarchy(group.PolicyGroupId);

            if (hierarchy.Count > 0)
            {
                if (hierarchy.Count == 1)
                {
                    HierarchyGroup hierarchyGroup = hierarchyRepository.GetHierarchyGroup(
                        hierarchy[0].HierarchyType ?? "",
                        hierarchy[0].HierarchyCode ?? "",
                        hierarchy[0].HierarchyName ?? "",
                        hierarchy[0].TravelerTypeGuid ?? "",
                        hierarchy[0].TravelerTypeName ?? "",
                        hierarchy[0].SourceSystemCode ?? ""
                        );

                    if (hierarchyGroup != null)
                    {
                        group.HierarchyType     = hierarchyGroup.HierarchyType;
                        group.HierarchyCode     = hierarchyGroup.HierarchyCode;
                        group.HierarchyItem     = hierarchyGroup.HierarchyItem;
                        group.ClientSubUnitGuid = hierarchyGroup.ClientSubUnitGuid;
                        group.ClientSubUnitName = hierarchyGroup.ClientSubUnitName;
                        group.TravelerTypeGuid  = hierarchyGroup.TravelerTypeGuid;
                        group.TravelerTypeName  = hierarchyGroup.TravelerTypeName;
                        group.ClientTopUnitName = hierarchyGroup.ClientTopUnitName;
                        group.SourceSystemCode  = hierarchyGroup.SourceSystemCode;
                    }
                }
                else
                {
                    List <MultipleHierarchyDefinition> multipleHierarchies = new List <MultipleHierarchyDefinition>();
                    foreach (fnDesktopDataAdmin_SelectPolicyGroupHierarchy_v1Result item in hierarchy)
                    {
                        multipleHierarchies.Add(new MultipleHierarchyDefinition()
                        {
                            HierarchyType    = item.HierarchyType,
                            HierarchyItem    = item.HierarchyName,
                            HierarchyCode    = item.HierarchyCode,
                            TravelerTypeGuid = item.TravelerTypeGuid,
                            SourceSystemCode = item.SourceSystemCode
                        });
                    }
                    group.ClientSubUnitsHierarchy = hierarchyRepository.GetClientSubUnitHierarchies(multipleHierarchies);

                    ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                    group.ClientTopUnitName = clientSubUnitRepository.GetClientSubUnitClientTopUnitName(group.ClientSubUnitsHierarchy.First().ClientSubUnitGuid);
                }
            }

            if (hierarchy.Count > 1)
            {
                group.IsMultipleHierarchy = true;
                group.HierarchyType       = "Multiple";
                group.HierarchyItem       = "Multiple";
                group.HierarchyCode       = "Multiple";
            }
            else
            {
                group.IsMultipleHierarchy = false;
            }
        }
Beispiel #12
0
        public CDRImportStep3VM Import(byte[] FileBytes, string clientSubUnitGuid, string displayName, string relatedToDisplayName = "")
        {
            System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            string fileToText            = fileToText = enc.GetString(FileBytes);

            /*
             * Regex to match on each line (5 items separated by commas, followed by a new line - last 2 items are optional)
             * CDR Value, SourceSystemCode, ClientAccountNumber, CreditCardID (optional), RelatedToValue (optional)
             */

            CDRImportStep3VM cdrPostImportResult = new CDRImportStep3VM();

            // Create the xml document container, this will be used to store the data after the Regex checks
            XmlDocument    doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("CSUCDRs");

            doc.AppendChild(root);


            ClientSubUnit clientSubUnit = new ClientSubUnit();
            ClientSubUnitClientAccountRepository clientSubUnitClientAccountRepository = new ClientSubUnitClientAccountRepository();
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);

            //Counters are above loop, every time we call proc,we have to sum values (old+new)
            int deletedItemCount = 0;
            int addedItemCount   = 0;

            //declare step flag for proc
            int step = 0;

            //Split the CSV into lines
            string[] lines = fileToText.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            //Max size of chunk
            int MaxSizeOfChunk = 10;

            //Lines buffer
            string[] linesBuffer;

            //begin loop for divide into chunks
            for (int j = 0; j < lines.Length; j += MaxSizeOfChunk)
            {
                int i = 0;

                //Set MaxSizeOfChunk for last iteration
                if (lines.Length - j < MaxSizeOfChunk)
                {
                    MaxSizeOfChunk = lines.Length - j;
                }
                //Copy from source (lines), array size(chunk), into buffer array
                linesBuffer = new string[MaxSizeOfChunk];
                Array.Copy(lines, j, linesBuffer, 0, MaxSizeOfChunk);

                //loop through CSV lines of buffer
                foreach (string line in linesBuffer)
                {
                    if (i != j)                     //ignore first line with titles-we have to avoid first line, position (0,0)
                    {
                        string[] cells = line.Split(',');

                        //extract the data items from the file
                        string fileCostCentre          = cells[0];                                     //CDRValue (Cost Centre)
                        string fileSourceSystemCode    = cells[1];                                     //SourceSystemCode
                        string fileClientAccountNumber = cells[2];                                     //CWT Account No (Air/Rail)

                        //Credit Card No field is an optional field on the .csv file
                        string fileCreditCardNumber = string.Empty;
                        if (cells.Length >= 4)
                        {
                            fileCreditCardNumber = cells[3] ?? "";
                        }

                        //The RelatedToValue field is an optional field on the .csv file.  If there is no CDR Display Name value entered in the Validate CDR field,
                        //then the Import should not look for a RelatedToValue column on the .csv file
                        string fileRelatedToValue = string.Empty;
                        if (cells.Length >= 5)
                        {
                            fileRelatedToValue = cells[4] ?? "";
                        }

                        //Build the XML Element for a CDR
                        XmlElement xmlCDRItem = doc.CreateElement("CSUCDR");

                        //Populate the XML Element for a CDR
                        //This XMLDoc is only used if the File Passes Validation
                        XmlElement xmlSourceSystemCode = doc.CreateElement("SourceSystemCode");
                        xmlSourceSystemCode.InnerText = fileSourceSystemCode;
                        xmlCDRItem.AppendChild(xmlSourceSystemCode);

                        XmlElement xmlClientAccountNumber = doc.CreateElement("ClientAccountNumber");
                        xmlClientAccountNumber.InnerText = fileClientAccountNumber;
                        xmlCDRItem.AppendChild(xmlClientAccountNumber);

                        XmlElement xmlCostCentre = doc.CreateElement("CostCentre");
                        xmlCostCentre.InnerText = fileCostCentre;
                        xmlCDRItem.AppendChild(xmlCostCentre);

                        //Check for numerical credit card
                        if (!string.IsNullOrEmpty(fileCreditCardNumber))
                        {
                            int creditCardId;
                            if (!Int32.TryParse(fileCreditCardNumber, out creditCardId))
                            {
                                fileCreditCardNumber = "";
                            }

                            XmlElement xmlCreditCardId = doc.CreateElement("CreditCardId");
                            xmlCreditCardId.InnerText = !string.IsNullOrEmpty(fileCreditCardNumber) ? fileCreditCardNumber : "";
                            xmlCDRItem.AppendChild(xmlCreditCardId);
                        }

                        if (!string.IsNullOrEmpty(fileRelatedToValue) && !string.IsNullOrEmpty(relatedToDisplayName))
                        {
                            XmlElement xmlRelatedToDisplayName = doc.CreateElement("RelatedToDisplayName");
                            xmlRelatedToDisplayName.InnerText = !string.IsNullOrEmpty(relatedToDisplayName) ? relatedToDisplayName : "";
                            xmlCDRItem.AppendChild(xmlRelatedToDisplayName);

                            XmlElement xmlRelatedToValue = doc.CreateElement("RelatedToValue");
                            xmlRelatedToValue.InnerText = !string.IsNullOrEmpty(fileRelatedToValue) ? fileRelatedToValue : "";
                            xmlCDRItem.AppendChild(xmlRelatedToValue);
                        }

                        //Attach the XML Element for a CDR to the Document
                        root.AppendChild(xmlCDRItem);
                    }

                    i++;
                }



                //DB Check
                string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

                //Extra param added to proc, send 0 if first page, 1 others(if it is first page in that case we delete in proc)
                step = (j == 0 ? 0 : 1);

                var output = (from n in db.spDesktopDataAdmin_UpdateClientSubUnitClientDefinedReferences_v1(
                                  clientSubUnit.ClientSubUnitGuid,
                                  displayName,
                                  System.Xml.Linq.XElement.Parse(doc.OuterXml),
                                  adminUserGuid,
                                  step)
                              select n).ToList();



                foreach (spDesktopDataAdmin_UpdateClientSubUnitClientDefinedReferences_v1Result message in output)
                {
                    deletedItemCount += message.DeletedCount;
                    addedItemCount   += message.AddedCount;
                }

                //empty xml nodes into root, ready for next iteration
                root.RemoveAll();
            }
            //end loop for divide into chunks

            cdrPostImportResult.ClientSubUnitGuid = clientSubUnitGuid;
            cdrPostImportResult.DisplayName       = displayName;
            cdrPostImportResult.AddedItemCount    = addedItemCount;
            cdrPostImportResult.DeletedItemCount  = deletedItemCount;
            return(cdrPostImportResult);
        }
Beispiel #13
0
        public CDRImportStep2VM PreImportCheck(HttpPostedFileBase file, string clientSubUnitGuid, string displayName, string relatedToDisplayName = "")
        {
            //convert file to string so that we can parse
            int length = file.ContentLength;

            byte[] tempFile = new byte[length];
            file.InputStream.Read(tempFile, 0, length);
            byte[] array = tempFile.ToArray();
            System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            string fileToText            = fileToText = enc.GetString(array);

            /*
             * Regex to match on CDRValue
             * The following Special Characters are currently allowed in CDR fields:
             * Alpha (A-Z), numeric (0-9), ampersand (&), asterisk (*), at sign (@), hypen (-), forward slash (/), period (.),
             * underscore (_), equal (=), colon (:), open/closed brackets ( ), space
             */
            //string dataRegex = @"[^(\w|\-|@|*|(|)| |=|:|/)]+";
            string dataRegex = @"[^(\w| |\-|\@|\*|\&|\(|\)|\=|\:|\/|\.)]+";

            // Create the xml document container, this will be used to store the data after the Regex checks
            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("CSUCDRs");

            doc.AppendChild(root);

            //Client SubUnit
            ClientSubUnit clientSubUnit = new ClientSubUnit();
            ClientSubUnitClientAccountRepository clientSubUnitClientAccountRepository = new ClientSubUnitClientAccountRepository();
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);
            string clientSubUnitName = clientSubUnit.ClientSubUnitName;

            List <string> returnMessages = new List <string>();
            string        returnMessage;
            int           i = 0;

            //Store Valid ClientSubUnitClientAccounts
            List <ClientSubUnitClientAccount>       validClientSubUnitClientAccounts   = new List <ClientSubUnitClientAccount>();
            List <ClientSubUnitClientAccountImport> invalidClientSubUnitClientAccounts = new List <ClientSubUnitClientAccountImport>();

            //Split the CSV into lines
            string[] lines = fileToText.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            //loop through CSV lines
            foreach (string line in lines)
            {
                i++;

                if (i > 1)                 //ignore first line with titles
                {
                    string[] cells = line.Split(',');

                    //extract the data items from the file
                    string fileCostCentre          = cells[0];                                 //CDRValue (Cost Centre)
                    string fileSourceSystemCode    = cells[1];                                 //SourceSystemCode
                    string fileClientAccountNumber = cells[2];                                 //CWT Account No (Air/Rail)

                    //Credit Card No field is an optional field on the .csv file
                    string fileCreditCardNumber = string.Empty;
                    if (cells.Length >= 4)
                    {
                        fileCreditCardNumber = cells[3] ?? "";
                    }

                    //The RelatedToValue field is an optional field on the .csv file.  If there is no CDR Display Name value entered in the Validate CDR field,
                    //then the Import should not look for a RelatedToValue column on the .csv file
                    string fileRelatedToValue = string.Empty;
                    if (cells.Length >= 5)
                    {
                        fileRelatedToValue = cells[4] ?? "";
                    }

                    //Build the XML Element for a CDR
                    XmlElement xmlCDRItem = doc.CreateElement("CSUCDR");

                    //Populate the XML Element for a CDR
                    //This XMLDoc is only used if the File Passes Validation
                    XmlElement xmlSourceSystemCode = doc.CreateElement("SourceSystemCode");
                    xmlSourceSystemCode.InnerText = fileSourceSystemCode;
                    xmlCDRItem.AppendChild(xmlSourceSystemCode);

                    XmlElement xmlClientAccountNumber = doc.CreateElement("ClientAccountNumber");
                    xmlClientAccountNumber.InnerText = fileClientAccountNumber;
                    xmlCDRItem.AppendChild(xmlClientAccountNumber);

                    XmlElement xmlCostCentre = doc.CreateElement("CostCentre");
                    xmlCostCentre.InnerText = fileCostCentre;
                    xmlCDRItem.AppendChild(xmlCostCentre);

                    //Check for numerical credit card
                    if (!string.IsNullOrEmpty(fileCreditCardNumber))
                    {
                        int creditCardId;
                        if (!Int32.TryParse(fileCreditCardNumber, out creditCardId))
                        {
                            fileCreditCardNumber = "";
                        }

                        XmlElement xmlCreditCardId = doc.CreateElement("CreditCardId");
                        xmlCreditCardId.InnerText = !string.IsNullOrEmpty(fileCreditCardNumber) ? fileCreditCardNumber : "";
                        xmlCDRItem.AppendChild(xmlCreditCardId);
                    }

                    if (!string.IsNullOrEmpty(fileRelatedToValue) && !string.IsNullOrEmpty(relatedToDisplayName))
                    {
                        XmlElement xmlRelatedToDisplayName = doc.CreateElement("RelatedToDisplayName");
                        xmlRelatedToDisplayName.InnerText = !string.IsNullOrEmpty(relatedToDisplayName) ? relatedToDisplayName : "";
                        xmlCDRItem.AppendChild(xmlRelatedToDisplayName);

                        XmlElement xmlRelatedToValue = doc.CreateElement("RelatedToValue");
                        xmlRelatedToValue.InnerText = !string.IsNullOrEmpty(fileRelatedToValue) ? fileRelatedToValue : "";
                        xmlCDRItem.AppendChild(xmlRelatedToValue);
                    }

                    //Attach the XML Element for a CDR to the Document
                    root.AppendChild(xmlCDRItem);

                    bool existingValidClient = validClientSubUnitClientAccounts.Where(x =>
                                                                                      x.ClientAccountNumber == fileClientAccountNumber &&
                                                                                      x.SourceSystemCode == fileSourceSystemCode &&
                                                                                      x.ClientSubUnitGuid == clientSubUnitGuid
                                                                                      ).Count() > 0;

                    bool existingInvalidClient = invalidClientSubUnitClientAccounts.Where(x =>
                                                                                          x.ClientAccountNumber == fileClientAccountNumber &&
                                                                                          x.SourceSystemCode == fileSourceSystemCode &&
                                                                                          x.ClientSubUnitGuid == clientSubUnitGuid
                                                                                          ).Count() > 0;

                    //Check Client Account belongs to this Client
                    if (existingInvalidClient)
                    {
                        //Error: Account and SourceSystemCode have been detected in the data file that are not associated to the ClientSubUnit
                        returnMessage = "Account '" + fileClientAccountNumber + "' and SourceSystemCode '" + fileSourceSystemCode + "' have been detected in the data file that are not associated to the ClientSubUnit that you have selected ('" + clientSubUnitName + "'). Please either associate the Account and SourceSystemCode to the chosen ClientSubUnit or update the data file with the correct Account and SourceSystemCode";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else if (existingValidClient)
                    {
                        //No processing required as already marked as valid
                    }
                    else
                    {
                        ClientSubUnitClientAccount clientSubUnitClientAccount = clientSubUnitClientAccountRepository.GetClientSubUnitClientAccount(
                            fileClientAccountNumber,
                            fileSourceSystemCode,
                            clientSubUnitGuid
                            );
                        if (clientSubUnitClientAccount == null)
                        {
                            //Error: Account and SourceSystemCode have been detected in the data file that are not associated to the ClientSubUnit
                            returnMessage = "Account '" + fileClientAccountNumber + "' and SourceSystemCode '" + fileSourceSystemCode + "' have been detected in the data file that are not associated to the ClientSubUnit that you have selected ('" + clientSubUnitName + "'). Please either associate the Account and SourceSystemCode to the chosen ClientSubUnit or update the data file with the correct Account and SourceSystemCode";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }

                            ClientSubUnitClientAccountImport clientSubUnitClientAccountImport = new ClientSubUnitClientAccountImport()
                            {
                                ClientAccountNumber = fileClientAccountNumber,
                                SourceSystemCode    = fileSourceSystemCode,
                                ClientSubUnitGuid   = clientSubUnitGuid,
                            };

                            if (!invalidClientSubUnitClientAccounts.Contains(clientSubUnitClientAccountImport))
                            {
                                invalidClientSubUnitClientAccounts.Add(clientSubUnitClientAccountImport);
                            }
                        }
                        else
                        {
                            if (!validClientSubUnitClientAccounts.Contains(clientSubUnitClientAccount))
                            {
                                validClientSubUnitClientAccounts.Add(clientSubUnitClientAccount);
                            }
                        }
                    }

                    //Error: There is a value that exceeds the maximum length of 50 characters
                    if (fileCostCentre.Length > 50)
                    {
                        returnMessage = fileCostCentre + "is a VALUE that exceeds the maximum Value length of 50 characters. Please update the data file or select a new data file.";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }

                    ////Error: There is a credit card id that is not present in the database
                    //if (!string.IsNullOrEmpty(fileCreditCardNumber))
                    //{
                    //	int creditCardId = Int32.Parse(fileCreditCardNumber);
                    //	CreditCardRepository creditCardRepository = new CreditCardRepository();
                    //	CreditCard creditCard = creditCardRepository.GetCreditCard(creditCardId, false);
                    //	if (creditCard == null)
                    //	{
                    //		returnMessage = "Credit Card Id  " + fileCreditCardNumber + " has been detected in the file but is not present in the database. Please check the value and try again";
                    //		if (!returnMessages.Contains(returnMessage))
                    //		{
                    //			returnMessages.Add(returnMessage);
                    //			break;
                    //		}
                    //	}
                    //}

                    //Error: An invalid character that has been detected within the data file
                    if (Regex.Match(fileCostCentre, dataRegex).Success)
                    {
                        foreach (Match n in Regex.Matches(fileCostCentre, dataRegex))
                        {
                            returnMessage = n.Groups[0].Value + " is an invalid character that has been detected within the data file. Please update the data file or select a new data file to import.";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    //Error: If a user doesn’t include the Validate CDR field on the UI, and there are RelatedToValues listed on the Import,
                    //the Import should fail and give the user an error message that Validate CDR value missing.
                    if (!string.IsNullOrEmpty(fileRelatedToValue) && string.IsNullOrEmpty(relatedToDisplayName))
                    {
                        returnMessage = "A value in the RelatedToValue column has been detected within the data file but the Validate CDR value missing. Please go back and enter a Validate CDR value or remove the RelatedToValue from the data file.";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }

                    //Error: If a user enters a value in the Validate CDR field on the UI, the Import file must include RelatedToValues else
                    // the Import should fail and give the user an error message that RelatedToValues missing on the Import
                    if (string.IsNullOrEmpty(fileRelatedToValue) && !string.IsNullOrEmpty(relatedToDisplayName))
                    {
                        returnMessage = "A Validate CDR has been detected but the RelatedToValue is missing. Please go back and remove the Validate CDR value or add the RelatedToValue data into the data file.";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                }
            }
            if (i == 0)
            {
                returnMessage = "There is no data in the file";
                returnMessages.Add(returnMessage);
            }

            CDRImportStep2VM preImportCheckResult = new CDRImportStep2VM();

            preImportCheckResult.ReturnMessages = returnMessages;

            if (returnMessages.Count != 0)
            {
                preImportCheckResult.IsValidData = false;
            }
            else
            {
                //DB Check
                string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

                var output = (
                    from n in db.spDesktopDataAdmin_UpdateClientSubUnitClientDefinedReferencesCount_v1(
                        clientSubUnit.ClientSubUnitGuid,
                        displayName,
                        System.Xml.Linq.XElement.Parse(doc.OuterXml),
                        adminUserGuid
                        )
                    select n).ToList();

                foreach (spDesktopDataAdmin_UpdateClientSubUnitClientDefinedReferencesCount_v1Result message in output)
                {
                    returnMessages.Add(message.MessageText.ToString());
                }

                preImportCheckResult.FileBytes = array;

                preImportCheckResult.IsValidData = true;
            }

            return(preImportCheckResult);
        }
Beispiel #14
0
        //Add Data From Linked Tables for Display
        //type is optional to letus know if it is a TopUnit card, which has no links to other tables
        public void EditForDisplay(CreditCardEditable creditCard)
        {
            ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
            ClientTopUnit           clientTopUnit           = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(creditCard.ClientTopUnitGuid);
            if (clientTopUnit != null)
            {
                creditCard.ClientTopUnitName = clientTopUnit.ClientTopUnitName;
            }

            CreditCardVendorRepository creditCardVendorRepository = new CreditCardVendorRepository();
            CreditCardVendor           creditCardVendor           = new CreditCardVendor();

            creditCardVendor = creditCardVendorRepository.GetCreditCardVendor(creditCard.CreditCardVendorCode);
            if (creditCardVendor != null)
            {
                creditCard.CreditCardVendorName = creditCardVendor.CreditCardVendorName;
            }

            if (creditCard.CreditCardTypeId != null)
            {
                int creditCardTypeId = (int)creditCard.CreditCardTypeId;
                CreditCardTypeRepository creditCardTypeRepository = new CreditCardTypeRepository();
                CreditCardType           creditCardType           = new CreditCardType();
                creditCardType = creditCardTypeRepository.GetCreditCardType(creditCardTypeId);
                if (creditCardType != null)
                {
                    creditCard.CreditCardTypeDescription = creditCardType.CreditCardTypeDescription;
                }
            }

            //If Linked to ClientSubUnit
            CreditCardClientSubUnit           creditCardClientSubUnit           = new CreditCardClientSubUnit();
            CreditCardClientSubUnitRepository creditCardClientSubUnitRepository = new CreditCardClientSubUnitRepository();

            creditCardClientSubUnit = creditCardClientSubUnitRepository.GetCreditCardClientSubUnit(creditCard.CreditCardId);

            if (creditCardClientSubUnit != null)
            {
                ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                ClientSubUnit           clientSubUnit           = new ClientSubUnit();
                clientSubUnit = clientSubUnitRepository.GetClientSubUnit(creditCardClientSubUnit.ClientSubUnitGuid);
                if (clientSubUnit != null)
                {
                    creditCard.ClientSubUnitGuid = clientSubUnit.ClientSubUnitGuid;
                    creditCard.ClientSubUnitName = clientSubUnit.ClientSubUnitName;
                    creditCard.ClientTopUnitGuid = clientSubUnit.ClientTopUnit.ClientTopUnitGuid;
                    creditCard.ClientTopUnitName = clientSubUnit.ClientTopUnit.ClientTopUnitName;
                }
            }

            //If Linked to ClientAccount
            CreditCardClientAccount           creditCardClientAccount           = new CreditCardClientAccount();
            CreditCardClientAccountRepository creditCardClientAccountRepository = new CreditCardClientAccountRepository();

            creditCardClientAccount = creditCardClientAccountRepository.GetCreditCardClientAccount(creditCard.CreditCardId);

            if (creditCardClientAccount != null)
            {
                ClientAccountRepository clientAccountRepository = new ClientAccountRepository();
                ClientAccount           clientAccount           = new ClientAccount();
                clientAccount = clientAccountRepository.GetClientAccount(creditCardClientAccount.ClientAccountNumber, creditCardClientAccount.SourceSystemCode);
                if (clientAccount != null)
                {
                    creditCard.ClientAccountNumber = clientAccount.ClientAccountNumber;
                    creditCard.ClientAccountName   = clientAccount.ClientAccountName;
                    creditCard.SourceSystemCode    = clientAccount.SourceSystemCode;
                }
            }


            HierarchyRepository hierarchyRepository = new HierarchyRepository();

            fnDesktopDataAdmin_SelectCreditCardHierarchy_v1Result hierarchy = new fnDesktopDataAdmin_SelectCreditCardHierarchy_v1Result();

            hierarchy = GetGroupHierarchy(creditCard.CreditCardId);

            if (hierarchy == null)
            {
            }
            else
            {
                creditCard.HierarchyType = hierarchy.HierarchyType;
                creditCard.HierarchyCode = hierarchy.HierarchyCode.ToString();
                creditCard.HierarchyItem = hierarchy.HierarchyName.Trim();

                if (hierarchy.HierarchyType == "ClientSubUnitTravelerType")
                {
                    creditCard.ClientSubUnitGuid = hierarchy.HierarchyCode.ToString();
                    creditCard.ClientSubUnitName = hierarchy.HierarchyName.Trim();
                    creditCard.TravelerTypeGuid  = hierarchy.TravelerTypeGuid;
                    creditCard.TravelerTypeName  = hierarchy.TravelerTypeName.Trim();
                }
            }
        }
        //Export Items to CSV
        public byte[] Export(string id)
        {
            StringBuilder sb = new StringBuilder();

            //Add Headers
            List <string> headers = new List <string>
            {
                "ClientSubUnitGuid",
                "GDSCode",
                "BookingChannel",
                "ProductChannel",
                "BookingPseudoCityOrOfficeId",
                "TicketingPseudoCityOrOfficeId",
                "DesktopUsed",
                "AdditionalBookingComment",
                "CreationTimestamp",
                "LastUpdateTimestamp"
            };

            sb.AppendLine(String.Join(",", headers.Select(x => x.ToString()).ToArray()));

            //Get ClientSubUnit
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
            ClientSubUnit           clientSubUnit           = clientSubUnitRepository.GetClientSubUnit(id);

            //Add Items
            List <BookingChannel> bookingChannels = db.BookingChannels.Where(x => x.ClientSubUnitGuid == clientSubUnit.ClientSubUnitGuid).ToList();

            foreach (BookingChannel item in bookingChannels)
            {
                string date_format = "MM/dd/yy HH:mm";

                //BookingChannelTypeDescription
                string bookingChannelTypeDescription = string.Empty;
                if (item.BookingChannelTypeId != null)
                {
                    BookingChannelTypeRepository bookingChannelTypeRepository = new BookingChannelTypeRepository();
                    BookingChannelType           bookingChannelType           = bookingChannelTypeRepository.GetBookingChannelType(Int32.Parse(item.BookingChannelTypeId.ToString()));
                    if (bookingChannelType != null)
                    {
                        bookingChannelTypeDescription = bookingChannelType.BookingChannelTypeDescription;
                    }
                }

                //ProductChannelTypeDescription
                string productChannelTypeDescription = string.Empty;
                if (item.ProductChannelTypeId != null)
                {
                    ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();
                    ProductChannelType           productChannelType           = productChannelTypeRepository.GetProductChannelType(Int32.Parse(item.ProductChannelTypeId.ToString()));
                    if (productChannelType != null)
                    {
                        productChannelTypeDescription = productChannelType.ProductChannelTypeDescription;
                    }
                }

                //DesktopUsedTypeDescription
                string desktopUsedTypeDescription = string.Empty;
                if (item.DesktopUsedTypeId != null)
                {
                    DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();
                    DesktopUsedType           desktopUsedType           = desktopUsedTypeRepository.GetDesktopUsedType(Int32.Parse(item.DesktopUsedTypeId.ToString()));
                    if (desktopUsedType != null)
                    {
                        desktopUsedTypeDescription = desktopUsedType.DesktopUsedTypeDescription;
                    }
                }

                //AdditionalBookingComments
                StringBuilder additionalBookingCommentsList = new StringBuilder();
                AdditionalBookingCommentRepository additionalBookingCommentRepository = new AdditionalBookingCommentRepository();
                List <AdditionalBookingComment>    additionalBookingComments          = additionalBookingCommentRepository.GetAdditionalBookingComments(item.BookingChannelId);
                foreach (AdditionalBookingComment additionalBookingComment in additionalBookingComments)
                {
                    additionalBookingCommentsList.AppendFormat("{0} - {1}; ", additionalBookingComment.AdditionalBookingCommentDescription, additionalBookingComment.LanguageCode);
                }

                sb.AppendFormat(
                    "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}",

                    clientSubUnit != null && !string.IsNullOrEmpty(clientSubUnit.ClientSubUnitGuid) ? clientSubUnit.ClientSubUnitGuid : "",
                    item.GDSCode != null && !string.IsNullOrEmpty(item.GDSCode) ? item.GDSCode : "",
                    bookingChannelTypeDescription != null && !string.IsNullOrEmpty(bookingChannelTypeDescription) ? bookingChannelTypeDescription : "",
                    productChannelTypeDescription != null && !string.IsNullOrEmpty(productChannelTypeDescription) ? productChannelTypeDescription : "",
                    item.BookingPseudoCityOrOfficeId != null && !string.IsNullOrEmpty(item.BookingPseudoCityOrOfficeId) ? item.BookingPseudoCityOrOfficeId : "",
                    item.TicketingPseudoCityOrOfficeId != null && !string.IsNullOrEmpty(item.TicketingPseudoCityOrOfficeId) ? item.TicketingPseudoCityOrOfficeId : "",
                    desktopUsedTypeDescription != null && !string.IsNullOrEmpty(desktopUsedTypeDescription) ? desktopUsedTypeDescription : "",
                    additionalBookingCommentsList != null && !string.IsNullOrEmpty(additionalBookingCommentsList.ToString()) ? string.Format("\"{0}\"", additionalBookingCommentsList) : "",
                    item.CreationTimestamp != null && item.CreationTimestamp.HasValue ? item.CreationTimestamp.Value.ToString(date_format) : "",
                    item.LastUpdateTimestamp != null && item.LastUpdateTimestamp.HasValue ? item.LastUpdateTimestamp.Value.ToString(date_format) : ""
                    );

                sb.Append(Environment.NewLine);
            }

            return(Encoding.ASCII.GetBytes(sb.ToString()));
        }
Beispiel #16
0
        private void ValidateLines(ref XmlDocument doc, string[] lines, ref List <string> returnMessages)
        {
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("TeamOutOfOfficeGroups");

            doc.AppendChild(root);

            string returnMessage;

            int i = 0;

            //Store Valid ClientSubUnits
            List <string> validClientSubUnitGuids   = new List <string>();
            List <string> invalidClientSubUnitGuids = new List <string>();

            //loop through CSV lines
            foreach (string line in lines)
            {
                i++;

                if (i > 1)                 //ignore first line with titles
                {
                    Regex    csvParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
                    String[] cells     = csvParser.Split(line);

                    //extract the data items from the file
                    string clientSubUnitGuid        = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[0]));                          //Required
                    string primaryBackupTeamValue   = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[1]));                          //Required
                    string secondaryBackupTeamValue = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[2]));
                    string tertiaryBackupTeamValue  = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[3]));

                    //Build the XML Element for items

                    XmlElement xmlTeamOutOfOfficeGroupItem = doc.CreateElement("TeamOutOfOfficeGroupItem");

                    //Validate data

                    /* Client SubUnit Guid */

                    //Required
                    if (string.IsNullOrEmpty(clientSubUnitGuid) == true)
                    {
                        returnMessage = "Row " + i + ": Client SubUnit Guid is missing. Please provide a Client SubUnit Guid";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else
                    {
                        bool existingValidClient   = validClientSubUnitGuids.Contains(clientSubUnitGuid);
                        bool existingInvalidClient = invalidClientSubUnitGuids.Contains(clientSubUnitGuid);

                        //Check ClientSubUnit is valid
                        if (existingInvalidClient)
                        {
                            //Error: ClientSubUnit is invalid
                            returnMessage = string.Format("Row " + i + ": ClientSubUnitGuid {0} is invalid. Please provide a valid Client SubUnit Guid", clientSubUnitGuid);
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else if (existingValidClient)
                        {
                            //No processing required as already marked as valid
                        }
                        else
                        {
                            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
                            ClientSubUnit           clientSubUnit           = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);
                            if (clientSubUnit == null)
                            {
                                //Error: ClientSubUnit is invalid
                                returnMessage = string.Format("Row " + i + ": ClientSubUnitGuid {0} is invalid. Please provide a valid Client SubUnit Guid", clientSubUnitGuid);
                                if (!returnMessages.Contains(returnMessage))
                                {
                                    returnMessages.Add(returnMessage);
                                }

                                if (!invalidClientSubUnitGuids.Contains(clientSubUnitGuid))
                                {
                                    invalidClientSubUnitGuids.Add(clientSubUnitGuid);
                                }
                            }
                            else
                            {
                                //We have a valid Client SubUnit, now check TeamOutOfOfficeGroupClientSubUnit
                                List <TeamOutOfOfficeGroupClientSubUnit> teamOutOfOfficeGroupClientSubUnits = db.TeamOutOfOfficeGroupClientSubUnits.Where(x => x.ClientSubUnitGuid == clientSubUnitGuid).ToList();
                                if (teamOutOfOfficeGroupClientSubUnits.Count > 0)
                                {
                                    //Error: ClientSubUnit relationship already exists
                                    returnMessage = string.Format("Row " + i + ": ClientSubUnitGuid {0} is not unique. Please update existing Team Out of Office Group", clientSubUnitGuid);
                                    if (!returnMessages.Contains(returnMessage))
                                    {
                                        returnMessages.Add(returnMessage);
                                    }

                                    if (!invalidClientSubUnitGuids.Contains(clientSubUnitGuid))
                                    {
                                        invalidClientSubUnitGuids.Add(clientSubUnitGuid);
                                    }
                                }
                                else
                                {
                                    //ClientSubUnitGuid must have an entry in the IsPrimaryTeamForSub table
                                    List <IsPrimaryTeamForSub> primaryTeamForClientSubUnits = db.IsPrimaryTeamForSubs.Where(x => x.ClientSubUnitGuid == clientSubUnitGuid).ToList();
                                    if (primaryTeamForClientSubUnits.Count == 0)
                                    {
                                        //Error: ClientSubUnit relationship already exists
                                        returnMessage = string.Format("Row " + i + ": ClientSubUnitGuid {0} does not have a Primary Team setup. Please complete in Client Wizard for this ClientSubUnitGuid", clientSubUnitGuid);
                                        if (!returnMessages.Contains(returnMessage))
                                        {
                                            returnMessages.Add(returnMessage);
                                        }

                                        if (!invalidClientSubUnitGuids.Contains(clientSubUnitGuid))
                                        {
                                            invalidClientSubUnitGuids.Add(clientSubUnitGuid);
                                        }
                                    }
                                    else
                                    {
                                        if (!validClientSubUnitGuids.Contains(clientSubUnitGuid))
                                        {
                                            validClientSubUnitGuids.Add(clientSubUnitGuid);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    XmlElement xmlClientSubUnitGuid = doc.CreateElement("ClientSubUnitGuid");
                    xmlClientSubUnitGuid.InnerText = clientSubUnitGuid;
                    xmlTeamOutOfOfficeGroupItem.AppendChild(xmlClientSubUnitGuid);

                    //Primary Backup Team
                    int primaryBackupTeamId = 0;
                    if (string.IsNullOrEmpty(primaryBackupTeamValue) || !Int32.TryParse(primaryBackupTeamValue, out primaryBackupTeamId))
                    {
                        //Error: PrimaryBackupTeamId is invalid
                        returnMessage = string.Format("Row " + i + ": PrimaryBackupTeamId is missing. Please provide a Team Id", clientSubUnitGuid);
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else
                    {
                        TeamRepository teamRepository    = new TeamRepository();
                        Team           primaryBackupTeam = teamRepository.GetTeam(primaryBackupTeamId);
                        if (primaryBackupTeam == null)
                        {
                            //Error: PrimaryBackupTeamId is invalid
                            returnMessage = string.Format("Row " + i + ": PrimaryBackupTeamId {0} is invalid. Please provide a valid Team Id", primaryBackupTeamValue);
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    XmlElement xmlPrimaryBackupTeamId = doc.CreateElement("PrimaryBackupTeamId");
                    xmlPrimaryBackupTeamId.InnerText = primaryBackupTeamValue;
                    xmlTeamOutOfOfficeGroupItem.AppendChild(xmlPrimaryBackupTeamId);

                    //Secondary Backup Team
                    if (!string.IsNullOrEmpty(secondaryBackupTeamValue))
                    {
                        int secondaryBackupTeamId = 0;
                        if (!Int32.TryParse(secondaryBackupTeamValue, out secondaryBackupTeamId))
                        {
                            //Error: SecondaryBackupTeamId is invalid
                            returnMessage = string.Format("Row " + i + ": SecondaryBackupTeamId {0} is invalid. Please provide a valid Team Id", secondaryBackupTeamValue);
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else
                        {
                            TeamRepository teamRepository      = new TeamRepository();
                            Team           secondaryBackupTeam = teamRepository.GetTeam(secondaryBackupTeamId);
                            if (secondaryBackupTeam == null)
                            {
                                //Error: SecondaryBackupTeamId is invalid
                                returnMessage = string.Format("Row " + i + ": SecondaryBackupTeamId {0} is invalid. Please provide a valid Team Id", secondaryBackupTeamValue);
                                if (!returnMessages.Contains(returnMessage))
                                {
                                    returnMessages.Add(returnMessage);
                                }
                            }
                        }
                    }

                    XmlElement xmlSecondaryBackupTeamId = doc.CreateElement("SecondaryBackupTeamId");
                    xmlSecondaryBackupTeamId.InnerText = secondaryBackupTeamValue;
                    xmlTeamOutOfOfficeGroupItem.AppendChild(xmlSecondaryBackupTeamId);

                    //Tertiary Backup Team
                    if (!string.IsNullOrEmpty(tertiaryBackupTeamValue))
                    {
                        int tertiaryBackupTeamId = 0;
                        if (!Int32.TryParse(tertiaryBackupTeamValue, out tertiaryBackupTeamId))
                        {
                            //Error: TertiaryBackupTeamId is invalid
                            returnMessage = string.Format("Row " + i + ": TertiaryBackupTeamId {0} is invalid. Please provide a valid Team Id", tertiaryBackupTeamValue);
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else
                        {
                            TeamRepository teamRepository     = new TeamRepository();
                            Team           tertiaryBackupTeam = teamRepository.GetTeam(tertiaryBackupTeamId);
                            if (tertiaryBackupTeam == null)
                            {
                                //Error: TertiaryBackupTeamId is invalid
                                returnMessage = string.Format("Row " + i + ": TertiaryBackupTeamId {0} is invalid. Please provide a valid Team Id", tertiaryBackupTeamValue);
                                if (!returnMessages.Contains(returnMessage))
                                {
                                    returnMessages.Add(returnMessage);
                                }
                            }
                        }
                    }

                    XmlElement xmlTertiaryBackupTeamId = doc.CreateElement("TertiaryBackupTeamId");
                    xmlTertiaryBackupTeamId.InnerText = tertiaryBackupTeamValue;
                    xmlTeamOutOfOfficeGroupItem.AppendChild(xmlTertiaryBackupTeamId);

                    //Attach the XML Element for an item to the Document
                    root.AppendChild(xmlTeamOutOfOfficeGroupItem);
                }
            }

            if (i == 0)
            {
                returnMessage = "There is no data in the file";
                returnMessages.Add(returnMessage);
            }
        }
        //Update Team ClientSubUnits
        public WizardMessages UpdateTeamClientSubUnits(TeamWizardVM teamChanges, WizardMessages wizardMessages)
        {
            Team team = new Team();

            team = teamChanges.Team;
            bool changesExist = false;

            // Create the xml document container
            XmlDocument    doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);// Create the root element
            XmlElement root = doc.CreateElement("TeamClientSubUnits");

            doc.AppendChild(root);

            ClientSubUnitTeamRepository clientSubUnitTeamRepository = new ClientSubUnitTeamRepository();
            ClientSubUnitRepository     clientSubUnitRepository     = new ClientSubUnitRepository();

            if (teamChanges.ClientSubUnitsAdded != null)
            {
                if (teamChanges.ClientSubUnitsAdded.Count > 0)
                {
                    changesExist = true;
                    XmlElement xmlClientSubUnitsAdded = doc.CreateElement("ClientSubUnitsAdded");


                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAdded)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);

                        XmlElement xmlClientSubUnit = doc.CreateElement("ClientSubUnit");
                        xmlClientSubUnitsAdded.AppendChild(xmlClientSubUnit);

                        XmlElement xmlClientSubUnitName = doc.CreateElement("ClientSubUnitName");
                        xmlClientSubUnitName.InnerText = clientSubUnit.ClientSubUnitName;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitName);

                        XmlElement xmlClientSubUnitGuid = doc.CreateElement("ClientSubUnitGuid");
                        xmlClientSubUnitGuid.InnerText = item.ClientSubUnitGuid;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitGuid);

                        XmlElement xmlIncludeInClientDroplistFlag = doc.CreateElement("IncludeInClientDroplistFlag");
                        xmlIncludeInClientDroplistFlag.InnerText = item.IncludeInClientDroplistFlag == true ? "1" : "0";
                        xmlClientSubUnit.AppendChild(xmlIncludeInClientDroplistFlag);
                    }
                    root.AppendChild(xmlClientSubUnitsAdded);
                }
            }
            if (teamChanges.ClientSubUnitsRemoved != null)
            {
                if (teamChanges.ClientSubUnitsRemoved.Count > 0)
                {
                    changesExist = true;
                    XmlElement xmlClientSubUnitsRemoved = doc.CreateElement("ClientSubUnitsRemoved");

                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsRemoved)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);

                        XmlElement xmlClientSubUnit = doc.CreateElement("ClientSubUnit");
                        xmlClientSubUnitsRemoved.AppendChild(xmlClientSubUnit);

                        XmlElement xmlClientSubUnitName = doc.CreateElement("ClientSubUnitName");
                        xmlClientSubUnitName.InnerText = clientSubUnit.ClientSubUnitName;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitName);

                        XmlElement xmlClientSubUnitGuid = doc.CreateElement("ClientSubUnitGuid");
                        xmlClientSubUnitGuid.InnerText = item.ClientSubUnitGuid;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitGuid);
                    }
                    root.AppendChild(xmlClientSubUnitsRemoved);
                }
            }

            if (teamChanges.ClientSubUnitsAltered != null)
            {
                if (teamChanges.ClientSubUnitsAltered.Count > 0)
                {
                    changesExist = true;
                    XmlElement xmlClientSubUnitsAltered = doc.CreateElement("ClientSubUnitsAltered");

                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAltered)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);

                        XmlElement xmlClientSubUnit = doc.CreateElement("ClientSubUnit");
                        xmlClientSubUnitsAltered.AppendChild(xmlClientSubUnit);

                        XmlElement xmlClientSubUnitName = doc.CreateElement("ClientSubUnitName");
                        xmlClientSubUnitName.InnerText = clientSubUnit.ClientSubUnitName;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitName);

                        XmlElement xmlClientSubUnitGuid = doc.CreateElement("ClientSubUnitGuid");
                        xmlClientSubUnitGuid.InnerText = item.ClientSubUnitGuid;
                        xmlClientSubUnit.AppendChild(xmlClientSubUnitGuid);

                        XmlElement xmlIncludeInClientDroplistFlag = doc.CreateElement("IncludeInClientDroplistFlag");
                        xmlIncludeInClientDroplistFlag.InnerText = item.IncludeInClientDroplistFlag == true ? "1" : "0";
                        xmlClientSubUnit.AppendChild(xmlIncludeInClientDroplistFlag);
                    }
                    root.AppendChild(xmlClientSubUnitsAltered);
                }
            }
            if (changesExist)
            {
                string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

                var output = (from n in db.spDDAWizard_UpdateTeamClientSubUnits_v1(
                                  team.TeamId,
                                  System.Xml.Linq.XElement.Parse(doc.OuterXml),
                                  adminUserGuid)
                              select n).ToList();

                foreach (spDDAWizard_UpdateTeamClientSubUnits_v1Result message in output)
                {
                    wizardMessages.AddMessage(message.MessageText.ToString(), (bool)message.Success);
                }
            }
            return(wizardMessages);
        }
        //Compare two Teams and return a list of messages about changes
        public WizardMessages BuildTeamChangeMessages(WizardMessages wizardMessages, Team originalTeam, TeamWizardVM teamChanges)
        {
            TeamRepository          teamRepository          = new TeamRepository();
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
            SystemUserRepository    systemUserRepository    = new SystemUserRepository();

            Team updatedTeam = new Team();

            updatedTeam = teamChanges.Team;
            //teamRepository.EditGroupForDisplay(updatedTeam); removed- gets info from original Team

            if (originalTeam == null)
            {
                wizardMessages.AddMessage("A new Team \"" + updatedTeam.TeamName + "\"has been added.", true);
            }
            else
            {
                if (originalTeam.TeamName != updatedTeam.TeamName)
                {
                    wizardMessages.AddMessage("Team Name will be updated to \"" + updatedTeam.TeamName + "\".", true);
                }

                if (originalTeam.TeamEmail != updatedTeam.TeamEmail)
                {
                    wizardMessages.AddMessage("Team Email will be updated to \"" + updatedTeam.TeamEmail + "\".", true);
                }

                if (originalTeam.TeamPhoneNumber != updatedTeam.TeamPhoneNumber)
                {
                    wizardMessages.AddMessage("Team phone Number will be updated to \"" + updatedTeam.TeamPhoneNumber + "\".", true);
                }
                if (originalTeam.CityCode != updatedTeam.CityCode)
                {
                    wizardMessages.AddMessage("Team City Code will be updated to \"" + updatedTeam.CityCode + "\".", true);
                }
                if (originalTeam.TeamQueue != updatedTeam.TeamQueue)
                {
                    wizardMessages.AddMessage("Team Queue will be updated to \"" + updatedTeam.TeamQueue + "\".", true);
                }


                if (originalTeam.TeamTypeCode != updatedTeam.TeamTypeCode)
                {
                    TeamType           teamType           = new TeamType();
                    TeamTypeRepository teamTypeRepository = new TeamTypeRepository();
                    teamType = teamTypeRepository.GetTeamType(updatedTeam.TeamTypeCode);
                    wizardMessages.AddMessage("Team Type will be updated to \"" + teamType.TeamTypeDescription + "\".", true);
                }

                if (originalTeam.HierarchyType != updatedTeam.HierarchyType)
                {
                    wizardMessages.AddMessage("Hierarchy will be updated to \"" + updatedTeam.HierarchyType + "\".", true);
                }

                if (originalTeam.HierarchyItem != updatedTeam.HierarchyItem)
                {
                    wizardMessages.AddMessage(updatedTeam.HierarchyType + " value will be updated to \"" + updatedTeam.HierarchyItem + "\".", true);
                }
                if (originalTeam.TravelerTypeGuid != updatedTeam.TravelerTypeGuid)
                {
                    wizardMessages.AddMessage("TravelerType will be updated to \"" + updatedTeam.TravelerTypeName + "\".", true);
                }
            }

            if (teamChanges.SystemUsersAdded != null)
            {
                if (teamChanges.SystemUsersAdded.Count > 0)
                {
                    foreach (SystemUser item in teamChanges.SystemUsersAdded)
                    {
                        SystemUser systemUser = new SystemUser();
                        systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid);
                        if (systemUser != null)
                        {
                            wizardMessages.AddMessage("You will add User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true);
                        }
                    }
                }
            }
            if (teamChanges.SystemUsersRemoved != null)
            {
                if (teamChanges.SystemUsersRemoved.Count > 0)
                {
                    foreach (SystemUser item in teamChanges.SystemUsersRemoved)
                    {
                        SystemUser systemUser = new SystemUser();
                        systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid);
                        if (systemUser != null)
                        {
                            wizardMessages.AddMessage("You will remove User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true);
                        }
                    }
                }
            }
            if (teamChanges.ClientSubUnitsAdded != null)
            {
                if (teamChanges.ClientSubUnitsAdded.Count > 0)
                {
                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAdded)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);
                        if (clientSubUnit != null)
                        {
                            wizardMessages.AddMessage("You will add ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true);
                        }
                    }
                }
            }
            if (teamChanges.ClientSubUnitsRemoved != null)
            {
                if (teamChanges.ClientSubUnitsRemoved.Count > 0)
                {
                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsRemoved)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);
                        if (clientSubUnit != null)
                        {
                            wizardMessages.AddMessage("You will remove ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true);
                        }
                    }
                }
            }

            if (teamChanges.ClientSubUnitsAltered != null)
            {
                if (teamChanges.ClientSubUnitsAltered.Count > 0)
                {
                    foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAltered)
                    {
                        ClientSubUnit clientSubUnit = new ClientSubUnit();
                        clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid);
                        if (clientSubUnit != null)
                        {
                            wizardMessages.AddMessage("You will alter ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true);
                        }
                    }
                }
            }
            return(wizardMessages);
        }