/// <summary> /// Delete one item /// </summary> /// <param name="queueItem"></param> /// Called from loader public static void DeleteQueueItem(GTPQueue gTPQueue, bool deleteAll = false) { try { ConnectionHelper.Connect(AutoCreateOption.None); Session session = new Session(XpoDefault.DataLayer); { if (deleteAll) { IQueryable <Queue> ps = new XPQuery <Queue>(session); foreach (Queue p in ps) { p.Delete(); } } else { IQueryable <Queue> ps = new XPQuery <Queue>(session).Where(q => q.Id.CompareTo(gTPQueue.Id) == 0); foreach (Queue p in ps) { p.Delete(); } } session.DataLayer.Dispose(); } } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPQueue", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } }
public static string InsertInterface(GTPInterface gTPInterface) { try { ConnectionHelper.Connect(AutoCreateOption.None); Session session = new Session(XpoDefault.DataLayer); { var interfaceInstance = new Models.GTPModel.Interface(session); interfaceInstance.Id = Guid.NewGuid(); //Values from WPF interfaceInstance.Description = gTPInterface.Description; interfaceInstance.TPCode = gTPInterface.TPCode; interfaceInstance.SIDECode = gTPInterface.SIDECode; interfaceInstance.NSICode = gTPInterface.NSICode; interfaceInstance.Frequency = gTPInterface.Frequency; interfaceInstance.Name = gTPInterface.Name; interfaceInstance.ContractName = gTPInterface.ContractName; interfaceInstance.IsActive = gTPInterface.IsActif; interfaceInstance.DtCrea = DateTime.Now; interfaceInstance.Save(); } } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPInterface", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(ex.ToString()); } return(string.Empty); }
/// <summary> /// Get the status of a QueueItem /// </summary> /// <param name="queueItem"></param> public static void GetStatusQueueItem(QueueItem queueItem) { try { ConnectionHelper.Connect(AutoCreateOption.None); using (Session session = new Session(XpoDefault.DataLayer)) { Queue r = new XPQuery <Queue>(session).SingleOrDefault(q => q.Id.CompareTo(queueItem.IdQueue) == 0); queueItem.FichierObjetIn = r.ObjectIn; queueItem.FichierObjetOut = r.ObjectOut; queueItem.ListeDesIdsAzureSeparesParUnPipe = r.ObjectsIds; queueItem.Etat = (QueueStatesEnum)r.Status; session.DataLayer.Dispose(); } } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPQueue", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); queueItem.Etat = QueueStatesEnum.EnErreur; queueItem.Message = "Record not found"; } }
/// <summary> /// Add a new QueuItem. /// </summary> /// <param name="queueItem"></param> public static void AddIntoQueue(QueueItem queueItem, BusinessConfig businessConfig) { try { log.Info("IN AddIntoQueue 1.0"); queueItem.Message = "Ok from AddIntoQueue"; //ConnectionHelper.Connect(AutoCreateOption.None); Session session = businessConfig.GetSession(ComptaPlusConfig.Constants.GTPKey); //Session session = new Session(XpoDefault.DataLayer); { var queue = new Queue(session); queue.DtCrea = DateTime.Now; queue.Id = queueItem.IdQueue; queue.RecIdERP = queueItem.IdQueue; queue.ObjectIn = queueItem.FichierObjetIn; queue.ObjectsIds = queueItem.ListeDesIdsAzureSeparesParUnPipe; queue.Status = (int)QueueStatesEnum.PasEncoreTraite; queue.Interface = queueItem.TPInterfaceID; queue.IsActive = true; queue.Priority = queueItem.Priority; queue.Save(); //session.DataLayer.Dispose(); //businessConfig.DisposeSessions(); } log.Info("IN AddIntoQueue 1.3"); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPQueue", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } }
/// <summary> /// Abandonned methods, will be managed by DB jobs and DB backups. /// </summary> /// <param name="dayAmount"></param> private static void DeleteAccessWs(int dayAmount) { try { //var oldDateFromWhichToDelete = DateTime.Now.AddDays(-dayAmount); //ConnectionHelper.Connect(AutoCreateOption.None); //Session session = new Session(XpoDefault.DataLayer); //{ // IQueryable<Access> ps = new XPQuery<Access>(session).Where(q => q.DtCrea < oldDateFromWhichToDelete); // foreach (Access p in ps) // { // //p.Delete(); // } // session.DataLayer.Dispose(); //} } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPAccessWs", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } }
/// <summary> /// Operates typical JWT checks on valid dates and other values. /// The only way to know if the token is valid is the NONE throwing /// exception possibly launched by the JWT library. /// </summary> /// <param name="token"></param> /// <returns></returns> public TokenHandler.Models.TokenCheckResult CheckTokenValidity(string tokenToChallange, string privateKey) { TokenHandler.Models.TokenCheckResult tokenCheckResult = new TokenHandler.Models.TokenCheckResult(); try { string sec = privateKey; var now = DateTime.UtcNow; var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(System.Text.Encoding.Default.GetBytes(sec)); Microsoft.IdentityModel.Tokens.SecurityToken securityToken; JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler(); TokenValidationParameters validationParameters = new TokenValidationParameters() { ValidAudience = TokenKey.Audience, ValidIssuer = TokenKey.Issuer, ValidateLifetime = true, ValidateIssuerSigningKey = true, LifetimeValidator = this.LifetimeValidator, IssuerSigningKey = securityKey }; handler.ValidateToken( tokenToChallange, validationParameters, out securityToken); tokenCheckResult.IsValidKey = true; } catch (Microsoft.IdentityModel.Tokens.SecurityTokenValidationException e) { tokenCheckResult.IsValidKey = false; tokenCheckResult.HttpStatusCode = HttpStatusCode.Unauthorized; tokenCheckResult.ErrorMessage = string.Format("{0}", e.ToString()); log.Error(FormatMessages.getLogMessage( this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, string.Concat("tokenToChallange:", tokenToChallange, " privateKey: ", " private"), e.ToString())); throw new TokenHandler.CustomException.InvalidTokenException(TokenKey.TokenNotFound); } catch (Exception ex) { tokenCheckResult.IsValidKey = false; tokenCheckResult.HttpStatusCode = HttpStatusCode.Unauthorized; tokenCheckResult.ErrorMessage = string.Format("{0}", ex.ToString()); log.Error(FormatMessages.getLogMessage( this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, string.Concat("tokenToChallange:", tokenToChallange, " privateKey: ", " private"), ex.ToString())); throw new TokenHandler.CustomException.InvalidTokenException(TokenKey.TokenNotFound); } //If we reach this place means the token has been validated by JWT. return(tokenCheckResult); }
public static void InsertAccessWs( Guid transactionGuid, string token, GTPUser gtpUser, string commentaire, BusinessConfig businessConfig) { try { //ConnectionHelper.Connect(AutoCreateOption.None); Session session = businessConfig.GetSession(ComptaPlusConfig.Constants.GTPKey); //Session session = new Session(XpoDefault.DataLayer); { User user = new XPQuery <User>(session).SingleOrDefault(q => q.Id.CompareTo(gtpUser.Id) == 0); var access = new Models.GTPModel.Access(session); access.DtCrea = DateTime.Now; access.Id = transactionGuid; access.Comment = commentaire; access.Token = token; access.User = user; access.IsActive = true; access.Save(); //session.DataLayer.Dispose(); //businessConfig.DisposeSessions(); } /* * BusinessConfig config = new BusinessConfig(); * ConnectionHelper.Connect(AutoCreateOption.None); * //Session session = new Session(XpoDefault.DataLayer); * Session session = config.GetSession("001"); * { * User user = new XPQuery<User>(session).SingleOrDefault(q => q.Id.CompareTo(gtpUser.Id) == 0); * var access = new Models.GTPModel.Access(session); * access.DtCrea = DateTime.Now; * access.Id = transactionGuid; * access.Description = commentaire; * access.Token = token; * access.User = user; * access.IsActive = true; * access.Save(); * session.DataLayer.Dispose(); * } * config.DisposeSessions(); */ } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPAccessWs", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } }
/// <summary> /// Load the queue according to the Policy. /// </summary> /// <param name="queueLoadingPolicy"></param> /// <returns>List<GTPQueue></returns> /// Called from Loader public static List <GTPQueue> GetAllGTPQueues(QueueLoadingPolicy queueLoadingPolicy = null) { //var value = (int)Enum.Parse(typeof(ContractEnum), contractPriority.ContractName); QueueStatesEnum contractEnum = (QueueStatesEnum)System.Enum.ToObject(typeof(QueueStatesEnum), 1); List <GTPQueue> listItemQueues = new List <GTPQueue>(); try { ConnectionHelper.Connect(AutoCreateOption.None); Session session = new Session(XpoDefault.DataLayer); { var queueItems = new XPQuery <Queue>(session).OrderBy(x => x.Priority).ToList(); foreach (var queuItem in queueItems) { var enumValue = (QueueStatesEnum)System.Enum.ToObject(typeof(QueueStatesEnum), queuItem.Status); try { listItemQueues.Add(new GTPQueue() { DateCreation = queuItem.DtCrea, Id = queuItem.Id, PriorityValue = queuItem.Priority, Interface = queuItem.Interface, SerizdIn = queuItem.ObjectIn, SerizdOut = queuItem.ObjectOut, ConcatIdsObjects = queuItem.ObjectsIds, Status = queuItem.Status, StatusEnum = enumValue, StatusEnumToString = enumValue.ToString() }); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPQueue", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } } session.DataLayer.Dispose(); } return(listItemQueues); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPQueue", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(listItemQueues); } }
/// <summary> /// Extracts the Type name from contract list. /// </summary> /// <param name="listOfInterfaceObjects"></param> /// <returns></returns> public static string GetInterfaceTypeNameFromList(object listOfInterfaceObjects) { try { return(GetInterfaceTypeFromList(listOfInterfaceObjects).Name); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "TypeDetector", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); throw ex; } }
/// <summary> /// Extract the Token without the secret header == TokenKey.TokenPrefixRaw /// </summary> /// <param name="authHeader"></param> /// <returns></returns> public string GetTokenFromAuthHeaderString(string authHeader) { try { return(authHeader.StartsWith(TokenHandler.Constants.TokenKey.PrefixSetByTheCallerBeforeTheKey) ? authHeader.Substring(TokenKey.TokenPrefixRaw.Length) : authHeader); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, string.Concat("authHeader:", authHeader), ex.ToString())); } return(string.Empty); }
/// <summary> /// Extracts the Type name from xml string. /// </summary> /// <param name="serializedAsXmlListOfInterfaces"></param> /// <returns></returns> public static string GetInterfaceTypeNameFromXml(string serializedAsXmlListOfInterfaces) { try { var xDocument = XDocument.Parse(serializedAsXmlListOfInterfaces); return(xDocument.Root.Name.ToString().Substring(ContractConst.XmlStartString.Length)); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "TypeDetector", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(ContractEnum.Unknown.ToString()); } }
/// <summary> /// The very place where the token is created. /// </summary> /// <param name="username"></param> /// <returns></returns> public string createToken(string username, int tokenLifeDuration, string privateKey) { try { //Set issued at date DateTime issuedAt = DateTime.UtcNow; //set the time when it expires DateTime expires = DateTime.UtcNow.AddMinutes(tokenLifeDuration); //To encrypt the private token -> http://stackoverflow.com/questions/18223868/how-to-encrypt-jwt-security-token var tokenHandler = new JwtSecurityTokenHandler(); //create an identity and add claims to the user which we want to log in ClaimsIdentity claimsIdentity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }); string sec = privateKey; var now = DateTime.UtcNow; var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(System.Text.Encoding.Default.GetBytes(sec)); var signingCredentials = new Microsoft.IdentityModel.Tokens.SigningCredentials( securityKey, Microsoft.IdentityModel.Tokens.SecurityAlgorithms.HmacSha256Signature); //create the jwt var token = (JwtSecurityToken) tokenHandler.CreateJwtSecurityToken( issuer: TokenKey.Issuer, audience: TokenKey.Audience, subject: claimsIdentity, notBefore: issuedAt, expires: expires, signingCredentials: signingCredentials); var tokenString = tokenHandler.WriteToken(token); return(tokenString); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, string.Concat("username:"******" tokenLifeDuration: ", tokenLifeDuration, " privateKey: ", " privateKey "), ex.ToString())); } return(string.Empty); }
public static List <PriorityQueue.Model.GTPInterface> GetInterfaces() { List <GTPInterface> lisiInterfacess = new List <GTPInterface>(); try { ConnectionHelper.Connect(AutoCreateOption.None); Session session = new Session(XpoDefault.DataLayer); { var interfaces = new XPQuery <Models.GTPModel.Interface>(session).OrderBy(x => x.Name).ToList(); foreach (var interf in interfaces) { try { lisiInterfacess.Add(new GTPInterface() { Name = interf.Name, Id = interf.Id, PriorityId = (interf.Priority != null) ? interf.Priority.Id : new Guid(), PriorityValue = (interf.Priority != null) ? interf.Priority.Code : -1, FakeGuid = (interf.Priority != null) ? false : true, ContractName = interf.ContractName }); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPInterface", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } } session.DataLayer.Dispose(); } return(lisiInterfacess); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPInterface", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(lisiInterfacess); } }
public static List <PriorityQueue.Model.GTPUser> GetUsers(BusinessConfig businessConfig) { List <GTPUser> listUsers = new List <GTPUser>(); try { //ConnectionHelper.Connect(AutoCreateOption.SchemaOnly); Session session = businessConfig.GetSession(ComptaPlusConfig.Constants.GTPKey); //Session session = new Session(XpoDefault.DataLayer); { var users = new XPQuery <Models.GTPModel.User>(session).ToList(); foreach (var user in users) { try { listUsers.Add(new GTPUser() { Name = user.Name, Id = user.Id, PassWord = TokenHandler.Utils.Md5Encryption.DecryptString(user.Password, Security.ToEncryptEncryptPw) }); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPUser", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } } //session.DataLayer.Dispose(); //businessConfig.DisposeSessions(); } return(listUsers); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPUser", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(listUsers); } }
/// <summary> /// Get the complete Authorization string from the header if any. /// </summary> /// <returns></returns> public string GetTokenInHeader() { string header = string.Empty; try { header = WebOperationContext.Current.IncomingRequest.Headers.GetValues(TokenKey.HeaderTokenToUse)[TokenKey.ExpectedPlaceToFindHeader].ToString(); } catch (Exception ex) { header = TokenKey.TokenNotFound; log.Error(FormatMessages.getLogMessage( this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, string.Empty, ex.ToString())); } return(header); }
public static List <PriorityQueue.Model.GTPPriority> GetPriorities() { List <GTPPriority> listPriorities = new List <GTPPriority>(); try { ConnectionHelper.Connect(AutoCreateOption.None); Session session = new Session(XpoDefault.DataLayer); { var priorities = new XPQuery <Models.GTPModel.Priority>(session).OrderBy(x => x.Code).ToList(); foreach (var prio in priorities) { try { listPriorities.Add(new GTPPriority() { Code = prio.Code, Id = prio.Id, Libelle = prio.Label, Description = prio.Description }); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPPriority", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } } session.DataLayer.Dispose(); } return(listPriorities); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "GTPPriority", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); return(listPriorities); } }
public bool CheckNewLoginFormat(string login = null) { if (AssignFieldOnCheck && login != null) { NewLogin = login; } else { login = NewLogin; } var result = _authProvider.CheckLoginFormat(login); _newLoginFormatMessage = FormatMessages.FirstOrDefault(); if (IsChatty) { RaisePropertyChanged(nameof(IsLoginFormatOk)); } return(result); }
public bool CheckPasswordFormat(string password = null) { if (AssignFieldOnCheck && password != null) { Password = password; } else { password = Password; } var result = _authProvider.CheckPasswordFormat(password); //_passwordFormatMessage = Array.Find<string>(FormatMessages, p => true); _passwordFormatMessage = FormatMessages.FirstOrDefault(); if (IsChatty) { RaisePropertyChanged(nameof(IsPasswordFormatOk)); } return(result); }
public bool CheckNewEmailFormat(string email = null) { if (AssignFieldOnCheck && email != null) { NewEmail = email; } else { email = NewEmail; } var result = _authProvider.CheckEmailFormat(email); // _newEmailFormatMessage = Array.Find<string>(FormatMessages, p => true); _newEmailFormatMessage = FormatMessages.FirstOrDefault(); if (IsChatty) { RaisePropertyChanged(nameof(IsEmailFormatOk)); } return(result); }
public bool CheckNewPhoneFormat(string phone = null) { if (AssignFieldOnCheck && phone != null) { NewPhone = phone; } else { phone = NewPhone; } var result = _authProvider.CheckPhoneFormat(phone); // _newPhoneFormatMessage = Array.Find<string>(FormatMessages, p => true); _newPhoneFormatMessage = FormatMessages.FirstOrDefault(); if (IsChatty) { RaisePropertyChanged(nameof(IsPhoneFormatOk)); } return(result); }
/// <summary> /// Extracts the Type from contract list. /// </summary> /// <param name="listOfInterfaceObjects"></param> /// <returns></returns> public static Type GetInterfaceTypeFromList(object listOfInterfaceObjects) { try { if (listOfInterfaceObjects != null) { log.Info("List not NULL"); return(listOfInterfaceObjects.GetType().GetGenericArguments().Single()); } return(null); } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "TypeDetector 3.0", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); throw ex; } }
public bool CheckCodeFormat(string code = null) { if (AssignFieldOnCheck && code != null) { Code = code; } else { code = Code; } var result = _authProvider.CheckCodeFormat(code); // _codeFormatMessage = Array.Find<string>(FormatMessages, p => true); _codeFormatMessage = FormatMessages.FirstOrDefault(); if (IsChatty) { RaisePropertyChanged(nameof(IsCodeFormatOk)); } return(result); }
/// <summary> /// Stores inside SerialiseInOutWS table /// </summary> /// <param name="transactionGuid"></param> /// <param name="serializIn"></param> /// <param name="serializOut"></param> /// <param name="token"></param> public static void InsertAccessWs( Guid transactionGuid, string serializIn, string serializOut, string token, BusinessConfig businessConfig) { //return; try { //ConnectionHelper.Connect(AutoCreateOption.None); Session session = businessConfig.GetSession(ComptaPlusConfig.Constants.GTPKey); //Session session = new Session(XpoDefault.DataLayer); //{ var serializedInOut = new Models.GTPModel.SerializedInOut(session); serializedInOut.DtCrea = DateTime.Now; serializedInOut.Id = transactionGuid; serializedInOut.ObjectsIn = serializIn; serializedInOut.ResponsesOut = serializOut; serializedInOut.Token = token; serializedInOut.IsActive = true; serializedInOut.Save(); //serializedInOut.Session.DataLayer.Dispose(); //session.Disconnect(); //session.DataLayer.Dispose(); //businessConfig.DisposeSessions(); //} } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "SerialiseInOutWS", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } }
/// <summary> /// Convert contracts to xml string. /// </summary> /// <param name="listToSerialize"></param> /// <returns></returns> public static string ListToString(object listToSerialize) { XmlSerializer serializer = null; string serializedValue = string.Empty; try { switch (TypeDetector.GetInterfaceTypeNameFromList(listToSerialize)) { //Response case nameof(ContractEnum.Response): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(Response) }; serializer = new XmlSerializer(typeof(List <Response>), personTypes); serializer.Serialize(textWriter, (List <Response>)listToSerialize); serializedValue = textWriter.ToString(); } break; //PcmnIn01 case nameof(ContractEnum.PcmnIn01): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(PcmnIn01) }; serializer = new XmlSerializer(typeof(List <PcmnIn01>), personTypes); serializer.Serialize(textWriter, (List <PcmnIn01>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxGroupIn361 case nameof(ContractEnum.TaxGroupIn361): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxGroupIn361) }; serializer = new XmlSerializer(typeof(List <TaxGroupIn361>), personTypes); serializer.Serialize(textWriter, (List <TaxGroupIn361>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxItemGroupIn362 case nameof(ContractEnum.TaxItemGroupIn362): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxItemGroupIn362) }; serializer = new XmlSerializer(typeof(List <TaxItemGroupIn362>), personTypes); serializer.Serialize(textWriter, (List <TaxItemGroupIn362>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxCodeIn363 case nameof(ContractEnum.TaxCodeIn363): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxCodeIn363) }; serializer = new XmlSerializer(typeof(List <TaxCodeIn363>), personTypes); serializer.Serialize(textWriter, (List <TaxCodeIn363>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxCodeTaxGroupIn364 case nameof(ContractEnum.TaxCodeTaxGroupIn364): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxCodeTaxGroupIn364) }; serializer = new XmlSerializer(typeof(List <TaxCodeTaxGroupIn364>), personTypes); serializer.Serialize(textWriter, (List <TaxCodeTaxGroupIn364>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxCodeTaxItemGroupIN365 case nameof(ContractEnum.TaxCodeTaxItemGroupIN365): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxCodeTaxItemGroupIN365) }; serializer = new XmlSerializer(typeof(List <TaxCodeTaxItemGroupIN365>), personTypes); serializer.Serialize(textWriter, (List <TaxCodeTaxItemGroupIN365>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxCodeValueIN366 case nameof(ContractEnum.TaxCodeValueIN366): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxCodeValueIN366) }; serializer = new XmlSerializer(typeof(List <TaxCodeValueIN366>), personTypes); serializer.Serialize(textWriter, (List <TaxCodeValueIN366>)listToSerialize); serializedValue = textWriter.ToString(); } break; //TaxCodeLanguageTxtIN367 case nameof(ContractEnum.TaxCodeLanguageTxtIN367): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(TaxCodeLanguageTxtIN367) }; serializer = new XmlSerializer(typeof(List <TaxCodeLanguageTxtIN367>), personTypes); serializer.Serialize(textWriter, (List <TaxCodeLanguageTxtIN367>)listToSerialize); serializedValue = textWriter.ToString(); } break; //DimensionAttributeSetupIn03 case nameof(ContractEnum.DimensionAttributeSetupIn03): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(DimensionAttributeSetupIn03) }; serializer = new XmlSerializer(typeof(List <DimensionAttributeSetupIn03>), personTypes); serializer.Serialize(textWriter, (List <DimensionAttributeSetupIn03>)listToSerialize); serializedValue = textWriter.ToString(); } break; //DimensionAttributeValueIn03 case nameof(ContractEnum.DimensionAttributeValueIn03): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(DimensionAttributeValueIn03) }; serializer = new XmlSerializer(typeof(List <DimensionAttributeValueIn03>), personTypes); serializer.Serialize(textWriter, (List <DimensionAttributeValueIn03>)listToSerialize); serializedValue = textWriter.ToString(); } break; //LedgerJournalNameIn43 case nameof(ContractEnum.LedgerJournalNameIn43): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(LedgerJournalNameIn43) }; serializer = new XmlSerializer(typeof(List <LedgerJournalNameIn43>), personTypes); serializer.Serialize(textWriter, (List <LedgerJournalNameIn43>)listToSerialize); serializedValue = textWriter.ToString(); } break; //FiscalCalendarPeriodIN22 case nameof(ContractEnum.FiscalCalendarPeriodIN22): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(FiscalCalendarPeriodIN22) }; serializer = new XmlSerializer(typeof(List <FiscalCalendarPeriodIN22>), personTypes); serializer.Serialize(textWriter, (List <FiscalCalendarPeriodIN22>)listToSerialize); serializedValue = textWriter.ToString(); } break; case nameof(ContractEnum.AssetService): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(AssetService) }; serializer = new XmlSerializer(typeof(List <AssetService>), personTypes); serializer.Serialize(textWriter, (List <AssetService>)listToSerialize); serializedValue = textWriter.ToString(); } break; case nameof(ContractEnum.AssetBook): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(AssetBook) }; serializer = new XmlSerializer(typeof(List <AssetBook>), personTypes); serializer.Serialize(textWriter, (List <AssetBook>)listToSerialize); serializedValue = textWriter.ToString(); } break; case nameof(ContractEnum.AssetDepreciation): using (StringWriter textWriter = new StringWriter()) { Type[] personTypes = { typeof(AssetDepreciation) }; serializer = new XmlSerializer(typeof(List <AssetDepreciation>), personTypes); serializer.Serialize(textWriter, (List <AssetDepreciation>)listToSerialize); serializedValue = textWriter.ToString(); } break; } } catch (Exception ex) { log.Error(FormatMessages.getLogMessage( "Serialization", System.Reflection.MethodBase.GetCurrentMethod().Name, TokenKey.NoMethodParams, ex.ToString())); } return(serializedValue); }
public void Warn(string nameAction, string warningMessage, string userName, Exception ex) { var message = FormatMessages.FormatLoggerInfoMessage(nameAction, warningMessage, userName); _logger.Warn(message, ex); }
public void Info(string nameAction, string infoMessage, string userName, Exception ex) { var message = FormatMessages.FormatLoggerInfoMessage(nameAction, infoMessage, userName); _logger.Info(message, ex); }
public void Error(string nameAction, string errorMessage, string userName, Exception ex) { var message = FormatMessages.FormatLoggerInfoMessage(nameAction, errorMessage, userName); _logger.Error(message, ex); }