예제 #1
0
        public override Object Perform(Object obj)    // throws IOException
        {
            RichDocument doc = (RichDocument)obj;
            MetaMetadata mmd = (MetaMetadata)doc.MetaMetadata;

/*		    Dictionary<MetaMetadataSelector, MetaMetadata> reselectMap = mmd.ReselectMap;
 *                  if (reselectMap != null)
 *                  {
 *                          foreach (MetaMetadataSelector selector in reselectMap.Keys)
 *                          {
 *                                  if (selector.reselect(doc))
 *                                  {
 *                                          MetaMetadata newMmd = reselectMap[selector];
 *                                          DocumentParser newParser = DocumentParser.get(newMmd, sessionScope);
 *                                          newParser.fillValues(documentParser.purlConnection(), doc.getOrConstructClosure(), sessionScope);
 *                                          if (documentParser instanceof ParserBase && newParser instanceof ParserBase)
 *                                          {
 *                                                  CompoundDocument newDoc = (CompoundDocument) newMmd.constructMetadata();
 *                                                  newDoc.setLocation(doc.getLocation());
 *                                                  ParserBase newParserBase = (ParserBase) newParser;
 *                                                  org.w3c.dom.Document dom = ((ParserBase) documentParser).getDom();
 *                                                  newParserBase.parse(newDoc, newMmd, dom);
 *
 *                                                  DocumentClosure closure = doc.getOrConstructClosure();
 *                                                  closure.changeDocument(newDoc);
 *
 *                                                  return newDoc;
 *                                          }
 *                                  }
 *                          }
 *                  }*/
            return(null);
        }
        public User LoginSMUSer(String user, String password)
        {
            User loggedUser = new User();

            try
            {
                RichDocument document = new RichDocument();

                document.SetResponseType(ResponseType.Data);

                document.AddUserLogin(user, password);
                document.EncryptAuthentication = false;
                //document.AddHeader("USER", "SYSTEM");
                //document.AddHeader("PASSWORD", "");

                Entity entity = document.AddEntity("USER");
                Thermo.SM.LIMSML.Helper.Low.Action action = entity.AddAction("LOGIN");

                Limsml response = callService(document.Xml);

                if (response != null)
                {
                    if (response.NumberOfErrors() > 0)
                    {
                        for (int i = 0; i < response.Errors.Count; i++)
                        {
                            log.Error(response.GetError(i).ToString());
                        }
                        //throw new ReportGeneratorException();
                    }
                    else
                    {
                        //success
                        if (response.GetData("").Tables.Count == 0)
                        {
                            throw new Exception("Unexpected return");
                        }

                        loggedUser.Login    = user;
                        loggedUser.Password = password;
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("Erro ao processar o Web Service", e);
            }
            return(loggedUser);
        }
        //private readonly String smURL = Properties.Settings.Default.samplemanager_url;

        public List <Report> ListAllReports(String user, String password)
        {
            List <Report> reportsList = new List <Report>();

            try
            {
                RichDocument document = new RichDocument();
                document.SetResponseType(ResponseType.Data);

                document.AddUserLogin(user, password);
                document.EncryptAuthentication = false;
                //document.AddHeader("USER", "SYSTEM");
                //document.AddHeader("PASSWORD", "");

                Entity entity = document.AddEntity("INFOMAKER_LINK");
                Thermo.SM.LIMSML.Helper.Low.Action action = entity.AddAction("BROWSE");

                action.AddParameter("CRITERIA", "INFOMAKER_LINKS");
                action.AddParameter("FIELD", "IDENTITY");
                //action.AddParameter("ALL_VERSIONS", "FALSE");

                Limsml response = callService(document.Xml);

                if (response != null)
                {
                    if (response.NumberOfErrors() > 0)
                    {
                        for (int i = 0; i < response.Errors.Count; i++)
                        {
                            log.Error(response.GetError(i).ToString());
                        }
                        //throw new ReportGeneratorException();
                    }
                    else
                    {
                        //success
                        if (response.GetData("").Tables.Count == 0)
                        {
                            throw new Exception("Unexpected return");
                        }

                        int rows = response.GetData("").Tables[0].Rows.Count;

                        for (int i = 0; i < rows; i++)
                        {
                            //ReportParameter parameter = new ReportParameter();
                            Report rep = new Report();
                            rep.Id          = response.GetData("").Tables[0].Rows[i][0].ToString();
                            rep.Name        = response.GetData("").Tables[0].Rows[i][6].ToString();
                            rep.Description = response.GetData("").Tables[0].Rows[i][7].ToString();
                            rep.Library     = response.GetData("").Tables[0].Rows[i][8].ToString();
                            rep.IM_Report   = response.GetData("").Tables[0].Rows[i][9].ToString();
                            reportsList.Add(rep);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("Erro ao processar o Web Service", e);
            }


            return(reportsList);
        }