/// <summary> /// A general HttpPut method, with delegates for progress and cancelling /// </summary> /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param> /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param> /// <param name="timeout">Whether to apply a timeout</param> /// <param name="task">The task used to track this http get</param> /// <param name="session">Session used to make api calls (may be replaced if logged out, hence ref)</param> /// <param name="path">Path to file to put</param> /// <returns>The result of the task passed in</returns> public static String Put(XenAPI.HTTP.UpdateProgressDelegate progressDelegate, HTTP.FuncBool cancellingDelegate, bool timeout, IXenConnection connection, XenRef <Task> task, ref Session session, string path, string hostname, Delegate f, params object[] p) { return(Put(progressDelegate, cancellingDelegate, XenAdminConfigManager.Provider.GetProxyTimeout(timeout), connection, task, ref session, path, hostname, f, p)); }
/// <summary> /// A general HttpPut method, with delegates for progress and cancelling /// </summary> /// <param name="progressDelegate">Delegate called periodically (500ms) with percent complete</param> /// <param name="cancellingDelegate">Delegate called periodically to see if need to cancel</param> /// <param name="timeout">Timeout value in ms</param> /// <param name="task">The task used to track this http get</param> /// <param name="session">Session used to make api calls (may be replaced if logged out, hence ref)</param> /// <param name="path">Path to file to put</param> /// <returns>The result of the task passed in</returns> public static String Put(XenAPI.HTTP.UpdateProgressDelegate progressDelegate, HTTP.FuncBool cancellingDelegate, int timeout, IXenConnection connection, XenRef <Task> task, ref Session session, string path, string hostname, Delegate f, params object[] p) { log.DebugFormat("HTTP PUTTING file from {0} to {1}", path, hostname); HTTP.FuncBool cancellingDelegate2 = (HTTP.FuncBool) delegate() { return(XenAdminConfigManager.Provider.ForcedExiting || cancellingDelegate != null && cancellingDelegate()); }; try { List <object> args = new List <object>(); args.Add(progressDelegate); args.Add(cancellingDelegate2); args.Add(timeout); args.Add(hostname); args.Add(XenAdminConfigManager.Provider.GetProxyFromSettings(connection)); args.Add(path); args.Add(task.opaque_ref); // task_id args.AddRange(p); f.DynamicInvoke(args.ToArray()); } catch (Exception e) { log.DebugFormat("Caught exception doing HTTP PUT from {0} to {1}", path, hostname); log.Debug(e, e); PollTaskForResult(connection, ref session, cancellingDelegate2, task); if (e is CancelledException || e.InnerException is CancelledException) { throw new XenAdmin.CancelledException(); } else { throw; } } return(PollTaskForResult(connection, ref session, cancellingDelegate2, task)); }