예제 #1
0
 /// <summary>
 /// 保存待发送的推送消息
 /// </summary>
 /// <param name="condtion"></param>
 /// <returns></returns>
 internal static ReplayBase RunSaveSentPush(SendGeTuiPushBySetRequestModel condtion)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection)) {
         ReplayBase result = new ReplayBase()
         {
             ReturnMessage = Guid.NewGuid().ToString()
         };
         Us_RunSentPush dbp = new Us_RunSentPush()
         {
             Us_RunSentPushId = result.ReturnMessage,
             createdBy        = condtion.createdBy,
             createdOn        = DateTime.Now,
             customInfo       = Newtonsoft.Json.JsonConvert.SerializeObject(condtion.customInfo),
             messageType      = (byte)condtion.messageType.GetHashCode(),
             msg       = condtion.msg,
             sentStats = false,
             title     = condtion.title
         };
         foreach (GeTuiSetModel s in condtion.sets)
         {
             dbp.Us_RunSentPushDetail.Add(new Us_RunSentPushDetail()
             {
                 clientId               = s.clientId,
                 deviceType             = (byte)s.deviceType.GetHashCode(),
                 sentUserId             = s.userId,
                 Us_RunSentPushDetailId = Guid.NewGuid().ToString(),
                 Us_RunSentPushId       = result.ReturnMessage
             });
         }
         context.Us_RunSentPush.InsertOnSubmit(dbp);
         context.SubmitChanges();
         return(result);
     }
 }
예제 #2
0
 /// <summary>
 /// 更新用户的百度推送设置
 /// 系统会自动将数据库中其他相同的推送设置清空,避免当同一个设备登录不同的账号后历史登录的账号收到推送消息
 /// </summary>
 /// <param name="condtion">推送设置</param>
 /// <param name="userId">用户ID</param>
 /// <returns></returns>
 internal static ReplayBase MemberUpdateMemberBaiduPushSet(BaiduPushSetModel condtion, string userId)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection)) {
         //先清空与该配置相同的其他用户的推送设置
         var d = (from c in context.Us_SysUser
                  where (c.baiduPushchannelId == condtion.channelId) &&
                  (c.baiduPushUserId == condtion.userId) &&
                  (c.baiduPushdeviceType == (byte)condtion.deviceType.GetHashCode())
                  select c).ToList();
         if (d.Count > 0)
         {
             foreach (var s in d)
             {
                 s.baiduPushchannelId  = null;
                 s.baiduPushUserId     = null;
                 s.baiduPushdeviceType = null;
             }
             context.SubmitChanges();
         }
         //然后再更新用户的推送设置
         Us_SysUser dbuser = context.Us_SysUser.Single(p => p.Us_SysUserId == userId);
         dbuser.baiduPushchannelId  = condtion.channelId;
         dbuser.baiduPushUserId     = condtion.userId;
         dbuser.baiduPushdeviceType = (byte)condtion.deviceType.GetHashCode();
         context.SubmitChanges();
         return(new ReplayBase()
         {
         });
     }
 }
예제 #3
0
 /// <summary>
 /// 获取地址信息
 /// </summary>
 /// <param name="condtion"></param>
 /// <returns></returns>
 internal static List <AddressInfoModel> GetAddressListByFkId(GetUserExInfoListRequest condtion)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         List <AddressInfoModel> result = (from c in context.Us_RsAddress
                                           where (condtion.onlyDefalut ? c.isDefault == true : true) &&
                                           (string.IsNullOrEmpty(condtion.id) ? true : c.Us_RsAddressId == condtion.id) &&
                                           (string.IsNullOrEmpty(condtion.fkId) ? true : c.fkId == condtion.fkId)
                                           orderby c.isDefault descending, c.modifiedOn descending
                                           select new AddressInfoModel
         {
             fkId = c.fkId,
             id = c.Us_RsAddressId,
             isDefault = c.isDefault,
             address = c.address,
             linkMan = c.linkMan,
             linkPhone = c.linkPhone,
             postCode = c.postCode,
             locationInfo = BaseSysTemDataBaseManager.RsGetLocaionInfo(new LocationInfoModel()
             {
                 cityInfo = new GeoCityInfoModel()
                 {
                     CityCode = c.cityId
                 },
                 DistrictId = c.districtId
             }),
             modifiedOn = c.modifiedOn
         }).ToList();
         return(result);
     }
 }
