Exemplo n.º 1
0
        public IHttpActionResult Get()
        {
            EmotionService emotionService = CreateEmotionService();
            var            emotions       = emotionService.GetEmotions();

            return(Ok(emotions));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 手机端帖子正文解析器
        /// </summary>
        /// <param name="body"></param>
        /// <param name="tenantTypeId"></param>
        /// <param name="associateId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string ProcessForMobile(string body, string tenantTypeId, long associateId, long userId)
        {
            //解析at用户
            AtUserService atUserService = new AtUserService(tenantTypeId);

            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            AttachmentService        attachmentService = new AttachmentService(tenantTypeId);
            IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(associateId);

            if (attachments != null && attachments.Count() > 0)
            {
                IList <BBTag> bbTags       = new List <BBTag>();
                string        htmlTemplate = "<a href=\"{1}\" target=\"_blank\" menu=\"#attachement-artdialog-{2}\">{0}</a>";

                //解析文本中附件
                IEnumerable <Attachment> attachmentsFiles = attachments.Where(n => n.MediaType != MediaType.Image);
                foreach (var attachment in attachmentsFiles)
                {
                    bbTags.Add(AddBBTagForMobile(htmlTemplate, attachment));
                }

                body = HtmlUtility.BBCodeToHtml(body, bbTags);
            }

            body = new EmotionService().EmoticonTransforms(body);
            body = DIContainer.Resolve <ParsedMediaService>().ResolveBodyForHtmlDetail(body, ParsedMediaTagGenerateForMobile);

            return(body);
        }
Exemplo n.º 3
0
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            //解析at用户
            AtUserService atUserService = new AtUserService(TenantTypeIds.Instance().BlogThread());

            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            AttachmentService        attachmentService = new AttachmentService(tenantTypeId);
            IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(associateId);

            if (attachments != null && attachments.Count() > 0)
            {
                IList <BBTag> bbTags       = new List <BBTag>();
                string        htmlTemplate = "<div class=\"tn-annexinlaid\"><a href=\"javascript:;\" target=\"_blank\" menu=\"#attachement-artdialog-{4}\">{0}</a>(<em>{1}</em>{2},<em>下载次数:{3}</em>)</div>";

                //解析文本中附件
                IEnumerable <Attachment> attachmentsFiles = attachments.Where(n => n.MediaType != MediaType.Image);
                foreach (var attachment in attachmentsFiles)
                {
                    bbTags.Add(AddBBTag(htmlTemplate, attachment));
                }

                body = HtmlUtility.BBCodeToHtml(body, bbTags);
            }

            body = new EmotionService().EmoticonTransforms(body);
            body = DIContainer.Resolve <ParsedMediaService>().ResolveBodyForHtmlDetail(body, ParsedMediaTagGenerate);

            return(body);
        }
        /// <summary>
        /// 内容处理
        /// </summary>
        /// <param name="body">待处理内容</param>
        /// <param name="associateId">待处理相关项Id</param>
        /// <param name="userId">相关项作者</param>
        /// <param name="ownerId">拥有者Id</param>
        /// <returns></returns>
        public string Process(string body, string ownerTenantTypeId, long associateId, long userId, long ownerId)
        {
            string        tenantTypeId  = TenantTypeIds.Instance().Microblog();
            AtUserService atUserService = new AtUserService(tenantTypeId);

            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            TagService tagService = new TagService(tenantTypeId);

            Func <KeyValuePair <string, long>, long, string> topicTagGenerate = delegate(KeyValuePair <string, long> _tagNameWithId, long _ownerId)
            {
                return(string.Format("<a href=\"{1}\">#{0}#</a>", _tagNameWithId.Key, MicroblogUrlGetterFactory.Get(ownerTenantTypeId).TopicDetail(_tagNameWithId.Key.Trim(), _ownerId)));
            };

            body = tagService.ResolveBodyForDetail(body, associateId, ownerId, topicTagGenerate);

            body = body.Replace("\n", "<br/>");

            EmotionService emotionService = DIContainer.Resolve <EmotionService>();

            body = emotionService.EmoticonTransforms(body);

            ParsedMediaService parsedMediaService = DIContainer.Resolve <ParsedMediaService>();

            body = parsedMediaService.ResolveBodyForDetail(body, associateId, userId, UrlTagGenerate);

            return(body);
        }
        private async void ButtonAnalyze_ClickedAsync(object sender, EventArgs e)
        {
            // Don't Working
            var level = await EmotionService.GetAverageHappinessScoreAsync(this.speaker.Avatar);

            await DisplayAlert("Happiness Level", EmotionService.GetHappinessMessage(level), "OK");
        }
        public async Task <string> AnalyzeImageAsync(string imageUrl)
        {
            var result = string.Empty;

            try
            {
                using (var client = new HttpClient())
                {
                    var stream = await client.GetStreamAsync(imageUrl);

                    var emotion = await EmotionService.GetAverageHappinessScoreAsync(stream);

                    result = EmotionService.GetHappinessMessage(emotion);
                }
            }
            catch (Exception ex)
            {
                result = "Unable to analyze image";
            }

            //await UserDialogs.Instance.AlertAsync(result);

            //Return the percentage
            return(result);
        }
