示例#1
0
        internal static void Listen()
        {
            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress   ipAddress  = ipHostInfo.AddressList[0];

            Listener.Bind(new IPEndPoint(IPAddress.Parse(ipAddress.ToString()), Convert.ToInt32(ConfigurationManager.AppSettings["Port"])));
            Listener.Listen(100);

            Program.Stopwatch.Stop();

            var args = GetArgs();

            StartAccept(args);

            Loggers.Log(Assembly.GetExecutingAssembly().GetName().Name + $" has been started on {Utils.LocalNetworkIP} in {Math.Round(Program.Stopwatch.Elapsed.TotalSeconds, 4)} Seconds!", true);
        }
示例#2
0
        public Region()
        {
            if (!Directory.Exists("Gamefiles/database/"))
            {
                throw new Exception("Directory Gamefiles/database does not exist!");
            }

            if (!File.Exists(DbPath))
            {
                throw new Exception($"{DbPath} does not exist in current directory!");
            }

            this.Reader = new DatabaseReader(DbPath, FileAccessMode.Memory);

            Loggers.Log("CRepublic.Boom region database loaded into memory.");
        }
示例#3
0
        public void RecommenderPrize(string VipID, string EventId)
        {
            string sql = "RecommenderPrize";

            List <SqlParameter> sqlParameter = new List <SqlParameter>();

            sqlParameter.Add(new SqlParameter("@CustomerID", CurrentUserInfo.ClientID));
            sqlParameter.Add(new SqlParameter("@VipID", VipID));
            sqlParameter.Add(new SqlParameter("@EventId", EventId));
            Loggers.Debug(new DebugLogInfo()
            {
                Message = "RecommenderPrize '" + CurrentUserInfo.ClientID + "','" + VipID + "'"
            });

            this.SQLHelper.ExecuteScalar(CommandType.StoredProcedure, sql, sqlParameter.ToArray());
        }
示例#4
0
        public bool IfRecordedRecommendTrace(string vipID, string reCommandId)
        {
            bool   result = true;
            object row    = _currentDAO.IfRecordedRecommendTrace(vipID, reCommandId);

            if (row == null)
            {
                result = false;
            }

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "result = " + result
            });
            return(result);
        }
示例#5
0
        internal Redis()
        {
            ConfigurationOptions Configuration = new ConfigurationOptions();

            Configuration.EndPoints.Add(Utils.ParseConfigString("RedisIPAddress"), Utils.ParseConfigInt("RedisPort"));

            Configuration.Password   = Utils.ParseConfigString("RedisPassword");
            Configuration.ClientName = this.GetType().Assembly.FullName;

            ConnectionMultiplexer Connection = ConnectionMultiplexer.Connect(Configuration);

            Redis.Players = Connection.GetDatabase((int)Database.Players);
            Redis.Clans   = Connection.GetDatabase((int)Database.Clans);

            Loggers.Log("Redis Database has been succesfully loaded.", true);
        }
示例#6
0
        public Region()
        {
            if (!Directory.Exists("Gamefiles/database/"))
            {
                throw new DirectoryNotFoundException("Directory Gamefiles/database does not exist!");
            }

            if (!File.Exists(DbPath))
            {
                throw new FileNotFoundException($"{DbPath} does not exist in current directory!");
            }

            //Reader = new DatabaseReader(DbPath, FileAccessMode.Memory);
            Reader = new DatabaseReader(DbPath, FileAccessMode.MemoryMapped); //Lower ram usage on start but idk the speed
            Loggers.Log("Region database loaded into memory.", true);
        }