예제 #4
0
 /// <summary>
 /// 更新推送设置的状态与结果
 /// </summary>
 /// <param name="pushId">推送的ID</param>
 /// <param name="r">推送结果信息</param>
 internal static void RunUpdateSentPushStatus(string pushId, SendGeTuiPushReplay r)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection)) {
         Us_RunSentPush dbp = context.Us_RunSentPush.Single(p => p.Us_RunSentPushId == pushId);
         dbp.sentStats         = r.ReturnCode == EnumErrorCode.Success ? true : false;
         dbp.sentResultAndroid = r.sentResultAndroid;
         dbp.sentResultIos     = r.sentResultIos;
         context.SubmitChanges();
     }
 }
예제 #5
0
 /// <summary>
 /// 查询推送历史
 /// </summary>
 /// <param name="condtion"></param>
 /// <returns></returns>
 internal static SearchSentPushListReplayModel RunSearchHistoryPushList(SearchSentPushListRequestModel condtion)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection)) {
         SearchSentPushListReplayModel result = new SearchSentPushListReplayModel();
         result.total = (from c in context.Us_RunSentPush
                         where (1 == 1) &&
                         (condtion.beginDate == null ? true : c.createdOn >= condtion.beginDate) &&
                         (condtion.endDate == null ? true : c.createdOn <= condtion.endDate) &&
                         (string.IsNullOrEmpty(condtion.keyWords) ? true : (SqlMethods.Like(c.title, string.Format("%{0}%", condtion.keyWords)) || SqlMethods.Like(c.msg, string.Format("%{0}%", condtion.keyWords))))
                         select c.Us_RunSentPushId).Count();
         if (result.total > 0)
         {
             result.rows = (from c in context.Us_RunSentPush
                            where (1 == 1) &&
                            (condtion.beginDate == null ? true : c.createdOn >= condtion.beginDate) &&
                            (condtion.endDate == null ? true : c.createdOn <= condtion.endDate) &&
                            (string.IsNullOrEmpty(condtion.keyWords) ? true : (SqlMethods.Like(c.title, string.Format("%{0}%", condtion.keyWords)) || SqlMethods.Like(c.msg, string.Format("%{0}%", condtion.keyWords))))
                            orderby c.createdOn descending
                            select new SentPushInfoModel
             {
                 id = c.Us_RunSentPushId,
                 createdBy = BaseSysTemDataBaseManager.SysGetSysUserById(c.createdBy),
                 createdOn = c.createdOn,
                 customInfo = c.customInfo,
                 messageType = (EnumPushMessagesType)c.messageType,
                 msg = c.msg,
                 sentResultAndroid = c.sentResultAndroid,
                 sentResultIos = c.sentResultIos,
                 sentStats = c.sentStats,
                 sentUserNum = c.Us_RunSentPushDetail.Count,
                 title = c.title,
                 sentUserList = (from x in c.Us_RunSentPushDetail
                                 select new SentPushInfoDetailInfoModel
                 {
                     sentDeviceInfo = new GeTuiSetModel()
                     {
                         clientId = x.clientId,
                         deviceType = (EnumUserDeviceType)x.deviceType,
                         userId = x.sentUserId
                     },
                     sentUserInfo = (x.sentUserId == null || x.sentUserId == "") ? null :
                                    BaseSysTemDataBaseManager.SysGetSysUserById(x.sentUserId)
                 }
                                 ).ToList()
             }).Skip((condtion.Page - 1) * condtion.PageSize).Take(condtion.PageSize).ToList();
         }
         else
         {
             result.rows = new List <SentPushInfoModel>();
         }
         return(result);
     }
 }
예제 #6
0
 /// <summary>
 /// 将FKID下的常旅客的全部设置为非默认
 /// </summary>
 /// <param name="fkid"></param>
 internal static void RsSetTravellertoUndefault(string fkid)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         var result = (from c in context.Us_RsTraveller where c.fkId == fkid select c).ToList();
         foreach (var a in result)
         {
             a.isDefault = false;
         }
         context.SubmitChanges();
     }
 }