Exemplo n.º 7
0
 public InitialEmotionRatingTemplate()
 {
     this.InitializeComponent();
     emotionNameSuggestions   = EmotionService.GetEmotionNameSuggestions();
     this.DataContextChanged += (s, e) => Bindings.Update();
     this.Loaded             += InitialEmotionRatingTemplate_Loaded;
 }
Exemplo n.º 8
0
        public IHttpActionResult Get(int id)
        {
            EmotionService emotionService = CreateEmotionService();
            var            emotion        = emotionService.GetEmotionById(id);

            return(Ok(emotion));
        }
Exemplo n.º 9
0
        private EmotionService CreateEmotionService()
        {
            var emotionId   = Guid.Parse(User.Identity.GetUserId());
            var noteService = new EmotionService(emotionId);

            return(noteService);
        }
Exemplo n.º 10
0
        protected BaseController()
        {
            this.FaceServiceClient = new FaceServiceClient(Config.FaceServiceClientKey, Config.FaceServiceApiRoot);

            this.EmotionService = new EmotionService();
            this.FaceService    = new FaceService(this.FaceServiceClient);
            this.SlackService   = new SlackService();
        }
Exemplo n.º 11
0
        private async Task TakePhotoClick()
        {
            if (!this.captureInProgress)
            {
                this.captureInProgress = true;

                var photoBytes = await this.cameraView.TakePicture();

                this.infoTitleText.Text       = RatingMsgHelper.GetRecognizingRatingTitle();
                this.infoDescriptionText.Text = RatingMsgHelper.GetRecognizingRatingDescription();

                this.stars.Visibility               = ViewStates.Visible;
                this.overlay.Visibility             = ViewStates.Visible;
                this.takePhotoImage.Visibility      = ViewStates.Invisible;
                this.smilePattern.Visibility        = ViewStates.Invisible;
                this.infoDescriptionText.Visibility = ViewStates.Visible;

                using (var memoryStream = new MemoryStream(photoBytes))
                {
                    var emotionService   = new EmotionService();
                    var firstFaceEmotion = default(Emotion);

                    try
                    {
                        var emotionList = await emotionService.RecognizeAsync(memoryStream);

                        firstFaceEmotion = emotionList.FirstOrDefault();
                    }
                    catch
                    {
                        await UserDialogs.Instance.AlertAsync("There was an error analyzing your photo. Please, try again.");
                    }

                    if (firstFaceEmotion != null)
                    {
                        var happiness = firstFaceEmotion.Scores.Happiness;

                        var textDescriptions = emotionService.GetTextsFor(happiness);

                        this.infoTitleText.Text       = textDescriptions.Top;
                        this.infoDescriptionText.Text = textDescriptions.Message;

                        RunStarAnimation(happiness);
                    }
                    else
                    {
                        this.infoTitleText.Text       = RatingMsgHelper.GetNoFaceDetectedTitle();
                        this.infoDescriptionText.Text = RatingMsgHelper.GetNoFaceDetectedMsg();
                    }

                    this.postButtons.Visibility = ViewStates.Visible;
                    this.overlay.Visibility     = ViewStates.Invisible;
                }

                this.captureInProgress = false;
            }
        }
