public void UploadConfig(ConfigUploadMessage configUploadMessage) { if (ValidateMessage(configUploadMessage)) { if (TryGetScadaInstance(configUploadMessage.SessionID, out var scadaInstance)) { lock (scadaInstance.SyncRoot) { string tempFileName = AppData.GetTempFileName("upload-config", "zip"); if (ReceiveFile(configUploadMessage.Stream, tempFileName)) { scadaInstance.UnpackConfig(tempFileName, configUploadMessage.ConfigOptions); } } } } else { Log.WriteError(Localization.UseRussian ? "Загружаемая конфигурация не определена или некорректна" : "Uploaded configuration is undefined or incorrect"); } }
/// <summary> /// Check message to load configuration /// </summary> private bool ValidateMessage(ConfigUploadMessage message) { return(message != null && message.ConfigOptions != null || message.Stream != null); }