예제 #7
0
        /// <summary>
        ///根据查看的默认常用旅客数量从而可以获取当前FKID下是否有历史数据
        /// </summary>
        /// <param name="fkid"></param>
        /// <returns></returns>
        internal static int RsGetTravellerDefaultCount(string fkid)
        {
            int defaultcount = 0;

            using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
            {
                if (!string.IsNullOrEmpty(fkid))
                {
                    defaultcount = (from c in context.Us_RsTraveller where c.isDefault == true && c.fkId == fkid select c.Us_RsTravellerId).Count();
                }
            }
            return(defaultcount);
        }
예제 #8
0
 /// <summary>
 ///  删除常用地址(物理删除)
 /// 如果删除的时候默认地址,[则将当前用户最近编辑的一条这是为默认地址(如果有的话)]
 /// </summary>
 /// <param name="id">地址id</param>
 /// <returns></returns>
 internal static ReplayBase DelAddress(string id)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         Us_RsAddress addrss = context.Us_RsAddress.Single(p => p.Us_RsAddressId == id);
         context.Us_RsAddress.DeleteOnSubmit(addrss);
         context.SubmitChanges();
         return(new ReplayBase()
         {
             ReturnMessage = id
         });
     }
 }
예제 #9
0
 /// <summary>
 /// 删除常用旅客
 /// </summary>
 /// <param name="id">常用旅客id</param>
 /// <returns></returns>
 internal static ReplayBase SysDelTraveller(string id)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         Us_RsTraveller trave = context.Us_RsTraveller.Single(p => p.Us_RsTravellerId == id);
         context.Us_RsTraveller.DeleteOnSubmit(trave);
         context.SubmitChanges();
         return(new ReplayBase()
         {
             ReturnMessage = id
         });
     }
 }
예제 #10
0
 /// <summary>
 /// 添加或编辑常用地址
 /// </summary>
 /// <param name="addressinfo">地址信息</param>
 /// <returns></returns>
 internal static ReplayBase EditAddress(AddressInfoModel addressinfo)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         string NewAddressId = Guid.NewGuid().ToString();
         if (string.IsNullOrEmpty(addressinfo.id))
         {
             //新增
             Us_RsAddress dbaddress = new Us_RsAddress()
             {
                 modifiedOn     = DateTime.Now,
                 Us_RsAddressId = NewAddressId,
                 address        = addressinfo.address,
                 cityId         = addressinfo.locationInfo.cityInfo.CityCode,
                 districtId     = addressinfo.locationInfo.DistrictId,
                 linkMan        = addressinfo.linkMan,
                 linkPhone      = addressinfo.linkPhone,
                 postCode       = addressinfo.postCode,
                 isDefault      = addressinfo.isDefault,
                 fkId           = addressinfo.fkId,
             };
             context.Us_RsAddress.InsertOnSubmit(dbaddress);
         }
         else
         {
             //编辑
             NewAddressId = addressinfo.id;
             Us_RsAddress dbaddress = context.Us_RsAddress.Single(p => p.Us_RsAddressId == addressinfo.id);
             dbaddress.modifiedOn = DateTime.Now;
             dbaddress.address    = addressinfo.address;
             dbaddress.cityId     = addressinfo.locationInfo.cityInfo.CityCode;
             dbaddress.districtId = addressinfo.locationInfo.DistrictId;
             dbaddress.linkMan    = addressinfo.linkMan;
             dbaddress.linkPhone  = addressinfo.linkPhone;
             dbaddress.postCode   = addressinfo.postCode;
             dbaddress.isDefault  = addressinfo.isDefault;
             dbaddress.fkId       = addressinfo.fkId;
         }
         context.SubmitChanges();
         return(new ReplayBase()
         {
             ReturnMessage = NewAddressId
         });
     }
 }
예제 #11
0
        /// <summary>
        /// 根据fkid查看是否有默认常用地址
        /// </summary>
        /// <param name="fkid"></param>
        /// <returns></returns>
        internal static bool RsGetAddressHaveDefault(string fkid)
        {
            bool defaults = false;

            using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
            {
                if (!string.IsNullOrEmpty(fkid))
                {
                    if ((from c in context.Us_RsAddress
                         where c.isDefault == true && c.fkId == fkid
                         select c.Us_RsAddressId).Count() > 0)
                    {
                        defaults = true;
                    }
                }
            }
            return(defaults);
        }