示例#7
0
        public async Task UpdateProduct_Success()
        {
            // Arrange
            var loggerController = Loggers.ProductControllerLogger();
            var loggerRepository = Loggers.ProductRepositoryLogger();
            var blobService      = BlobService.BlobServiceUpload();

            var mapper = Mapper.Get();

            var dbContext = _fixture.Context;

            var oldCategory = NewDatas.NewCategory();
            var newCategory = NewDatas.NewCategory();
            await dbContext.Categories.AddRangeAsync(oldCategory, newCategory);

            await dbContext.SaveChangesAsync();

            var product = NewDatas.NewProduct();

            product.CategoryId = oldCategory.CategoryId;
            await dbContext.Products.AddAsync(product);

            await dbContext.SaveChangesAsync();

            var productRepository = new ProductRepository(loggerRepository, mapper, blobService, dbContext);

            var productRequest = NewDatas.NewProductRequest();

            productRequest.CategoryId = newCategory.CategoryId;

            // Act
            var productController = new ProductsController(loggerController, productRepository);
            var result            = await productController.UpdateProduct(product.ProductId, productRequest);

            // Assert
            var updatedResult = Assert.IsType <OkObjectResult>(result.Result);
            var updatedValue  = Assert.IsType <ProductRespone>(updatedResult.Value);

            Assert.Equal(product.Name, updatedValue.Name);
            Assert.Equal(product.Price, updatedValue.Price);
            Assert.Equal(product.Description, updatedValue.Description);
            Assert.Equal(product.Image, updatedValue.Image);
            Assert.Equal(product.Rated, updatedValue.Rated);

            Assert.Equal(newCategory.CategoryId, updatedValue.CategoryId);
            Assert.Equal(newCategory.Name, updatedValue.CategoryName);
        }
示例#8
0
        /// <summary>
        /// 获取Access Token
        /// </summary>
        /// <param name="code"></param>
        private void GetAccessToken(string code)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
                string url = "https://api.weixin.qq.com/sns/oauth2/access_token";
                //https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
                WebClient myWebClient = new WebClient();
                // 注意这种拼字符串的ContentType
                myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                // 转化成二进制数组
                var    postData  = "appid=" + strAppId + "&secret=" + strAppSecret + "&code=" + code + "&grant_type=authorization_code";
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                // 上传数据,并获取返回的二进制数据.
                byte[] responseArray = myWebClient.UploadData(url, "POST", byteArray);
                var    data          = System.Text.Encoding.UTF8.GetString(responseArray);
                var    tokenInfo     = data.DeserializeJSONTo <cAccessTokenReturn>();
                //Response.Write("<br/>");
                //Response.Write("获取Access Token");
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetAccessToken: {0}", data)
                });
                if (tokenInfo != null)
                {
                    //Response.Write("<br/>");
                    //Response.Write("获取Access Token不为空");
                    if (tokenInfo.openid == null || tokenInfo.openid.Equals(""))
                    {
                        Response.Redirect(strNoFollowUrl);
                    }
                    else
                    {
                        GetUserIdByOpenId(tokenInfo.openid);
                    }
                }

                //Response.Write(data);
            }
            catch (Exception ex)
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetAccessToken错误: {0}", ex.ToString())
                });
            }
        }
示例#9
0
        public CommonResponse Process(CommandResponse pRequest)
        {
            CommonResponse response = new CommonResponse();

            try
            {
                response.ResultCode = 0;
                DefaultSQLHelper       _sqlHelper = new DefaultSQLHelper(ConfigurationManager.AppSettings["MobileLogConn"]);
                MobileCommandRecordDAO DAO        = new MobileCommandRecordDAO(new Base.MobileDeviceManagementUserInfo(), _sqlHelper);
                var entity = DAO.GetByID(pRequest.CommandID);
                if (entity != null)
                {
                    entity.CommandResponseCount++;
                    entity.ResponseJson = pRequest.ToJSON();
                    if (pRequest.ResponseCode < 100)
                    {
                        entity.Status       = 100;
                        entity.ResponseCode = 0;
                    }
                    else
                    {
                        entity.Status       = 2;
                        entity.ResponseCode = 1;
                        if (entity.CommandResponseCount >= 3)
                        {
                            entity.Status = 3;
                        }
                    }
                    if (pRequest.NeedRepeat)
                    {
                        entity.LastUpdateTime = DateTime.Now;
                    }
                    DAO.Update(entity);
                }
                else
                {
                    throw new Exception("未找到命令");
                }
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                response.Message    = ex.Message;
                response.ResultCode = 200;
            }
            return(response);
        }
