public void Load(HttpDownload.LoadThread loadThread) { _isComplete = false; if (IsComplete) { downloadFile.OnLoadBlock(this); return; } downloadFile.state = DownloadFile.StateType.Loading; MLog.LogFormat("", "HttpDownloadFileBlock Load downloadFile.state={0}", downloadFile.state); this.loadThread = loadThread; Byte[] buffer = new Byte[1024]; int readSize = 0; httpRequest = WebRequest.Create(downloadFile.url) as HttpWebRequest; if (end > 0) { httpRequest.AddRange((int)(begin + loadedSize), (int)end); } httpResponse = httpRequest.GetResponse() as HttpWebResponse; httpStream = httpResponse.GetResponseStream(); outStream = new FileStream(tmpPath, loadedSize == 0 ? FileMode.Create : FileMode.Append); while (true) { readSize = httpStream.Read(buffer, 0, buffer.Length); if (readSize <= 0) { break; } outStream.Write(buffer, 0, readSize); loadedSize += readSize; lock (downloadFile) { downloadFile.loadedSize += readSize; } } Abort(); if (end <= 0) { lock (downloadFile) { downloadFile.size = downloadFile.loadedSize; } } IsComplete = true; this.loadThread = null; downloadFile.OnLoadBlock(this); }
public void run() { while (true) { lock (this) { //Iterator<Integer> it = taskTable.Keys.iterator(); //while (it.hasNext()) //{ // int id = it.next(); // AckListTask at = taskTable[id]; // at.run(); //} //用foreach来代替迭代器 foreach (AckListTask at in taskTable.Values) { at.run(); } taskTable.Clear(); taskTable = null; taskTable = new Dictionary <int, AckListTask>(); } try { Thread.Sleep(RUDPConfig.ackListDelay); } catch (Exception e) { MLog.info(e.Message); } } }
public void StartJointRay(long userID, UserManager userManager) { //userID是当前用户,UserID是操作中的用户 if (userManager.IsUserNear(UserID)) { return; } //如果当前用户在检测区域中并且不是操作中的用户,则设置当前用户为操作用户 if (userManager.IsUserNear(userID) && userID != UserID) { SetUserID(userID); HandStatus = KinectHandStatus.Enable; MLog.WriteLog(userID + "被检测到,开启双手操作——StartJointRay()"); //StartHand(2); } if (!userManager.IsUserNear(userID) && userID == UserID) { SetUserIDNull(); MLog.WriteLog(userID + "被检测到,停止双手操作——StartJointRay()"); StopHand(2); HandStatus = KinectHandStatus.Identify; userManager.StartNearUsers(); } }
public ActionResult Transition_GaleriKategoriGuncelle(FormCollection formCollection) { try { akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); gallery_categories albume_category = (gallery_categories)MTranslation.BuildObject(formCollection, "gallery_categories"); gallery_categories updated_albume_category = db.gallery_categories.Where(w => w.id == albume_category.id).FirstOrDefault(); if (updated_albume_category != null) { updated_albume_category.name = albume_category.name; db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Galeri Kategorisi Güncellendi.", Message_Type.Success); return(RedirectToAction("Galeri_Kategori_Detay", new { id = albume_category.id })); } else { MLog.Error("Galeri Kategorisi Güncellenemedi.", "Eksik veya Yanlış Bilgiler Girildi."); Session["message"] = new MessageModel("ERROR", "Eksik veya Yanlış Bilgiler Girildi.", Message_Type.Error); return(RedirectToAction("Galeri_Kategori_Detay", new { id = albume_category.id })); } } catch (Exception exception) { MLog.Error("Galeri Kategorisi Güncellenemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir Hata Oluştu.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } }
public ActionResult Transition_GaleriKategoriSil(string id) { try { int albume_category_id = Convert.ToInt32(id); akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); gallery_categories albume = db.gallery_categories.Where(w => w.id == albume_category_id).FirstOrDefault(); if (albume != null) { // delete albume category db.gallery_categories.Remove(albume); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Galeri Kategorisi Silindi.", Message_Type.Success); return(RedirectToAction("Galeri_Listele")); } else { MLog.Error("Galeri Kategorisi Silinemedi.", "Belirtilen Galeri Kategorisi Bulunamadı."); Session["message"] = new MessageModel("HATA", "Belirtilen Galeri Kategorisi Bulunamadı.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } } catch (Exception exception) { MLog.Error("Galeri Kategorisi Silinemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir hata oluştu.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } }
public ActionResult Transition_MenuEkle(FormCollection formCollection) { try { site_menu _site_menu = (site_menu)MTranslation.BuildObject(formCollection, "site_menu"); akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); if (_site_menu.name != "") { db.site_menu.Add(_site_menu); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Menü Ekendi.", Message_Type.Success); return(RedirectToAction("Menu_Listele")); } else { Session["message"] = new MessageModel("Menü Eklenemedi.", "Eksik Bilgi Girildi.", Message_Type.Error); MLog.Error("Menü Eklenemedi.", "Eksik Bilgi Girildi."); return(RedirectToAction("Menu_Listele")); } } catch (Exception exception) { MLog.Error("Menü Ekenemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir hata oluştu.", Message_Type.Error); return(RedirectToAction("Menu_Listele")); } }
public ActionResult Transition_GaleriKategoriEkle(FormCollection formCollection) { try { gallery_categories albume_category = (gallery_categories)MTranslation.BuildObject(formCollection, "gallery_categories"); if (albume_category.name != "") { akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); db.gallery_categories.Add(albume_category); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Galeri Kategorisi Eklendi.", Message_Type.Success); return(RedirectToAction("Galeri_Listele")); } else { MLog.Error("Galeri Kategorisi Eklenemedi.", "Eksik veya Yanlış Bilgiler Girildi."); Session["message"] = new MessageModel("ERROR", "Eksik veya Yanlış Bilgiler Girildi.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } } catch (Exception exception) { MLog.Error("Galeri Kategorisi Eklenemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir Hata Oluştu.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } }
public ActionResult Transition_MenuSil(string id) { try { int menu_id = Convert.ToInt32(id); akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); site_menu _site_menu = db.site_menu.Where(w => w.id == menu_id).FirstOrDefault(); if (_site_menu != null) { db.site_menu.Remove(_site_menu); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Menü Silindi.", Message_Type.Success); return(RedirectToAction("Menu_Listele")); } else { MLog.Error("Menü Silinemedi.", "Belirtilen Menu Bulunamadı."); Session["message"] = new MessageModel("HATA", "Belirtilen Menu Bulunamadı.", Message_Type.Error); return(RedirectToAction("Menu_Listele")); } } catch (Exception exception) { MLog.Error("Menü Silinemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir hata oluştu.", Message_Type.Error); return(RedirectToAction("Menu_Listele")); } }
private void Run() { while (!isExit) { MLog.LogFormat("[LoadThread]", "Run Doing Before {0}, httpDownload.waitBlockList.Count={1}", this, httpDownload.waitBlockList.Count); lock (httpDownload.waitBlockList) { if (httpDownload.waitBlockList.Count <= 0) { break; } block = httpDownload.waitBlockList[0]; httpDownload.waitBlockList.RemoveAt(0); } block.Load(this); block = null; MLog.LogFormat("[LoadThread]", "Run Doing After {0}, httpDownload.waitBlockList.Count={1}, block={2}", this, httpDownload.waitBlockList.Count, block); } state = StateType.End; thread = null; MLog.LogFormat("[LoadThread]", "Run End {0}", this); }
/// <summary> /// 变更平台 /// </summary> void ChangePlatform() { if (!MInputKinect.IsHandActive(2)) { if (MUtility.CurrentPlatform != OperatePlatform.Mouse) { mouseController.IsEnable = true; MUtility.CurrentPlatform = OperatePlatform.Mouse; MLog.WriteLog("切换:鼠标平台"); //Debug.Log("切换:鼠标平台"); } } else { if (MUtility.CurrentPlatform != OperatePlatform.Kinect) { mouseController.IsEnable = false; MUtility.CurrentPlatform = OperatePlatform.Kinect; MLog.WriteLog("切换:Kinect平台"); //Debug.Log("切换:Kinect平台"); } } }
public void Init() { if (!initialized) { log_module = (Modules.LogModule)AddModule(new Modules.LogModule()); application_module = (Modules.ApplicationModule)AddModule(new Modules.ApplicationModule()); platform_module = (Modules.PlatformModule)AddModule(new Modules.PlatformModule()); input_module = (Modules.InputModule)AddModule(new Modules.InputModule()); game_data_save_module = (Modules.GameDataSaveModule)AddModule(new Modules.GameDataSaveModule()); localization_module = (Modules.LocalizationModule)AddModule(new Modules.LocalizationModule()); event_module = (Modules.EventModule)AddModule(new Modules.EventModule()); game_module = (Modules.GameModule)AddModule(new Modules.GameModule()); scenes_module = (Modules.ScenesModule)AddModule(new Modules.ScenesModule()); settings_data_save_module = (Modules.SettingsDataSaveModule)AddUpdatableModule(new Modules.SettingsDataSaveModule()); time_module = (Modules.TimeModule)AddUpdatableModule(new Modules.TimeModule()); time_sliced_module = (Modules.TimeSlicedModule)AddUpdatableModule(new Modules.TimeSlicedModule()); particles_module = (Modules.ParticlesModule)AddUpdatableModule(new Modules.ParticlesModule()); ui_module = (Modules.UIModule)AddUpdatableModule(new Modules.UIModule()); flow_commands = (Modules.FlowCommandsModule)AddUpdatableModule(new Modules.FlowCommandsModule()); InitScenesConfig(); SpawnServicesPrefab(); StartModules(); initialized = true; MLog.LogInfo(this, "Fast services inited"); } }
void removeMapRule(String name) { MapRule mapRule = getMapRule(name); if (mapRule != null) { mapList.Remove(mapRule); mapRuleTable.Remove(mapRule.listen_port); if (mapRule.serverSocket != null) { try { mapRule.serverSocket.Close(); } catch (Exception e) { MLog.info(e.Message); } } try { saveMapRule(); } catch (Exception e) { MLog.info(e.Message); } } }
public ActionResult Transition_SetServerMappathManual(FormCollection formCollection) { string serverMappath = formCollection["server_mappath"]; MLog.SetLogPath(serverMappath); return(RedirectToAction("Index")); }
//接收流数据 public byte[] receive() { DataMessage me = null; if (conn.isConnected()) { me = receiveTable[lastRead + 1]; lock (availOb) { if (me == null) { //MLog.println("等待中 "+conn.connectId+" "+(lastRead+1)); try { Monitor.Wait(availOb); //availOb.Wait();//这里不知道c#如何改写 } catch (Exception e) { MLog.println(e.Message); } me = receiveTable[lastRead + 1]; //MLog.println("等待完成aaa "+conn.connectId+" "+(lastRead+1)); } } } else { throw new ConnectException("连接未建立"); } if (!streamClose) { checkCloseOffset_Remote(); if (me == null) { throw new ConnectException("连接已断开ccccccc"); } else { } conn.sender.sendLastReadDelay(); lastRead++; lock (availOb) { receiveTable.Remove(me.getSequence()); } received += me.getData().Length; //System.out.println("received "+received/1024/1024+"MB"); return(me.getData()); } else { throw new ConnectException("连接已断开"); } }
private void OnDestroy() { if (IsRecordLog) { MLog.WriteLogs(); } DestoryPlatform(Application.platform); }
private void Complete() { state = StateType.End; MLog.LogFormat("", "DownloadFile Complete {0}", this); if (completeCallback != null) { HttpDownload.AddLoaded(this); } }
//纳秒 public void sendSleep(long startTime, int length) { lock (this) { if (route.mode == 1) { currentSpeed = Route.localUploadSpeed; } if (sended == 0) { markTime = startTime; } sended += length; //10K sleep if (sended > 10 * 1024) { long needTime = (long)(1000 * 1000 * 1000f * sended / currentSpeed); long usedTime = DateTime.Now.Ticks * 100 - markTime;// 原文是纳秒,DateTime.Now.Ticks只能获取到100纳秒为单位 if (usedTime < needTime) { long sleepTime = needTime - usedTime; needSleep_All += sleepTime; long moreTime = trueSleep_All - needSleep_All; if (moreTime > 0) { if (sleepTime <= moreTime) { sleepTime = 0; trueSleep_All -= sleepTime; } } long s = needTime / (1000 * 1000); int n = (int)(needTime % (1000 * 1000)); long t1 = DateTime.Now.Ticks * 100; if (sleepTime > 0) { try { Thread.Sleep((int)s);//这里可能有问题,实际上Sleep做不到纳米级别的 } catch (Exception e) { MLog.info(e.Message); } trueSleep_All += (DateTime.Now.Ticks * 100 - t1); //#MLog.println("sssssssssss "+(trueSleep_All-needSleep_All)/(1000*1000)); } ////#MLog.println("sleepb "+sleepTime+" l "+sended+" s "+s+" n "+n+" tt "+(moreTime)); } sended = 0; } } }
void sendDataMessage(DataMessage me, bool resend, bool twice, bool block) { lock (conn.clientControl.getSynlock()) { long startTime = DateTime.Now.Ticks * 100;//c#没有Java的nano秒,只能用ticks*100来模拟 long t1 = DateTime.Now.Millisecond; conn.clientControl.onSendDataPacket(conn); int timeId = conn.clientControl.getCurrentTimeId(); me.create(timeId); SendRecord record_current = conn.clientControl.getSendRecord(timeId); if (!resend) { //第一次发,修改当前时间记录 me.setFirstSendTimeId(timeId); me.setFirstSendTime(DateTime.Now.Millisecond); record_current.addSended_First(me.getData().Length); record_current.addSended(me.getData().Length); } else { //重发,修改第一次发送时间记录 SendRecord record = conn.clientControl.getSendRecord(me.getFirstSendTimeId()); record.addResended(me.getData().Length); record_current.addSended(me.getData().Length); } try { sendSum++; sum++; unAckMax++; long t = DateTime.Now.Millisecond; send(me.getDatagramPacket()); if (twice) { send(me.getDatagramPacket());//发两次 } if (block) { conn.clientControl.sendSleep(startTime, me.getData().Length); } TrafficEvent tevent = new TrafficEvent("", (long)Math.Floor(ran.NextDouble() * 1000000000D), me.getData().Length, TrafficEvent.type_uploadTraffic); Route.fireEvent(tevent); } catch (Exception e) { MLog.info(e.Message); } } }
public ActionResult Transition_MenuYemekEkle(FormCollection formCollection) { int random_number = new Random().Next(0, 1024); int menu_id = 0; try { site_food_menu site_food = (site_food_menu)MTranslation.BuildObject(formCollection, "site_food_menu"); menu_id = site_food.site_menu_id; // adding picture to Disk HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { string filename = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Files/Food_Menu"), "" + random_number + filename); file.SaveAs(path); // food image_name is uploaded picture name site_food.image_name = "" + random_number + filename; // adding food to Database akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); if (site_food.name != "") { db.site_food_menu.Add(site_food); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Yemek Menüye Ekendi.", Message_Type.Success); return(RedirectToAction("Menu_Detay", new { id = "" + menu_id })); } else { MLog.Error("Yemek Menüye Ekenemedi.", "Eksik Bilgi Girildi."); Session["message"] = new MessageModel("HATA", "Eksik Bilgi Girildi.", Message_Type.Error); return(RedirectToAction("Menu_Detay", new { id = "" + menu_id })); } } else { MLog.Error("Yemek Menüye Ekenemedi.", "Eksik Bilgi Girildi."); Session["message"] = new MessageModel("HATA", "Eksik Bilgi Girildi.", Message_Type.Error); return(RedirectToAction("Menu_Detay", new { id = "" + menu_id })); } } catch (Exception exception) { MLog.Error("Yemek Menüye Ekenemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir hata oluştu.", Message_Type.Error); return(RedirectToAction("Menu_Detay", new { id = "" + menu_id })); } }
private void InitScenesConfig() { if (scenes_config == null) { MLog.LogError(this, "Scenes config is null, quitting application"); MApplication.Quit(); return; } MScenes.SetScenesConfig(scenes_config); }
private void DeleteMissedUser() { if ((!usersID.Contains(UserID)) && UserID != 0) { MLog.WriteLog("执行双手停止操作,方法名:DeleteMissedUser"); StopHand(2); SetUserIDNull(); HandStatus = KinectHandStatus.Identify; } }
public ActionResult Transition_GaleriResimSil(string id) { int albume_id = 0; try { int gimage_id = Convert.ToInt32(id); akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); gallery_images gimage = db.gallery_images.Where(w => w.id == gimage_id).FirstOrDefault(); if (gimage != null) { albume_id = gimage.title_id; string content_type = (gimage.file_name.Contains(".")) ? "image" : "video"; if (content_type == "image") { //deleting picture from disk string file_path = Path.Combine(Server.MapPath("~/Files/Galleries/" + albume_id), gimage.file_name); if (System.IO.File.Exists(file_path)) { System.IO.File.Delete(file_path); } } else if (content_type == "video") { // not need to anything } // deleting from database db.gallery_images.Remove(gimage); db.SaveChanges(); Session["message"] = new MessageModel("Bilgi", "Fotoğraf/Video Silindi.", Message_Type.Success); return(RedirectToAction("Galeri_Detay", new { id = "" + albume_id })); } else { MLog.Error("Fotoğraf/Video Silinemedi.", "Belirtilen Fotoğraf/Video Bulunamadı."); Session["message"] = new MessageModel("HATA", "Belirtilen Fotoğraf Bulunamadı.", Message_Type.Error); return(RedirectToAction("Galeri_Detay")); } } catch (Exception exception) { MLog.Error("Fotoğraf Silinemedi.", exception.Message + Environment.NewLine + exception.StackTrace); Session["message"] = new MessageModel("HATA", "Bir hata oluştu.", Message_Type.Error); return(RedirectToAction("Galeri_Listele")); } }
private void SpawnServicesPrefab() { if (services_prefab == null) { MLog.LogError(this, "Services prefab is null, quitting application"); MApplication.Quit(); return; } GameObject services_instance = Instantiate(services_prefab); services_instance.name = "Services"; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // setting MLog MLog.SetLogPath(Server.MapPath("")); // MLog.Info("Setted value", "Global.asax: Server Mappath setted"); }
public ActionResult Transition_IletisimFormu(FormCollection formCollection) { try { // getting website's mail address from db akgul_yemek_dbEntities db = new akgul_yemek_dbEntities(); string web_site_email = db.details.Where(w => w.key_ == "email").FirstOrDefault().value; // fortest //web_site_email = "*****@*****.**"; // Creating a mail schema IletisimForm_Model iletisimForm_model = (IletisimForm_Model)MTranslation.BuildObject(formCollection, "IletisimForm_Model"); string name = iletisimForm_model.name; string email = iletisimForm_model.email; string tel = iletisimForm_model.tel; string subject = iletisimForm_model.subject; string message = iletisimForm_model.message; string konu = "Akggül Yemek Web Sitesi İletisim Formu Gönderisi"; string mesaj = "İsim : " + name + " --- " + Environment.NewLine + "Tel : " + tel + " --- " + Environment.NewLine + "Email: " + email + " --- " + Environment.NewLine + Environment.NewLine + "Konu : " + subject + Environment.NewLine + Environment.NewLine + "Mesaj: " + message; // sending email: bool sonuc = MEmail.MailGonder(web_site_email, konu, mesaj); if (sonuc) { TempData["message_model"] = new MessageModel("Sonuç", "Mesajınınız Başarıyla Sisteme İletildi", Message_Type.Success); } else { MLog.Error("Site İletişim Formu: Sisteme mesaj iletilemedi.", "Mesajınınız Sisteme İletilirken Bir Hata Oluştu"); TempData["message_model"] = new MessageModel("Sonuç", "Mesajınınız Sisteme İletilirken Bir Hata Oluştu", Message_Type.Error); } } catch (Exception exception) { MLog.Error("Site İletişim Formu: Sisteme mesaj iletilemedi.", exception.Message + Environment.NewLine + exception.StackTrace); TempData["message_model"] = new MessageModel("Sonuç", "Bir Hata Oluştu", Message_Type.Error); } return(RedirectToAction("Index")); }
public CapServer() { CapEnv capEnv = null; try { capEnv = new CapEnv(false); capEnv.init(); } catch (Exception e) { MLog.info(e.Message); } }
private void CheckLoadSizeThreadStart() { MLog.LogFormat("[Main]", "HttpDownload.CheckLoadSizeThreadStart waitFileList.Count={0}, loadSizeThread.state={1}", waitFileList.Count, loadSizeThread.state); if (waitFileList.Count == 0) { return; } if (loadSizeThread.state != LoadSizeThread.StateType.Runing) { loadSizeThread.Start(); } }
public ActionResult Transition_DeleteLogFile(string id) { string logFileName = id; string logsPath = MLog.GetLogDirectory(); string logFilePath = Path.Combine(logsPath, logFileName); if (System.IO.File.Exists(logFilePath)) { System.IO.File.Delete(logFilePath); } return(RedirectToAction("Index")); }
public void CreateError(string errCaption) { Exception excp = Server.GetLastError(); //string actor = (Context.Session == null) ? "GUEST" : "USER"; string message = "URL: " + Request.Url.ToString() + Environment.NewLine + " ERROR: " + excp.Message; if (excp.InnerException != null) { message += Environment.NewLine + " Inner Error: " + excp.InnerException.Message; } MLog.Error(errCaption, message); Server.ClearError(); }
public void sendPingMessage2(int pingId, IPAddress dstIp, int dstPort) { PingMessage2 lm = new PingMessage2(0, route.localclientId, pingId); lm.setDstAddress(dstIp); lm.setDstPort(dstPort); try { sendPacket(lm.getDatagramPacket()); } catch (Exception e) { MLog.info(e.Message); } }