예제 #12
0
 /// <summary>
 /// 新增/编辑 常用旅客,[isDefault:默认:true,非默认:false]
 /// </summary>
 /// <param name="travellerInfo"></param>
 /// <returns></returns>
 internal static ReplayBase RsSaveTraveller(Traveller travellerInfo)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         string NewTravellerId = Guid.NewGuid().ToString();
         if (string.IsNullOrEmpty(travellerInfo.ravellerId))
         {
             //新增
             Us_RsTraveller dbtraveller = new Us_RsTraveller()
             {
                 modifiedOn       = DateTime.Now,
                 fullName         = travellerInfo.fullName,
                 idType           = (byte)travellerInfo.idType.GetHashCode(),
                 idCard           = travellerInfo.idCard,
                 isDefault        = travellerInfo.isDefault,
                 fkId             = travellerInfo.fkId,
                 Us_RsTravellerId = NewTravellerId
             };
             context.Us_RsTraveller.InsertOnSubmit(dbtraveller);
         }
         else
         {
             //编辑
             NewTravellerId = travellerInfo.ravellerId;
             Us_RsTraveller dbtraveller = context.Us_RsTraveller.Single(p => p.Us_RsTravellerId == travellerInfo.ravellerId);
             dbtraveller.modifiedOn = DateTime.Now;
             dbtraveller.fullName   = travellerInfo.fullName;
             dbtraveller.idType     = (byte)travellerInfo.idType.GetHashCode();
             dbtraveller.idCard     = travellerInfo.idCard;
             dbtraveller.isDefault  = travellerInfo.isDefault;
             dbtraveller.fkId       = travellerInfo.fkId;
         }
         context.SubmitChanges();
         return(new ReplayBase()
         {
             ReturnMessage = NewTravellerId
         });
     }
 }
예제 #13
0
 /// <summary>
 ///获取常旅客信息
 /// </summary>
 /// <param name="condtion"></param>
 /// <returns></returns>
 internal static List <Traveller> RsGetTravellerInfoByfkid(GetUserExInfoListRequest condtion)
 {
     using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection))
     {
         List <Traveller> result = (from c in context.Us_RsTraveller
                                    where (condtion.onlyDefalut ? c.isDefault == true : true) &&
                                    (string.IsNullOrEmpty(condtion.id) ? true : c.Us_RsTravellerId == condtion.id) &&
                                    (string.IsNullOrEmpty(condtion.fkId) ? true : c.fkId == condtion.fkId)
                                    orderby c.isDefault descending, c.modifiedOn descending
                                    select new Traveller
         {
             fkId = c.fkId,
             ravellerId = c.Us_RsTravellerId,
             isDefault = c.isDefault,
             idCard = c.idCard,
             idType = (EnumUserIdType)c.idType,
             fullName = c.fullName,
             modifiedOn = c.modifiedOn
         }).ToList();
         return(result);
     }
 }
예제 #14
0
        /// <summary>
        /// 更新用户的个推设置信息
        /// 系统会自动将数据库中其他相同的推送设置清空,避免当同一个设备登录不同的账号后历史登录的账号收到推送消息
        /// </summary>
        /// <param name="condtion"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        internal static ReplayBase MemberUpdateMemberGetuiPushSet(GeTuiSetModel condtion, string userId)
        {
            using (SysTemDataBaseDataContext context = new SysTemDataBaseDataContext(SqlConnection)) {
                var d = (from c in context.Us_SysUser
                         where (c.getuiPushClientId == condtion.clientId) &&
                         (c.getuiPushDeviceType == (byte)condtion.deviceType.GetHashCode())
                         select c).ToList();
                if (d.Count > 0)
                {
                    foreach (var s in d)
                    {
                        s.getuiPushClientId   = null;
                        s.getuiPushDeviceType = null;
                    }
                    context.SubmitChanges();
                }

                Us_SysUser dbuser = context.Us_SysUser.Single(p => p.Us_SysUserId == userId);
                dbuser.getuiPushClientId   = condtion.clientId;
                dbuser.getuiPushDeviceType = (byte)condtion.deviceType.GetHashCode();
                context.SubmitChanges();
                return(new ReplayBase());
            }
        }