private void StartGC() { Thread gc = new Thread(() => { while (true) { judpSocket socket = null; foreach (var item in dicMap) { if (!item.Key.TryGetTarget(out socket)) { UDTSession serversession = endPoint.RemoveSession(item.Value); if (serversession != null) { serversession.Socket.Close(); serversession.Socket.GetReceiver().Stop(); serversession.Socket.GetSender().Stop(); FlashLogger.Info("移除socket:" + item.Value); } } } } }); gc.IsBackground = true; gc.Name = "GCSocket"; if (!gc.IsAlive) { gc.Start(); } }
public ReturnEntity <ErrorListEntity_Order, Order> Response(string orderDetailInfo) { try { string url = ModelFactory.Url + "/companyInterface/drug/purchaseOrder/response"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "orderDetailInfo", orderDetailInfo }, }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ReturnEntityCommon <ErrorListEntity_Order, Order>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(Read(orderDetailInfo)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
public ListEntity <PayOrderDetail> GetPayOrderDetails(string payOrderCode, string currentPageNumber) { try { string url = ModelFactory.Url + "/companyInterface/pay/getPayOrderDetail"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "payOrderCode", payOrderCode }, { "currentPageNumber", currentPageNumber } }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon <PayOrderDetail>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(GetPayOrderDetails(payOrderCode, currentPageNumber)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
/** * handle the connection handshake:<br/> * <ul> * <li>set initial sequence number</li> * <li>send response handshake</li> * </ul> * @param handshake * @param peer * @throws IOException */ protected void HandleHandShake(ConnectionHandshake handshake) { ConnectionHandshake responseHandshake = new ConnectionHandshake(); //compare the packet size and choose minimun long clientBufferSize = handshake.PacketSize; long myBufferSize = datagramSize; long bufferSize = Math.Min(clientBufferSize, myBufferSize); long initialSequenceNumber = handshake.InitialSeqNo; this.initialSequenceNumber = initialSequenceNumber; this.DatagramSize = (int)bufferSize; // setDatagramSize((int) bufferSize); responseHandshake.PacketSize = bufferSize; responseHandshake.UdtVersion = 4; responseHandshake.InitialSeqNo = initialSequenceNumber; responseHandshake.ConnectionType = -1; responseHandshake.MaxFlowWndSize = handshake.MaxFlowWndSize; //tell peer what the socket ID on this side is responseHandshake.SocketID = mySocketID; responseHandshake.DestinationID = this.destination.SocketID; //cd 2018-08-28 if (this.cookie == 0) { this.cookie = CreateCookie(); } responseHandshake.Cookie = cookie; responseHandshake.SetSession(this); FlashLogger.Info("Sending reply " + responseHandshake); endPoint.DoSend(responseHandshake); }
public void Execute(IJobExecutionContext context) { ICompanySCBLL companyBll = new CompanySCBLL(); List <Company> companyList = null; DateTime dateTimeM = DateTime.Now; FlashLogger.Error(string.Format("下载生产企业信息【{0}】", System.Threading.Thread.CurrentThread.ManagedThreadId)); while (dateTimeM > Convert.ToDateTime("2016-03-01")) { var listEntity = companyBll.GetCompanys("", dateTimeM.ToString("yyyy-MM"), "1"); if (listEntity == null) { break; } companyList = listEntity.DataList; if (companyList != null && companyList.Count > 0) { for (int i = 1; i <= listEntity.TotalPageCount; i++) { companyBll.AddCompanys(companyList); FlashLogger.Warn(string.Format("{0} : 第{1}页/共{2}页 成功下载 {3} 条生产企业信息.【{4}】", dateTimeM.ToString("yyyy-MM"), i, listEntity.TotalPageCount, companyList.Count, System.Threading.Thread.CurrentThread.ManagedThreadId)); companyList = companyBll.GetCompanys("", dateTimeM.ToString("yyyy-MM"), (i + 1).ToString()).DataList; } } dateTimeM = dateTimeM.AddMonths(-1); } FlashLogger.Error(string.Format("下载完毕【{0}】", System.Threading.Thread.CurrentThread.ManagedThreadId)); }
/** * process EXP event (see spec. p 13) */ protected void ProcessEXPEvent() { if (session.Socket == null) { return; } UDTSender sender = session.Socket.GetSender(); //put all the unacknowledged packets in the senders loss list sender.PutUnacknowledgedPacketsIntoLossList(); if (expCount > 16 && (DateTime.Now.Ticks - sessionUpSince) / TicksMS > IDLE_TIMEOUT) { if (!connectionExpiryDisabled && !stopped) { SendShutdown(); Stop(); FlashLogger.Info("Session " + session + " expired."); return; } } if (!sender.HaveLostPackets()) { SendKeepAlive(); } expCount++; }
public ListEntity<Hospital> GetHospitals(string hospitalIds, string month, string currentPageNumber) { try { string url = ModelFactory.Url + "/companyInterface/hospital/getHospital"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "hospitalIds", hospitalIds }, { "month", month }, { "currentPageNumber", currentPageNumber } }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon<Hospital>().CheckReturnCode(result, out int rcode); if (rcode == 0) return GetHospitals(hospitalIds, month, currentPageNumber); return list; } catch (Exception ex) { FlashLogger.Error(ex.Message); return null; } }
public ListEntity <Procurecatalog> CheckExist(string procureCatalogInfo) { try { string url = ModelFactory.Url + "/companyInterface/drug/procurecatalog/checkExist"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "procureCatalogInfo", procureCatalogInfo }, }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon <Procurecatalog>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(CheckExist(procureCatalogInfo)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
public ListEntity <WareHouse> GetWareHouses(string distributeInfo, string currentPageNumber) { try { string url = ModelFactory.Url + "/companyInterface/drug/wareHouse/getWareHouse"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "distributeInfo", distributeInfo }, { "currentPageNumber", currentPageNumber } }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon <WareHouse>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(GetWareHouses(distributeInfo, currentPageNumber)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
public ListEntity <Order> GetOrders(DateTime startTime, DateTime endTime, string currentPageNumber) { try { string url = ModelFactory.Url + "/companyInterface/drug/purchaseOrder/getOrder"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "startTime", startTime.ToString("yyyy-MM-dd hh:mm:ss") }, { "endTime", endTime.ToString("yyyy-MM-dd hh:mm:ss") }, { "currentPageNumber", currentPageNumber } }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon <Order>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(GetOrders(startTime, endTime, currentPageNumber)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
//starts the sender algorithm private void DoStart() { senderThread = new Thread(() => { try { while (!stopped) { //wait until explicitely (re)started startLatch.Wait(); paused = false; SenderAlgorithm(); } } catch (IOException ex) { FlashLogger.Error("", ex); } FlashLogger.Info("STOPPING SENDER for " + session); }); senderThread.Name = UDTThreadFactory.Instance.NewThreadName(); senderThread.IsBackground = true; senderThread.Start(); }
public ReturnEntity <ErrorListEntity_Sale, Sale> AddSale(string saleInfo) { try { string url = ModelFactory.Url + "/companyInterface/drug/saleList/addSale"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "saleInfo", saleInfo }, }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ReturnEntityCommon <ErrorListEntity_Sale, Sale>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(AddSale(saleInfo)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
public ListEntity <Company> GetCompanys(string companyIds, string month, string currentPageNumber) { try { string url = ModelFactory.Url + "/companyInterface/companySc/getCompanySc"; var postVars = new NameValueCollection { { "accessToken", AccessTokeBLL.AccessToken.AccessToken }, { "companyIds", companyIds }, { "month", month }, { "currentPageNumber", currentPageNumber } }; string result = WebClientHttp.Post(url, postVars); FlashLogger.Info(result); var list = new ListEntityCommon <Company>().CheckReturnCode(result, out int rcode); if (rcode == 0) { return(GetCompanys(companyIds, month, currentPageNumber)); } return(list); } catch (Exception ex) { FlashLogger.Error(ex.Message); return(null); } }
public void Execute(IJobExecutionContext context) { var dbName = ConfigurationManager.AppSettings["ReductDbName"]; var openAway = ConfigurationManager.AppSettings["ReductOpenAway"]; var dbName_Data = ConfigurationManager.AppSettings["ReductDataPath"]; var dbName_Log = ConfigurationManager.AppSettings["ReductLogPath"]; var movePath = ConfigurationManager.AppSettings["ReductMovePath"]; IReductSqlBLL bll = new ReductSqlBLL(); try { var dbFile = FileOperate.GetLatestFileTimeInfo(openAway, ".bak"); if (dbFile != null) { FlashLogger.Info(string.Format("最新备份文件[{0}],\r\n数据库[{1}]\r\n正在还原中...", dbFile.FullName, dbName)); FlashLogger.Info(bll.ReductGo(dbName, dbFile.FullName)); FlashLogger.Info(string.Format("开始移动数据库备份文件,\r\n[{0}]\r\n --->\r\n[{1}]", dbFile.FullName, movePath + dbFile.Name)); FileOperate.FileMove(dbFile.FullName, movePath + dbFile.Name); FlashLogger.Info("删除目录下多余的备份文件!"); FileOperate.DeleteFolderFiles(openAway); FlashLogger.Info("备份文件还原完毕!"); } else { FlashLogger.Error("未找到数据库备份文件,还原失败"); } } catch (Exception ex) { FlashLogger.Error("ReductSqlJob_Execute:" + ex.Message); } }
private static void Test() { string userCommand = ""; while (userCommand != "exit") { IConnectionBLL connectionBll = new ConnectionBLL(); var baseEntity = connectionBll.TestConnection(); FlashLogger.Error("药械平台接口连接测试"); WriteLine(baseEntity.ResultJson); IAccessTokeBLL accessTokeBll = new AccessTokeBLL(); var accessTokenEntity = accessTokeBll.GetAccessTokenEntity(); if (accessTokenEntity == null || string.IsNullOrEmpty(accessTokenEntity.AccessToken)) { FlashLogger.Error("有效令牌凭据不存在,重新获取令牌"); accessTokenEntity = accessTokeBll.GetToken(); accessTokeBll.SaveToken(accessTokenEntity); } else { FlashLogger.Error("从数据库成功获取有效令牌凭据"); } WriteLine(accessTokenEntity.ResultJson); //WriteLine(string.Format("过期时间:{0}", // ((DateTime)accessTokenEntity.CurrentTime).AddSeconds((double)accessTokenEntity.ExpiresIn).ToString("yyyy-MM-dd HH:mm"))); IProcurecatalogBLL procurecatalogBll = new ProcurecatalogBLL(); var procurecatalogIdList = new List <object> { new { procurecatalogId = 1 }, new { procurecatalogId = 2 }, new { procurecatalogId = 3 } }; var procurecatalogIds = JsonConvert.SerializeObject(new { list = procurecatalogIdList }); List <Entity.QuartzLog.Procurecatalog> procurecatalogList = null; DateTime dateTimeM = DateTime.Now; FlashLogger.Error("下载商品信息"); while (dateTimeM > Convert.ToDateTime("2017-09-01")) { var listEntity = procurecatalogBll.GetProcurecatalogs("", dateTimeM.ToString("yyyy-MM"), "1"); procurecatalogList = listEntity.DataList; if (procurecatalogList != null && procurecatalogList.Count > 0) { for (int i = 1; i <= listEntity.TotalPageCount; i++) { //procurecatalogBll.AddProcurecatalogs(procurecatalogList); FlashLogger.Fatal(string.Format("{0} : 第{1}页/共{2}页 成功下载 {3} 条商品信息.", dateTimeM.ToString("yyyy-MM"), i, listEntity.TotalPageCount, procurecatalogList.Count)); procurecatalogList = procurecatalogBll.GetProcurecatalogs("", dateTimeM.ToString("yyyy-MM"), (i + 1).ToString()).DataList; } } dateTimeM = dateTimeM.AddMonths(-1); } Console.WriteLine("请输入您的指令"); userCommand = Console.ReadLine(); } Console.ReadKey(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //写日志 FlashLogger.Instance().Register(); }
void Application_Start(object sender, EventArgs e) { // 在应用程序启动时运行的代码 AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); GlobalFilters.Filters.Add(new ExceptionAttribute()); FlashLogger.GetInstance().Register(); }
/** * 移除session * cd * @param socketid * @return */ public UDTSession RemoveSession(long socketid) { //cd sessionnum--; UDTSession session = null; FlashLogger.Info("Storing Sessionnum:" + sessionnum); sessions.TryRemove(socketid, out session); return(session); }
//http://www.cnblogs.com/emrys5/p/6693454.html static void Main(string[] args) { FlashLogger.Instance().Register(); FlashLogger.Debug("Debug"); FlashLogger.Debug("Debug", new Exception("testexception")); FlashLogger.Info("Info"); FlashLogger.Fatal("Fatal"); FlashLogger.Error("Error"); FlashLogger.Warn("Warn", new Exception("testexception")); }
public void TestWriteLog() { FlashLogger.Instance().Register(); FlashLogger.Debug("Debug"); FlashLogger.Debug("Debug", new Exception("testexception")); FlashLogger.Info("Info"); FlashLogger.Fatal("Fatal"); FlashLogger.Error("Error"); FlashLogger.Warn("Warn", new Exception("testexception")); }
public BaseEntity TestConnection() { string url = ModelFactory.Url + "/testConnection"; string result = WebRequestHttp.Post(url, "", Encoding.UTF8); FlashLogger.Info(result); var baseEntity = (BaseEntity)JsonConvert.DeserializeObject(result, typeof(BaseEntity)); baseEntity.ResultJson = result; return(baseEntity); }
public void EncryptTest() { FlashLogger.Instance().Register(); string orgUserName = "******"; string secret = "111111"; string key = "yss.yh"; var uname = MySecurity.SEncryptString(orgUserName, key); var psd = MySecurity.SEncryptString(secret, key); FlashLogger.Info(string.Format("\r\nOrgUserName:\r\n{0}\r\nSecret:\r\n{1}\r\n", uname, psd)); }
/** * * @param localIP 本地IP * @param port 端口 */ public judpServer(string localIP, int port) { try { server = new UDTServerSocket(port, localIP); } catch (SocketException e) { FlashLogger.Warn("绑定失败:" + e.Message); isSucess = false; } catch (Exception e) { isSucess = false; Console.WriteLine(e); } }
public ActionResult Index() { ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; FlashLogger.Debug("Debug"); FlashLogger.Debug("Debug", new Exception("testexception")); FlashLogger.Info("Info"); FlashLogger.Fatal("Fatal"); FlashLogger.Error("Error"); FlashLogger.Warn("Warn", new Exception("testexception")); return(View()); }
/** * * @param port 端口 */ public judpServer(int port) { try { server = new UDTServerSocket(port); } catch (SocketException e) { // logger.log(Level.WARNING, "绑定失败:" + e.getMessage()); FlashLogger.Warn("绑定失败:" + e.Message); isSucess = false; } catch (Exception e) { isSucess = false; Console.WriteLine(e); } }
public static void Warn(object message) { switch (LogEngineType) { case LogEngineTypeEnum.DefaultLogger: DefaultLogger.Warn(message); break; case LogEngineTypeEnum.FlashLogger: FlashLogger.Warn(message); break; } }
public static void Info(object message, System.Exception ex) { switch (LogEngineType) { case LogEngineTypeEnum.DefaultLogger: DefaultLogger.Info(message, ex); break; case LogEngineTypeEnum.FlashLogger: FlashLogger.Info(message, ex); break; } }
// GET: LogTest public ActionResult T() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < 100000; i++) { FlashLogger.Debug("Debug", new Exception(string.Concat("testexception", i))); } stopwatch.Stop(); double milliseconds = stopwatch.Elapsed.TotalMilliseconds; ViewBag.milliseconds = milliseconds; return(View()); }
/** * re-submits an entry from the sender loss list * @param entry */ protected void HandleResubmit(long seqNumber) { try { //retransmit the packet and remove it from the list DataPacket pktToRetransmit = null; sendBuffer.TryGetValue(seqNumber, out pktToRetransmit); if (pktToRetransmit != null) { endpoint.DoSend(pktToRetransmit); statistics.incNumberOfRetransmittedDataPackets(); } }catch (Exception e) { FlashLogger.Error("", e); } }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main(string[] args) { FlashLogger.Instance().Register(); HostFactory.Run(x => { x.UseLog4Net(); x.Service <ServiceRunner>(); x.SetDescription("浙江省药械采购中心基础数据下载更新同步,上传下载各类单据."); x.SetDisplayName("药械采购平台数据定时更新同步服务"); x.SetServiceName("ZjyxcgServiceQuartz"); x.EnablePauseAndContinue(); }); //Test(); }