Exemplo n.º 12
0
        async void ComputeImage(object sender, System.EventArgs e)
        {
            if (_file == null)
            {
                return;
            }

            var result = await EmotionService.GetAverageEmotionAsync(_file.GetStream());

            await DisplayAlert("Message", result, "Ok");
        }
Exemplo n.º 13
0
 private async void ButtonAnalyze_Clicked(object sender, EventArgs e)
 {
     try
     {
         var level = await EmotionService.GetAverageHappinessScoreAsync(this.speaker.Avatar);
         await DisplayAlert("Happiness Level", EmotionService.GetHappinessMessage(level), "OK");
     }
     catch (Exception ex)
     {
         await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK");
     }
 }
Exemplo n.º 14
0
        public async Task TakePhoto()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                Message = ":(No camera avaialble.";
                IsBusy  = false;
                return;
            }
            try
            {
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory   = "Sample",
                    Name        = "EmotionCheckPic.jpg",
                    SaveToAlbum = true
                });

                if (file == null)
                {
                    return;
                }

                SelectedImage = ImageSource.FromStream(() =>
                {
                    return(file.GetStream());
                });
                selectedPicStream = file.GetStream();
                var emotion = await EmotionService.GetAverageHappinessScoreAsync(selectedPicStream);

                Message = EmotionService.GetHappinessMessage(emotion);
                file.Dispose();
            }
            catch (Exception ex)
            {
                Message = "Uh oh :( Something went wrong \n " + ex.Message;
                IsBusy  = false;
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 内容处理
        /// </summary>
        /// <param name="body">待处理内容</param>
        /// <param name="associateId">待处理相关项Id</param>
        /// <param name="userId">相关项作者</param>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <returns></returns>
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            tenantTypeId = TenantTypeIds.Instance().Comment();

            AtUserService atUserService = new AtUserService(tenantTypeId);

            atUserService.ResolveBodyForEdit(body, userId, associateId);
            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            EmotionService emotionService = DIContainer.Resolve <EmotionService>();

            body = emotionService.EmoticonTransforms(body);

            return(body);
        }
        public async Task <double> TakePhotoAndAnalyzeAsync(bool useCamera = true)
        {
            string          result  = "Error";
            double          emotion = 100.0;
            MediaFile       file    = null;
            IProgressDialog progress;

            try
            {
                await CrossMedia.Current.Initialize();

                if (useCamera)
                {
                    file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        Directory = "Sample",
                        Name      = "face.jpg",
                        PhotoSize = PhotoSize.Medium
                    });
                }
                else
                {
                    file = await CrossMedia.Current.PickPhotoAsync();
                }


                if (file == null)
                {
                    result = "No photo taken.";
                }
                else
                {
                    emotion = await EmotionService.GetAverageHappinessScoreAsync(file.GetStream());

                    result = EmotionService.GetHappinessMessage((float)emotion);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            //await UserDialogs.Instance.AlertAsync(result);

            emotion = emotion * 100;
            emotion = Math.Round(emotion, 2);
            return(emotion);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Calculates the stories.
        /// </summary>
        /// <returns></returns>
        public async Task <string> updateHappiness()
        {
            try
            {
                var error = await EmotionProcessingLogic.Instance.TakePicture();

                var byteRA = ReadFully(EmotionProcessingLogic.Instance.MediaFile.GetStream());
                _emotions = await EmotionService.getEmotion(byteRA);

                return(null);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
        private async Task ProcessPhoto(MediaFile file)
        {
            if (file == null)
            {
                return;
            }

            using (file)
            {
                SelectedImage = ImageSource.FromStream(() => file.GetStream());
                var selectedPicStream = file.GetStream();
                Emotion = await EmotionService.GetAverageHappinessScoreAsync(selectedPicStream);

                Message = EmotionService.GetHappinessMessage(Emotion);
            }
        }
Exemplo n.º 19
0
        public async Task TakePhotoAndAnalyzeAsync(bool useCamera = true)
        {
            string    result = "Error";
            MediaFile file   = null;

            try
            {
                await CrossMedia.Current.Initialize();


                if (useCamera)
                {
                    file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        Directory   = "Samples",
                        Name        = "test.jpg",
                        SaveToAlbum = true
                    });
                }
                else
                {
                    file = await CrossMedia.Current.PickPhotoAsync();
                }


                if (file == null)
                {
                    result = "No photo taken.";
                }
                else
                {
                    var emotion = await EmotionService.GetAverageHappinessScoreAsync(file.GetStream());

                    result = EmotionService.GetHappinessMessage(emotion);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            await UserDialogs.Instance.AlertAsync(result, "Emotion", "OK");
        }
Exemplo n.º 20
0
        /// <summary>
        /// 사진 찍기 요청
        /// </summary>
        /// <param name="useCamera"></param>
        /// <returns></returns>
        public async Task TakePhotoAndAnalyzeAsync(bool useCamera = true)
        {
            string          result = "Error";
            MediaFile       file   = null;
            IProgressDialog progress;

            try
            {
                // CrossMedia 플러그인을 사용하여 사진찍기
                await CrossMedia.Current.Initialize();

                if (useCamera)
                {
                    file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        Directory = "Sample",
                        Name      = "face.jpg",
                        PhotoSize = PhotoSize.Medium
                    });
                }
                else
                {
                    file = await CrossMedia.Current.PickPhotoAsync();
                }

                if (file == null)
                {
                    result = "No photo taken.";
                }
                else
                {
                    var emotion = await EmotionService.GetAverageHappinessScoreAsync(file.GetStream());

                    result = EmotionService.GetHappinessMessage(emotion);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            await UserDialogs.Instance.AlertAsync(result);
        }
Exemplo n.º 21
0
        public async Task AnalyzeImageAsync(string imageUrl)
        {
            var result = string.Empty;

            try
            {
                using (var client = new HttpClient())
                {
                    var stream = await client.GetStreamAsync(imageUrl);

                    var emotion = await EmotionService.GetAverageHappinessScoreAsync(stream);

                    result = EmotionService.GetHappinessMessage(emotion);
                }
            }
            catch (Exception ex)
            {
                result = "Unable to analyze image";
            }
        }
Exemplo n.º 22
0
        public async Task SelectPhoto()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                Message = "Permission not granted to photos.";
                IsBusy  = false;
                return;
            }
            try
            {
                var file = await CrossMedia.Current.PickPhotoAsync().ConfigureAwait(true);


                if (file == null)
                {
                    return;
                }
                SelectedImage     = ImageSource.FromStream(() => file.GetStream());
                selectedPicStream = file.GetStream();
                var emotion = await EmotionService.GetAverageHappinessScoreAsync(selectedPicStream);

                Message = EmotionService.GetHappinessMessage(emotion);
                file.Dispose();
            }
            catch (Exception ex)
            {
                Message = "Uh oh :( Something went wrong \n" + ex.Message;
                IsBusy  = false;
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Emotion";

            askForHelp.Hidden = true;

            personPhoto.Image           = null;
            personPhoto.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 70);
            personPhoto.ContentMode     = UIViewContentMode.ScaleAspectFit;

            emotionService = new EmotionService();
            photoService   = new PhotoService();

            CreateActionPrompts();

            takePhoto.TouchUpInside += (sender, e) =>
            {
                askForHelp.Hidden = true;
                PresentViewController(photoPrompt, true, null);
            };
        }
Exemplo n.º 24
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            this.capturedImage.Source = null;

            VisualStateManager.GoToState(this, ProcessingState.Name, true);

            this.processedControl.Blink();

            var photoStream = await this.mediaCaptureHelper.TakePhotoAsync();

            photoStream = await this.mediaCaptureHelper.RotatePhoto(photoStream);

            await this.SetCapturedImage(photoStream);

            var emotionService = new EmotionService();

            var detectedEmotions = await emotionService.RecognizeAsync(photoStream.AsStream());

            Emotion emotion = detectedEmotions.FirstOrDefault();

            if (emotion != null)
            {
                var texts = emotionService.GetTextsFor(emotion.Scores.Happiness);
                this.TextState.Text             = texts.Top;
                this.processedControl.Happiness = emotion.Scores.Happiness;
                this.processedControl.Text      = texts.Message;
                VisualStateManager.GoToState(this, RateState.Name, true);
            }
            else
            {
                await Dialog.AlertAsync("No face detected. Please, try again.");

                Dialog.HideLoading();
                VisualStateManager.GoToState(this, CaptureState.Name, true);
            }
        }
        public async Task <string> GetEmotion()
        {
            if (IsBusy)
            {
                return(null);
            }

            Exception error = null;

            try
            {
                IsBusy = true;

                IEmotionService emotionService = new EmotionService();

                var score = await emotionService.GetAverageHappinessScoreAsync(SelectedEmployee.Avatar);

                return(emotionService.GetHappinessMessage(score));
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK");
            }

            return(null);
        }
