public void AddFinishedCallback(FinishedCallback callback) { if (!this.m_finishedListeners.Contains(callback)) { this.m_finishedListeners.Add(callback); } }
public bool RemoveFinishedCallback(FinishedCallback callback, object userData) { FinishedListener item = new FinishedListener(); item.SetCallback(callback); item.SetUserData(userData); return(this.m_finishedListeners.Remove(item)); }
public void AddFinishedListener(FinishedCallback callback, object userData) { FinishedListener item = new FinishedListener(); item.SetCallback(callback); item.SetUserData(userData); this.m_finishedListeners.Add(item); }
public static HttpWebRequest MultipartFormDataPost(string postUrl, string userAgent, Dictionary<string, object> postParameters, FinishedCallback callback) { string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid()); string contentType = "multipart/form-data; boundary=" + formDataBoundary; byte[] formData = GetMultipartFormData(postParameters, formDataBoundary); return PostForm(postUrl, userAgent, contentType, formData, callback); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; SetNewDirectory(Directory.GetCurrentDirectory()); SwitchDirectoryNow(); }
// Browsers need at least a rect, name and callback internal Browser(FinishedCallback finished_callback) { type = BrowserType.FILE; callback = finished_callback; SetNewDirectory(Directory.GetCurrentDirectory()); SwitchDirectoryNow(); }
public static void Execute(WWW request, FinishedCallback callback) { var window = GetWindow(typeof(MadWWWFormSender), true) as MadWWWFormSender; window.request = request; window.callback = callback; window.autoRepaintOnSceneChange = true; window.minSize = new Vector2(200, 200); window.Show(); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; UIManager.instance.windowOpen = true; SetNewDirectory(Directory.GetCurrentDirectory()); SwitchDirectoryNow(); }
public void Execute(object parameter) { Executing = true; _action(parameter).ContinueWith((task) => { Executing = false; FinishedCallback?.Invoke(); }); }
//Alex Tek modif public ImprovedFileBrowser(Rect screenRect, string name, FinishedCallback callback, string startingPath) { m_name = name; m_screenRect = screenRect; buttonWidth = (int)m_screenRect.width / 3; m_browserType = FileBrowserType.File; m_callback = callback; SetNewDirectory(startingPath); SwitchDirectoryNow(); }
public void MessageQueue(MessageCallback mcb, ErrorCallback ecb, FinishedCallback fcb) { Send( "/messagequeue", ReceiveMode.Lines, sw => sw.Write("token=" + HttpUtility.UrlEncode(token)), cipher => ParseMessage(cipher, mcb, ecb), null, ecb, fcb ); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; //SetNewDirectory(Application.dataPath+"/Music"); Debug.Log(Directory.GetCurrentDirectory() + "\\Assets\\resources\\"); //SetNewDirectory(Directory.GetCurrentDirectory()+ "\\Assets\\resources\\"); // unity환경에서의 디렉토리 정하기 SetNewDirectory(Directory.GetCurrentDirectory() + "\\Harmony_Data\\resources\\"); // build환경에서의 디렉토리 정하기 >>player settings에서 product name >> Harmony SwitchDirectoryNow(); }
// Browsers need at least a rect, name and callback public FileBrowser(/*Rect screenRect, */ string name, FinishedCallback callback) { m_name = name; // m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; SetNewDirectory(Directory.GetCurrentDirectory()); SwitchDirectoryNow(); m_fileImage = Resources.Load("GUI/FileBrowser/FileImage", typeof(Texture2D)) as Texture2D; m_fileImageNonMatching = Resources.Load("GUI/FileBrowser/FileImageNonMatching", typeof(Texture2D)) as Texture2D; m_directoryImage = Resources.Load("GUI/FileBrowser/DirectoryImage", typeof(Texture2D)) as Texture2D; }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback, string lastUsedDirectory) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; if(lastUsedDirectory == null) SetNewDirectory(Directory.GetCurrentDirectory()); else SetNewDirectory(lastUsedDirectory); SwitchDirectoryNow(); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback, string directory = "") { if (directory == string.Empty) { directory = Directory.GetCurrentDirectory(); } m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; SetNewDirectory(directory); SwitchDirectoryNow(); }
public void Execute(object parameter) { if (!CanExecute(parameter)) { return; } Executing = true; _action(parameter).ContinueWith(task => { Executing = false; FinishedCallback?.Invoke(); }); }
public FileBrowser(Rect screenRect, string name, FileBrowserType type, FinishedCallback callback, string dirpath) { m_name = name; m_screenRect = screenRect; m_browserType = type; m_callback = callback; UIManager.instance.windowOpen = true; if (Directory.Exists(dirpath)) { SetNewDirectory(dirpath); } else { SetNewDirectory(Directory.GetCurrentDirectory()); } SwitchDirectoryNow(); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback, string lastUsedDirectory) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; if (lastUsedDirectory == null) { SetNewDirectory(Directory.GetCurrentDirectory()); } else { SetNewDirectory(lastUsedDirectory); } SwitchDirectoryNow(); }
public FileBrowser(Rect screenRect, string name, FinishedCallback callback) { #if UNITY_ANDROID pathDir = "/storage/"; // write here images path for your android device. #endif #if UNITY_EDITOR || UNITY_WEBPLAYER pathDir = Directory.GetCurrentDirectory(); #endif #if UNITY_IPHONE pathDir = Application.dataPath; // write here images path for your iOS device.For e.g "/private/var/" etc. #endif #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX pathDir = Directory.GetCurrentDirectory(); #endif m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = callback; SetNewDirectory(pathDir); SwitchDirectoryNow(); }
// Browsers need at least a rect, name and callback public FileBrowser(Rect screenRect, string name, FinishedCallback callback) { m_name = name; m_screenRect = screenRect; m_browserType = FileBrowserType.File; m_callback = (s) => { if (callback != null) { callback(s); } m_path = s; }; DirectoryImage = m_directoryImage ?? Resources.Load <Texture2D>("Icons/folder"); //No estoy seguro de si esto funcionará FileImage = m_fileImage ?? Resources.Load <Texture2D>("Icons/file"); m_skin = Resources.Load <GUISkin>("Skins/File Browser"); SetNewDirectory(Directory.GetCurrentDirectory()); SwitchDirectoryNow(); }
public MusicBrowser(Rect screenRect, string name, FinishedCallback callback, string filePattern) { m_name = name; m_screenRect = screenRect; m_browserType = MusicBrowserType.File; m_callback = callback; m_filePattern = filePattern; string lastD = LoadLastD(); if (lastD != null && lastD != "" && Directory.Exists(lastD)) { SetNewDirectory(lastD); } else { selectDrive = true; SetNewDirectory("/"); } drives = Directory.GetLogicalDrives(); SwitchDirectoryNow(); }
/// <summary> /// در اینجا موارد قابل اجر به لیست منحصر به فرد فراخواننده اضافه می گردند و درصورتیکه این موارد قبلا وجود داشته باشند به عنوان مورد جدید پذیرفته نمی شود /// </summary> /// <param name="ExectablePrsCalcList"></param> /// <returns>مواردی که برای اجر پذیرفته شده اند</returns> public static IList <ExecutablePersonCalculation> AddThreads(String CallerIdentity, IList <ExecutablePersonCalculation> ExectablePrsCalcList, FinishedCallback Callback) { try { mut.WaitOne(); IDictionary <decimal, ExecutableThread> ExecThreads = null; int ExecThreadsCount = 0; executableThreadsWithCaller.TryGetValue(CallerIdentity, out ExecThreads); executableThreadsCountWithCaller.TryGetValue(CallerIdentity, out ExecThreadsCount); if (ExecThreads == null) { ExecThreads = new Dictionary <decimal, ExecutableThread>(); executableThreadsWithCaller.Add(CallerIdentity, ExecThreads); executableThreadsCountWithCaller.Add(CallerIdentity, 0); } IList <ExecutablePersonCalculation> ItemAdded = new List <ExecutablePersonCalculation>(); for (int i = 0; i <= ExectablePrsCalcList.Count - 1; i++) { decimal PrsId = ExectablePrsCalcList[i].PersonId; ///این پرسنل در لیستی با شناسه فراخواننده متفاوت قبلا درج شده است if (ExsitThreadNotInCaller(CallerIdentity, PrsId)) { continue; } if (!ExecThreads.ContainsKey(PrsId)) { ExecutableThread executableThread = new ExecutableThread(CallerIdentity, ExectablePrsCalcList[i].ID, ExectablePrsCalcList[i].PersonId, ExectablePrsCalcList[i].FromDate.Date, ExectablePrsCalcList[i].ToDate.Date, Callback); ExecThreads.Add(PrsId, executableThread); executableThreadsCountWithCaller[CallerIdentity]++; ItemAdded.Add(ExectablePrsCalcList[i]); } //else if (!ExecThreads[PrsId].Executing) //{ // ItemAdded.Add(ExectablePrsCalcList[i]); //} } return(ItemAdded); } finally { mut.ReleaseMutex(); } }
/// <summary> /// مورد ارسال شده را برای اجرا تست می کند، اگر قبلا برای اجرا ارسال نشده باشد یا اجرا نشده باشد آن را برای اجرا برمی گرداند /// </summary> /// <param name="Threads"></param> /// <returns>موردی که برای اجر پذیرفته شده است</returns> public static ExecutableThread.ThreadParam ForceToExecute(string CallerIdentity, ExecutablePersonCalculation MustExecuted, FinishedCallback Callback) { try { mut.WaitOne(); //if (IsThreadExecute(MustExecuted.PersonId)) //{ // ///نخی که محاسبات را در حالت اجرا قرار داده با فراخواننده ی این تابع متفاوت است // if (executableThreadsWithCaller.ContainsKey(CallerIdentity) && // executableThreadsWithCaller[CallerIdentity].ContainsKey(MustExecuted.PersonId) && // !executableThreadsWithCaller[CallerIdentity][MustExecuted.PersonId].Executing) // { // executableThreadsWithCaller[CallerIdentity].Remove(MustExecuted.PersonId); // } // return null; //} //else //{ if (!executableThreadsWithCaller.ContainsKey(CallerIdentity)) { executableThreadsWithCaller.Add(CallerIdentity, new Dictionary <decimal, ExecutableThread>()); executableThreadsCountWithCaller.Add(CallerIdentity, 0); } if (!executableThreadsWithCaller[CallerIdentity].ContainsKey(MustExecuted.PersonId)) { ExecutableThread executableThread = new ExecutableThread(CallerIdentity, MustExecuted.ID, MustExecuted.PersonId, MustExecuted.FromDate.Date, MustExecuted.ToDate.Date, Callback); executableThreadsWithCaller[CallerIdentity].Add(MustExecuted.PersonId, executableThread); executableThreadsCountWithCaller[CallerIdentity]++; } executableThreadsWithCaller[CallerIdentity][MustExecuted.PersonId].Executing = true; executableThreadsWithCaller[CallerIdentity][MustExecuted.PersonId].Duration.Start(); executableThreadsWithCaller[CallerIdentity][MustExecuted.PersonId].Param.ToDate = MustExecuted.ToDate; return(executableThreadsWithCaller[CallerIdentity][MustExecuted.PersonId].Param); //} } finally { mut.ReleaseMutex(); } }
public static IEnumerator Download(string url, string fileName, ENFileExist existOpt, DownloadCallback downloadCallback, FinishedCallback finishedCallback) { string finalFilePath = Application.persistentDataPath + "/" + fileName; FileInfo finalFileInfo = new FileInfo(finalFilePath); if (finalFileInfo.Exists) { switch (existOpt) { case ENFileExist.enReplace: break; case ENFileExist.enCancel: yield break; default: break; } } string tempFilePath = Application.temporaryCachePath + "/" + fileName + ".tmp"; FileInfo tempFileInfo = new FileInfo(tempFilePath); using (FileStream fileStream = File.Open(tempFilePath, tempFileInfo.Exists ? FileMode.Append : FileMode.CreateNew)) { using (UnityWebRequest request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET, new DownloadFileHandler(fileStream, downloadCallback, finishedCallback), null)) { if (tempFileInfo.Exists) { request.SetRequestHeader("RANGE", string.Format("bytes={0}-", tempFileInfo.Length)); } yield return(request.Send()); } } if (finalFileInfo.Exists) { File.Delete(finalFilePath); } File.Move(tempFilePath, finalFilePath); File.Delete(tempFilePath); }
/// <summary> /// <para>所有任务正常结束后, 调用callback方法.</para> /// 在调用callback时, manager已经停止, 需要重新start. /// </summary> public TaskManager(FinishedCallback callback = null) { mOnTaskFinished = callback; }
public HttpDownloadHandler(FileStream fileStream, ProgressCallback downloadCallback, FinishedCallback finishedCallback) { mFileStream = fileStream; mDownloadCallback = downloadCallback; mFinishedCallback = finishedCallback; }
private void Send( string uri, ReceiveMode mode, WriteDataCallback wdcb, SuccessCallback scb, BinarySuccessCallback bcb, ErrorCallback ecb, FinishedCallback fcb) { if (!LoggedIn && uri != "/login" && uri != "/crashreport") { throw new InvalidOperationException("Not logged in"); } var req = WebRequest.CreateHttp(((uri == "/login" || uri == "/crashreport") ? DefaultRootUrl : RootUrl) + uri); req.ContentType = "application/x-www-form-urlencoded"; req.Method = "POST"; var waitHandle = new ManualResetEvent(false); req.BeginGetRequestStream(ar => { try { using (var requestStream = req.EndGetRequestStream(ar)) { using (var sr = new StreamWriter(requestStream)) { wdcb(sr); } } req.BeginGetResponse( a => { waitHandle.Set(); try { var response = (HttpWebResponse)req.EndGetResponse(a); var responseStream = response.GetResponseStream(); if (mode == ReceiveMode.Blob) { var data = new byte[response.ContentLength]; responseStream.BeginRead( data, 0, (int)response.ContentLength, result => { if (result.IsCompleted) { bcb(response.ContentType, data); } else { ecb("Incomplete response"); } }, null ); } else { using (var sr = new StreamReader(responseStream)) { switch (mode) { case ReceiveMode.Lines: string line; while ((line = sr.ReadLine()) != null) { if (line != string.Empty) { scb(line); } } break; case ReceiveMode.SingleString: scb(sr.ReadToEnd()); break; } if (fcb != null) { fcb(); } } } } catch (WebException e) { if (e.Status == WebExceptionStatus.RequestCanceled) { ecb(""); return; } var response = (HttpWebResponse)e.Response; if (response.StatusCode == HttpStatusCode.Forbidden) { LoggedIn = false; } try { using (var responseStream = response.GetResponseStream()) { using (var sr = new StreamReader(responseStream)) { ecb(sr.ReadToEnd()); } } } catch (Exception ex) { // What is wrong with this platform?! ecb(ex.Message + "\n" + e.Message); } } }, null ); } catch (WebException) { // The request was aborted ecb(""); } }, null); ThreadPool.QueueUserWorkItem( state => { if (!waitHandle.WaitOne(MessageTimeout)) { (state as HttpWebRequest).Abort(); } }, req ); }
private static HttpWebRequest PostForm(string postUrl, string userAgent, string contentType, byte[] formData, FinishedCallback callback) { HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest; if (request == null) { throw new NullReferenceException("request is not a http request"); } // Set up the request properties. request.Method = "POST"; request.ContentType = contentType; //request.UserAgent = userAgent; // TODO: check and comment in! request.CookieContainer = new CookieContainer(); //request.ContentLength = formData.Length; // Not needed in WP7 // You could add authentication here as well if needed: // request.PreAuthenticate = true; // request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested; // request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("username" + ":" + "password"))); // Send the form data to the request. request.BeginGetRequestStream(ar => { var requestStream = request.EndGetRequestStream(ar); using (var sw = new StreamWriter(requestStream)) { requestStream.Write(formData, 0, formData.Length); //requestStream.Close(); // TODO: Works without this line? } request.BeginGetResponse(a => { var response = request.EndGetResponse(a); var responseStream = response.GetResponseStream(); using (var sr = new StreamReader(responseStream)) { // Parse the response message here callback(sr.ReadToEnd()); } }, null); }, null); return request; }
private void Send( string uri, ReceiveMode mode, WriteDataCallback wdcb, SuccessCallback scb, BinarySuccessCallback bcb, ErrorCallback ecb, FinishedCallback fcb) { if (!LoggedIn && uri != "/login" && uri != "/crashreport") { throw new InvalidOperationException("Not logged in"); } var req = WebRequest.CreateHttp(((uri == "/login" || uri == "/crashreport") ? DefaultRootUrl : RootUrl) + uri); req.ContentType = "application/x-www-form-urlencoded"; req.Method = "POST"; var waitHandle = new ManualResetEvent(false); req.BeginGetRequestStream(ar => { try { using (var requestStream = req.EndGetRequestStream(ar)) { using (var sr = new StreamWriter(requestStream)) { wdcb(sr); } } req.BeginGetResponse( a => { waitHandle.Set(); try { var response = (HttpWebResponse) req.EndGetResponse(a); var responseStream = response.GetResponseStream(); if (mode == ReceiveMode.Blob) { var data = new byte[response.ContentLength]; responseStream.BeginRead( data, 0, (int) response.ContentLength, result => { if (result.IsCompleted) { bcb(response.ContentType, data); } else { ecb("Incomplete response"); } }, null ); } else { using (var sr = new StreamReader(responseStream)) { switch (mode) { case ReceiveMode.Lines: string line; while ((line = sr.ReadLine()) != null) { if (line != string.Empty) { scb(line); } } break; case ReceiveMode.SingleString: scb(sr.ReadToEnd()); break; } if (fcb != null) { fcb(); } } } } catch (WebException e) { if(e.Status == WebExceptionStatus.RequestCanceled) { ecb(""); return; } var response = (HttpWebResponse) e.Response; if (response.StatusCode == HttpStatusCode.Forbidden) { LoggedIn = false; } try { using (var responseStream = response.GetResponseStream()) { using (var sr = new StreamReader(responseStream)) { ecb(sr.ReadToEnd()); } } } catch (Exception ex) { // What is wrong with this platform?! ecb(ex.Message + "\n" + e.Message); } } }, null ); } catch(WebException) { // The request was aborted ecb(""); } }, null); ThreadPool.QueueUserWorkItem( state => { if (!waitHandle.WaitOne(MessageTimeout)) { (state as HttpWebRequest).Abort(); } }, req ); }
public void AddFinishedListener(FinishedCallback callback) { this.AddFinishedListener(callback, null); }
public bool RemoveFinishedCallback(FinishedCallback callback) { return(this.RemoveFinishedCallback(callback, null)); }
public ExecutableThread(string CallerIdentity, Decimal ExecutablePrsCalcID, Decimal PersonId, DateTime FromDate, DateTime ToDate, FinishedCallback Callback) { Executing = false; this.Param = new ThreadParam { ExecuteByRobot = false, CallerIdentity = CallerIdentity, ExecutablePrsCalcId = ExecutablePrsCalcID, PersonId = PersonId, FromDate = FromDate, ToDate = ToDate, ThreadContext = null, FinishedCallback = Callback }; Duration = new Stopwatch(); }
public static string Download(string URL_, string ToPath_, HttpFileExistOption existOpt, ProgressCallback progressCallback, FinishedCallback finishedCallback) { var guid = System.Guid.NewGuid().ToString(); GameObject go = new GameObject("HttpSender(" + HttpMethod.DOWNLOAD.ToString() + ")" + guid); var sender = go.AddComponent <HttpSender>(); sender.GUID = guid; sender.Url = URL_; sender.Data = null; sender.Method = HttpMethod.DOWNLOAD; sender.Timeout = 60; sender.RefHold = ReferenceHold.WaitForComplete; sender.FilePath = ToPath_; sender.mProgressCallback = progressCallback; sender.mFinishedCallback = finishedCallback; sender.ExistOption = existOpt; sender.Completion = null; if (!Instance._senders.ContainsKey(guid)) { Instance._senders.Add(guid, sender); } sender.Send(); return(guid); }
public ValueInterpolator SetFinishedCallback(FinishedCallback finishedCallback) { callback = finishedCallback; return(this); }
public void AddFinishedCallback(FinishedCallback callback) { this.AddFinishedCallback(callback, null); }