public bool MergeLOB(string listLob, int lOperation) { if (lOperation != addLobOperation && lOperation != deleteLobOperation) { return(false); } bool bUpdateNeeded = false; var dicLob = new SortedDictionary <string, string>(); string[] myList = Lob.Split(DecodeLobCharacter, StringSplitOptions.RemoveEmptyEntries); foreach (string strLob in myList) { dicLob[strLob.Trim()] = strLob.Trim(); } myList = listLob.Split(DecodeLobCharacter, StringSplitOptions.RemoveEmptyEntries); foreach (string strLob in myList) { string strLobTrimmed = strLob.Trim(); if (!_validLobs.Any(validLob => string.Compare(validLob, strLobTrimmed, true) == 0)) { continue; // Do not add undesired LOBs } if (lOperation == addLobOperation) { dicLob[strLobTrimmed] = strLobTrimmed; } else { dicLob.Remove(strLobTrimmed); } } // NOTE: NOT CHECKING FOR EMPTY LOB LIST StringBuilder sbLob = new StringBuilder(255); foreach (KeyValuePair <string, string> valuePair in dicLob) { sbLob.AppendFormat("{0} ;", valuePair.Key); } // Now check if LOB has changed. if (Lob.CompareTo(sbLob.ToString()) != 0) { bUpdateNeeded = true; Lob = sbLob.ToString(); // Also update the Upload_key string[] strUpload_key = UploadKey.Split("/".ToCharArray(), StringSplitOptions.None); strUpload_key[5] = sbLob.ToString(); UploadKey = string.Join("/", strUpload_key); } return(bUpdateNeeded); }
/// <summary> /// /// </summary> /// <param name="record"></param> public bool MergeLOB(SpecificDestinationActiveRecord record) { bool bUpdateNeeded = false; var dicLob = new SortedDictionary <string, string>(); string[] myList = Lob.Split(DecodeLobCharacter, StringSplitOptions.RemoveEmptyEntries); foreach (string strLob in myList) { dicLob[strLob.Trim()] = strLob.Trim(); } myList = record.Lob.Split(DecodeLobCharacter, StringSplitOptions.RemoveEmptyEntries); foreach (string strLob in myList) { dicLob[strLob.Trim()] = strLob.Trim(); } StringBuilder sbLob = new StringBuilder(255); foreach (KeyValuePair <string, string> valuePair in dicLob) { sbLob.AppendFormat("{0} ;", valuePair.Key); } // Now check if LOB has changed. if (Lob.CompareTo(sbLob.ToString()) != 0) { bUpdateNeeded = true; Lob = sbLob.ToString(); // Also update the Upload_key string[] strUpload_key = UploadKey.Split("/".ToCharArray(), StringSplitOptions.None); strUpload_key[5] = sbLob.ToString(); UploadKey = string.Join("/", strUpload_key); } return(bUpdateNeeded); }