Ejemplo n.º 1
0
 public ImagePoller(TelegramClient telegramClient, PSNService psnService, AccountService accounts, TimeStampService timestampService, long chatId)
 {
     _chatId           = chatId;
     _telegramClient   = telegramClient;
     _psnService       = psnService;
     _accounts         = accounts;
     _timestampService = timestampService;
 }
Ejemplo n.º 2
0
        public static AddNewsOutDTO AddNews(AddNewsInDTO inDto)
        {
            AddNewsOutDTO outDto = new AddNewsOutDTO();

            try
            {
                if (inDto == null || string.IsNullOrEmpty(inDto.Title))
                {
                    outDto.ErrorMsg = "参数错误";
                    return(outDto);
                }

                if (inDto.Title.Length > 50)
                {
                    outDto.ErrorMsg = "标题长度错误";
                    return(outDto);
                }
                //如果直接new也是可以的,目前是等效的,建议统一使用CreateObject,未来可以利用CreateObject搞一些事情
                //News news = new News();
                News news = PersisterService.CreateObject <News>();
                news.SetId(TimeStampService.GetOneId <News>());

                news.Title   = inDto.Title;
                news.Context = inDto.Context;
                news.Author  = inDto.Author;
                news.Type    = inDto.Type;

                string    remark    = "增加新闻";
                SystemLog systemLog = LogService.CreateSystemLog(SystemLogType.AddNews, typeof(News), news.Id, remark);

                PersisterService.SaveObject(new SRO[] { news, systemLog });
                outDto.IsSucceed = true;
                outDto.Id        = news.Id;
            }
            catch (Exception ex)
            {
                outDto.ErrorMsg = ex.Message;
                LogProxy.Error(ex, false);
            }

            return(outDto);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;

            var client = new PSNService();
            var task   = client.Login("*****@*****.**", "");

            task.Wait();

            if (!task.Result)
            {
                Console.WriteLine("Failed to login");
                return;
            }

            var telegramClient = new Telegram.TelegramClient("");
            var database       = new DatabaseService("../../../psnbot.sqlite");

            var accounts         = new AccountService(database);
            var timestampService = new TimeStampService(database);

            var registrationProcess = new RegistrationProcess(telegramClient, client, accounts);

            var chatId = -1001019649766;

            using (var poller = new MessagePoller(database, telegramClient, client, accounts, registrationProcess, chatId))
                using (var imagePoller = new ImagePoller(telegramClient, client, accounts, timestampService, chatId))
                    using (var trophyPoller = new TrophyPoller(telegramClient, client, accounts, timestampService, chatId))
                        using (var friendPoller = new FriendPoller(telegramClient, client, accounts, registrationProcess))
                        {
                            poller.Start();
                            imagePoller.Start();
                            //trophyPoller.Start();
                            friendPoller.Start();

                            var host = new WebHostBuilder()
                                       .UseKestrel()
                                       .UseStartup <Startup>()
                                       .Build();
                            host.Run();
                        }
        }
Ejemplo n.º 4
0
        public static AddUserOutDTO AddUser(AddUserInDTO inDto)
        {
            AddUserOutDTO outDto = new AddUserOutDTO();

            try
            {
                if (inDto == null || string.IsNullOrEmpty(inDto.Name))
                {
                    outDto.ErrorMsg = "参数错误";
                    return(outDto);
                }

                //如果直接new也是可以的,目前是等效的,建议统一使用CreateObject,未来可以利用CreateObject搞一些事情
                //User User = new User();
                User user = PersisterService.CreateObject <User>();
                user.SetId(TimeStampService.GetOneId <User>(inDto.Gender.ToString()));

                user.Name             = inDto.Name;
                user.Gender           = inDto.Gender;
                user.Mobile           = inDto.Mobile;
                user.AvailableBalance = inDto.AvailableBalance;

                string    remark    = "增加用户";
                SystemLog systemLog = LogService.CreateSystemLog(SystemLogType.AddUser, typeof(User), user.Id, remark);

                PersisterService.SaveObject(new SRO[] { user, systemLog });
                outDto.IsSucceed = true;
                outDto.Id        = user.Id;
            }
            catch (Exception ex)
            {
                outDto.ErrorMsg = ex.Message;
                LogProxy.Error(ex, false);
            }

            return(outDto);
        }
Ejemplo n.º 5
0
 static News()
 {
     TimeStampService.RegisterIdFormat <News>("xw{0:yyMMdd}{1}");
 }
Ejemplo n.º 6
0
Archivo: User.cs Proyecto: winal/Scree
 static User()
 {
     TimeStampService.RegisterIdFormat <User>("US{3}{0:yyyyMMdd}{4}{2}");
 }