Exemple #1
0
  ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
  {
    context = c;
    
    /* Check the version of the Orthanc core */
    if (OrthancPluginCheckVersion(c) == 0)
    {
      char info[256];
      sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
              c->orthancVersion,
              ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
      OrthancPluginLogError(context, info);
      return -1;
    }

    /* Register the callbacks */

#if ORTHANC_PLUGIN_STANDALONE == 1
    OrthancPluginLogInfo(context, "Serving static resources (standalone build)");
    OrthancPluginRegisterRestCallback(context, ORTHANC_PLUGIN_WEB_ROOT "(.*)", ServeStaticResource);
#else
    OrthancPluginLogInfo(context, "Serving resources from folder: " ORTHANC_PLUGIN_RESOURCES_ROOT);
    OrthancPluginRegisterRestCallback(context, ORTHANC_PLUGIN_WEB_ROOT "(.*)", ServeFolder);
#endif

    OrthancPluginRegisterRestCallback(context, "/", RedirectRoot);
 
    return 0;
  }
Exemple #2
0
  ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
  {
    OrthancContext::GetInstance().Initialize(context);
    OrthancContext::GetInstance().LogWarning("Initializing GDCM decoding");

    // Check the version of the Orthanc core
    if (OrthancPluginCheckVersion(context) == 0)
    {
      OrthancContext::GetInstance().LogError(
        "Your version of Orthanc (" + std::string(context->orthancVersion) +
        ") must be above " + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) +
        "." + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) +
        "." + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER) +
        " to run this plugin");
      return -1;
    }

    OrthancContext::GetInstance().Register("/instances/([^/]+)/(preview|image-uint8|image-uint16|image-int16)", DecodeImage);
    return 0;
  }
Exemple #3
0
  ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
  {
    context_ = c;
    OrthancPluginLogWarning(context_, "Sample worklist plugin is initializing");
    OrthancPluginSetDescription(context_, "Serve DICOM modality worklists from a folder with Orthanc.");

    /* Check the version of the Orthanc core */
    if (OrthancPluginCheckVersion(c) == 0)
    {
      char info[1024];
      sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
              context_->orthancVersion,
              ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
      OrthancPluginLogError(context_, info);
      return -1;
    }

    Json::Value configuration;
    if (!ConvertToJson(configuration, OrthancPluginGetConfiguration(context_)))
    {
      OrthancPluginLogError(context_, "Cannot access the configuration of the worklist server");
      return -1;
    }

    bool enabled = false;

    if (configuration.isMember("Worklists"))
    {
      const Json::Value& config = configuration["Worklists"];
      if (!config.isMember("Enable") ||
          config["Enable"].type() != Json::booleanValue)
      {
        OrthancPluginLogError(context_, "The configuration option \"Worklists.Enable\" must contain a Boolean");
        return -1;
      }
      else
      {
        enabled = config["Enable"].asBool();
        if (enabled)
        {
          if (!config.isMember("Database") ||
              config["Database"].type() != Json::stringValue)
          {
            OrthancPluginLogError(context_, "The configuration option \"Worklists.Database\" must contain a path");
            return -1;
          }

          folder_ = config["Database"].asString();
        }
        else
        {
          OrthancPluginLogWarning(context_, "Worklists server is disabled by the configuration file");
        }
      }
    }
    else
    {
      OrthancPluginLogWarning(context_, "Worklists server is disabled, no suitable configuration section was provided");
    }

    if (enabled)
    {
      std::string message = "The database of worklists will be read from folder: " + folder_;
      OrthancPluginLogWarning(context_, message.c_str());

      OrthancPluginRegisterWorklistCallback(context_, Callback);
    }

    return 0;
  }