예제 #1
0
        public void TestMethod1()
        {
            /////////////////////////////////////////////////////////
            //测试嵌入                      ---------------------------
            //                              ---------------------------
            //小马 大马  老马               ---------------------------
            //老马 讲讲  html               ---------------------------
            //                              ---------------------------
            //-------------------------------------------------

            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///
            //我那个去。。。。。。。。。。。。。。!!!!!!!!///

            UserInfoDal dal = new UserInfoDal();

            Console.WriteLine(dal.GetEntities(u => true));
            Console.ReadLine();
        }
        public List <UFSM_UserInfo> GetUserList(out string returnMessage)
        {
            UserInfoDal          userInfoDal = new UserInfoDal();
            List <UFSM_UserInfo> userList    = userInfoDal.GetUserList(out returnMessage);

            return(userList);
        }
예제 #3
0
 /// <summary>
 /// 购物车商品条目数
 /// </summary>
 /// <param name="entId">企业</param>
 /// <param name="userId">用户</param>
 /// <param name="ywyId">业务员</param>
 /// <returns></returns>
 public ActionResult NumberOfItems(string entId, string userId, string ywyId = "")
 {
     try
     {
         if (string.IsNullOrEmpty(userId))
         {
             return(Json(new { success = false, message = "用户未登录,请先登录" }));
         }
         ///获取用户信息
         UserInfoDal     dal  = new UserInfoDal();
         List <UserInfo> user = dal.GetUserInfo(userId, entId);
         if (user.Count <= 0)
         {
             return(Json(new { success = false, message = "用户未登录,请重新登录" }));
         }
         ///获取购物车信息
         CartDal cdal = new CartDal();
         int     num  = cdal.GetCartCount(entId, userId, ywyId);
         return(Json(new { success = true, message = "购物车商品条目数获取成功", num }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Cart/NumberOfItems", ex.Message.ToString());
         return(Json(new { success = false, message = ex.Message.ToString() }));
     }
 }
        /// <summary>
        /// 向数据库注册UserInfo,返回一个bool。
        /// </summary>
        /// <param name="user">注册的UserInfo对象</param>
        /// <param name="returnMessage">返回注册信息字符串:如注册成功、失败</param>
        /// <returns></returns>
        public bool AddUserInfo(UserInfo user, out string returnMessage)
        {
            foreach (UserInfo u in userList)
            {
                if (user.Account == u.Account)
                {
                    returnMessage = "对不起,该账号名已被占用!";
                    return(false);
                }
            }

            UserInfoDal uid          = new UserInfoDal();
            int         influenceRow = uid.AddUserInfo(user);

            if (influenceRow > 0)
            {
                userList      = new UserInfoDal().GetUserInfoList();
                returnMessage = "注册成功,请返回登录";
                return(true);
            }
            else
            {
                returnMessage = "数据库异常,注册失败,请稍后重试";
                return(false);
            }
        }
예제 #5
0
 /// <summary>
 /// 获取购物车金额
 /// </summary>
 /// <param name="entId">企业Id</param>
 /// <param name="userId">用户id</param>
 /// <param name="goodsList">选中的商品id</param>
 /// <returns></returns>
 public JsonResult CartAmount(string entId, string userId, string goodsList, string ywyId = "")
 {
     try
     {
         if (string.IsNullOrEmpty(userId))
         {
             return(Json(new { success = false, message = "用户未登录,请先登录" }));
         }
         ///获取用户信息
         UserInfoDal     dal  = new UserInfoDal();
         List <UserInfo> user = dal.GetUserInfo(userId, entId);
         if (user.Count <= 0)
         {
             return(Json(new { success = false, message = "E002" }));
         }
         ///获取购物车信息
         CartDal         cdal = new CartDal();
         List <CartList> list = cdal.GetCartAmount(user[0].EntId, userId, goodsList, user[0].Pricelevel, user[0].KhType, ywyId);
         return(Json(new { success = true, list = list }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Cart/CartAmount", ex.Message.ToString());
         return(Json(new { success = false, message = ex.Message.ToString() }));
     }
 }
예제 #6
0
        public JsonResult GetBrandList(string userId, string faType, string billno, string entId, int pageIndex = 1, int pageSize = 3)
        {
            try
            {
                if (string.IsNullOrEmpty(entId))
                {
                    entId = BaseConfiguration.EntId;
                }
                ///获取用户信息
                UserInfoDal     dal        = new UserInfoDal();
                List <UserInfo> user       = dal.GetUserInfo(userId, entId);
                bool            landing    = false;
                bool            staleDated = false;
                string          Pricelevel = "";
                string          KhType     = "";
                if (user.Count > 0)
                {
                    entId      = user[0].EntId;
                    Pricelevel = user[0].Pricelevel;
                    KhType     = user[0].KhType;
                    landing    = true;
                    staleDated = user[0].StaleDated;
                }

                BrandDal         bdal = new BrandDal();
                List <BrandList> list = bdal.GetBrandList(entId, userId, Pricelevel, KhType, landing, staleDated, faType, billno, pageIndex, pageSize, out int recordCount, out int pageCount);
                return(Json(new { success = true, list = list, recordCount = recordCount, pageCount = pageCount }));
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Brand/GetBrandList", ex.Message);
                return(Json(new { success = false, message = ex.Message }));
            }
        }
예제 #7
0
        public void TestGetUsers()
        {
            //单元测试是没用的,浪费开发时间而已?
            //1、节省的改bug的时间。

            //2、对项目非常有自信。

            //3、单元测试也是一种设计(写单元测试的时候促进对方法进行再思考)

            //4、它也是一种 项目管理的手段。TDD:测试驱动开发。

            //测试  获取数据的方法。
            UserInfoDal dal = new UserInfoDal();

            //单元测y试必须自己处理数据,不能依赖第三方数据。如果依赖数据那么先自己创建数据,然后用完之后再清除数据。
            //创建测试的数据
            for (var i = 0; i < 10; i++)
            {
                dal.Add(new UserInfo()
                {
                    UName = i + "ssss"
                });
            }

            IQueryable <UserInfo> temp = dal.GetEntities(u => u.DelFlag == DeleteFlag.DelflagNormal && u.UName.Contains("ss"));

            //断言
            Assert.AreEqual(true, temp.Count() >= 10);
            ///////////////////葛洋洋
            ////喜洋洋,慢洋洋!
        }
        public void Remove()
        {
            IUserInfoDal userInfoDal = new UserInfoDal(new SqlConnection("server=.;uid=sa;pwd=123456;database=MultilayerFrameworkSampleDb"));
            var          result      = userInfoDal.Remove("53cd0b6a63336783");

            result.Should().BeTrue();
        }
예제 #9
0
        static void GenerateUserInfo(int num)
        {
            UserInfoDal dal       = new UserInfoDal();
            DbSession   dbSession = new DbSession();

            for (int i = 0; i < num; i++)
            {
                UserInfo user = new UserInfo();
                user.UserInfoLoginId   = Guid.NewGuid().ToString().Substring(0, 10);
                user.UserInfoShowName  = (Faker.Name.First() + Faker.Name.First()).Substring(3);
                user.UserInfoPwd       = MD5Helper.Get_MD5(Faker.Name.First()).Substring(3);
                user.UserInfoStuId     = Faker.Phone.Extension() + Faker.Phone.Extension();
                user.MajorID           = new Random().Next(1, 5);
                user.UserInfoEmail     = Faker.Internet.FreeEmail().Substring(0, 10);
                user.OrganizeInfoID    = new Random().Next(3, 10);
                user.PoliticalID       = new Random().Next(1, 12);
                user.DepartmentID      = new Random().Next(2, 7);
                user.UserInfoTalkCount = new Random().Next(100);
                user.UserInfoIcon      = "/Content/Upload/images/1.jpg";
                user.UserInfoLastTime  = Convert.ToDateTime(Faker.Business.CreditCardExpiryDate());
                user.CreateTime        = user.UserInfoLastTime.AddMonths(-10);
                user.ModfiedOn         = user.UserInfoLastTime.AddMonths(-4);
                user.Status            = (short)((new Random().Next(9)) % 3);
                dal.Add(user);
            }
            dbSession.SaveChanges();
        }
예제 #10
0
        public void GetUsersTest()
        {
            IUserInfoDal dal = new UserInfoDal();


            // Insert test data
            for (var i = 0; i < 10; i++)
            {
                dal.Add(new UserInfo()
                {
                    UserName  = "******" + i,
                    FirstName = "firstName" + i,
                    LastName  = "lastName" + i,
                    Password  = "******" + i
                });
            }


            IQueryable <UserInfo> temp = dal.GetEntities(u => true);


            Assert.AreEqual(true, temp.Count() >= 10);


            //Assert.Fail();
        }
예제 #11
0
 /// <summary>
 /// 再次购买
 /// </summary>
 /// <param name="userId">用户Id</param>
 /// <param name="entId">机构Id</param>
 /// <param name="billNo">订单序号</param>
 /// <returns></returns>
 public JsonResult OnceAgain(string userId, string entId, int billNo, string cartType, string bs = "XQ", string loginId = "")
 {
     try
     {
         if (string.IsNullOrEmpty(userId))
         {
             LogQueue.Write(LogType.Error, "Cart/OnceAgain", $"userId:{userId},entId:{entId},billNo:{billNo}");
             return(Json(new{ success = false, message = "用户未登录,请先登录!" }));
         }
         ///获取用户信息
         UserInfoDal     udal = new UserInfoDal();
         List <UserInfo> user = udal.GetUserInfo(userId, entId);
         string          jgjb = "", khType = "";
         if (user.Count > 0)
         {
             jgjb   = user[0].Pricelevel;
             khType = user[0].KhType;
         }
         CartDal dal    = new CartDal();
         string  result = dal.OnceAgain(userId, entId, billNo, loginId, out bool flag, jgjb, khType, cartType, bs);
         return(Json(new { success = flag, message = result }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Cart/OnceAgain", ex.Message.ToString());
         return(Json(new { success = false, message = ex.Message }));
     }
 }
예제 #12
0
        /// <summary>
        /// 结算可用优惠券
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="entId"></param>
        /// <param name="goodsList"></param>
        /// <returns></returns>
        public JsonResult UsableCoupon(string userId, string entId, string goodsList, int pageIndex, int pageSize, string channelName, string ywyId = "")
        {
            try
            {
                if (string.IsNullOrEmpty(userId))
                {
                    return(Json(new { success = false, message = "用户未登录,请先登录" }));
                }
                ///获取用户信息
                UserInfoDal     udal = new UserInfoDal();
                List <UserInfo> user = udal.GetUserInfo(userId, entId);
                if (user.Count <= 0)
                {
                    return(Json(new { success = false, message = "E002" }));
                }
                ///获取金额信息
                OrderInfoDal cdal   = new OrderInfoDal();
                OrderAmount  Amount = cdal.OrderOriginalAmount(user[0].EntId, userId, goodsList, user[0].Pricelevel, user[0].KhType, "", "", ywyId)[0];

                decimal           OrdersAmount   = Amount.OrdersAmount;
                decimal           RealAmount     = Amount.RealAmount;
                decimal           DiscountAmount = Amount.DiscountAmount;
                decimal           PtAmount       = Amount.PtAmount;
                var               dal            = new CouponDal();
                List <UserCoupon> list           = dal.UsableCoupon(userId, entId, goodsList, pageIndex, pageSize, ywyId, out int pageCount, out int recordCount, channelName, user[0].Pricelevel, user[0].KhType, OrdersAmount, RealAmount, DiscountAmount, PtAmount);
예제 #13
0
        public void GetAllUserInfoTest()
        {
            UserInfoDal dal      = new UserInfoDal();
            var         userList = dal.GetAllEntities();

            Console.WriteLine(userList.Count());
            Assert.AreEqual(true, 15 > userList.Count());
        }
        public void Add()
        {
            IUserInfoDal userInfoDal = new UserInfoDal(new SqlConnection("server=.;uid=sa;pwd=123456;database=MultilayerFrameworkSampleDb"));
            var          result      = userInfoDal.RegisterAccount(new MultilayerFrameworkSample.Dto.RegisterDto {
                EMail = "*****@*****.**", Password = "******"
            });

            result.Should().BeTrue();
        }
        public void Update()
        {
            IUserInfoDal userInfoDal = new UserInfoDal(new SqlConnection("server=.;uid=sa;pwd=123456;database=MultilayerFrameworkSampleDb"));
            var          result      = userInfoDal.Modify(new UserInfo {
                Id = "53cd0b6a63336783", EMail = "*****@*****.**", Password = "******"
            });

            result.Should().BeTrue();
        }
예제 #16
0
        public ActionResult Delete(int id)
        {
            UserInfoDal     ud = new UserInfoDal();
            UserInfoService us = new UserInfoService();

            //BaseDal<UserInfo>.GetEntities(u => u.UserId ==id);
            // ViewData.Model = ud.GetUserInfoById(id);
            ViewData.Model = UserInfoService.Get(id);
            return(View());
        }
예제 #17
0
        /// <summary>
        /// 查询所有用户的信息
        /// </summary>
        /// <returns></returns>
        public static List <UserInfo> SelectAllUser()
        {
            List <UserInfo> list = UserInfoDal.SelectAllUser();

            if (list != null && list.Count() > 0)
            {
                return(list);
            }
            return(null);
        }
예제 #18
0
        public ActionResult SearchFastGoods(string entid, string userId, string searchValue)
        {
            try
            {
                if (string.IsNullOrEmpty(entid) || string.IsNullOrEmpty(userId))
                {
                    return(Json(new { flag = 0, message = "请先登录!" }));
                }
                //获取用户信息
                UserInfoDal     dal  = new UserInfoDal();
                List <UserInfo> user = new List <UserInfo>();
                if (!string.IsNullOrEmpty(userId))
                {
                    user = dal.GetUserInfo(userId, entid);
                }
                string jgjb = "", clientlimit = "", KhType = "";
                bool   landing    = false;
                bool   staleDated = false;
                if (user.Count > 0)
                {
                    entid       = user[0].EntId;
                    jgjb        = user[0].Pricelevel;
                    clientlimit = user[0].ClientLimit;
                    KhType      = user[0].KhType;
                    staleDated  = user[0].StaleDated;
                    landing     = true;
                }

                GoodsInfoDal infoDal = new GoodsInfoDal();
                if (searchValue.Trim().Contains(" "))
                {
                    int    length = searchValue.Length;
                    int    index = searchValue.IndexOf(" ");
                    string goodsValue, factoryValue;
                    goodsValue   = searchValue.Substring(0, index).Trim();
                    factoryValue = searchValue.Substring(index, length - index).ToString().Trim();
                    searchValue  = goodsValue + ',' + factoryValue;
                }
                List <GoodsList> lists = new List <GoodsList>();
                lists = infoDal.SearchFastGoods(entid, searchValue, jgjb, KhType, landing, staleDated);
                if (lists == null)
                {
                    return(Json(new { flag = 2, message = "无符合商品!" }));
                }
                else
                {
                    return(Json(new { flag = 2, message = "商品查询成功!", lists }));
                }
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Search/SearchFastGoods", ex.Message.ToString());
                return(Json(new { flag = 99, message = "商品获取失败!" }));
            }
        }
예제 #19
0
        static void Main(string[] args)
        {
            UserInfoDal dal      = new UserInfoDal();
            var         userInfo = dal.GetEntities(u => true).FirstOrDefault();

            //var userInfo =
            //    UserInfoService.GetEntities(u => u.UName == name && u.Pwd == pwd && u.DelFlag == delNormal)
            //                   .FirstOrDefault();
            Console.WriteLine("ok");
            Console.ReadLine();
        }
예제 #20
0
 /// <summary>
 /// 查询指定账号
 /// </summary>
 /// <param name="useraccount">账号</param>
 /// <returns></returns>
 public static bool SelectUserAccount(string useraccount)
 {
     if (UserInfoDal.SelectUserAccount(useraccount) == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #21
0
        public void AddTest()
        {
            UserInfoDal dal  = new UserInfoDal();
            UserInfo    user = new UserInfo();

            user.UName    = "曹操1103";
            user.Pwd      = "123456";
            user.ShowName = "曹阿瞒";
            bool sum = dal.Add(user);

            Assert.AreEqual(true, sum);
        }
예제 #22
0
 /// <summary>
 /// 注册账户
 /// </summary>
 /// <param name="userinfo">注册账户实体</param>
 /// <returns>是否注册成功</returns>
 public bool AddUserInfo(UserInfo userinfo)
 {
     try
     {
         UserInfoDal userinfoDal = new UserInfoDal();
         return(userinfoDal.AddUser(userinfo));
     }
     catch (System.Exception ex)
     {
         throw new Exception.BllException(ex.Message);
     }
 }
예제 #23
0
 public UserInfo GetUserInfo(string username, string password)
 {
     try
     {
         UserInfoDal dal = new UserInfoDal();
         return(dal.GetUser(username, password));
     }
     catch (System.Exception ex)
     {
         throw new Exception.BllException(ex.Message);
     }
 }
        public bool CheckUserInfo(string account, string pwd, out string returnMessage)
        {
            UserInfoDal   userInfoDal = new UserInfoDal();
            UFSM_UserInfo user        = userInfoDal.CheckUserInfo(account, pwd, out returnMessage);

            if (user != null)
            {
                StaticObject.user = user;
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #25
0
        static void DeleteUser()
        {
            int         id          = 3;
            UserInfoDal userInfoDal = new UserInfoDal();
            var         d           = userInfoDal.Delete(id);

            if (d)
            {
                Console.WriteLine("成功");
            }
            else
            {
                Console.WriteLine("失败");
            }
        }
예제 #26
0
        public JsonResult OftenBuy(string userId, string entId, string searchValue, int pageIndex = 1, int pageSize = 15)
        {
            try
            {
                if (string.IsNullOrEmpty(entId) || string.IsNullOrEmpty(userId))
                {
                    return(Json(new { success = false, message = "请先登录" }));
                }
                //获取用户信息
                UserInfoDal     dal  = new UserInfoDal();
                List <UserInfo> user = new List <UserInfo>();
                if (!string.IsNullOrEmpty(userId))
                {
                    user = dal.GetUserInfo(userId, entId);
                }
                string jgjb = "", clientlimit = "", KhType = "";
                bool   landing    = false;
                bool   staleDated = false;
                if (user.Count > 0)
                {
                    entId       = user[0].EntId;
                    jgjb        = user[0].Pricelevel;
                    clientlimit = user[0].ClientLimit;
                    KhType      = user[0].KhType;
                    staleDated  = user[0].StaleDated;
                    landing     = true;
                }

                GoodsInfoDal infoDal = new GoodsInfoDal();
                if (searchValue.Trim().Contains(" "))
                {
                    int    length = searchValue.Length;
                    int    index = searchValue.IndexOf(" ");
                    string goodsValue, factoryValue;
                    goodsValue   = searchValue.Substring(0, index).Trim();
                    factoryValue = searchValue.Substring(index, length - index).ToString().Trim();
                    searchValue  = goodsValue + ',' + factoryValue;
                }
                List <GoodsList> lists = new List <GoodsList>();
                lists = infoDal.OftenBuy(userId, entId, searchValue, jgjb, KhType, landing, staleDated, pageIndex, pageSize, out int pageCount, out int recordCount);
                return(Json(new { success = true, message = "常购商品获取成功", lists, pageCount, recordCount }));
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Search/OftenBuy", $"{ex.Message}");
                return(Json(new { success = false, message = "常购商品获取失败!" }));
            }
        }
        public bool ChangeUserInfo(UserInfo user, out string returnMessage)
        {
            UserInfoDal userInfoDal = new UserInfoDal();

            if (userInfoDal.ChangeUserInfo(user) > 0)
            {
                userList      = new UserInfoDal().GetUserInfoList();
                returnMessage = "修改成功";
                return(true);
            }
            else
            {
                returnMessage = "数据库异常,修改失败,请稍后重试";
                return(false);
            }
        }
예제 #28
0
        /// <summary>
        /// 判断员工的登录时间是否修改成功
        /// </summary>
        /// <param name="name"></param>
        /// <returns>返回值位ture成功否知失败</returns>
        public static bool UpdateUser(string name)
        {
            int a = UserInfoDal.UpdateUser(name);

            if (a == 0)
            {
                return(false);
            }
            else if (a > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #29
0
        /// <summary>
        /// 判断是否注册成功
        /// </summary>
        /// <param name="name">注册账号</param>
        /// <param name="pwd">注册密码</param>
        /// <returns>返回ture成功返回false失败</returns>
        public static bool AddUser(string name, string pwd)
        {
            int a = UserInfoDal.AddUser(name, pwd);

            if (a == 0)
            {
                return(false);
            }
            else if (a > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #30
0
 /// <summary>
 /// 同类商品推荐
 /// </summary>
 /// <param name="entId">企业</param>
 /// <param name="userId">用户</param>
 /// <param name="articleId">商品ID</param>
 /// <param name="num">条目数</param>
 /// <returns></returns>
 public ActionResult Commendation(string entId, string userId, string articleId, int num)
 {
     try
     {
         if (string.IsNullOrEmpty(entId))
         {
             entId = BaseConfiguration.EntId;
         }
         if (string.IsNullOrEmpty(articleId))
         {
             return(Json(new { success = false, message = "参数异常" }));
         }
         ///获取用户信息
         UserInfoDal     dal  = new UserInfoDal();
         List <UserInfo> user = new List <UserInfo>();
         if (!string.IsNullOrEmpty(userId))
         {
             user = dal.GetUserInfo(userId, entId);
         }
         string jgjb = "", clientlimit = "", KhType = "";
         bool   landing    = false;
         bool   staleDated = false;
         //获取客户价格级别
         if (user.Count > 0)
         {
             entId       = user[0].EntId;
             jgjb        = user[0].Pricelevel;
             clientlimit = user[0].ClientLimit;
             KhType      = user[0].KhType;
             staleDated  = user[0].StaleDated;
             landing     = true;
         }
         GoodsInfoDal infoDal = new GoodsInfoDal();
         ///商品详情
         List <GoodsList> list = infoDal.GetGoodDetail(userId, articleId, entId);
         var category          = list[0].GoodsInfo[0].Category;
         //同类商品推荐
         List <Models.GoodsInfo> klist = infoDal.Commendation(entId, category, num, jgjb, KhType, landing, staleDated);
         return(Json(new { success = true, message = "商品推荐获取成功", klist }));
     }
     catch (Exception ex)
     {
         LogQueue.Write(LogType.Error, "Goods/Commendation", ex.Message.ToString());
         return(Json(new { success = false, message = "商品推荐加载失败!" }));
     }
 }
예제 #31
0
        /// <summary>
        /// 发送图文信息
        /// </summary>
        /// <param name="context"></param>
        public void SendNewsMessage(HttpContext context)
        {
            var hashTable = new Hashtable();
            var key = context.Request.Params["key"];
            var type = context.Request.Params["type"];
            var count = context.Request.Params["count"];
            var accessToken = new AccessToken();
            var sendDataToUser = new SendDataToWeChat();
            var userInfoDal = new UserInfoDal();
            var infoReleaseDal = new InfoReleaseDal();
            var listnews = new List<object>();
            try
            {
                //获取发布信息数据
                var dataDt = infoReleaseDal.QueryInfo(new InfoRelease()
                {
                    BusinessType = key,
                    FlagRelease = type
                }, "2");//todo:替换count
                var listDt = from ldt in dataDt.AsEnumerable()
                             select new
                             {
                                 Title = ldt.Field<string>("Title"),
                                 MessageDescription = ldt.Field<string>("MessageDescription")
                             };
                foreach (var ldt in listDt)
                {
                    listnews.Add(new
                    {
                        title = ldt.Title,
                        description = ldt.MessageDescription,
                        url = "http://218.22.27.236/views/messagelist/messagelist.htm?key=" + key + "&name=停电信息列表",
                        picurl = "http://218.22.27.236/tl/UploadImages/topleft.jpg"
                    });
                }

                //获取用户数据
                var data = userInfoDal.QueryAll();
                var list = from da in data.AsEnumerable()
                           select new
                           {
                               openid = da.Field<string>("openid"),
                           };
                foreach (var li in list)
                {
                    hashTable["touser"] = li.openid;
                    hashTable["msgtype"] = "news";
                    hashTable["news"] = new
                    {
                        articles = listnews
                    };
                    var json = _jss.Serialize(hashTable);
                    var token = accessToken.GetExistAccessToken();
                    var back = sendDataToUser.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + token, json);
                    Log.Debug("调试信息:" + back);
                }
            }
            catch (Exception ex)
            {
                Log.Debug("错误信息:" + ex.Message);
            }
        }
예제 #32
0
 /// <summary>
 /// 发布信息到人(实际上只是修改了下发布状态,仅此而已)
 /// </summary>
 /// <param name="context"></param>
 public void PublishInfoToPerson(HttpContext context)
 {
     var hashtable = new Hashtable();
     var infoReleaseDal = new PowerCutDal();
     var userInfoDal = new UserInfoDal();
     var id = context.Request.Params["id"];
     try
     {
         infoReleaseDal.Modify(new PowerCut()
         {
             Id = id,
             FlagRelease = "2"
         });
         hashtable["isSuccess"] = true;
         hashtable["jsMethod"] = "ajax_PublishInfoToPerson";
         var json = _jss.Serialize(hashtable);
         context.Response.Write(json);
     }
     catch (Exception e)
     {
         Log.Debug("方法名:PublishInfoToPerson,,错误原因:" + e.Message);
     }
 }
예제 #33
0
        /// <summary>
        /// 发布信息到人(实际上只是修改了下发布状态,仅此而已)
        /// </summary>
        /// <param name="context"></param>
        public void PublishInfoToPerson(HttpContext context)
        {
            var hashtable = new Hashtable();
            var infoReleaseDal = new InfoReleaseDal();
            var userInfoDal = new UserInfoDal();
            var id = context.Request.Params["id"];
            try
            {
                //var data = userInfoDal.QueryAll();
                //var tmp = string.Join(",",
                //    (
                //        from DataRow da in data.Rows
                //        select da["openid"].ToString()
                //    ).ToArray());

                infoReleaseDal.Modify(new InfoRelease()
                    {
                        Id = id,
                        FlagRelease = "1"
                    });
                hashtable["isSuccess"] = true;
                hashtable["jsMethod"] = "ajax_PublishInfoToPerson";
                var json = _jss.Serialize(hashtable);
                context.Response.Write(json);
            }
            catch (Exception e)
            {
                Log.Debug("方法名:PublishInfoToPerson,,错误原因:" + e.Message);
            }
        }
예제 #34
0
 /// <summary>
 /// 发送文本信息
 /// </summary>
 /// <param name="context"></param>
 public void SendTxtMessage(HttpContext context)
 {
     var hashTable = new Hashtable();
     var accessToken = new AccessToken();
     var sendDataToUser = new SendDataToWeChat();
     var userInfoDal = new UserInfoDal();
     try
     {
         var data = userInfoDal.QueryAll();
         var list = from da in data.AsEnumerable()
                    select new
                        {
                            openid = da.Field<string>("openid"),
                        };
         foreach (var li in list)
         {
             hashTable["touser"] = li.openid;
             hashTable["msgtype"] = "text";
             hashTable["text"] = new
                 {
                     content = "你好张威,这是你的测试内容"
                 };
             var json = _jss.Serialize(hashTable);
             var token = accessToken.GetExistAccessToken();
             var back = sendDataToUser.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + token, json);
             Log.Debug("调试信息:" + back);
         }
     }
     catch (Exception ex)
     {
         Log.Debug("错误信息:" + ex.Message);
     }
 }
예제 #35
0
파일: Form1.cs 프로젝트: mildrock/wechat
        public void Send()
        {
            while (true)
            {
                try
                {
                    Log.Debug("主网、配网、监控 推送。");
                    InfoReleaseDal dal = new InfoReleaseDal();
                    DataTable dt = dal.QueryByTypes(new string[] { "3080_youo_zwtz", "3081_youo_pwtz", "3082_youo_jkxx" });

                    UserGroupDal userGroupDal = new UserGroupDal();
                    DataTable dtUser = userGroupDal.QueryInternalUser();
                    //发送:主网、配网、监控
                    foreach (DataRow row in dt.Rows)
                    {
                        Success = false;
                        var title = row["Title"].ToString();
                        var MessageDescription = row["MaterialContent"].ToString();
                        //var content = "标题:" + title + "\n内容:" + MessageDescription + "\n发布人:" + row["CreatePerson"].ToString();
                        var content = "标题:" + title + "\n内容:" + MessageDescription + "\n\r       国网铜陵供电公司";

                        foreach (DataRow row1 in dtUser.Rows)
                        {
                            var openId = row1["openid"].ToString();
                            SendMsg(openId, content);
                        }
                        if (Success)
                        {
                            dal.Modify(new InfoRelease()
                                {
                                    Id = row["id"].ToString(),
                                    FlagRelease = "2",
                                });
                        }
                    }

                    PowerCutDal powerCutDal = new PowerCutDal();
                    DataTable dtPowerCut = powerCutDal.Query(new PowerCut()
                        {
                            State = "1", //未送电
                            FlagRelease = "'2'", //已发布
                            DateBegin = DateTime.Now.Date,
                            DateEnd = DateTime.MaxValue.AddDays(-2),
                            BusinessType = "011_youo_tdtz2",
                        });
                    //发送:故障停电
                    Log.Debug("故障停电");
                    foreach (DataRow row in dtPowerCut.Rows)
                    {
                        Success = false;
                        var content = "尊敬的电力客户:\n\r       因突发电力故障,安排以下故障抢修工作安排。未经铜陵供电公司有关部门许可,严禁任何单位和个人在停电线路及设备上工作。为此造成的不便,敬请各客户给予谅解和支持。如有任何疑问,请致电供电公司24小时服务热线95598。\n\r       停电时间:" + row["PowerCutTime"].ToString().Split(' ')[0] + " " + row["TimeArea"].ToString() +
                          "\n\r       停电设备:" + row["Device"].ToString() + "\n\r       停电区域:" + row["Area"].ToString() + "\n\r       国网铜陵供电公司";

                        foreach (DataRow row1 in dtUser.Rows)
                        {
                            var openId = row1["openid"].ToString();
                            SendMsg(openId, content);
                        }
                        if (Success)
                        {
                            powerCutDal.Modify(new PowerCut()
                            {
                                Id = row["id"].ToString(),
                                FlagRelease = "3",
                            });
                            Log.Debug("修改状态为已推送--" + row["id"].ToString());
                        }
                    }

                    #region  发送最新资讯091_youo_zxzx

                    var sendMessage = new SendMessage();
                    var listnews = new List<Articles>();
                    var articles = new Articles();
                    InfoReleaseDal infoReleaseDal = new InfoReleaseDal();
                    DataTable yhcsDt = infoReleaseDal.Query(new InfoRelease()
                        {
                            FlagRelease = "1",
                            BusinessType = "091_youo_zxzx",
                        });

                    DataTable userDt = new UserInfoDal().Query(new UserInfo());//获取所有关注的微信用户
                    WebServ.WebService1 service1 = new WebService1();
                    var token = service1.GetToken();
                    foreach (DataRow row in yhcsDt.Rows)
                    {
                        var id = row["id"].ToString();
                        var discrip = row["MessageDescription"].ToString();
                        if (discrip.Length > 200)
                        {
                            discrip = discrip.Substring(0, 190) + "...";
                        }
                        articles = new Articles()
                        {
                            title = row["title"].ToString(),
                            description = discrip,
                            picurl = "http://60.173.29.191/UploadImages/091_youo_zxzx.jpg",
                            url = "http://60.173.29.191/views/messagelist/messagedetail.htm?id=" + id,
                        };
                        listnews.Add(articles);
                        foreach (DataRow uRow in userDt.Rows)
                        {
                            var openid = uRow["openid"].ToString();
                            sendMessage.SendNewsMessage(token, openid, listnews);
                        }
                        infoReleaseDal.Modify(new InfoRelease()
                            {
                                Id = id,
                                FlagRelease = "2",
                            });
                        Log.Debug("最新资讯-修改状态为已推送--" + row["id"].ToString());
                    }
                    #endregion

                    Thread.Sleep(10000);
                }
                catch (Exception ex)
                {
                    Log.Debug("发送故障" + ex);
                    Thread.Sleep(100000);
                }
            }
        }