示例#1
0
        public void AddSystemLog(SystemLogDataInfo systemLogDatainfo)
        {
            SystemLog systemLog = SimpleObjectMapper.CreateTargetObject <SystemLogDataInfo, SystemLog>(systemLogDatainfo);

            db.SystemLog.Add(systemLog);
            db.SaveChanges();
        }
示例#2
0
        public IEnumerable <UserComment> GetComments(string idsubtitle)
        {
            var response = proxy.GetComments(token, new string[] { idsubtitle });

            VerifyResponseCode(response);

            var comments       = new List <UserComment>();
            var commentsStruct = response.data as XmlRpcStruct;

            if (commentsStruct == null)
            {
                return(comments);
            }

            if (commentsStruct.ContainsKey("_" + idsubtitle))
            {
                object[] commentsList = commentsStruct["_" + idsubtitle] as object[];
                if (commentsList != null)
                {
                    foreach (XmlRpcStruct commentStruct in commentsList)
                    {
                        var comment = SimpleObjectMapper.MapToObject <CommentsData>(commentStruct);
                        comments.Add(BuildUserCommentObject(comment));
                    }
                }
            }

            return(comments);
        }
示例#3
0
        private Task <IList <Subtitle> > SearchSubtitlesInternal(SearchSubtitlesRequest request)
        {
            var tcs = new TaskCompletionSource <IList <Subtitle> >();

            try
            {
                var response = Proxy.SearchSubtitles(Token, new[] { request });
                VerifyResponseCode(response);

                var subtitles     = new List <Subtitle>();
                var subtitlesInfo = response.data as object[];
                if (null != subtitlesInfo)
                {
                    foreach (var infoObject in subtitlesInfo)
                    {
                        var subInfo = SimpleObjectMapper.MapToObject <SearchSubtitlesInfo>((XmlRpcStruct)infoObject);
                        subtitles.Add(BuildSubtitleObject(subInfo));
                    }
                }
                tcs.TrySetResult(subtitles);
            }
            catch (Exception ex)
            {
                tcs.TrySetException(ex);
            }

            return(tcs.Task);
        }
示例#4
0
        public SystemUserDataInfo GetSystemUserDataInfoByID(int Id)
        {
            SystemUser         user         = db.SystemUser.Find(Id);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(user);

            return(userDataInfo);
        }
