Сохраните метафайл в C#

Ваш текущий код попытается проверить .length из results независимо от того, есть ли ошибка . Если есть ошибка, results может быть undefined, поэтому при проверке results.length будет выброшено. Рассмотрим return в нижней части блока if (error):

connection.query(userCheck, function (error, results) {
  if (error) {
    userExists = true;
    res.json({
      status: false,
      message: 'there are some error with query'
    });
    return;
  }
  if (results.length > 0) {
    userExists = true;
    res.json({
      status: false,
      message: 'Username already exists'
    });
  } else {
    userExists = false;
  }
});
6
задан skaffman 11 May 2011 в 11:37
поделиться

3 ответа

This should do what you want:

function notempty($var) {
    return ($var==="0"||$var);
}

Edit: I guess tables only work in the preview, not in actual answer submissions. So please refer to the PHP type comparison tables for more info.

notempty("")       : false
notempty(null)     : false
notempty(undefined): false
notempty(array())  : false
notempty(false)    : false
notempty(true)     : true
notempty(1)        : true
notempty(0)        : false
notempty(-1)       : true
notempty("1")      : true
notempty("0")      : true
notempty("php")    : true

Basically, notempty() is the same as !empty() for all values except for "0", for which it returns true.


Edit: If you are using error_reporting(E_ALL), you will not be able to pass an undefined variable to custom functions by value. And as mercator points out, you should always use E_ALL to conform to best practices. This link (comment #11) he provides discusses why you shouldn't use any form of error suppression for performance and maintainability/debugging reasons. полученный файл сохраняется как файл Portable Network Graphics (PNG). Это происходит потому, что компонент GDI + .NET Framework не имеет кодировщика, который можно использовать для сохранения файлов в формате .wmf или .emf.

2
ответ дан 16 December 2019 в 21:46
поделиться

Несмотря на эту страницу MSDN, можно сохранить настоящий файл EMF. См. Этот вопрос: gdi-c-how-to-save-an-image-as-emf

4
ответ дан 16 December 2019 в 21:46
поделиться

Можно сохранить метафайл в исходном формате, если вы используете gdi32.dll.

Я использую метод, описанный здесь , и он отлично работает.

2
ответ дан 16 December 2019 в 21:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: