Объявление

Свернуть
Пока нет объявлений.

Подключение к OMNITRACKER из Java

Свернуть
X
  • Фильтр
  • Время
  • Показать
Очистить всё
новые сообщения

  • Подключение к OMNITRACKER из Java

    Чтобы из Java поработать с OMNITRACKER, а именно с COM-объектом "OtAut.OtApplication", можно использовать решение проекта JACOB (JACOB - Java COM Bridge, сайт проекта).

    Пример подключения к OMNITRACKER (test.java) -
    Код:
    import com.jacob.com.*;
    import com.jacob.activeX.*;
    
    public class test
    {
      public static void main(String[] args)
      {
        ActiveXComponent objApplication = new ActiveXComponent("OtAut.OtApplication");
        Variant conRet = objApplication.invoke("MakeSessionEx", 
                                               new Variant("hostname"), 
                                               new Variant(5085), 
                                               new Variant("login"), 
                                               new Variant("password"), 
                                               new Variant("ru"));
        ActiveXComponent objSession = new ActiveXComponent(conRet.toDispatch());
        try {
          System.out.println("LockingMode = " + objSession.getProperty("LockingMode"));
        } catch (Exception e) {
          e.printStackTrace();
        } finally {
          objSession.invoke("Logoff", new Variant[] {});
        }
      }
    }
    Запускаем -
    Код:
    javac.exe -cp jacob.jar test.java
    jar.exe cf test.jar test.class
    java.exe -cp jacob.jar;test.jar test
    С уважением, Сергей Осадчий

  • #2
    Нужно будет попробовать. Спасибо за информацию.
    С уважением, Олег Шиловский.

    Комментарий


    • #3
      Hello,

      I wish to make a filter in Java (I also use the jacob class).

      When I use the "SetSearchExpression" method of the object "OtFilter" it works well.
      However, when I use the property "UserField" the object "OtFilter", it returns me errors.

      Advantage of the use of "UserField" versus "SetSearchExpression"
      - SetSearchExpression (expression = "Token: Messi.L") ==> Return all tokens that begin with "Messi.L" : Messi.Lionel, Messi.Louis ...
      - UserField ("Token", "Messi.L") ==> THE Returns token with the value "Messi.L".

      My "filter" function:

      public EnumVariant filter(Dispatch folder, String field, String value)
      { try
      { String expression = field + ":" + value;
      Dispatch otFilter = Dispatch.call( folder, "MakeFilter").getDispatch();
      Dispatch.call(otFilter, "SetSearchExpression", expression);
      Dispatch requests = Dispatch.call (folder, "Search", otFilter, false).getDispatch();
      EnumVariant collection = new EnumVariant(requests);
      if (collection.hasMoreElements())
      return collection;
      else return null;
      }
      catch (Exception e)
      { e.printStackTrace();
      return null;
      }
      }

      When I replace:
      "Dispatch.call (otFilter,"SetSearchExpression", expression);" by
      "Dispatch.call (otFilter,"UserField", field, value);",
      it gives me the following error :
      "com.jacob.com.ComFailException: A COM exception has been encountered:
      At Invoke of: UserField
      Description: 8002000e / Invalid number of parameters."

      Would you have a solution to my problem ?
      Последний раз редактировалось thirem; 21-12-2015, 12:06.

      Комментарий


      • #4
        Сообщение от thirem Посмотреть сообщение
        Hello,
        ....
        - UserField ("Token", "Messi.L") ==> THE Returns token with the value "Messi.L".

        Would you have a solution to my problem ?
        In VB UserFields construction for filter looks like

        OtFilter.UserField("Token") = "Messi.L"

        I think in your case java use "value" as parameter, but it should be as value.

        Hope this helps
        С уважением, Олег Шиловский.

        Комментарий


        • #5
          No it is not a problem of the parameter "value"

          In fact, I can not implement in Java, the line you offer in VB :
          OtFilter.UserField("Token") = "Messi.L"
          If I put "Dispatch.call (otFilter,"UserField","token","Messi.L");", I get the error: 8002000e / Invalid number of parameters.
          So that must mean that I have to "splitter" the "UserField" instruction in several steps.

          Of style :

          XXX vartmp = Dispatch.call (otFilter, "UserField", "Token"). getXXX
          Dispatch.put (otFilter, vartmp, "Messi.L")

          What should match the "getXXX"?

          I try: Dispatch.call (otFilter, "UserField", "Token").putString ("Messi.L"); ==> but that does not work either.

          Комментарий


          • #6
            I think rootcause in jacob using
            Here is example with MSexcel (Example 5) http://www.programcreek.com/java-api...b.com.Dispatch. May be instead of getXXX should be .toDispatch();
            С уважением, Олег Шиловский.

            Комментарий


            • #7
              Exactly that,
              it is indeed a problem with the return value of dispatch.
              The instruction :
              Dispatch.call (otFilter, "UserField", "Token");
              works but returns no value.

              Just have to find the solution to integrate the value of my filter "Messi.L"

              I progress ! ^^

              As soon as I have a solution, I'll post.
              And thank you again for your help.

              Комментарий

              Обработка...
              X