Exemplo n.º 26
0
        private static void RunServer()
        {
            Data.Data.DataPath = "data/";

            Stopwatch sw = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            Console.WriteLine("----===== Tera-Project C# GameServer Emulator =====----\n\n");
            Console.WriteLine("Starting Game Server!\n"
                              + "-------------------------------------------");

            TcpServer = new TcpServer("*", Config.GetServerPort(), Config.GetServerMaxCon());
            Connection.SendAllThread.Start();

            OpCodes.Init();
            Console.WriteLine("OpCodes - Revision 1725 initialized!\n"
                              + "-------------------------------------------\n");

            #region global_components

            //services
            FeedbackService    = new FeedbackService();
            AccountService     = new AccountService();
            PlayerService      = new PlayerService();
            MapService         = new MapService();
            ChatService        = new ChatService();
            VisibleService     = new VisibleService();
            ControllerService  = new ControllerService();
            CraftService       = new CraftService();
            ItemService        = new ItemService();
            AiService          = new AiService();
            GeoService         = new GeoService();
            StatsService       = new StatsService();
            ObserverService    = new ObserverService();
            AreaService        = new AreaService();
            InformerService    = new InformerService();
            TeleportService    = new TeleportService();
            PartyService       = new PartyService();
            SkillsLearnService = new SkillsLearnService();
            CraftLearnService  = new CraftLearnService();
            GuildService       = new GuildService();
            EmotionService     = new EmotionService();
            RelationService    = new RelationService();
            DuelService        = new DuelService();
            StorageService     = new StorageService();
            TradeService       = new TradeService();
            MountService       = new MountService();

            //engines
            ActionEngine = new ActionEngine.ActionEngine();
            AdminEngine  = new AdminEngine.AdminEngine();
            SkillEngine  = new SkillEngine.SkillEngine();
            QuestEngine  = new QuestEngine.QuestEngine();

            #endregion

            GlobalLogic.ServerStart("SERVER=" + Config.GetDatabaseHost() + ";DATABASE=" + Config.GetDatabaseName() + ";UID=" + Config.GetDatabaseUser() + ";PASSWORD="******";PORT=" + Config.GetDatabasePort() + ";charset=utf8");

            Console.WriteLine("-------------------------------------------\n"
                              + "Loading Tcp Service.\n"
                              + "-------------------------------------------");
            TcpServer.BeginListening();

            try
            {
                ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232));
                ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService);
                ServiceApplication.Start();
                Log.Info("InformerService started at *:23232.");

                var webservices = new ServiceManager();
                webservices.Run();
            }
            catch (Exception ex)
            {
                Log.ErrorException("InformerService can not be started.", ex);
            }

            sw.Stop();
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine("           Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s"));
            Console.WriteLine("-------------------------------------------");
        }