示例#10
0
        ToolStripMenuItem InternalBuildMenus(bool _userMode)
        {
            ToolStripMenuItem result = new ToolStripMenuItem();

            foreach (ToolInfo info in this)
            {
                try
                {
                    if (_userMode && !info.PresentInUserMode)
                    {
                        continue;
                    }
                    if (!_userMode && !info.PresentInAdminMode)
                    {
                        continue;
                    }

                    string category = info.Category;
                    if (String.IsNullOrEmpty(category))
                    {
                        category = "Tools";
                    }

                    string[]          splitCategory = category.Split(new Char[] { '/', '\\', '|' });
                    ToolStripMenuItem currentMenu   = result;
                    for (int index = 0; index < splitCategory.Count(); index++)
                    {
                        currentMenu = GetSubMenu(splitCategory[index], currentMenu);
                    }

                    ToolStripMenuItem newItem = new ToolStripMenuItem();
                    ITool             tool    = info.Type.GetConstructor(new Type[] { }).Invoke(new object[] { }) as ITool;
                    newItem.Tag    = tool;
                    newItem.Name   = info.Type.FullName;
                    newItem.Text   = info.DisplayName;
                    newItem.Click += new System.EventHandler(MenuItemClick);
                    currentMenu.DropDownItems.Add(newItem);
                    //currentMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
                }
                catch (Exception e)
                {
                    Loggers.WriteError(LogTags.UI, "error while creating menu for command: " + info.Type.FullName + "\n    " + e.Message);
                }
            }

            return(result);
        }
示例#11
0
        /// <summary>
        /// 获取某个客户的所有门店所在的城市列表,地级市
        /// </summary>
        public string GetCityList()
        {
            string content = string.Empty;

            var respData = new GetCityListRespData();

            try
            {
                string reqContent = Request["ReqContent"];
                var    reqObj     = reqContent.DeserializeJSONTo <GetCityListReqData>();

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetCityList: {0}", reqContent)
                });

                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                else
                {
                    respData.code        = "103";
                    respData.description = "customerId不能为空";
                    return(respData.ToJSON());
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                respData.content          = new GetCityListRespContentData();
                respData.content.cityList = new List <CityEntity>();

                DataSet ds = new TUnitSortBLL(loggingSessionInfo).GetCityListByCustomerId(customerId);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    respData.content.cityList = DataTableToObject.ConvertToList <CityEntity>(ds.Tables[0]);
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
示例#12
0
        public void Activate()
        {
            _Data = new ComputeClassicRankData();
            TaxonUtils.OriginalRoot.GetAllLastChildrenRecursively(_Data.Leaves);

            string file = Path.Combine(TaxonUtils.GetLogPath(), "ComputeClassicRank.log");

            if (File.Exists(file))
            {
                File.Delete(file);
            }

            using (_Data.Writer = new StreamWriter(file))
            {
                ComputeTwoWordsSpeciesSupSpecies();
                ComputeWithoutLatinName();
                ComputeSubSpeciesSecond();
                ComputeSpeciesFirst();
                ComputeSubGenreFirst();
                ComputeGenreFirst();

                _Data.Holozoa = TaxonUtils.OriginalRoot.FindTaxonByName("holozoa");
                if (_Data.Holozoa != null)
                {
                    Compute4Animals();
                }

                Compute4Others();
            }

            string message = "";

            message += String.Format("detect {0} new sub species\n", _Data.NewSubSpecies);
            message += String.Format("detect {0} new species\n", _Data.NewSpecies);
            message += String.Format("detect {0} new sub genre\n", _Data.NewSousGenre);
            message += String.Format("detect {0} new genre\n", _Data.NewGenre);
            message += String.Format("detect {0} new sous tribu\n", _Data.NewSousTribu);
            message += String.Format("detect {0} new tribus\n", _Data.NewTribu);
            message += String.Format("detect {0} new sous familles\n", _Data.NewSousFamille);
            message += String.Format("detect {0} new familles\n", _Data.NewFamille);
            message += String.Format("detect {0} new super famille\n", _Data.NewSuperFamille);
            message += String.Format("detect {0} new order\n", _Data.NewOrder);
            message += String.Format("detect {0} new without latin name\n", _Data.WithoutLatinName.Count);
            message += String.Format("for more details, look at ComputeClassicRank.log file");
            Loggers.WriteInformation(LogTags.Data, message);
        }
示例#13
0
        /// <summary>
        /// Logs the specified event.
        /// </summary>
        /// <param name="logEvent">The event (object) to log.</param>
        /// <param name="type">Event type</param>
        public static void Log(object logEvent, LogEventType type = LogEventType.Information)
        {
            if (Loggers == null)
            {
                return;
            }

            var currentLoggers = Loggers.ToArray();

            foreach (var logger in currentLoggers)
            {
                if (logger.TypeFilter == LogEventType.Undefined || ((logger.TypeFilter & type) == type))
                {
                    logger.Log(logEvent, type);
                }
            }
        }
示例#14
0
        public async Task Delete_Success()
        {
            // Arrange
            var loggerController = Loggers.ProductControllerLogger();
            var loggerRepository = Loggers.ProductRepositoryLogger();
            var blobService      = BlobService.BlobServiceUpload();

            var mapper = Mapper.Get();

            var dbContext = _fixture.Context;

            var category = NewDatas.NewCategory();
            await dbContext.Categories.AddRangeAsync(category);

            await dbContext.SaveChangesAsync();

            var product = NewDatas.NewProduct();

            product.CategoryId = category.CategoryId;
            await dbContext.Products.AddAsync(product);

            await dbContext.SaveChangesAsync();

            var productRepository = new ProductRepository(loggerRepository, mapper, blobService, dbContext);
            var productController = new ProductsController(loggerController, productRepository);

            // Act
            var result = await productController.RemoveProduct(product.ProductId);

            // Assert
            var deletedResult      = Assert.IsType <OkObjectResult>(result.Result);
            var deletedResultValue = Assert.IsType <ProductRespone>(deletedResult.Value);

            Assert.Equal(product.Name, deletedResultValue.Name);
            Assert.Equal(product.Price, deletedResultValue.Price);
            Assert.Equal(product.Description, deletedResultValue.Description);
            Assert.Equal(product.Image, deletedResultValue.Image);
            Assert.Equal(product.Rated, deletedResultValue.Rated);
            Assert.Equal(category.CategoryId, deletedResultValue.CategoryId);
            Assert.Equal(category.Name, deletedResultValue.CategoryName);

            await Assert.ThrowsAsync <NotFoundException>(async() =>
            {
                await productController.GetProduct(deletedResultValue.ProductId);
            });
        }
示例#15
0
        public DataSet SearchVipCardList(VipCardEntity searchInfo)
        {
            int beginSize = searchInfo.startRowIndex - 1;
            int endSize   = searchInfo.startRowIndex * searchInfo.maxRowCount + searchInfo.maxRowCount;

            string sql = SearchVipCardSql(searchInfo);

            sql += " select * From #tmp a where 1=1 and a.displayindex between '" +
                   beginSize + "' and '" + endSize + "' order by  a.displayindex ";
            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("GetEventListSql:{0}", sql)
            });
            DataSet ds = this.SQLHelper.ExecuteDataset(sql);

            return(ds);
        }
示例#16
0
        public static void Main(string[] args)
        {
            ILogger logger = Loggers.Logger(msg => Console.WriteLine(msg));

            logger.Error("ERROR");
            logger.Warning("WARNING");

            ILogger quiet = logger.Quiet();

            quiet.Error("ERROR");
            quiet.Warning("WARNING");

            ILogger logger2 = quiet.Chatty();

            logger2.Error("ERROR");
            logger2.Warning("WARNING");
        }
示例#17
0
        public static long GetPlayerSeed()
        {
            try
            {
                const string SQL  = "SELECT coalesce(MAX(ID), 0) FROM player";
                long         Seed = -1;

                MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder()
                {
                    Server          = Utils.ParseConfigString("MysqlIPAddress"),
                    UserID          = Utils.ParseConfigString("MysqlUsername"),
                    Port            = (uint)Utils.ParseConfigInt("MysqlPort"),
                    Pooling         = false,
                    Database        = Utils.ParseConfigString("MysqlDatabase"),
                    MinimumPoolSize = 1
                };

                if (!string.IsNullOrWhiteSpace(Utils.ParseConfigString("MysqlPassword")))
                {
                    builder.Password = Utils.ParseConfigString("MysqlPassword");
                }

                Credentials = builder.ToString();

                Connections = new MySqlConnection(Credentials);
                Connections.Open();


                using (MySqlCommand CMD = new MySqlCommand(SQL, Connections))
                {
                    CMD.Prepare();
                    Seed = Convert.ToInt64(CMD.ExecuteScalar());
                }


                return(Seed);
            }
            catch (Exception ex)
            {
                Loggers.Log("An exception occured when reconnecting to the MySQL Server.", true, Defcon.ERROR);
                Loggers.Log("Please check your database configuration!", true, Defcon.ERROR);
                Loggers.Log(ex.Message, true, Defcon.ERROR);
                Console.ReadKey();
            }
            return(0);
        }
示例#18
0
 public void BeginVariation(string variationName)
 {
     if (LoggingState == LoggingState.IsConnected) //Proper scenario
     {
         Loggers.BeginVariation(variationName);
         currentVariationName = variationName;
         currentVariationIndex++;
         hasReceivedBeginVariation = true;
     }
     else if (LoggingState == LoggingState.HasVariation) //We're in a bad state. Synthesize corrective sequence.
     {
         LogMessage("BUG: Test began a second variation without ending the previous one.");
         LogResult(Result.Fail);
         EndVariation(currentVariationName);
         BeginVariation(variationName);
     }
 }
示例#19
0
 public void EndVariation(string variationName)
 {
     if (LoggingState == LoggingState.IsConnected) //We're in a semi-bogus state. Synthesize sequence of corrective actions.
     {
         BeginVariation("Missing BeginVariation");
         LogMessage("BUG: No BeginVariation message was recieved");
         LogResult(Result.Fail);
         EndVariation("Missing BeginVariation");
     }
     else if (LoggingState == LoggingState.HasVariation) //Proper scenario
     {
         Loggers.EndVariation(variationName);
         currentVariationName = null;
         currentResult        = null;
         currentTestLogResult = null;
     }
 }
示例#20
0
 void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         try
         {
             var bll = new AppOrderBLL(new JIT.Utility.BasicUserInfo());
             //获取未通知的订单信息
             var entitys = bll.GetNotNodify();
             Loggers.Debug(new DebugLogInfo()
             {
                 Message = string.Format("找到{0}条待通知记录", entitys.Length)
             });
             foreach (var item in entitys)
             {
                 string msg;
                 if (NotifyHandler.Notify(item, out msg))
                 {
                     item.IsNotified = true;
                 }
                 else
                 {
                     //设定下次通知时间
                     item.NextNotifyTime = GetNextNotifyTime(item.NotifyCount ?? 0);
                 }
                 //NotifyCount++
                 item.NotifyCount++;
                 //更新数据
                 bll.Update(item);
             }
         }
         catch (Exception ex)
         {
             Loggers.Exception(new ExceptionLogInfo(ex));
         }
         _runCount++;
         if (_runCount % 100 == 0)
         {
             Loggers.Debug(new DebugLogInfo()
             {
                 Message = string.Format("轮循了{0}次", _runCount)
             });
         }
         Thread.Sleep(TimeSpan.FromSeconds(_intval));
     }
 }
示例#21
0
        /// <summary>
        /// 用户否注册接口
        /// </summary>
        public string Register()
        {
            string content  = string.Empty;
            var    respData = new Default.LowerRespData();

            try
            {
                string reqContent = Request["ReqContent"];
                var    reqObj     = reqContent.DeserializeJSONTo <RegisterReqData>();

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("Register: {0}", reqContent)
                });

                var loggingSessionInfo = Default.GetLjLoggingSession();
                Default.WriteLog(loggingSessionInfo, "Register", reqObj, respData, reqObj.ToJSON());

                VipBLL vipBLL = new VipBLL(loggingSessionInfo);
                string result = vipBLL.Register(reqObj.common.userId, reqObj.special.mobile, reqObj.special.name, reqObj.special.code, reqObj.common.customerId);

                switch (result)
                {
                case "101":
                    respData.code        = result;
                    respData.description = "验证码验证失败,请重试。";
                    break;

                case "102":
                    respData.code        = result;
                    respData.description = "无法找到用户信息,请重试。";
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
        /// <summary>
        /// 某人某天在某个店的相关照片
        /// </summary>
        /// <param name="pQueryParams">查询参数(部门标识:ClientStructureID,职位标识:ClientPositionID,执行人员标识:ClientUserID,拜访任务执行标识:VisitingTaskDataID,拜访步骤标识:VisitingTaskStepID,开始日期:DateFrom,截止日期:DateTo)</param>
        /// <param name="pOrderBys">排序条件</param>
        /// <param name="pPageSize">每页记录数</param>
        /// <param name="pCurrentPageIndex">从1开始的当前页码</param>
        /// <returns>明细信息</returns>
        public PagedQueryResult <VisitingTaskPicturesViewEntity> GetVisitingTaskPictures(Dictionary <string, object> pQueryParams, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
        {
            DateTime dtStart = DateTime.Now;

            Loggers.Debug(new DebugLogInfo()
            {
                ClientID = this.CurrentUserInfo.ClientID, UserID = this.CurrentUserInfo.UserID, Message = "某人某天在某个店的相关照片.查询开始:[" + dtStart.ToString() + "]"
            });
            var      result   = this._currentDAO.GetVisitingTaskPictures(pQueryParams, pOrderBys, pPageSize, pCurrentPageIndex);
            DateTime dtFinish = DateTime.Now;

            Loggers.Debug(new DebugLogInfo()
            {
                ClientID = this.CurrentUserInfo.ClientID, UserID = this.CurrentUserInfo.UserID, Message = "某人某天在某个店的相关照片.查询完成:[" + dtFinish.ToString() + "].花费时间:[" + (dtFinish - dtStart).TotalSeconds.ToString() + "]s"
            });
            return(result);
        }
        public void Activate()
        {
            List <TaxonTreeNode> extincts          = new List <TaxonTreeNode>();
            List <TaxonTreeNode> extinctsInherited = new List <TaxonTreeNode>();

            string logFile = Path.Combine(TaxonUtils.GetLogPath(), "ExtinctsTaxons.log");

            using (StreamWriter log = new StreamWriter(logFile))
            {
                log.WriteLine("Move extinct flag to red list category EX (" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ")\n");

                TaxonUtils.OriginalRoot.ParseNode((d) =>
                {
                    if (d.Desc.HasFlag(FlagsEnum.Extinct))
                    {
                        extincts.Add(d);
                    }
                    if (d.Desc.HasFlag(FlagsEnum.ExtinctInherited))
                    {
                        extinctsInherited.Add(d);
                    }
                });

                log.WriteLine("taxon with extincts flag: " + extincts.Count.ToString());
                foreach (TaxonTreeNode node in extincts)
                {
                    log.WriteLine("    [" + node.Desc.RedListCategory.ToString() + "] " + node.GetHierarchicalName());
                }
                log.WriteLine();

                log.WriteLine("taxon with extincts inherited flag: " + extincts.Count.ToString());
                foreach (TaxonTreeNode node in extinctsInherited)
                {
                    log.WriteLine("    [" + node.Desc.RedListCategory.ToString() + "] " + node.GetHierarchicalName());
                }
                log.WriteLine();


                string message = "Move extinct flag to red list category EX results:\n";
                message += string.Format("{0} taxons with extinct flag\n", extincts.Count.ToString());
                message += string.Format("{0} taxons with extinct inherited flag\n", extinctsInherited.Count.ToString());
                message += string.Format("for more details, look at {0}", logFile);
                Loggers.WriteInformation(LogTags.Data, message);
                log.Write(message);
            }
        }
示例#24
0
 /// <summary>
 ///     returns UserLog listener, applyable for given context
 /// </summary>
 /// <param name="context"> </param>
 /// <param name="host"> </param>
 /// <returns> </returns>
 public IUserLog GetLog(string context, object host)
 {
     lock (Sync) {
         var usableloggers = Loggers.Where(x => x.IsApplyable(context));
         var enumerable    = usableloggers as ILogger[] ?? usableloggers.ToArray();
         if (enumerable.Any())
         {
             return(new LoggerBasedUserLog(enumerable.ToArray(), this, (context ?? "NONAME"))
             {
                 HostObject = host
             });
         }
         return(new StubUserLog {
             HostObject = host
         });
     }
 }
示例#25
0
文件: Form1.cs 项目: radtek/crm
        //private bool IsSuccess(string result)
        //{
        //    if (result.EndsWith("000"))
        //        return true;
        //    else
        //        return false;
        //}

        private void button3_Click(object sender, EventArgs e)
        {
            //BaiYunSMS sms = new BaiYunSMS();
            //sms.Mobile = "18302159648";
            //sms.Message = "你好";
            //var result = sms.Send(JIT.Utility.SMS.Base.SendType.Get);
            //var blance = sms.GetBalance();

            SMSSendDAO Dao = new SMSSendDAO(new BasicUserInfo());

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "开始查询数据库"
            });
            var entities = Dao.GetNoSend();

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("获取{0}条数据", entities.Length)
            });
            foreach (var item in entities)
            {
                var NO     = item.MobileNO;
                var result = GetResult(item.GetSMS().Send2(JIT.Utility.SMS.Base.SendType.Get));
                if (result.IsSuccess)
                {
                    item.Status            = 1;
                    item.SendCount         = (item.SendCount ?? 0) + 1;
                    item.Mtmsgid           = result.SMSID;
                    item.RegularlySendTime = DateTime.Now;
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                    });
                }
                else
                {
                    item.SendCount = (item.SendCount ?? 0) + 1;
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                    });
                }
                Dao.Update(item);
            }
        }
示例#26
0
        /// <summary>
        /// 获取活动列表
        /// </summary>
        public DataSet GetEventList(int Page, int PageSize)
        {
            int beginSize = Page * PageSize;
            int endSize   = Page * PageSize + PageSize;

            string sql = GetEventListSql();

            sql += " select * From #tmp a where 1=1 and a.displayindex between '" +
                   beginSize + "' and '" + endSize + "' order by  a.displayindex ";
            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("GetEventListSql:{0}", sql)
            });
            DataSet ds = this.SQLHelper.ExecuteDataset(sql);

            return(ds);
        }
示例#27
0
        public static void Remove(params VMwareHostSystemInformation[] rows)
        {
            try {
                var hostnames = new string[rows.Length];
                for (int i = 0; i != rows.Length; i++)
                {
                    hostnames[i] = rows[i].ipOrHostname;
                }

                Remove(hostnames);
            }
            catch (Exception ex) {
                //Let IIS handle the errors, but using own logging.
                Loggers.Log(Level.Error, "Failed removing vhost system info", ex, new object[] { rows });
                throw;
            }
        }
示例#28
0
        public static VMwareHostSystemInformation Get(string ipOrHostname)
        {
            try {
                var dt = SQLiteDataAccess.GetDataTable("Select * from VMwareHostSystemInformations where ipOrHostname=@param1", CommandType.Text, null, new SQLiteParameter("@param1", ipOrHostname));
                if (dt.Rows.Count == 0)
                {
                    return(null);
                }

                return(Parse(dt.Rows[0]));
            }
            catch (Exception ex) {
                //Let IIS handle the errors, but using own logging.
                Loggers.Log(Level.Error, "Failed retrieving vhost system info", ex, new object[] { ipOrHostname });
                throw;
            }
        }