示例#5
0
        public UserDataInfo SaveWeiXinUser(UserDataInfo userDataInfo)
        {
            UserDataInfo newUserDataInfo = null;

            try
            {
                User user = db.User.FirstOrDefault(n => n.OpenID == userDataInfo.OpenID);
                if (user == null)
                {
                    user                         = new User();
                    user.OpenID                  = userDataInfo.OpenID;
                    user.AttentionDateTime       = userDataInfo.AttentionDateTime;
                    user.CanAttention            = userDataInfo.CanAttention;
                    user.City                    = userDataInfo.City;
                    user.Country                 = userDataInfo.Country;
                    user.CreationDateTime        = userDataInfo.CreationDateTime;
                    user.DisplayName             = userDataInfo.DisplayName;
                    user.IsUse                   = userDataInfo.IsUse;
                    user.Province                = userDataInfo.Province;
                    user.Remark                  = userDataInfo.Remark;
                    user.Sex                     = userDataInfo.Sex;
                    user.SourceProductID         = userDataInfo.SourceProductID;
                    user.UserFace                = userDataInfo.UserFace;
                    user.CancelAttentionDateTime = null;
                    ServerLogger.Info("SaveWeiXinUser :"******"User",
                        Remark         = string.Format("{0}关注了公众号,用户微信数据为:{1}", userDataInfo.DisplayName, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                        CreationDate   = DateTime.Now,
                        CreationUserID = null
                    });
                }
                else
                {
                    if (!user.CanAttention)
                    {
                        user.CanAttention      = true;
                        user.AttentionDateTime = DateTime.Now;
                        db.SaveChanges();
                        AddSystemLog(new SystemLogDataInfo()
                        {
                            ModulePage     = "User",
                            Remark         = string.Format("{0}重新关注了公众号,用户微信数据为:{1}", userDataInfo.DisplayName, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                            CreationDate   = DateTime.Now,
                            CreationUserID = null
                        });
                    }
                }
                newUserDataInfo = SimpleObjectMapper.CreateTargetObject <User, UserDataInfo>(user);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(newUserDataInfo);
        }
示例#6
0
        public TDestination Map <TSource, TDestination>(TSource source)
            where TSource : new() where TDestination : new()
        {
            TDestination toReturn = new SimpleObjectMapper <TSource, TDestination>()
                                    .Map(source);

            return(toReturn);
        }
示例#7
0
        public SystemUserDataInfo GetSystemUserDataInfoByLogin(string userName, string password)
        {
            SystemUser         user         = db.SystemUser.FirstOrDefault(n => !n.IsDelete && n.UserName == userName && n.Password == password);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(user);

            if (userDataInfo != null)
            {
                AddSystemLog(new SystemLogDataInfo()
                {
                    ModulePage     = "SystemUser",
                    Remark         = "登录了系统",
                    CreationDate   = DateTime.Now,
                    CreationUserID = userDataInfo.ID,
                });
            }
            return(userDataInfo);
        }
示例#8
0
        public List <SystemUserDataInfo> GetSystemUserDataInfos(string searchText, int pageSize, int pageIndex, out int recordCount)
        {
            List <SystemUser> users = null;

            if (string.IsNullOrEmpty(searchText))
            {
                users       = db.SystemUser.Where(n => !n.IsDelete).OrderByDescending(n => n.ID).ToList();
                recordCount = db.SystemUser.Where(n => !n.IsDelete).Count();
            }
            else
            {
                users       = db.SystemUser.Where(n => !n.IsDelete && (n.DisplayName.Contains(searchText) || n.UserName.Contains(searchText))).OrderByDescending(n => n.ID).ToList();
                recordCount = db.SystemUser.Where(n => !n.IsDelete && (n.DisplayName.Contains(searchText) || n.UserName.Contains(searchText))).Count();
            }
            users = users.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            List <SystemUserDataInfo> userDataInfos = SimpleObjectMapper.ListMap <SystemUser, SystemUserDataInfo>(users).ToList();

            return(userDataInfos);
        }
示例#9
0
        public void DeleteSystemUser(int Id)
        {
            SystemUser existUser = db.SystemUser.Find(Id);

            if (existUser == null)
            {
                throw new DuplicatedDomainObjectException("用户不存在");
            }
            existUser.IsDelete = true;
            db.SaveChanges();
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);

            AddSystemLog(new SystemLogDataInfo()
            {
                ModulePage     = "SystemUser",
                Remark         = string.Format("虚拟删除了用户,用户数据为:{0}", Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                CreationDate   = DateTime.Now,
                CreationUserID = CurrentAdminUserId,
            });
        }
示例#10
0
        private IList <Subtitle> SearchSubtitlesInternal(SearchSubtitlesRequest request)
        {
            var response = _proxy.SearchSubtitles(_token, new[] { request });

            VerifyResponseCode(response);

            var subtitles = new List <Subtitle>();

            var subtitlesInfo = response.data as object[];

            if (null != subtitlesInfo)
            {
                foreach (var infoObject in subtitlesInfo)
                {
                    var subInfo = SimpleObjectMapper.MapToObject <SearchSubtitlesInfo>((XmlRpcStruct)infoObject);
                    subtitles.Add(BuildSubtitleObject(subInfo));
                }
            }
            return(subtitles);
        }
示例#11
0
        public async Task <IEnumerable <UserComment> > GetComments(string idsubtitle)
        {
            var tcs = new TaskCompletionSource <IEnumerable <UserComment> >();
            await Task.Run(() =>
            {
                try
                {
                    var response = Proxy.GetComments(Token, new[] { idsubtitle });
                    VerifyResponseCode(response);

                    var comments       = new List <UserComment>();
                    var commentsStruct = response.data as XmlRpcStruct;
                    if (commentsStruct == null)
                    {
                        tcs.TrySetResult(comments);
                        return;
                    }

                    if (commentsStruct.ContainsKey("_" + idsubtitle))
                    {
                        var commentsList = commentsStruct["_" + idsubtitle] as object[];
                        if (commentsList != null)
                        {
                            foreach (XmlRpcStruct commentStruct in commentsList)
                            {
                                var comment = SimpleObjectMapper.MapToObject <CommentsData>(commentStruct);
                                comments.Add(BuildUserCommentObject(comment));
                            }
                        }
                    }

                    tcs.TrySetResult(comments);
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);
                }
            }).ConfigureAwait(false);

            return(await tcs.Task.ConfigureAwait(false));
        }
示例#12
0
        public IEnumerable <MovieInfo> CheckMovieHash(string moviehash)
        {
            var response = proxy.CheckMovieHash(token, new string[] { moviehash });

            VerifyResponseCode(response);

            var movieInfoList = new List <MovieInfo>();

            var hashInfo = response.data as XmlRpcStruct;

            if (null != hashInfo && hashInfo.ContainsKey(moviehash))
            {
                var movieInfoArray = hashInfo[moviehash] as object[];
                foreach (XmlRpcStruct movieInfoStruct in movieInfoArray)
                {
                    var movieInfo = SimpleObjectMapper.MapToObject <CheckMovieHashInfo>(movieInfoStruct);
                    movieInfoList.Add(BuildMovieInfoObject(movieInfo));
                }
            }

            return(movieInfoList);
        }
示例#13
0
        public void UpdateSystemUser(SystemUserDataInfo userInfo)
        {
            if (string.IsNullOrEmpty(userInfo.UserName))
            {
                throw new MissingDomainObjectException("用户名不能为空");
            }
            SystemUser existUserByUserName = db.SystemUser.FirstOrDefault(n => !n.IsDelete && n.UserName == userInfo.UserName && n.ID != userInfo.ID);

            if (existUserByUserName != null)
            {
                throw new DuplicatedDomainObjectException(string.Format("【{0}】用户名已存在,修改失败", existUserByUserName.UserName));
            }
            SystemUser         existUser    = db.SystemUser.Find(userInfo.ID);
            SystemUserDataInfo userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);
            string             oldData      = Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo);

            if (existUser == null)
            {
                throw new DuplicatedDomainObjectException(string.Format("【{0}】用户不存在", existUser.UserName));
            }
            if (existUser != null)
            {
                existUser.DisplayName = userInfo.DisplayName;
                existUser.UserName    = userInfo.UserName;
                if (!string.IsNullOrEmpty(userInfo.Password))
                {
                    existUser.Password = userInfo.Password;
                }
                db.SaveChanges();
                userDataInfo = SimpleObjectMapper.CreateTargetObject <SystemUser, SystemUserDataInfo>(existUser);
                AddSystemLog(new SystemLogDataInfo()
                {
                    ModulePage     = "SystemUser",
                    Remark         = string.Format("修改了用户,原数据为:{0} 修改后数据为:{1}", oldData, Newtonsoft.Json.JsonConvert.SerializeObject(userDataInfo)),
                    CreationDate   = DateTime.Now,
                    CreationUserID = CurrentAdminUserId,
                });
            }
        }