Exemplo n.º 27
0
        private static void RunServer()
        {
            //Start ServerStartTime
            Stopwatch serverStartStopwatch = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            //CheckServerMode
            CheckServerMode();

            //ConsoleOutput-Infos
            PrintServerLicence();
            PrintServerInfo();

            //Initialize TcpServer
            TcpServer = new TcpServer("*", Configuration.Network.GetServerPort(), Configuration.Network.GetServerMaxCon());
            Connection.SendAllThread.Start();

            //Initialize Server OpCodes
            OpCodes.Init();
            Console.WriteLine("----------------------------------------------------------------------------\n"
                              + "---===== OpCodes - Revision: " + OpCodes.Version + " EU initialized!");

            //Global Services
            #region global_components
            //Services
            FeedbackService    = new FeedbackService();
            AccountService     = new AccountService();
            PlayerService      = new PlayerService();
            MapService         = new MapService();
            ChatService        = new ChatService();
            VisibleService     = new VisibleService();
            ControllerService  = new ControllerService();
            CraftService       = new CraftService();
            ItemService        = new ItemService();
            AiService          = new AiService();
            GeoService         = new GeoService();
            StatsService       = new StatsService();
            ObserverService    = new ObserverService();
            AreaService        = new AreaService();
            TeleportService    = new TeleportService();
            PartyService       = new PartyService();
            SkillsLearnService = new SkillsLearnService();
            CraftLearnService  = new CraftLearnService();
            GuildService       = new GuildService();
            EmotionService     = new EmotionService();
            RelationService    = new RelationService();
            DuelService        = new DuelService();
            StorageService     = new StorageService();
            TradeService       = new TradeService();
            MountService       = new MountService();

            //Engines
            ActionEngine = new ActionEngine.ActionEngine();
            AdminEngine  = new AdminEngine.AdminEngine();
            SkillEngine  = new SkillEngine.SkillEngine();
            QuestEngine  = new QuestEngine.QuestEngine();
            #endregion

            //Set SqlDatabase Connection
            GlobalLogic.ServerStart("SERVER=" + DAOManager.MySql_Host + ";DATABASE=" + DAOManager.MySql_Database + ";UID=" + DAOManager.MySql_User + ";PASSWORD="******";PORT=" + DAOManager.MySql_Port + ";charset=utf8");
            Console.ForegroundColor = ConsoleColor.Gray;

            //Start Tcp-Server Listening
            Console.WriteLine("----------------------------------------------------------------------------\n"
                              + "---===== Loading GameServer Service.\n"
                              + "----------------------------------------------------------------------------");
            TcpServer.BeginListening();

            //Stop ServerStartTime
            serverStartStopwatch.Stop();
            Console.WriteLine("----------------------------------------------------------------------------");
            Console.WriteLine("---===== GameServer start in {0}", (serverStartStopwatch.ElapsedMilliseconds / 1000.0).ToString("0.00s"));
            Console.WriteLine("----------------------------------------------------------------------------");
        }