示例#29
0
        public void ProcessRequest(HttpContext context)
        {
            string res = "{\"CODE\": \"00\", \"MSG\": \"OK\"}";// Y/N 接收成功或失败

            try
            {
                context.Response.ContentType = "application/json";
                #region 获取流数据
                System.IO.Stream s    = context.Request.InputStream;
                int           count   = 0;
                byte[]        buffer  = new byte[1024];
                StringBuilder builder = new StringBuilder();
                while ((count = s.Read(buffer, 0, 1024)) > 0)
                {
                    builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
                }
                s.Flush();
                s.Close();
                s.Dispose();
                #endregion

                string rspStr = builder.ToString();
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("Receive data from PAPayRetAmt : {0}", rspStr)
                });

                string result = HttpHelper.SendSoapRequest(rspStr, System.Configuration.ConfigurationManager.AppSettings["PAReturnAmountNotify"], "application/json");
                if (result.ToLower().Equals("true"))
                {
                    res = "{\"CODE\": \"00\", \"MSG\": \"OK\"}"; //
                }
                res = "{\"CODE\": \"01\", \"MSG\": \"OK\"}";     //
            }
            catch (Exception ex)
            {
                res = "{\"CODE\": \"01\", \"MSG\": \"" + ex + "\"}";//
            }
            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("Response data from PAPayRetAmt : {0}", res)
            });
            context.Response.Write(res);
            context.Response.End();
        }
示例#30
0
        /// <summary>
        /// 调用汇付充值接口
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="facePrice"></param>
        /// <param name="appOrder"></param>
        /// <returns></returns>
        private string RechargeCard(string cardNo, decimal facePrice, AppOrderEntity appOrder)
        {
            string url          = PrePaidCardUtil.GetTonyRechargeUrl();
            string desKey       = PrePaidCardUtil.GetEncodingKey();
            string merchantCode = PrePaidCardUtil.GetMerchantCode();
            BaseRequest <RechargeReqBody> req = new BaseRequest <RechargeReqBody>();
            var recordBll    = new PayRequestRecordBLL(new Utility.BasicUserInfo());
            var recordEntity = new PayRequestRecordEntity()
            {
                ChannelID = appOrder.PayChannelID,
                ClientID  = appOrder.AppClientID,
                UserID    = appOrder.AppUserID,
                Platform  = 8
            };

            req.bizCd             = "recharge";
            req.reqSeq            = DateTime.Now.ToString("yyMMddHHmmss");
            req.reqBody           = new RechargeReqBody();
            req.reqBody.orderId   = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            req.reqBody.transDate = DateTime.Now.ToString("yyyyMMddHHmmss");
            req.reqBody.transAmt  = (facePrice * 100).ToString();
            // req.reqBody.cardNo = "9300100203000020002";
            // req.reqBody.transAmt = "10";    // 交易金额以分为单位
            req.reqBody.cardNo = cardNo;

            string reqJson = JsonMapper.ToJson(req).Replace("\\\"", "'");
            string strReq  = CommonUtil.EncryptDES(reqJson, desKey);

            url = string.Format("{0}{1}&merchantCode={2}", url, HttpContext.Current.Server.UrlEncode(strReq), merchantCode);
            string result = HttpService.Get(url);

            string strRsp = CommonUtil.DecryptDES(result);

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("多利【{0}】充值结果:", appOrder.AppOrderID) + strRsp,
            });
            recordEntity.RequestJson  = reqJson;
            recordEntity.ResponseJson = strRsp;
            recordBll.Create(recordEntity);

            var rspEntity = JsonMapper.ToObject <BaseRsponse>(strRsp);

            return(rspEntity.rspCd == "0000" ? "SUCCESS" : "FAIL");
        }
 //fix for 796185: leaking internal exceptions to customers,
 //we should catch and log exceptions but never propagate them.
 private static void LogAndDisable(Exception ex)
 {
     f_LoggingOn = 0;
     Debugger.Log(0, "AsyncCausalityTracer", ex.ToString());
 }
 private static void TracingStatusChangedHandler(Object sender, WFD.TracingStatusChangedEventArgs args)
 {
     if (args.Enabled)
        f_LoggingOn |= Loggers.CausalityTracer;
     else 
        f_LoggingOn &= ~Loggers.CausalityTracer;
 }