示例#14
0
        public List <UserDataInfo> GetUserDataInfos(string searchText, int pageSize, int pageIndex, out int recordCount)
        {
            List <User> users = null;

            if (string.IsNullOrEmpty(searchText))
            {
                users       = db.User.ToList();
                recordCount = db.User.Count();
            }
            else
            {
                users       = db.User.Where(n => n.DisplayName.Contains(searchText) || n.UserName.Contains(searchText)).ToList();
                recordCount = db.User.Where(n => n.DisplayName.Contains(searchText) || n.UserName.Contains(searchText)).Count();
            }
            users = users.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            List <UserDataInfo> userDataInfos = SimpleObjectMapper.ListMap <User, UserDataInfo>(users).ToList();

            foreach (var item in userDataInfos)
            {
            }
            return(userDataInfos);
        }
示例#15
0
        protected static MovieDetails BuildMovieDetailsObject(IMDBMovieDetails info)
        {
            var movie = new MovieDetails {
                Aka       = info.aka,
                Cast      = SimpleObjectMapper.MapToDictionary(info.cast as XmlRpcStruct),
                Cover     = info.cover,
                Id        = info.id,
                Rating    = info.rating,
                Title     = info.title,
                Votes     = info.votes,
                Year      = info.year,
                Country   = info.country,
                Directors = SimpleObjectMapper.MapToDictionary(info.directors as XmlRpcStruct),
                Duration  = info.duration,
                Genres    = info.genres,
                Language  = info.language,
                Tagline   = info.tagline,
                Trivia    = info.trivia,
                Writers   = SimpleObjectMapper.MapToDictionary(info.writers as XmlRpcStruct)
            };

            return(movie);
        }