Exemplo n.º 28
0
 public RatingProcessingViewController(IntPtr handle) : base(handle)
 {
     emotionClient = new EmotionService();
 }
Exemplo n.º 29
0
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            //if (string.IsNullOrEmpty(body) || !body.Contains("[attach:"))
            //    return body;

            //List<long> attachmentIds = new List<long>();

            //Regex rg = new Regex(@"\[attach:(?<id>[\d]+)\]", RegexOptions.Multiline | RegexOptions.Singleline);
            //MatchCollection matches = rg.Matches(body);

            //if (matches != null)
            //{
            //    foreach (Match m in matches)
            //    {
            //        if (m.Groups["id"] == null || string.IsNullOrEmpty(m.Groups["id"].Value))
            //            continue;
            //        long attachmentId = 0;
            //        long.TryParse(m.Groups["id"].Value, out attachmentId);
            //        if (attachmentId > 0 && !attachmentIds.Contains(attachmentId))
            //            attachmentIds.Add(attachmentId);
            //    }
            //}

            //IEnumerable<ContentAttachment> attachments = new ContentAttachmentService().Gets(attachmentIds);

            //if (attachments != null && attachments.Count() > 0)
            //{
            //    IList<BBTag> bbTags = new List<BBTag>();
            //    string htmlTemplate = "<div class=\"tn-annexinlaid\"><a href=\"{3}\" rel=\"nofollow\">{0}</a>(<em>{1}</em>,<em>下载次数:{2}</em>)<a href=\"{3}\" rel=\"nofollow\">下载</a> </div>";

            //    //解析文本中附件
            //    foreach (var attachment in attachments)
            //    {
            //        bbTags.Add(AddBBTag(htmlTemplate, attachment));
            //    }

            //    body = HtmlUtility.BBCodeToHtml(body, bbTags);
            //}

            //解析at用户
            AtUserService atUserService = new AtUserService(tenantTypeId);

            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            AttachmentService        attachmentService = new AttachmentService(tenantTypeId);
            IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(associateId);

            if (attachments != null && attachments.Count() > 0)
            {
                IList <BBTag> bbTags       = new List <BBTag>();
                string        htmlTemplate = "<div class=\"tn-annexinlaid\"><a href=\"{3}\" rel=\"nofollow\">{0}</a>(<em>{1}</em>,<em>下载次数:{2}</em>)<a href=\"{3}\" rel=\"nofollow\">下载</a> </div>";

                //解析文本中附件
                IEnumerable <Attachment> attachmentsFiles = attachments.Where(n => n.MediaType != MediaType.Image);
                foreach (var attachment in attachmentsFiles)
                {
                    bbTags.Add(AddBBTag(htmlTemplate, attachment));
                }

                body = HtmlUtility.BBCodeToHtml(body, bbTags);
            }

            body = new EmotionService().EmoticonTransforms(body);
            body = DIContainer.Resolve <ParsedMediaService>().ResolveBodyForHtmlDetail(body, ParsedMediaTagGenerate);



            return(body);
        }
