Esempio n. 1
0
 /// <summary>
 /// Détermine si la base de données est vérouillée pour l'utilisateur spécifié.
 /// </summary>
 /// <param name="username">le nom d'utilisateur</param>
 public async Task <bool> IsLocked(string username) =>
 await Task.Run(async() =>
 {
     dynamic param  = new ExpandoObject();
     param.username = username;
     return(await _apiHttpClient.ServiceAsync <bool>(KL2_Server.API, nameof(SharedDatabaseService), nameof(IsLocked), param));
 });
Esempio n. 2
0
        public Task SaveColumnsInfo(string uiPartCode, IDictionary <string, double> columnInfo)
        {
            dynamic param = new ExpandoObject();

            param.uiPartCode = uiPartCode;
            param.columnInfo = columnInfo;
            return(_apiHttpClient.ServiceAsync(KL2_Server.API, nameof(UISettingsService), nameof(SaveColumnsInfo), param));
        }
Esempio n. 3
0
 /// <summary>
 /// Obtient l'utilisateur associé au login spécifié.
 /// </summary>
 /// <param name="username">Le login de l'utilisateur.</param>
 public virtual async Task <User> GetUser(string username, string language = null) =>
 await Task.Run(async() =>
 {
     dynamic param  = new ExpandoObject();
     param.username = username;
     param.language = _localizationManager.CurrentCulture.Name ?? IoC.Resolve <ILocalizationManager>().CurrentCulture.Name;
     return(await _apiHttpClient.ServiceAsync <User>(KL2_Server.API, nameof(AuthenticationService), nameof(GetUser), param));
 });
Esempio n. 4
0
 /// <summary>
 /// Obtient les données pour l'écran Acquérir.
 /// </summary>
 /// <param name="projectId">L'identifiant du projet.</param>
 public virtual async Task <AcquireData> GetAcquireData(int projectId, bool getSyncedVideos = true)
 {
     return(await Task.Run(async() =>
     {
         dynamic param = new ExpandoObject();
         param.projectId = projectId;
         return await _apiHttpClient.ServiceAsync <AcquireData>(KL2_Server.API, nameof(AnalyzeService), nameof(GetAcquireData), param);
     }));
 }
Esempio n. 5
0
 /// <summary>
 /// Obtient les données pour l'écran Acquérir.
 /// </summary>
 /// <param name="projectId">L'identifiant du projet.</param>
 public virtual async Task <AcquireData> GetAcquireData(int projectId) =>
 await Task.Run(async() =>
 {
     dynamic param   = new ExpandoObject();
     param.projectId = projectId;
     return(await _apiHttpClient.ServiceAsync <AcquireData>(KL2_Server.API, nameof(ValidateService), nameof(GetAcquireData), param));
 });
Esempio n. 6
0
 /// <summary>
 /// Exporte un projet.
 /// </summary>
 /// <param name="projectId">L'identifiant du projet.</param>
 public virtual async Task <Stream> ExportProject(int projectId) =>
 await Task.Run(async() =>
 {
     dynamic param   = new ExpandoObject();
     param.projectId = projectId;
     return(await _apiHttpClient.ServiceAsync <Stream>(KL2_Server.API, nameof(ImportExportService), nameof(ExportProject), param));
 });
Esempio n. 7
0
        public async Task <Notification> PushNotification(string body, int notificationTypeId, List <byte[]> attachments, List <string> attachmentNames = null)
        {
            dynamic param = new ExpandoObject();

            param.notificationTypeId = notificationTypeId;
            param.body            = body;
            param.attachments     = attachments;
            param.attachmentNames = attachmentNames;
            return(await _apiHttpClient.ServiceAsync <Notification>(KL2_Server.API, nameof(NotificationService), nameof(PushNotification), param));
        }
Esempio n. 8
0
 /// <summary>
 /// Obtient la configuration des réferentiels.
 /// </summary>
 /// <returns>Lse référentiels.</returns>
 public Task <Referential[]> GetApplicationReferentials() =>
 _apiHttpClient.ServiceAsync <Referential[]>(KL2_Server.API, nameof(ReferentialsService), nameof(GetApplicationReferentials));
Esempio n. 9
0
        /// <summary>
        /// Envoie un rapport d'erreur par ticket.
        /// </summary>
        /// <param name="e">L'exception.</param>
        /// <param name="username">Le nom d'utilisateur.</param>
        /// <param name="company">La société.</param>
        /// <param name="email">L'email.</param>
        /// <param name="additionalInformation">Des informations complémentaires.</param>
        /// <returns>
        ///   <c>true</c> si l'envoi a réussi.
        /// </returns>
        public async Task SendErrorReportTicketAsync(Exception e, string username, string company, string email, string additionalInformation)
        {
            Ticket ticket = new Ticket()
            {
                Email         = DevEmail,
                Name          = username,
                Subject       = "[KL2] Rapport d'erreur",
                EmailConfigId = email_config_id,
                GroupId       = group_id,
                Type          = "Bug",
                CcEmails      = new[] { ccmail }
            };

            StringBuilder sb = new StringBuilder();

            // HEURE
            sb.AppendLine(DateTimeOffset.Now.ToString());

            // Informations client
            sb.AppendLine("Informations client :");
            sb.AppendLine($"Nom : {(!string.IsNullOrEmpty(username) ? username : string.Empty)}");

            sb.AppendLine($"Société : {(!string.IsNullOrEmpty(company) ? company : string.Empty)}");

            sb.AppendLine($"Email : {(!string.IsNullOrEmpty(email) ? email : string.Empty)}");

            sb.AppendLine();


            // VERSION APPLI
            sb.AppendLine($"Version : {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}");
            sb.AppendLine();


            // Informations complémentaires

            /*sb.AppendLine("Informations complémentaires :");
             * if (!string.IsNullOrEmpty(additionalInformation))
             *  sb.AppendLine(additionalInformation);
             * sb.AppendLine();*/


            // Inforamtions licence
            sb.AppendLine("Informations licence :");
            IAPIHttpClient apiClient   = IoC.Resolve <IAPIHttpClient>();
            var            licenseInfo = await apiClient.ServiceAsync <WebProductLicense>(KL2_Server.API, "LicenseService", "GetLicense");

            if (licenseInfo != null && licenseInfo.Status != WebLicenseStatus.NotFound)
            {
                sb.AppendFormat("{0} {1}", licenseInfo.Status, licenseInfo.StatusReason);
            }
            else
            {
                sb.AppendLine("Aucune licence chargée");
            }
            sb.AppendLine();

            // Informations erreur en cours
            sb.AppendLine("Erreur en cours");
            if (e != null)
            {
                sb.AppendLine(e.ToString());
            }
            sb.AppendLine();

            StringBuilder log = new StringBuilder();

            log.AppendLine("Contenu des fichiers de logs");

            try
            {
                foreach (var appender in ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Appenders.OfType <FileAppender>())
                {
                    using (var fs = new FileStream(appender.File, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        using (var sr = new StreamReader(fs, appender.Encoding))
                        {
                            var    lines = new List <string>();
                            string line;
                            while ((line = await sr.ReadLineAsync()) != null)
                            {
                                lines.Add(line);
                            }

                            log.AppendLine();
                            log.AppendLine(appender.File);
                            log.AppendLine();
                            foreach (string l in lines.Skip(lines.Count - LogFilesLinesToInclude).Take(LogFilesLinesToInclude))
                            {
                                log.AppendLine(l);
                            }
                            log.AppendLine();
                            log.AppendLine();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.AppendLine("Impossible de récupérer les fichiers de log. Erreur :");
                log.AppendLine(ex.Message);
            }

            ticket.Description = sb.Replace(Environment.NewLine, "<br />").ToString();

            ticket.Attachments = new Dictionary <string, byte[]>
            {
                ["Log.txt"] = Encoding.UTF8.GetBytes(log.ToString())
            };

            try
            {
                await FreshdeskClient.Instance.SendTicketAsync(ticket);
            }
            catch (Exception ex)
            {
                TraceManager.TraceWarning(ex.Message);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Envoie un rapport d'erreur par email.
        /// </summary>
        /// <param name="e">L'exception.</param>
        /// <param name="username">Le nom d'utilisateur.</param>
        /// <param name="company">La société.</param>
        /// <param name="email">L'email.</param>
        /// <param name="additionalInformation">Des informations complémentaires.</param>
        /// <returns>
        ///   <c>true</c> si l'envoi a réussi.
        /// </returns>
        public async Task <bool> SendErrorReportEmail(Exception e, string username, string company, string email, string additionalInformation)
        {
            string errorReportEmail = ConfigurationManager.AppSettings["ErrorReportEmail"];

            bool sendCopyToDev = false;

#if !DEBUG
            string copyReportEmail = ConfigurationManager.AppSettings["SendReportCopy"];
            if (copyReportEmail != null)
            {
                bool.TryParse(copyReportEmail, out sendCopyToDev);
            }
#endif

            var emailessage = new Email()
            {
                From = errorReportEmail,
                PreferConfigurationFrom = true,
                To      = new string[] { errorReportEmail },
                Subject = "[Ksmed] Rapport d'erreur",
            };

            if (sendCopyToDev)
            {
                emailessage.Bcc = new string[] { DevEmail }
            }
            ;

            emailessage.AttachmentsStreams = new Dictionary <string, Stream>();

            var sb = new StringBuilder();

            // HEURE
            sb.AppendLine(DateTimeOffset.Now.ToString());

            // Informations client
            sb.AppendLine("Informations client :");
            sb.AppendLine("Nom : ");
            if (!string.IsNullOrEmpty(username))
            {
                sb.AppendLine(username);
            }
            else
            {
                sb.AppendLine();
            }

            sb.AppendLine("Société : ");
            if (!string.IsNullOrEmpty(company))
            {
                sb.AppendLine(company);
            }
            else
            {
                sb.AppendLine();
            }

            sb.AppendLine("Email : ");
            if (!string.IsNullOrEmpty(email))
            {
                sb.AppendLine(email);
            }
            else
            {
                sb.AppendLine();
            }

            sb.AppendLine();


            // VERSION APPLI
            sb.AppendLine("Version :");
            sb.AppendLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            sb.AppendLine();


            // Informations complémentaires
            sb.AppendLine("Informations complémentaires :");
            if (!string.IsNullOrEmpty(additionalInformation))
            {
                sb.AppendLine(additionalInformation);
            }
            sb.AppendLine();


            // Informations licence
            sb.AppendLine("Informations licence :");
            IAPIHttpClient apiClient   = IoC.Resolve <IAPIHttpClient>();
            var            licenseInfo = await apiClient.ServiceAsync <WebProductLicense>(KL2_Server.API, "LicenseService", "GetLicense");

            if (licenseInfo != null && licenseInfo.Status != WebLicenseStatus.NotFound)
            {
                sb.AppendFormat("{0} {1}", licenseInfo.Status, licenseInfo.StatusReason);
            }
            else
            {
                sb.AppendLine("Aucune licence chargée");
            }
            sb.AppendLine();

            // Informations erreur en cours
            sb.AppendLine("Erreur en cours");
            if (e != null)
            {
                sb.AppendLine(e.ToString());
            }
            sb.AppendLine();


            sb.AppendLine("Contenu des fichiers de logs");

            try
            {
                foreach (var appender in ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Appenders.OfType <FileAppender>())
                {
                    using (var fs = new FileStream(appender.File, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        using (var sr = new StreamReader(fs, appender.Encoding))
                        {
                            var    lines = new List <string>();
                            string line;
                            while ((line = await sr.ReadLineAsync()) != null)
                            {
                                lines.Add(line);
                            }

                            sb.AppendLine();
                            sb.AppendLine(appender.File);
                            sb.AppendLine();
                            foreach (string l in lines.Skip(lines.Count - LogFilesLinesToInclude).Take(LogFilesLinesToInclude))
                            {
                                sb.AppendLine(l);
                            }
                            sb.AppendLine();
                            sb.AppendLine();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine("Impossible de récupérer les fichiers de log. Erreur :");
                sb.AppendLine(ex.Message);
            }
            sb.AppendLine();

            emailessage.Body = sb.ToString();

            var ret = SendEmail(emailessage);

            return(ret);
        }
    }
Esempio n. 11
0
 /// <summary>
 /// Obtient les langues disponibles pour l'application.
 /// </summary>
 public virtual async Task <Language[]> GetLanguages() =>
 await Task.Run(async() =>
 {
     return(await _apiHttpClient.ServiceAsync <Language[]>(KL2_Server.API, nameof(AppResourceService), nameof(GetLanguages)));
 });