示例#16
0
        public List <SystemLogDataInfo> GetSystemLogDataInfos(string searchText, int userID, int pageSize, int pageIndex, out int recordCount)
        {
            recordCount = 0;
            List <SystemLog> logs = null;

            if (string.IsNullOrEmpty(searchText) && userID == 0)
            {
                logs        = db.SystemLog.OrderByDescending(n => n.ID).ToList();
                recordCount = db.SystemLog.Count();
            }
            else
            {
                if (!string.IsNullOrEmpty(searchText))
                {
                    logs        = db.SystemLog.Where(n => n.ModulePage.Contains(searchText) || n.Remark.Contains(searchText)).OrderByDescending(n => n.ID).ToList();
                    recordCount = db.SystemLog.Where(n => n.ModulePage.Contains(searchText) || n.Remark.Contains(searchText)).Count();
                }
                if (userID != 0)
                {
                    logs        = db.SystemLog.Where(n => n.CreationUserID == userID).OrderByDescending(n => n.ID).ToList();
                    recordCount = db.SystemLog.Where(n => n.CreationUserID == userID).Count();
                }
            }
            logs = logs.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            List <SystemLogDataInfo> logDataInfos = SimpleObjectMapper.ListMap <SystemLog, SystemLogDataInfo>(logs).ToList();

            foreach (var item in logDataInfos)
            {
                SystemUser user = logs.FirstOrDefault(n => n.ID == item.ID).SystemUser;
                if (user != null)
                {
                    item.UserDisplayName = user.DisplayName;
                }
                item.Remark = item.UserDisplayName + item.Remark;
            }
            return(logDataInfos);
        }
示例#17
0
        public async Task <IEnumerable <MovieInfo> > CheckMovieHash(string moviehash)
        {
            var tcs = new TaskCompletionSource <IEnumerable <MovieInfo> >();
            await Task.Run(() =>
            {
                try
                {
                    var response = Proxy.CheckMovieHash(Token, new[] { moviehash });
                    VerifyResponseCode(response);

                    var movieInfoList = new List <MovieInfo>();

                    var hashInfo = response.data as XmlRpcStruct;
                    if (hashInfo != null && hashInfo.ContainsKey(moviehash))
                    {
                        var movieInfoArray = hashInfo[moviehash] as object[];
                        if (movieInfoArray != null)
                        {
                            foreach (XmlRpcStruct movieInfoStruct in movieInfoArray)
                            {
                                var movieInfo = SimpleObjectMapper.MapToObject <CheckMovieHashInfo>(movieInfoStruct);
                                movieInfoList.Add(BuildMovieInfoObject(movieInfo));
                            }
                        }
                    }

                    tcs.TrySetResult(movieInfoList);
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);
                }
            }).ConfigureAwait(false);

            return(await tcs.Task.ConfigureAwait(false));
        }
示例#18
0
 public AutomobileDbModelToClientDto()
 {
     simpleMapper = new SimpleObjectMapper <S, T>();
 }