/// <summary> /// Créer le smartforme sur base d'un dictionnaire pour le plan (généré lors du pdf). /// </summary> /// <param name="Attachement"></param> /// <param name="RisqueAndValue"></param> /// <returns></returns> private PMADRService.CreateMPIAttachment CreateSmartFormPlan(Dictionary <string, string> RisqueAndValue) { PMADRService.CreateMPIAttachment Attachement = new PMADRService.CreateMPIAttachment(); foreach (PropertyInfo property in Attachement.GetType().GetProperties()) { if (RisqueAndValue.ContainsKey(property.Name)) { property.SetValue(Attachement, RisqueAndValue[property.Name], null); } } return(Attachement); }
/// <summary> /// Créer l'attachement à envoyer au webservice (Plan) /// </summary> /// <param name="Plan"></param> /// <param name="UserdId"></param> /// <returns></returns> private PMADRService.CreateMPIAttachment CreatePMAttachement(string UserdId, string Plan, string RiskLevel, Dictionary <string, string> RisqueAndValue) { PMADRService.Attachment Attachement = new PMADRService.Attachment(); Attachement.FileName = $"ADR_{Plan}.pdf"; Attachement.Content = Convert.ToBase64String(File.ReadAllBytes($"{Path.GetTempPath()}\\ADR.pdf")); Attachement.Description = $"ADR risk {RiskLevel}"; PMADRService.CreateMPIAttachment CAttachement = CreateSmartFormPlan(RisqueAndValue); CAttachement.MaintenanceItem = Plan; CAttachement.UserID = UserdId; CAttachement.RiskLevel = RiskLevel; CAttachement.Attachment = new PMADRService.Attachment[] { Attachement }; return(CAttachement); }