Exemplo n.º 30
0
        public ActionResult EditPost(long threadId, long?postId)
        {
            BarThread thread = barThreadService.Get(threadId);

            if (thread == null)
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = "没有找到你要编辑的回帖",
                    Title = "没有找到回帖",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }
            pageResourceManager.InsertTitlePart(thread.BarSection.Name);

            BarPost post = null;

            if (postId.HasValue && postId.Value > 0)
            {
                post = barPostService.Get(postId ?? 0);
                if (!authorizer.BarPost_Edit(post))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = "您没有权限编辑此回帖",
                        Title = "没有权限"
                    })));
                }
                if (post == null)
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = "没有找到你要编辑的回帖",
                        Title = "没有找到回帖"
                    })));
                }
                pageResourceManager.InsertTitlePart("编辑回帖");
            }
            else
            {
                string errorMessage = string.Empty;
                if (!authorizer.BarPost_Create(thread.SectionId, out errorMessage))
                {
                    if (UserContext.CurrentUser == null)
                    {
                        return(Redirect(SiteUrls.Instance().Login(true)));
                    }

                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = errorMessage,
                        Title = "没有权限"
                    })));
                }
                pageResourceManager.InsertTitlePart("发表回帖");
            }

            BarPostEditModel postModel = null;

            if (post != null)
            {
                postModel = post.AsEditModel();
            }
            else
            {
                postModel = new BarPostEditModel
                {
                    ThreadId = threadId,
                    PostId   = postId,
                    Subject  = thread.Subject
                };
                string body = Request.QueryString.Get <string>("MultilineBody", null);
                if (!string.IsNullOrEmpty(body))
                {
                    postModel.Body = body = new EmotionService().EmoticonTransforms(body);
                }
            }
            ViewData["PostBodyMaxLength"] = barSettings.PostBodyMaxLength;

            postModel.SectionId = thread.SectionId;
            return(View(postModel));
        }