How can i get data from REMOTE database using OnStart method?
protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
{
ApplicationEntity ae = studyLoaderArgs.Server as ApplicationEntity;
_ae = ae;
EventResult result = EventResult.Success;
AuditedInstances loadedInstances = new AuditedInstances();
try
{
XmlDocument doc = RetrieveHeaderXml(studyLoaderArgs);
StudyXml studyXml = new StudyXml();
studyXml.SetMemento(doc);
_instances = GetInstances(studyXml).GetEnumerator();
loadedInstances.AddInstance(studyXml.PatientId, studyXml.PatientsName, studyXml.StudyInstanceUid);
return studyXml.NumberOfStudyRelatedInstances;
}
finally
{
AuditHelper.LogOpenStudies(new string[] { ae.AETitle }, loadedInstances, EventSource.CurrentUser, result);
}
}
i need to use OnStart in main project. How cn i use or call OnStart method
Just a thought, OnStart
is an event; if you can provide the StudyLoaderArgs
some how, then you can move your code in Init(ApplicationEntity)
method and call it like following:
Init(myStudyArgs);
and in OnStart
:
protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
{
Init(StudyLoaderArgs.Server as ApplicationEntity);
}
--EDIT--
Move existing OnStart()
body in Init()
void Init(ApplicationEntity ae) { EventResult result = EventResult.Success; AuditedInstances loadedInstances = new AuditedInstances(); try {
XmlDocument doc = RetrieveHeaderXml(studyLoaderArgs); StudyXml studyXml = new StudyXml(); studyXml.SetMemento(doc); _instances = GetInstances(studyXml).GetEnumerator(); loadedInstances.AddInstance(studyXml.PatientId, studyXml.PatientsName, studyXml.StudyInstanceUid); return studyXml.NumberOfStudyRelatedInstances; } finally { AuditHelper.LogOpenStudies(new string[] { ae.AETitle }, loadedInstances, EventSource.CurrentUser, result); }
}
Call Init()
from OnStart()
protected override int OnStart(StudyLoaderArgs studyLoaderArgs) { ApplicationEntity ae = studyLoaderArgs.Server as ApplicationEntity; _ae = ae; Init(ae); }
OnStart()
is an event, and would be called upon service(assuming that it is a service) start. TO be more specific, events are not there to be called, rather events are raised as a notification that something has happened; all we do is handle the event; ie register a method as a handler for that event, and then that method will be invoked each time the event is raised.
So, to achieve want you want, you can call Init()
rather than OnStart()
; but to call Init()
you will have to provide the input arguments, which is what my first sentence says - or it'd be something like OnStart(EventArgs.Empty);
Not sure if this answers your question, but above the top of my skull! (0:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.