public SoapExceptionOccured(System.Web.Services.Protocols.SoapException ex = null) { if (ex != null) { Exception = ex; } }
public VtDocs.BusinessServices.Entities.Response LogoutUser(VtDocs.BusinessServices.Entities.Request request) { VtDocs.BusinessServices.Entities.Response response = new VtDocs.BusinessServices.Entities.Response(); try { using (DocsPaWS.DocsPaWebService ws = new DocsPaWS.DocsPaWebService()) { if (ws.Logoff(request.InfoUtente.userId, request.InfoUtente.idAmministrazione, string.Empty, request.InfoUtente.dst)) { } } } catch (Exception ex) { System.Web.Services.Protocols.SoapException soapEx = DocsPaUtils.Exceptions.SoapExceptionFactory.Create(ex); if (request.TrowOnError) { throw soapEx; } else { response.Exception = soapEx.ToString(); } } return(response); }
public SPResult(System.Web.Services.Protocols.SoapException ex) { if (ex.Detail.ChildNodes.Count > 1) { this.codeResult = ex.Detail.ChildNodes[1].InnerText; } this.messageResult = "Error"; this.detailResult = ex.Detail.InnerText; }
/// <summary> /// Marks a imaging as completed. /// </summary> void IImagingTaskProvider.ImagedPlate(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } if (null == imagingID) { throw new System.NullReferenceException("imagingID must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".ImagedPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", imagingID=\"" + imagingID + "\")"; _log.Debug(msg); } // Set the request imagedPlate request = new imagedPlate(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; request.imagingID = imagingID; // Make the call WSPlate wsPlate = new WSPlate(); imagedPlateResponse response = null; try { response = wsPlate.imagedPlate(request); } catch (Exception e) { // Log it string msg = "WSPlate.imagedPlate threw " + e.GetType() + ": " + e.Message + " - panic!"; msg = msg + "\nin " + this + ".ImagedPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", imagingID=\"" + imagingID + "\")"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Fatal(msg, e); // Panic throw e; } // Webservice always returns true if it doesn't throw an exception return; }
/// <summary> /// If this <c>IImagingTaskProvider</c> supports changing priority, /// changes the priority of the IImagingTask with this <c>dateToImage</c>. /// </summary> void IImagingTaskProvider.UpdatedPriority(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, DateTime dateToImage, int priority) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".UpdatedPriority(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, priority=" + priority + ")"; _log.Debug(msg); } // Set the request updatedPriority request = new updatedPriority(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; // .NET < 2.0 //request.dateToImage = dateToImage; // .NET >= 2.0 request.dateToImage = dateToImage.ToUniversalTime(); request.priority = priority; // Make the call WSPlate wsPlate = new WSPlate(); try { wsPlate.updatedPriority(request); } catch (Exception e) { // Log it string msg = "WSPlate.updatedPriority threw " + e.GetType() + ": " + e.Message + " - ignoring"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return - don't really care if this didn't work return; } // Webservice always returns true if there is no exception return; }
/// <summary> /// Marks an imaging as skipped. /// </summary> void IImagingTaskProvider.SkippedImaging(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, DateTime dateToImage) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".SkippedImaging(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC)"; _log.Debug(msg); } // Set the request skippedImaging request = new skippedImaging(); request.robot = OPPF.Utilities.Robot2Utils.createProxy(robot); request.plateID = plateID; request.dateToImage = dateToImage.ToUniversalTime(); // Make the call WSPlate wsPlate = WSPlateFactory.getWSPlate2(); skippedImagingResponse response = null; try { response = wsPlate.skippedImaging(request); } catch (Exception e) { // Log it string msg = "WSPlate.skippedImaging threw " + e.GetType() + ": " + e.Message + " - ignoring"; msg = msg + "\nin " + this + ".SkippedImaging(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC)"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return - don't really care if this didn't work return; } // Webservice always returns true if it doesn't throw an exception return; }
/// <summary> /// Return <c>true</c> if this provider supplies <c>IImagingTask.Priority</c>. /// Otherwise the imager should manage individual task priority. /// </summary> bool IImagingTaskProvider.SupportsPriority(Formulatrix.Integrations.ImagerLink.IRobot robot) { // OPPF PERFORMANCE BODGE - Actually this method should always return true! return(true); // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".SupportsPriority(robot=" + RobotUtils.iRobotToString(robot) + ")"; _log.Debug(msg); } // Set the request supportsPriority request = new supportsPriority(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); // Make the call WSPlate wsPlate = new WSPlate(); supportsPriorityResponse response = null; try { response = wsPlate.supportsPriority(request); } catch (Exception e) { // Log it string msg = "WSPlate.supportsPriority threw " + e.GetType() + ": " + e.Message + " - ignoring"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return false return(false); } // Return the response's value //_log.Debug("supportsPriority returned " + response.supportsPriorityReturn); return(response.supportsPriorityReturn); }
/// <summary> /// Handles the exception. /// </summary> /// <param name="ex">The ex.</param> /// <returns>System.String.</returns> public static string HandleException(Exception ex) { string Error = "Error Message : " + ex.Message + System.Environment.NewLine; if (ex.InnerException != null) { Error += ex.InnerException.Message + System.Environment.NewLine; } System.Web.Services.Protocols.SoapException se = ex as System.Web.Services.Protocols.SoapException; if (se != null) { Error += "Code : " + GetError(se.Detail, "//code") + System.Environment.NewLine; Error += "Desription : " + GetError(se.Detail, "//description") + System.Environment.NewLine; Error += "Type : " + GetError(se.Detail, "//type") + System.Environment.NewLine; } return(Error); }
/// <summary> /// Extract a string describing a SoapException from the specified Exception /// </summary> /// <param name="e">The Exception to process</param> /// <returns>Details.InnerXml or Details.InnerText or an empty string</returns> public static string SoapExceptionToString(Exception e) { string msg = ""; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; if (null != ee.Detail) { if (null != ee.Detail.InnerXml) { msg = "\n\n" + ee.Detail.InnerXml; } else if (null != ee.Detail.InnerText) { msg = "\n\n" + ee.Detail.InnerText; } } } return(msg); }
public VtDocs.BusinessServices.Entities.Authentication.GetLoginResponse LoginUser(VtDocs.BusinessServices.Entities.Authentication.GetLoginRequest request) { VtDocs.BusinessServices.Entities.Authentication.GetLoginResponse response = new VtDocs.BusinessServices.Entities.Authentication.GetLoginResponse(); try { using (DocsPaWS.DocsPaWebService ws = new DocsPaWS.DocsPaWebService()) { DocsPaVO.utente.Utente user; string ipAddress; response.Result = ws.Login(request.Login, out user, request.Forced, request.WebSessionId, out ipAddress); response.User = user; response.IpAddress = ipAddress; } } catch (Exception ex) { System.Web.Services.Protocols.SoapException soapEx = DocsPaUtils.Exceptions.SoapExceptionFactory.Create(ex); if (request.TrowOnError) { throw soapEx; } else { response.Exception = soapEx.ToString(); response.User = null; response.Result = DocsPaVO.utente.UserLogin.LoginResult.APPLICATION_ERROR; response.IpAddress = null; } } return(response); }
/// <summary> /// web servis yöntemlerinden dönen SoapException sınıfına özel, detail alanındaki hata kodunun ayrıştırılması /// </summary> static int GetErrorCodeFromSoapException(System.Web.Services.Protocols.SoapException sexc) { if (sexc == null) { return(-1); } if (sexc.Detail == null) { return(-1); } if (String.IsNullOrEmpty(sexc.Detail.InnerXml)) { return(-1); } var xml = new System.Xml.XmlDocument(); xml.LoadXml(sexc.Detail.InnerXml); if (xml.DocumentElement == null) { return(-1); } var codeNode = xml.DocumentElement.ChildNodes[0]; if (codeNode == null) { return(-1); } if (codeNode.Name != "code") { return(-1); } if (codeNode.FirstChild == null) { return(-1); } return(Convert.ToInt32(codeNode.FirstChild.Value)); }
private static int?GetTfsErrorNumberFromSoapException(System.Web.Services.Protocols.SoapException soapException) { int tfsErrorNumber; if (soapException.Detail != null) { foreach (XmlNode childNode in soapException.Detail.ChildNodes) { XmlElement childElement = childNode as XmlElement; if (childElement != null && string.Equals(childElement.Name, "details", StringComparison.OrdinalIgnoreCase)) { foreach (XmlAttribute attribute in childElement.Attributes) { if (string.Equals(attribute.Name, "id", StringComparison.OrdinalIgnoreCase)) { if (int.TryParse(attribute.Value, out tfsErrorNumber)) { return(tfsErrorNumber); } else { Debug.Fail("Unable to parse TFS error id to int: " + attribute.Value); return(null); } } } Debug.Fail("The 'id' attribute was not found in the 'details' element of the SoapException: {0}" + soapException.ToString()); return(null); } } Debug.Fail("Did not a find the 'details' element of the SoapException: {0}" + soapException.ToString()); } else { Debug.Fail("The SoapException Detail property is null"); } return(null); }
/// <summary> /// Procesa las exepciones tipo SoapException <see cref="System.Web.Services.Protocols.SoapException"/> /// </summary> /// <param name="soapException">SoapException <see cref="System.Web.Services.Protocols.SoapException"/></param> /// <returns>ServiceError <see cref="ServiceError"/></returns> private static ServiceError ProcessSoapException(System.Web.Services.Protocols.SoapException soapException) { ServiceError wServiceError = new ServiceError(); StringBuilder wMessage = new StringBuilder(); wMessage.AppendLine("Ocurrio un problema al intentar ejecutar un servicio."); wMessage.AppendLine("Verifique que el despachador de servicio se encuentre actualizado con las ultimas librerias del Framework ."); wMessage.AppendLine(); wMessage.AppendLine("Mensaje SOAP: "); wMessage.AppendLine(soapException.Message); wServiceError.StackTrace = soapException.StackTrace; wServiceError.Message = wMessage.ToString(); if (soapException.InnerException != null) { wServiceError.InnerMessageException = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(soapException.InnerException); } wMessage = null; return(wServiceError); }
public static void LogException(Exception ex) { lock (_syncObject) { if (_logStreamWriter != null) { _logStreamWriter.WriteLine(GetLineFormatted("Exception Caught: " + GetCurrentMethod(1))); _logStreamWriter.WriteLine(GetLineFormatted("Source: " + ex.Source)); _logStreamWriter.WriteLine(GetLineFormatted("Type: " + ex.GetType().ToString())); _logStreamWriter.WriteLine(GetLineFormatted("Message: " + ex.Message)); _logStreamWriter.WriteLine(GetLineFormatted("Target Site:\n" + ex.TargetSite.ToString())); _logStreamWriter.WriteLine(GetLineFormatted("Stack Trace:\n" + ex.StackTrace)); Exception inner = ex.InnerException; while (inner != null) { _logStreamWriter.WriteLine(GetLineFormatted("Message: " + inner.Message)); _logStreamWriter.WriteLine(GetLineFormatted("Stack Trace:\n" + inner.StackTrace)); inner = inner.InnerException; } #if ERROR_LOG_HANDLE_SOAP_EXCEPTION if (ex is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException se = ex as System.Web.Services.Protocols.SoapException; _logStreamWriter.WriteLine(GetLineFormatted("Actor: " + se.Actor)); if (se.Code != null) { _logStreamWriter.WriteLine(GetLineFormatted("Code: " + se.Code)); } if (se.Detail != null) { _logStreamWriter.WriteLine(GetLineFormatted("Detail: " + se.Detail.OuterXml)); } } #endif } } }
public static WebServiceException[] ParseSoapException(System.Web.Services.Protocols.SoapException soapException) { WebServiceException[] exceptions; try { exceptions = new WebServiceException[soapException.Detail.ChildNodes.Count]; for (int i = 0; i < exceptions.Length; i++) { exceptions[i] = new WebServiceException (Convert.ToInt32(soapException.Detail.ChildNodes[i].Attributes["e:number"].Value) , soapException.Detail.ChildNodes[i].Attributes["e:type"].Value , soapException.Detail.ChildNodes[i].Attributes["e:message"].Value); } return(exceptions); } catch (Exception exception) { throw exception; } finally { exceptions = null; } }
/// <summary>Hit when the updating is finished.</summary> /// <param name="sender">Client</param> /// <param name="e">Event Args</param> private void _Client_Task_UpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { try { if (e.Error == null) { this.LoadItem_Task(); this.panelError.Visibility = Visibility.Collapsed; this.panelInfo.Visibility = Visibility.Visible; this.msgInfMessage.Text = "Task details saved."; this.panelWarning.Visibility = Visibility.Collapsed; this.panelNone.Visibility = Visibility.Collapsed; this._NumRunning--; //Reload the item. this.LoadItem_Task(); this._DetailsWindow.Caption = this._DetailsWindow.Caption.Replace(" *", ""); } else { Type eType = e.Error.GetType(); if (eType == typeof(System.Web.Services.Protocols.SoapException)) { System.Web.Services.Protocols.SoapException ex = (System.Web.Services.Protocols.SoapException)e.Error; if (ex.Detail.FirstChild.Name == "DataValidationException") { this.panelError.Visibility = Visibility.Visible; this.msgErrMessage.Text = ex.Detail.InnerText; this.panelInfo.Visibility = Visibility.Collapsed; this.panelWarning.Visibility = Visibility.Collapsed; this.panelNone.Visibility = Visibility.Collapsed; } else if (ex.Detail.FirstChild.Name == "DataAccessConcurrencyException") { this.panelError.Visibility = Visibility.Visible; this.panelInfo.Visibility = Visibility.Collapsed; this.msgErrMessage.Text = "This incident was modified by another user. New data has been loaded." + Environment.NewLine + "Yellow fields were modified by the other user. Red fields were both modified by you and the other user."; this._isInConcurrency = true; this.LoadItem_Task(); } } else { this.panelError.Visibility = Visibility.Visible; this.msgErrMessage.Text = "Error saving: " + e.Error.Message; this.panelInfo.Visibility = Visibility.Collapsed; this.panelWarning.Visibility = Visibility.Collapsed; this.panelNone.Visibility = Visibility.Collapsed; } } this.panelForm.IsEnabled = true; } catch (Exception ex) { Connect.logEventMessage("wpfDetailsTask::_Client_Task_UpdateCompleted", ex, System.Diagnostics.EventLogEntryType.Error); } }
/// <summary> /// Retrieves a plate description from the web service. /// </summary> /// <param name="robot">The robot to find the plate type for.</param> /// <param name="plateID">The <c>plateID</c> of the plate.</param> /// <returns>The <c>IPlateInfo</c> describing the plate.</returns> public IPlateInfo FetchPlateInfo(IRobot robot, string plateID) { // Check arguments - do it up front to avoid possible inconsistencies later if (robot == null) { throw new System.NullReferenceException("robot must not be null"); } if (plateID == null) { throw new System.NullReferenceException("plateID must not be null"); } // Log the call if (_log.IsDebugEnabled) { string msg = "Called " + this + ".FetchPlateInfo(robot=" + robot.ToString() + ", plateID=\"" + plateID + "\")"; _log.Debug(msg); } // Special case for ReliabilityTestPlate if ("ReliabilityTestPlate".Equals(plateID)) { OPPF.Integrations.ImagerLink.PlateInfo dummy = new OPPF.Integrations.ImagerLink.PlateInfo(); dummy.SetDateDispensed(DateTime.Now); dummy.SetExperimentName("Dummy Expt Name"); dummy.SetPlateNumber(1); dummy.SetPlateTypeID("1"); dummy.SetProjectName("Dummy Project Name"); dummy.SetUserEmail("DummyEmailAddress"); dummy.SetUserName("Dummy UserName"); return(dummy); } // Declare the return variable OPPF.Integrations.ImagerLink.PlateInfo pi = null; try { // Create and populate the request object getPlateInfo request = new getPlateInfo(); request.robot = OPPF.Utilities.Robot2Utils.createProxy(robot); request.plateID = plateID; // Make the web service call WSPlate wsPlate = WSPlateFactory.getWSPlate2(); _log.Info("Calling WSPlate.getPlateInfo()"); getPlateInfoResponse response = wsPlate.getPlateInfo(request); // Get the webservice proxy PlateInfo OPPF.Proxies2.PlateInfo ppi = response.getPlateInfoReturn; // Map it into an IPlateInfo pi = new OPPF.Integrations.ImagerLink.PlateInfo(); pi.SetDateDispensed(ppi.dateDispensed); pi.SetExperimentName(ppi.experimentName); pi.SetPlateNumber(ppi.plateNumber); // TODO Figure out how to get pims to tell us the right answer //pi.SetPlateTypeID(ppi.plateTypeID); pi.SetPlateTypeID(PlateInfoProviderNew.getIDForName(ppi.plateTypeID)); pi.SetProjectName(ppi.projectName); pi.SetUserEmail(ppi.userEmail); pi.SetUserName(ppi.userName); } catch (Exception e) { string msg = "WSPlate.getPlateInfo threw " + e.GetType() + ":\n" + e.Message + "\nfor plate \"" + plateID + "\" in robot \"" + robot.Name + "\"\n - probably not in LIMS - not fatal."; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } // Log it _log.Error(msg, e); // Don't rethrow - return null - don't want to stop imaging } // Return the IPlateInfo return(pi); }
private void JobWorkLoop() { try { while (true) { //check to see if we should still be running if (jobLoopRunning == false) { break; } jobsToCheck = false; lock (JobsDictLock) { List <Job> jobsToDelete = new List <Job>(); foreach (Job j in jobs.Keys) { try { JobStatus js = jobs[j]; if (js.State == JobStates.Received) { if (vmMap.ContainsKey(j.Configuration)) { VirtualMachine vm = vmMap[j.Configuration]; try { //check other jobs to see if any are using this VM, if so don't start this job yet //also count the number of running VMs so we can check against the max bool vmInUse = false; Dictionary <string, int> runningVMsCount = new Dictionary <string, int>();//per host foreach (Job otherJob in jobs.Keys) { JobStatus otherJobStatus = jobs[otherJob]; if (otherJobStatus.IsRunning) { VirtualMachine otherVM = vmMap[otherJob.Configuration]; string computeResource = otherVM.ComputeResourceName; if (!runningVMsCount.ContainsKey(computeResource)) { runningVMsCount[computeResource] = 0; } runningVMsCount[computeResource]++; if (vm.Identifier == otherVM.Identifier) { vmInUse = true; } } } //check to see if the vm is locked foreach (string lockedVMPath in lockedVMs) { if (lockedVMPath == vm.Identifier) { vmInUse = true; break; } } //if this job relies on another job, make sure that job has finished before starting this one bool waitingForAnotherJob = false; if (j.DependsOnJobIds != null && j.DependsOnJobIds.Count > 0) { foreach (string jobId in j.DependsOnJobIds) { bool jobFinished = false; foreach (Job baseJob in jobs.Keys) { JobStatus baseJobStatus = jobs[baseJob]; if (baseJob.JobID == jobId) { if (baseJobStatus.State == JobStates.WaitingForChildJobs) { jobFinished = true; } } } if (!jobFinished) { waitingForAnotherJob = true; } } } int vmsRunningOnThisResource = 0; string thisComputeResource = vm.ComputeResourceName; if (runningVMsCount.ContainsKey(thisComputeResource)) { vmsRunningOnThisResource = runningVMsCount[thisComputeResource]; } if (!vmInUse && !waitingForAnotherJob && vmsRunningOnThisResource < AppConfig.MaxVMsAtOnce) { //copy ISO to drop directory List <string> keys = new List <string>(j.ISOs.Keys); foreach (string isoName in keys) { string isoPath = j.ISOs[isoName]; if (File.Exists(isoPath)) { string dropFile = dropManager.GetDropFilePath(isoPath, isoPath); j.ISOs[isoName] = dropFile; } else { //TODO error? } } if (j.Packages == null || j.Packages.Count == 0) { js.ErrorOut("Job does not have any packages defined", null, null); } else { //copy Test Files to readable dir foreach (ExecutablePackage ep in j.Packages) { DirectoryInfo sourceDir = new DirectoryInfo(ep.ContentDirectory); DirectoryData testFiles = DirectoryData.FromDirectory(sourceDir); DirectoryInfo destDir = new DirectoryInfo(AppConfig.FileDrop.FullName + "\\" + Guid.NewGuid().ToString()); destDir.Create(); testFiles.DumpContentsToDir(destDir); foreach (string subDirName in ep.SubContentDirectories.Keys) { DirectoryInfo subDirSource = new DirectoryInfo(ep.SubContentDirectories[subDirName]); DirectoryData subDirFiles = DirectoryData.FromDirectory(subDirSource); DirectoryInfo subDirDest = new DirectoryInfo(Path.Combine(destDir.FullName, subDirName)); subDirDest.Create(); subDirFiles.DumpContentsToDir(subDirDest); } ep.ContentDirectory = destDir.FullName; } vm.RevertToNamedSnapshot(); //vm.RevertToCurrentSnapshot(); vm.Start(); js.State = JobStates.VMStarted; } } } catch (Exception ex) { List <FileData> attachements = new List <FileData>(); FileData exceptionDetails = new FileData(); string exceptionDetailsStr = ex.ToString(); if (ex is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException soapEx = (System.Web.Services.Protocols.SoapException)ex; if (soapEx.Detail != null) { exceptionDetailsStr += Environment.NewLine + soapEx.Detail.OuterXml; } } exceptionDetails.Data = Encoding.ASCII.GetBytes(exceptionDetailsStr); exceptionDetails.Name = "exception.txt"; attachements.Add(exceptionDetails); js.ErrorOut("Exception: " + ex.Message, null, attachements); } } else { js.ErrorOut("Could not find a VM suitable for this configuration(" + j.Configuration.ToString() + ")", null, null); } } else if (js.State == JobStates.VMStarted || js.State == JobStates.AutoStarted) { if (DateTime.Now.Subtract(js.LastStateChange) > JOB_RUN_TIMEOUT) { js.ErrorOut("Job timed out. No response from VM after " + JOB_RUN_TIMEOUT.TotalHours + " hours", null, null); } } else if (js.State == JobStates.AutoFinished) { //check to see if any jobs rely on this job bool hasChildJobs = false; foreach (Job other in jobs.Keys) { if (other.DependsOnJobIds != null && other.DependsOnJobIds.Contains(j.JobID))//if the other job relies on this job { hasChildJobs = true; break; } } if (hasChildJobs) { js.State = JobStates.WaitingForChildJobs; jobsToCheck = true; } else if (js.Result.SnapshotOnShutdown) { js.State = JobStates.TakingSnapshot; } else { js.State = JobStates.JobFinishedNotSent; } } else if (js.State == JobStates.TakingSnapshot) { VirtualMachine vm = vmMap[j.Configuration]; if (vm.IsStarted) { //VM is still shuting down, do nothing, this will get checked again on the next go around. } else { string snapshotName = vm.SnapshotName; if (!String.IsNullOrEmpty(js.Result.SnapshotName)) { snapshotName = js.Result.SnapshotName; } string snapshotDesc = String.Empty; if (js.Result.SnapshotDesc != null) { snapshotDesc = js.Result.SnapshotDesc; } vm.TakeSnapshot(snapshotName, snapshotDesc); if (js.Result.CloneOnShutdown) { try { vm.CreateLinkedClone(snapshotName, vm.VMName + "_" + snapshotName); } catch (Exception ex) { js.ErrorOut("Exception: " + ex.Message, null, null); } } js.State = JobStates.JobFinishedNotSent; } } else if (js.State == JobStates.WaitingForChildJobs) { bool inUse = false; foreach (Job other in jobs.Keys) { if (other.DependsOnJobIds != null && other.DependsOnJobIds.Contains(j.JobID))//if the other job relies on this job { JobStatus otherStatus = jobs[other]; if (!otherStatus.IsFinished) { inUse = true; break; } } } if (!inUse) { if (js.Result.SnapshotOnShutdown) { js.State = JobStates.TakingSnapshot; } else { js.State = JobStates.JobFinishedNotSent; } } } } catch (Exception ex) { //TODO throw; } } foreach (Job j in jobs.Keys) { JobStatus js = jobs[j]; if (js.State == JobStates.JobFinishedNotSent) { AutomationMessage m = new AutomationMessage(j.OriginalHost, j.OriginalMessageID, new JobCompleted(j, js.Result)); SendToHost(m); js.State = JobStates.JobFinishedSent; //if the iso has been copied to the temp directory, delete it if (j.ISOs != null) { foreach (string isoPath in j.ISOs.Values) { if (isoPath.Contains(AppConfig.FileDrop.FullName)) { try { //release the iso copy dropManager.ReleaseDropFile(isoPath); } catch (Exception ex) { EventLog.WriteEntry("Could not release ISO \"" + isoPath + "\" : " + ex.ToString()); } } } } //if the test package directory has been copied to the temp directory, delete it if (j.Packages != null) { foreach (ExecutablePackage ep in j.Packages) { string packageDir = ep.ContentDirectory; if (packageDir != null) { if (packageDir.Contains(AppConfig.FileDrop.FullName)) { try { //delete the test files System.IO.Directory.Delete(packageDir, true); } catch (Exception ex) { EventLog.WriteEntry("Could not delete directory \"" + packageDir + "\" : " + ex.ToString()); } } } } } } else if (js.State == JobStates.JobFinishedSent) { if (DateTime.Now.Subtract(js.LastStateChange) > DURATION_TO_KEEP_JOBS) { jobsToDelete.Add(j); } } } foreach (Job j in jobsToDelete) { jobs.Remove(j); } } lock (ExecuteJobsLock) { if (jobsToCheck) { continue; } //check to see if we should still be running if (jobLoopRunning == false) { break; } Monitor.Wait(ExecuteJobsLock); } } } catch (ThreadAbortException) { //eat it } catch (Exception ex) { EventLog.WriteEntry("Exception in work loop: " + ex.ToString(), EventLogEntryType.Error); throw; } }
private bool SubmitBatchedAddOrDeleteLinkChanges( List <XmlDocument> updateDocuments, Dictionary <int, LinkChangeAction> updateDocIndexToLinkChangeActionMap, ITranslationService translationService, ConfigurationService configService, ConflictManager conflictManager) { bool succeeded = true; UpdateResult[] results = TfsBatchUpdateHelper.Submit(Core, WorkItemServer, updateDocuments.ToArray()); if (results.Length != updateDocuments.Count) { throw new SynchronizationEngineException("Wrong number of link update results."); } // Collect list of successful LinkChangeActions (for LinkTypes with GetsActionsFromLinkChangeHistory true) to pass to SetServerLinkChangeIds() List <LinkChangeAction> actionsNeedingServerLinkIdSet = new List <LinkChangeAction>(); for (int i = 0; i < results.Length; ++i) { if (results[i] == null) { continue; } UpdateResult rslt = results[i]; if (rslt.Exception != null) { MigrationConflict conflict = null; ConflictResolutionResult resolutionRslt = null; List <MigrationAction> actions; bool createWitGeneralConflict = false; System.Web.Services.Protocols.SoapException soapException = rslt.Exception as System.Web.Services.Protocols.SoapException; if (soapException != null) { int?tfsErrorNumber = GetTfsErrorNumberFromSoapException(soapException); if (tfsErrorNumber.HasValue) { LinkChangeAction linkChangeAction = updateDocIndexToLinkChangeActionMap[i]; switch (tfsErrorNumber) { case TfsConstants.TfsError_AddLink_LinkExists: case TfsConstants.TfsError_DeleteLink_LinkNotFound: // it is ok to eat these exception and skip the action // mark the change action completed so it is not retried later linkChangeAction.Status = LinkChangeAction.LinkChangeActionStatus.Skipped; if (tfsErrorNumber == TfsConstants.TfsError_AddLink_LinkExists) { TraceManager.TraceInformation("Tried to add a link that already exists so skipping it: " + GetLinkChangeActionDescription(linkChangeAction)); } else { TraceManager.TraceInformation("Tried to delete a link that does not exist so skipping it: " + GetLinkChangeActionDescription(linkChangeAction)); } if (soapException.Detail != null) { TraceManager.TraceVerbose("SoapException.Detail.InnerXml for ignored exception: " + soapException.Detail.InnerXml); } break; case TfsConstants.TfsError_AddLink_TooManyParents: if (linkChangeAction.Group.IsForcedSync) { if (DeleteExistingParentLinkToForceSyncAddLink(linkChangeAction, updateDocuments[i])) { break; } } conflict = TFSMulitpleParentLinkConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; succeeded = false; } break; case TfsConstants.TfsError_AddLink_Circular: case TfsConstants.TfsError_AddLink_ChildIsAncestor: ILinkProvider linkProvider = ServiceContainer.GetService(typeof(ILinkProvider)) as ILinkProvider; Debug.Assert(null != linkProvider, "linkProvider is NULL"); LinkChangeAction conflictedAction = updateDocIndexToLinkChangeActionMap[i]; NonCyclicReferenceClosure linkRefClosure = linkProvider.CreateNonCyclicLinkReferenceClosure(conflictedAction.Link.LinkType, conflictedAction.Link.SourceArtifact); conflict = TFSCyclicLinkConflictType.CreateConflict(conflictedAction, rslt.Exception, linkRefClosure); resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; succeeded = false; } break; case TfsConstants.TfsError_LinkAuthorizationFailedLinkLocked: conflict = TFSModifyLockedWorkItemLinkConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; } // returning "not succeeded" so that the caller keeps this change group in "ReadyForMigration" status succeeded = false; break; case TfsConstants.TfsError_LinkAuthorizationFailed: case TfsConstants.TfsError_LinkAuthorizationFailedNotServiceAccount: conflict = TFSLinkAccessViolationConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; } // returning "not succeeded" so that the caller keeps this change group in "ReadyForMigration" status succeeded = false; break; default: // TFS error doesn't match any that we explicitly handle TraceManager.TraceError("SubmitBatchedAddOrDeleteLinkChanges:TFS error number in SoapException not explictly handled: {0}", tfsErrorNumber); createWitGeneralConflict = true; break; } } else { TraceManager.TraceError("SubmitBatchedAddOrDeleteLinkChanges: Unable to get TFS error number from SoapException: {0}", soapException.ToString()); createWitGeneralConflict = true; } } else // Exception is not SoapException { TraceManager.TraceError("SubmitBatchedAddOrDeleteLinkChanges: Exception returned is not SoapException: {0}", rslt.Exception.ToString()); createWitGeneralConflict = true; } if (createWitGeneralConflict) { conflict = WitGeneralConflictType.CreateConflict(rslt.Exception); resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; succeeded = false; } } } else // rslt.Exception == null { LinkChangeAction successfulAction = updateDocIndexToLinkChangeActionMap[i]; MarkLinkChangeActionCompleted(successfulAction); TraceManager.TraceVerbose("Successful " + GetLinkChangeActionDescription(successfulAction)); List <LinkChangeAction> updatedActions = new List <LinkChangeAction>(); updatedActions.Add(successfulAction); if (successfulAction.Link.LinkType.GetsActionsFromLinkChangeHistory) { actionsNeedingServerLinkIdSet.Add(successfulAction); } UpdateLinkConversionHistory(configService, translationService, rslt, updatedActions); } } SetServerLinkChangeIds(actionsNeedingServerLinkIdSet); return(succeeded); }
/// <summary> /// Plate is starting to image. Returns an imaging identifier that will be /// embedded in the image names, and returned in ImagedPlate or null if /// the ImagingID is unavailable. /// </summary> string IImagingTaskProvider.ImagingPlate(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, bool scheduled, DateTime dateToImage, DateTime dateImaged) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Debug(msg); } // Set the request imagingPlate request = new imagingPlate(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; request.scheduled = scheduled; request.dateToImage = dateToImage.ToUniversalTime(); request.dateImaged = dateImaged.ToUniversalTime(); // Make the call WSPlate wsPlate = new WSPlate(); imagingPlateResponse response = null; try { response = wsPlate.imagingPlate(request); } catch (Exception e) { string msg = "WSPlate.imagingPlate threw " + e.GetType() + ": " + e.Message + " - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Fatal(msg, e); // Panic throw e; } // If we got no response if (null == response) { string msg = "WSPlate.imagingPlate returned null - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // If we got a null imagingID if (null == response.imagingPlateReturn) { string msg = "WSPlate.imagingPlate returned a null imagingID - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // Return the imagingID return(response.imagingPlateReturn); }
private bool SubmitBatchedAddOrDeleteLinkChanges( List <XmlDocument> updateDocuments, Dictionary <int, LinkChangeAction> updateDocIndexToLinkChangeActionMap, ITranslationService translationService, ConfigurationService configService, ConflictManager conflictManager) { bool succeeded = true; UpdateResult[] results = TfsBatchUpdateHelper.Submit(Core, WorkItemServer, updateDocuments.ToArray()); if (results.Length != updateDocuments.Count) { throw new SynchronizationEngineException("Wrong number of link update results."); } // Collect list of successful LinkChangeActions (for LinkTypes with GetsActionsFromLinkChangeHistory true) to pass to SetServerLinkChangeIds() List <LinkChangeAction> actionsNeedingServerLinkIdSet = new List <LinkChangeAction>(); for (int i = 0; i < results.Length; ++i) { UpdateResult rslt = results[i]; if (rslt.Exception != null) { if (rslt.Exception.Message.Contains("The specified link already exists")) { // it is ok to eat this exception // mark the change action completed so it is not retried later LinkChangeAction action = updateDocIndexToLinkChangeActionMap[i]; action.Status = LinkChangeAction.LinkChangeActionStatus.Skipped; TraceManager.TraceInformation("Tried to add a link that already exists so skipping it: " + GetLinkChangeActionDescription(action)); System.Web.Services.Protocols.SoapException soapException = rslt.Exception as System.Web.Services.Protocols.SoapException; if (soapException != null) { TraceManager.TraceVerbose("SoapException.Detail.InnerXml for ignored exception: " + soapException.Detail.InnerXml); } } else if (updateDocIndexToLinkChangeActionMap[i].ChangeActionId == WellKnownChangeActionId.Delete && rslt.Exception.Message.Contains("This specified link does not exist")) { // it is ok to eat this exception and skip the action // mark the change action completed so it is not retried later LinkChangeAction action = updateDocIndexToLinkChangeActionMap[i]; action.Status = LinkChangeAction.LinkChangeActionStatus.Skipped; TraceManager.TraceInformation("Tried to delete a link that does not exist so skipping it: " + GetLinkChangeActionDescription(action)); System.Web.Services.Protocols.SoapException soapException = rslt.Exception as System.Web.Services.Protocols.SoapException; if (soapException != null) { TraceManager.TraceVerbose("SoapException.Detail.InnerXml for ignored exception: " + soapException.Detail.InnerXml); } } else if (rslt.Exception is System.Web.Services.Protocols.SoapException && null != rslt.Exception.Message && rslt.Exception.Message.StartsWith( TFSMulitpleParentLinkConflictType.SingleParentViolationMessage, StringComparison.OrdinalIgnoreCase)) { MigrationConflict conflict = TFSMulitpleParentLinkConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); List <MigrationAction> actions; var resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; succeeded = false; } } else if (rslt.Exception is System.Web.Services.Protocols.SoapException && null != rslt.Exception.Message && rslt.Exception.Message.StartsWith( TFSCyclicLinkConflictType.CircularityLinkHierarchyViolationMessage, StringComparison.OrdinalIgnoreCase)) { ILinkProvider linkProvider = ServiceContainer.GetService(typeof(ILinkProvider)) as ILinkProvider; Debug.Assert(null != linkProvider, "linkProvider is NULL"); LinkChangeAction conflictedAction = updateDocIndexToLinkChangeActionMap[i]; NonCyclicReferenceClosure linkRefClosure = linkProvider.CreateNonCyclicLinkReferenceClosure(conflictedAction.Link.LinkType, conflictedAction.Link.SourceArtifact); MigrationConflict conflict = TFSCyclicLinkConflictType.CreateConflict(conflictedAction, rslt.Exception, linkRefClosure); List <MigrationAction> actions; var resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; succeeded = false; } } else if (rslt.Exception is System.Web.Services.Protocols.SoapException && null != rslt.Exception.Message && rslt.Exception.Message.StartsWith( TFSModifyLockedWorkItemLinkConflictType.ModifyLockedWorkItemLinkViolationMessage, StringComparison.OrdinalIgnoreCase)) { MigrationConflict conflict = TFSModifyLockedWorkItemLinkConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); List <MigrationAction> actions; var resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; } // returning "not succeeded" so that the caller keeps this change group in "ReadyForMigration" status succeeded = false; } else if (rslt.Exception is System.Web.Services.Protocols.SoapException && null != rslt.Exception.Message && (rslt.Exception.Message.StartsWith(TFSLinkAccessViolationConflictType.LinkAccessViolationMessage1, StringComparison.OrdinalIgnoreCase) || rslt.Exception.Message.StartsWith(TFSLinkAccessViolationConflictType.LinkAccessViolationMessage2, StringComparison.OrdinalIgnoreCase))) { MigrationConflict conflict = TFSLinkAccessViolationConflictType.CreateConflict( updateDocIndexToLinkChangeActionMap[i], rslt.Exception); List <MigrationAction> actions; var resolutionRslt = conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { updateDocIndexToLinkChangeActionMap[i].IsConflicted = true; } // returning "not succeeded" so that the caller keeps this change group in "ReadyForMigration" status succeeded = false; } else { LinkChangeAction action = updateDocIndexToLinkChangeActionMap[i]; // TODO // Try resolve conflict and push to backlog if resolution fails action.IsConflicted = true; TraceManager.TraceError(String.Format(CultureInfo.InvariantCulture, "Exception processing {0}: {1}", GetLinkChangeActionDescription(action), rslt.Exception.ToString())); succeeded = false; } } else // rslt.Exception == null { LinkChangeAction successfulAction = updateDocIndexToLinkChangeActionMap[i]; MarkLinkChangeActionCompleted(successfulAction); TraceManager.TraceVerbose("Successful " + GetLinkChangeActionDescription(successfulAction)); List <LinkChangeAction> updatedActions = new List <LinkChangeAction>(); updatedActions.Add(successfulAction); if (successfulAction.Link.LinkType.GetsActionsFromLinkChangeHistory) { actionsNeedingServerLinkIdSet.Add(successfulAction); } UpdateLinkConversionHistory(configService, translationService, rslt, updatedActions); } } SetServerLinkChangeIds(actionsNeedingServerLinkIdSet); return(succeeded); }
/// <summary> /// Retrieve all the plate types. The list of PlateTypes is cached for _cacheLifetime min. /// </summary> /// <param name="robot">The robot to find the plate types for.</param> /// <returns>An array of plate types, or null if there are none.</returns> IPlateType[] IPlateInfoProvider.GetPlateTypes(IRobot robot) { // Check arguments - do it up front to avoid possible inconsistencies later if (robot == null) { throw new System.NullReferenceException("robot must not be null"); } // Log the call if (_log.IsDebugEnabled) { string msg = "Called " + this + ".GetPlateTypes(robot=" + robot.ToString() + ")"; _log.Debug(msg); } // Return cached values if appropriate if ((_plateTypes != null) && (System.DateTime.Now.Ticks <= _plateTypesCacheExpires)) { _log.Debug("GetPlateTypes() using cached response"); return(_plateTypes); } _log.Debug("GetPlateTypes() refreshing cache"); // Sychronize this block as we are interacting with the cache lock (_plateTypesLock) { try { // Create and populate the request object getPlateTypes request = new getPlateTypes(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); // Make the web service call WSPlate wsPlate = new WSPlate(); // New stuff wsPlate.Url = "http://localhost:8080/xtalpims-ws/services/WSPlate.WSPlateSOAP12port_http/"; ServicePointManager.Expect100Continue = false; wsPlate.Credentials = new NetworkCredential("jon", "test123"); // End new stuff getPlateTypesResponse response = wsPlate.getPlateTypes(request); // Get the array of proxy PlateType[] OPPF.Proxies.PlateType[] pptArray = response.wrapper; // Map into an array of IPlateType[] OPPF.Integrations.ImagerLink.PlateType[] iptArray = new OPPF.Integrations.ImagerLink.PlateType[pptArray.Length]; int i = 0; foreach (OPPF.Proxies.PlateType ppt in pptArray) { iptArray[i] = new OPPF.Integrations.ImagerLink.PlateType(); iptArray[i].SetID(ppt.iD); iptArray[i].SetName(ppt.name); iptArray[i].SetNumColumns(ppt.numColumns); iptArray[i].SetNumDrops(ppt.numDrops); iptArray[i].SetNumRows(ppt.numRows); i++; } // Copy into the cache and update cache expiry _plateTypes = iptArray; _plateTypesCacheExpires = System.DateTime.Now.Ticks + _cacheLifetime; _log.Debug("GetPlateTypes() using fresh response"); } catch (Exception e) { // Log it string msg = "WSPlate.getPlateTypes threw " + e.GetType() + ": " + e.Message + " for robot \"" + robot.Name + "\" - returning null"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Error(msg, e); // Don't rethrow - return cache (which might be null) - don't want to stop imaging } } // Return the array of IPlateType[] return(_plateTypes); }
/// <summary> /// Web service version of GetImagingTasks - useful because it will /// cause a full schedule to be written if one doesn't already /// exist. /// /// Warning - this is a lot slower than going straight to platedb! /// </summary> /// <param name="robot">The robot</param> /// <param name="plateID">The barcode of the plate</param> /// <returns></returns> public IImagingTask[] GetImagingTasksFromWebService(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } // Log the call if (_log.IsInfoEnabled) { string msg = "Calling WSPlate.getImagingTasks() for plate " + plateID + ", robot " + RobotUtils.iRobotToString(robot); _log.Info(msg); } // Declare the array that will be populated and returned // - default to a zero-length array IImagingTask[] iImagingTasks = new IImagingTask[0]; // Set the request getImagingTasks request = new getImagingTasks(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; // Make the call getImagingTasksResponse response = null; try { WSPlate wsPlate = new WSPlate(); response = wsPlate.getImagingTasks(request); } catch (Exception e) { // Log it string msg = "WSPlate.getImagingTasks threw " + e.GetType() + ": " + e.Message + " for plateid \"" + plateID + "\" in robot \"" + robot.Name + "\" - returning empty IImagingTask[]"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Error(msg, e); // Don't rethrow - just return empty array return(iImagingTasks); } // If we got a response if (null != response) { // Get the array of ImagingTasks from the response OPPF.Proxies.ImagingTask[] wrapper = response.wrapper; // Convert to IImagingTasks iImagingTasks = new IImagingTask[wrapper.GetLength(0)]; for (int i = 0; i < wrapper.GetLength(0); i++) { OPPF.Integrations.ImagerLink.Scheduling.ImagingTask task = new OPPF.Integrations.ImagerLink.Scheduling.ImagingTask(); task.SetDateImaged(wrapper[i].dateImaged); task.SetDateToImage(wrapper[i].dateToImage); task.SetInQueue(wrapper[i].inQueue); task.SetPriority(wrapper[i].priority); task.SetState((Formulatrix.Integrations.ImagerLink.Scheduling.ImagingState)wrapper[i].state); iImagingTasks[i] = task; } } // Return the IImagingTask array return(iImagingTasks); }