Пример #1
0
        static PostModels() 
        { 
            List<PostDataObject> posts1 = new List<PostDataObject>();
            DateTime datetimeOne = DateTime.Parse("2015-03-11");
            DateTime datetimeTwo = DateTime.Parse("2015-03-12");

            var p1 = new PostDataObject() { Id = 1000, Content = "LALALALALALA" };
            p1.Author.Name = "SB";
            p1.CreationDateTime = datetimeOne;

            var p2 = new PostDataObject() { Id = 1001, Content = "XXXXXXXXXXXX" };
            p2.Author.Name = "ZYL";
            p2.CreationDateTime = datetimeOne;
            posts1.AddRange(new PostDataObject[] { p1, p2 });

            List<PostDataObject> posts2 = new List<PostDataObject>();
            var p3= new PostDataObject() { Id = 1002, Content = "LOLOLOLOLOLO" };
            p3.Author.Name = "YSY";
            p3.CreationDateTime = datetimeTwo;

            var p4 = new PostDataObject() { Id = 1003, Content = "AIAIAIAIAIAIAI" };
            p4.Author.Name = "GQ";
            p3.CreationDateTime = datetimeTwo;

            posts2.AddRange(new PostDataObject[] { p3, p4 });

            postsByDate.Add(datetimeOne, posts1);
            postsByDate.Add(datetimeTwo, posts2);

            allPosts.AddRange(new PostDataObject[] { p1, p2, p3, p4 });
        }
Пример #2
0
        /// <summary>
        /// 这是最普通的DDD 应用层 (application service) 创建一个Post并保存到数据库中发布。
        /// 没有考虑用异步来保存数据库 或者 用 异步Domain Event handler 来保存Post到数据, 
        /// 用异步保存的同时 Post 的传输对象 PostDataObject返回 (加快速度,不需要等待数据库保存完成再返回)
        /// 也没有考虑将Post 送至 消息队列 由 另一个处理消息队列的系统来保存Post.
        /// </summary>
        private void PublishPostWithCommonSync(PostDataObject postDataObject)
        {
            //Topic topic = postDataObject.MapTo().Topic; //this.topicRepository.FindByKey(postDataObject.TopicId);

            //User author = postDataObject.MapTo().Author; //this.userRepository.FindByKey(postDataObject.AuthorId);

            Post post = postDataObject.MapTo();
            this.postRepository.Add(post);
            this.RepositoryContext.Commit();
        }
Пример #3
0
        public ActionResult CreatePost(PostDataObject post)
        {
            bool updated = this.TryUpdateModel<PostDataObject>(post);

            if (updated)
            {

            }

            return View("index");
        }
Пример #4
0
        public void PublishPost(PostDataObject post)
        {
            PostPublishCommand command = new PostPublishCommand();
          
            command.TopicId = post.Topic.Id;
            command.AuthorId = post.Author.Id;
            command.Content = post.Content;

            command.PostDataObject = post;

            this.ExecuteCommand(command);
        }
Пример #5
0
        /// <summary>
        /// 将 Post 送入 Rabbit 消息 队列,由另一个处理消息队列的系统来 进行Post的更新操作!
        /// </summary>
        private void PublishPostWithRabbitMessageQueue(PostDataObject postDataObject)
        {
            //Topic topic = postDataObject.MapTo().Topic; //this.topicRepository.FindByKey(postDataObject.TopicId);

            //User author = postDataObject.MapTo().Author; //this.userRepository.FindByKey(postDataObject.AuthorId);

            //Post post = Post.Create(topic, author, postDataObject.Content);

            Post post = postDataObject.MapTo();

            // 领域模型业务的真正实现,而不是一个 贫血的模型 是 一个充血的模型.
            post.Publish();
        }
Пример #6
0
        public ActionResult GetPostDetail(DateTime date, int id)
        {
            PostDataObject post;
            if (PostModel.PostsByDate.ContainsKey(date))
            {
                post = PostModel.PostsByDate[date].SingleOrDefault(p => p.Id == id);
            }
            else
            {
                post = new PostDataObject();
            }

            return View("Index", post);
        }
Пример #7
0
        public void Test_PublishPost()
        {
            IPostService postService = ServiceLocator.Instance.GetService<IPostService>();

            PostDataObject post = new PostDataObject();

            post.Content = "Add By Application Service";
            post.Topic.Id = 1000;
            post.Author.Id = 1000;
            post.InternalId = Guid.NewGuid();
            post.InternalStatus = "NEW";

            postService.PublishPost(post);
        }
Пример #8
0
        public void Test_PostRepository_FindAllOrderByWithoutPaging() 
        {
            PostQueryRequest request = new PostQueryRequest();
            request.TopicId = 1000;
            request.CreationDateTimeParam.CreationDateTimeOperator = Operator.LessThanEqual;
            request.CreationDateTimeParam.CreationDateTime = DateTimeUtils.ToDateTime("2015-1-22").Value;

            using (IRepositoryContext repositoryContext = ServiceLocator.Instance.GetService<IRepositoryContext>())
            {
                IRepository<Post> postRepository = repositoryContext.GetRepository<Post>();

                Expression<Func<Post, bool>> dateTimeExpression = (p) => true;

                //DateTime dt = request.CreationDateTimeParam.CreationDateTime;

                switch (request.CreationDateTimeParam.CreationDateTimeOperator)
                {
                    case Operator.LessThanEqual:
                        dateTimeExpression = p => p.CreationDateTime <= request.CreationDateTimeParam.CreationDateTime;
                        break;
                    case Operator.GreaterThanEqual:
                        dateTimeExpression = p => p.CreationDateTime >= request.CreationDateTimeParam.CreationDateTime;
                        break;
                    case Operator.Equal:
                        dateTimeExpression = p => p.CreationDateTime.Equals(request.CreationDateTimeParam.CreationDateTime);
                        break;
                }

                QueryBuilder<Post> postQueryBuilder = new QueryBuilder<Post>();

                //int topicId = request.TopicId;

                postQueryBuilder.And(p => p.TopicId == request.TopicId).And(dateTimeExpression);

                IEnumerable<Post> posts = postRepository.FindAll(postQueryBuilder.QueryPredicate);

                IList<PostDataObject> postDataObjects = new List<PostDataObject>();

                foreach (Post post in posts)
                {
                    var postDataObject = new PostDataObject();
                    postDataObject.MapFrom(post);

                    postDataObjects.Add(postDataObject);
                }

                Assert.AreEqual(5, postDataObjects.Count);
            }
        
        }
Пример #9
0
        static PostModel()
        {
            List<PostDataObject> posts1 = new List<PostDataObject>();
            var p1 = new PostDataObject() { Id = 1000, Content = "LALALALALALA" };
            p1.Author.Name = "SB";
            var p2 = new PostDataObject() { Id = 1001, Content = "XXXXXXXXXXXX" };
            p2.Author.Name = "ZYL";
            posts1.AddRange(new PostDataObject[] { p1, p2 });

            List<PostDataObject> posts2 = new List<PostDataObject>();
            var p3= new PostDataObject() { Id = 1002, Content = "LOLOLOLOLOLO" };
            p3.Author.Name = "YSY";
            var p4 = new PostDataObject() { Id = 1003, Content = "AIAIAIAIAIAIAI" };
            p4.Author.Name = "GQ";
            posts2.AddRange(new PostDataObject[] { p3, p4 });

            postsByDate.Add(DateTime.Parse("2015-03-11"), posts1);
            postsByDate.Add(DateTime.Parse("2015-03-12"), posts2);
        }
Пример #10
0
        /// <summary>
        /// 用 异步Domain Event handler 来保存Post到数据, 
        /// 用异步保存的同时 Post 的传输对象 PostDataObject返回 (加快速度,不需要等待数据库保存完成再返回)
        /// </summary>
        private void PublishPostWithAsyncDomainEventHandler(PostDataObject postDataObject)
        {
            //Topic topic = postDataObject.MapTo().Topic; //this.topicRepository.FindByKey(postDataObject.TopicId);

            //User author = postDataObject.MapTo().Author; //this.userRepository.FindByKey(postDataObject.AuthorId);

            //Post post = Post.Create(topic, author, postDataObject.Content);

            Post post = postDataObject.MapTo();

            //用 多线程 异步 并行 Domain Event Handler 来 保存
            DomainEventAggregator.Instance.Publish<PostDomainEvent>
                (
                    new PostDomainEvent(post)
                    {
                        Post = post
                    }
                );
        }
Пример #11
0
        /// <summary>
        /// 用 异步Domain Event handler 来保存Post到数据,
        /// 用异步保存的同时 Post 的传输对象 PostDataObject返回 (加快速度,不需要等待数据库保存完成再返回)
        /// </summary>
        private void PublishPostWithAsyncDomainEventHandler(PostDataObject postDataObject)
        {
            //Topic topic = postDataObject.MapTo().Topic; //this.topicRepository.FindByKey(postDataObject.TopicId);

            //User author = postDataObject.MapTo().Author; //this.userRepository.FindByKey(postDataObject.AuthorId);

            //Post post = Post.Create(topic, author, postDataObject.Content);

            Post post = postDataObject.MapTo();

            //用 多线程 异步 并行 Domain Event Handler 来 保存
            DomainEventAggregator.Instance.Publish <PostDomainEvent>
            (
                new PostDomainEvent(post)
            {
                Post = post
            }
            );
        }
Пример #12
0
        public IEnumerable <PostDataObject> GetPostsByQueryRequest(PostQueryRequest request)
        {
            using (IRepositoryContext repositoryContext = ServiceLocator.Instance.GetService <IRepositoryContext>())
            {
                IRepository <Post> postRepository = repositoryContext.GetRepository <Post>();

                Expression <Func <Post, bool> > dateTimeExpression = (p) => true;

                switch (request.CreationDateTimeParam.CreationDateTimeOperator)
                {
                case Operator.LessThanEqual:
                    dateTimeExpression = p => p.CreationDateTime <= request.CreationDateTimeParam.CreationDateTime;
                    break;

                case Operator.GreaterThanEqual:
                    dateTimeExpression = p => p.CreationDateTime >= request.CreationDateTimeParam.CreationDateTime;
                    break;

                case Operator.Equal:
                default:
                    dateTimeExpression = p => p.CreationDateTime.Equals(request.CreationDateTimeParam.CreationDateTime);
                    break;
                }

                QueryBuilder <Post> postQueryBuilder = new QueryBuilder <Post>();

                postQueryBuilder.And(p => p.TopicId == request.TopicId).And(dateTimeExpression);

                IEnumerable <Post> posts = postRepository.FindAll(postQueryBuilder.QueryPredicate);

                IList <PostDataObject> postDataObjects = new List <PostDataObject>();

                foreach (Post post in posts)
                {
                    var postDataObject = new PostDataObject();
                    postDataObject.MapFrom(post);

                    postDataObjects.Add(postDataObject);
                }

                return(postDataObjects);
            }
        }
        public void PrepareBlog(PostDataObject item)
        {
            if (!string.IsNullOrEmpty(item.Blog?.Title))
            {
                var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Blog?.Title, 60));
                item.Blog.Title = prepareTitle;
            }

            if (!string.IsNullOrEmpty(item.Blog?.Description))
            {
                var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Blog?.Title, 120));
                item.Blog.Description = prepareDescription;
            }

            if (!string.IsNullOrEmpty(item.Blog?.CategoryName))
            {
                item.Blog.CategoryName = item.Blog?.CategoryName;
            }
        }
        public void PrepareEvent(PostDataObject item)
        {
            if (!string.IsNullOrEmpty(item.Event?.EventClass?.Name))
            {
                var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Name, 100));
                item.Event.Value.EventClass.Name = prepareTitle;
            }
            if (!string.IsNullOrEmpty(item.Event?.EventClass?.Description))
            {
                var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Description, 100));
                item.Event.Value.EventClass.Description = prepareDescription;
            }

            if (!string.IsNullOrEmpty(item.Event?.EventClass?.Location))
            {
                var prepareLocation = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Location, 60));
                item.Event.Value.EventClass.Location = prepareLocation;
            }
        }
Пример #15
0
        public ActionResult Index()
        {
            this.HttpContext.Session["user"] = new User()
            {
                Id       = 1000,
                Name     = "Philips",
                NickName = "会飞的猪猪",
                Email    = "*****@*****.**"
            };

            PostDataObject postDataObject = new PostDataObject();

            postDataObject.Author.Name = GlobalApplication.LoginUser.Name;
            postDataObject.Content     = "啦啦啦啦啦啦啦啦哈哈哈哈哈哈";
            postDataObject.Topic.Id    = 1000;
            postDataObject.Topic.Name  = "热门";

            return(View(postDataObject));
        }
        public async void PrepareMapPost(PostDataObject item)
        {
            try
            {
                switch (item.PostMap.Contains("https://maps.googleapis.com/maps/api/staticmap?"))
                {
                case false:
                {
                    string imageUrlMap = "https://maps.googleapis.com/maps/api/staticmap?";
                    //imageUrlMap += "center=" + item.CurrentLatitude + "," + item.CurrentLongitude;
                    imageUrlMap += "center=" + item.PostMap.Replace("/", "");
                    imageUrlMap += "&zoom=10";
                    imageUrlMap += "&scale=1";
                    imageUrlMap += "&size=300x300";
                    imageUrlMap += "&maptype=roadmap";
                    imageUrlMap += "&key=" + MainContext.GetText(Resource.String.google_maps_key);
                    imageUrlMap += "&format=png";
                    imageUrlMap += "&visual_refresh=true";
                    imageUrlMap += "&markers=size:small|color:0xff0000|label:1|" + item.PostMap.Replace("/", "");

                    item.ImageUrlMap = imageUrlMap;
                    break;
                }

                default:
                    item.ImageUrlMap = item.PostMap;
                    break;
                }

                var latLng = await GetLocationFromAddress(item.PostMap).ConfigureAwait(false);

                if (latLng != null)
                {
                    item.CurrentLatitude  = latLng.Latitude;
                    item.CurrentLongitude = latLng.Longitude;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #17
0
 public void PrepareOffer(PostDataObject item)
 {
     try
     {
         if (!string.IsNullOrEmpty(item.Offer?.OfferClass?.OfferText))
         {
             var prepareOfferText = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Offer?.OfferClass?.OfferText, 100));
             item.Offer.Value.OfferClass.OfferText = prepareOfferText;
         }
         if (!string.IsNullOrEmpty(item.Offer?.OfferClass?.Description))
         {
             var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Offer?.OfferClass?.Description, 100));
             item.Offer.Value.OfferClass.Description = prepareDescription;
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
        private void MAdapterOnOnItemClick(object sender, MyPhotosAdapterClickEventArgs e)
        {
            try
            {
                PostDataObject item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    ListUtils.ListCachedDataMyPhotos = MAdapter.MyPhotosList;

                    var intent = new Intent(this, typeof(MyPhotoViewActivity));
                    intent.PutExtra("itemIndex", e.Position.ToString());
                    intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(item)); // PostDataObject
                    StartActivity(intent);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.share_group_sheet);

            groups   = JsonConvert.DeserializeObject <List <GroupClass> >(Intent.GetStringExtra("Groups"));
            postData = JsonConvert.DeserializeObject <PostDataObject>(Intent.GetStringExtra("PostObject"));

            rvShareGroup      = FindViewById <RecyclerView>(Resource.Id.rv_share_group);
            shareGroupAdapter = new ShareGroupAdapter(groups, this);
            rvShareGroup.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Vertical, false));
            rvShareGroup.SetAdapter(shareGroupAdapter);

            //
            RelativeLayout rlClose = FindViewById <RelativeLayout>(Resource.Id.rl_close);

            rlClose.Click += RlClose_Click;
        }
Пример #20
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                MAdapter           = null;
                SwipeRefreshLayout = null;
                MRecycler          = null;
                EmptyStateLayout   = null;
                ImageData          = null;
                Toolbar            = null;
                ActionButton       = null;
                MAdView            = null;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #21
0
        private void DestroyBasic()
        {
            try
            {
                MAdView?.Destroy();

                MAdapter           = null !;
                SwipeRefreshLayout = null !;
                MRecycler          = null !;
                EmptyStateLayout   = null !;
                ImageData          = null !;
                Toolbar            = null !;
                ActionButton       = null !;
                MAdView            = null !;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #22
0
        public IEnumerable<PostDataObject> GetPostsByQueryRequest(PostQueryRequest request)
        {
            using (IRepositoryContext repositoryContext = ServiceLocator.Instance.GetService<IRepositoryContext>())
            {
                IRepository<Post> postRepository = repositoryContext.GetRepository<Post>();

                Expression<Func<Post, bool>> dateTimeExpression = (p) => true;

                switch (request.CreationDateTimeParam.CreationDateTimeOperator)
                {
                    case Operator.LessThanEqual:
                        dateTimeExpression = p => p.CreationDateTime <= request.CreationDateTimeParam.CreationDateTime;
                        break;
                    case Operator.GreaterThanEqual:
                        dateTimeExpression = p => p.CreationDateTime >= request.CreationDateTimeParam.CreationDateTime;
                        break;
                    case Operator.Equal:
                    default:
                        dateTimeExpression = p => p.CreationDateTime.Equals(request.CreationDateTimeParam.CreationDateTime);
                        break;
                }

                QueryBuilder<Post> postQueryBuilder = new QueryBuilder<Post>();

                postQueryBuilder.And(p => p.TopicId == request.TopicId).And(dateTimeExpression);

                IEnumerable<Post> posts = postRepository.FindAll(postQueryBuilder.QueryPredicate);

                IList<PostDataObject> postDataObjects = new List<PostDataObject>();

                foreach (Post post in posts)
                {
                    var postDataObject = new PostDataObject();
                    postDataObject.MapFrom(post);

                    postDataObjects.Add(postDataObject);
                }

                return postDataObjects;
            }
        }
        public void PrepareProduct(PostDataObject item)
        {
            if (item.Product != null && item.Product.Value.ProductClass?.Seller == null)
            {
                if (item.Product.Value.ProductClass != null)
                {
                    item.Product.Value.ProductClass.Seller = item.Publisher;
                }
            }

            if (item.Product?.ProductClass != null)
            {
                if (!string.IsNullOrEmpty(item.Product.Value.ProductClass?.Location))
                {
                    item.Product.Value.ProductClass.LocationDecodedText = item.Product.Value.ProductClass?.Location;
                    var prepareLocation = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Product.Value.ProductClass?.Location, 100));
                    item.Product.Value.ProductClass.LocationDecodedText = prepareLocation;
                }

                if (!string.IsNullOrEmpty(item.Product.Value.ProductClass?.Name))
                {
                    var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Product.Value.ProductClass?.Name, 100));
                    item.Product.Value.ProductClass.Name = prepareTitle;
                }

                if (!string.IsNullOrEmpty(item.Product.Value.ProductClass?.Description))
                {
                    var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Product.Value.ProductClass?.Description, 100));
                    item.Product.Value.ProductClass.Description = prepareDescription;
                }

                var(currency, currencyIcon) = WoWonderTools.GetCurrency(item.Product.Value.ProductClass?.Currency);
                Console.WriteLine(currency);
                if (item.Product.Value.ProductClass != null)
                {
                    item.Product.Value.ProductClass.CurrencyText      = currencyIcon + " " + item.Product.Value.ProductClass?.Price;
                    item.Product.Value.ProductClass.TypeDecodedText   = MainContext.GetString(item.Product.Value.ProductClass?.Type == "0" ? Resource.String.Radio_New : Resource.String.Radio_Used); //TODO Should be array from API
                    item.Product.Value.ProductClass.StatusDecodedText = item.Product.Value.ProductClass?.Status == "0" ? MainContext.GetString(Resource.String.Lbl_In_Stock) : " ";                   //TODO Should be array from API
                }
            }
        }
Пример #24
0
        public String InsertPostData(PostDataObject postDataObjec)
        {
            String sqlString = "INSERT INTO aaa_file ( " +
                               " aaa01, aaa02, aaa03, aaa04, aaa05, " +
                               " aaa06, aaa07, aaa08 " +
                               ") VALUES ( " +
                               " @val01, @val02, @val03, @val04, @val05, @val06, " +
                               " @val07, @val08                                  " +
                               ")";

            OpenConnection();
            actionResult = "SUCCESS";

            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = sqlString;

                sqlCommand.Parameters.AddWithValue("@val01", postDataObjec.Aaa01);
                sqlCommand.Parameters.AddWithValue("@val02", postDataObjec.Aaa02);
                sqlCommand.Parameters.AddWithValue("@val03", postDataObjec.Aaa03);
                sqlCommand.Parameters.AddWithValue("@val04", postDataObjec.Aaa04);
                sqlCommand.Parameters.AddWithValue("@val05", postDataObjec.Aaa05);
                sqlCommand.Parameters.AddWithValue("@val06", postDataObjec.Aaa06);
                sqlCommand.Parameters.AddWithValue("@val07", postDataObjec.Aaa07);
                sqlCommand.Parameters.AddWithValue("@val08", postDataObjec.Aaa08);

                sqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                actionResult = "FAIL" + ex.Message;
            }
            finally
            {
                CloseConnection();
            }
            return(actionResult);
        }//End of Insert Into
Пример #25
0
        private void MAdapterOnOnItemClick(object sender, MyPhotosAdapterClickEventArgs e)
        {
            try
            {
                PostDataObject item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    ListUtils.ListCachedDataMyPhotos = MAdapter.MyPhotosList;

                    var intent = new Intent(this, typeof(MyPhotoViewActivity));
                    intent.PutExtra("itemIndex", e.Position.ToString());
                    intent.PutExtra("AlbumObject", JsonConvert.SerializeObject(item)); // PostDataObject
                    OverridePendingTransition(Resource.Animation.abc_popup_enter, Resource.Animation.popup_exit);
                    StartActivity(intent);
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Пример #26
0
        public void AddPostBoxPostView(string typePost, int index, PostDataObject postData = null)
        {
            var item = new AdapterModelsClass
            {
                TypeView = PostModelType.AddPostBox,
                TypePost = typePost,
                Id       = 959595959,
                PostData = postData
            };

            if (index == -1)
            {
                PostList.Add(item);
                AddPostDivider();
            }
            else
            {
                PostList.Insert(index, item);
                AddPostDivider(index);
            }
        }
 private void DestroyBasic()
 {
     try
     {
         CollapsingToolbar = null;
         MAdapter          = null;
         ToolbarTitle      = null;
         AddImage          = null;
         TxtAlbumName      = null;
         MAdapter          = null;
         MRecycler         = null;
         LayoutManager     = null;
         PublishButton     = null;
         ImageData         = null;
         PathImage         = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Пример #28
0
        //Get Data
        private void Get_DataImage()
        {
            try
            {
                ImageData = JsonConvert.DeserializeObject <PostDataObject>(Intent.GetStringExtra("ItemData"));
                if (ImageData != null)
                {
                    Toolbar.Title = Methods.FunString.DecodeString(ImageData.AlbumName);

                    MAdapter.PhotosList = new ObservableCollection <PhotoAlbumObject>(ImageData.PhotoAlbum);
                    MAdapter.NotifyDataSetChanged();

                    MRecycler.Visibility        = ViewStates.Visible;
                    EmptyStateLayout.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #29
0
        //Get Data
        private void Get_DataImage()
        {
            try
            {
                IndexImage = int.Parse(Intent.GetStringExtra("itemIndex"));
                PostData   = JsonConvert.DeserializeObject <PostDataObject>(Intent.GetStringExtra("AlbumObject"));
                if (PostData != null)
                {
                    ViewPager.Adapter     = new TouchMyPhotoAdapter(this, ListUtils.ListCachedDataMyPhotos);
                    ViewPager.CurrentItem = IndexImage;
                    ViewPager.Adapter.NotifyDataSetChanged();
                    ViewPager.PageScrolled += ViewPagerOnPageScrolled;

                    SetDataPost();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #30
0
        //Get Data
        private void Get_DataImage()
        {
            try
            {
                IndexImage = Convert.ToInt32(Intent?.GetStringExtra("itemIndex"));
                PostData   = JsonConvert.DeserializeObject <PostDataObject>(Intent?.GetStringExtra("AlbumObject"));
                if (PostData != null)
                {
                    ViewPager.Adapter     = new TouchMyPhotoAdapter(this, ListUtils.ListCachedDataMyPhotos);
                    ViewPager.CurrentItem = IndexImage;
                    ViewPager.Adapter.NotifyDataSetChanged();
                    ViewPager.PageScrolled += ViewPagerOnPageScrolled;

                    SetDataPost();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
 private void DestroyBasic()
 {
     try
     {
         CollapsingToolbar = null !;
         MAdapter          = null !;
         ToolbarTitle      = null !;
         AddImage          = null !;
         TxtAlbumName      = null !;
         MAdapter          = null !;
         MRecycler         = null !;
         LayoutManager     = null !;
         PublishButton     = null !;
         ImageData         = null !;
         PathImage         = null !;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Пример #32
0
        public IEnumerable <PostDataObject> GetPosts()
        {
            using (IRepositoryContext repositoryContext = ServiceLocator.Instance.GetService <IRepositoryContext>())
            {
                IRepository <Post> postRepository = repositoryContext.GetRepository <Post>();

                IEnumerable <Post> posts = postRepository.FindAll();

                IList <PostDataObject> postDataObjects = new List <PostDataObject>();

                foreach (Post post in posts)
                {
                    PostDataObject postDataObject = new PostDataObject();

                    postDataObject.MapFrom(post);

                    postDataObjects.Add(postDataObject);
                }

                return(postDataObjects);
            }
        }
        private async Task LoadPostDataAsync()
        {
            var(apiStatus, respond) = await RequestsAsync.Posts.GetPostDataAsync(PostId, "post_data");

            switch (apiStatus)
            {
            case 200:
            {
                switch (respond)
                {
                case GetPostDataObject result:
                {
                    DataObject = result.PostData;
                    if (DataObject != null)
                    {
                        DataObject.GetPostComments = new List <GetCommentObject>();

                        var combine = new FeedCombiner(DataObject, NativeFeedAdapter.ListDiffer, this);
                        combine.CombineDefaultPostSections();

                        await LoadDataComment();

                        RunOnUiThread(() => { NativeFeedAdapter.NotifyDataSetChanged(); });
                    }

                    break;
                }
                }

                break;
            }

            default:
                Methods.DisplayReportResult(this, respond);
                break;
            }

            RunOnUiThread(ShowEmptyPage);
        }
 private void ViewPagerOnPageScrolled(object sender, ViewPager.PageScrolledEventArgs e)
 {
     try
     {
         switch (e.Position)
         {
         case >= 0 when ListUtils.ListCachedDataMyPhotos.Count > e.Position:
         {
             PostData = ListUtils.ListCachedDataMyPhotos[e.Position];
             if (PostData != null)
             {
                 SetDataPost();
             }
             break;
         }
         }
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
Пример #35
0
 private void DestroyBasic()
 {
     try
     {
         Adapter      = null !;
         ViewPager    = null !;
         TabLayout    = null !;
         AngryTab     = null !;
         HahaTab      = null !;
         LikeTab      = null !;
         LoveTab      = null !;
         SadTab       = null !;
         WowTab       = null !;
         PostId       = null !;
         TypeReaction = null !;
         PostData     = null !;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Пример #36
0
        public IEnumerable<PostDataObject> GetPosts()
        {
            using (IRepositoryContext repositoryContext = ServiceLocator.Instance.GetService<IRepositoryContext>())
            {
                IRepository<Post> postRepository = repositoryContext.GetRepository<Post>();

                IEnumerable<Post> posts = postRepository.FindAll();

                IList<PostDataObject> postDataObjects = new List<PostDataObject>();

                foreach (Post post in posts)
                {
                    PostDataObject postDataObject = new PostDataObject();

                    postDataObject.MapFrom(post);

                    postDataObjects.Add(postDataObject);
                }

                return postDataObjects;
            }
        }
        public void PrepareEvent(PostDataObject item)
        {
            try
            {
                switch (string.IsNullOrEmpty(item.Event?.EventClass?.Name))
                {
                case false:
                {
                    var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Name, 100));
                    item.Event.Value.EventClass.Name = prepareTitle;
                    break;
                }
                }
                switch (string.IsNullOrEmpty(item.Event?.EventClass?.Description))
                {
                case false:
                {
                    var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Description, 100));
                    item.Event.Value.EventClass.Description = prepareDescription;
                    break;
                }
                }

                switch (string.IsNullOrEmpty(item.Event?.EventClass?.Location))
                {
                case false:
                {
                    var prepareLocation = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Event?.EventClass?.Location, 60));
                    item.Event.Value.EventClass.Location = prepareLocation;
                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #38
0
        public void PrepareFacebookVideo(PostDataObject item)
        {
            try
            {
                switch (AppSettings.EmbedFacebookVideoPostType)
                {
                case VideoPostTypeSystem.EmbedVideo:
                    item.PostLink = "https://www.facebook.com/video/embed?video_id=" + item.PostFacebook.Split("/videos/").Last();
                    break;

                case VideoPostTypeSystem.Link:
                    item.PostLink        = "https://www.facebook.com/video/embed?video_id=" + item.PostFacebook.Split("/videos/").Last();
                    item.PostLinkTitle   = "facebook.com";
                    item.PostLinkContent = MainContext.GetText(Resource.String.Lbl_PostLinkContentFacebook);
                    item.PostLinkImage   = "facebook.png";
                    break;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #39
0
        public void PreparVimeoVideo(PostDataObject item)
        {
            try
            {
                switch (AppSettings.EmbedVimeoVideoPostType)
                {
                case VideoPostTypeSystem.EmbedVideo:
                    item.PostLink = "https://player.vimeo.com/video/" + item.PostVimeo;
                    break;

                case VideoPostTypeSystem.Link:
                    item.PostLink        = "https://player.vimeo.com/video/" + item.PostVimeo;
                    item.PostLinkTitle   = "vimeo.com";
                    item.PostLinkContent = "Vimeo" + " " + MainContext.GetText(Resource.String.Lbl_PostLinkContentVideo);
                    item.PostLinkImage   = "vimeo.png";
                    break;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #40
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                Context        contextThemeWrapper = AppSettings.SetTabDarkTheme ? new ContextThemeWrapper(Activity, Resource.Style.MyTheme_Dark_Base) : new ContextThemeWrapper(Activity, Resource.Style.MyTheme_Base);
                LayoutInflater localInflater       = inflater.CloneInContext(contextThemeWrapper);
                View           view = localInflater.Inflate(Resource.Layout.NativeShareBottomDialog, container, false);

                DataPost = JsonConvert.DeserializeObject <PostDataObject>(Arguments.GetString("ItemData") ?? "");

                TypePost = JsonConvert.DeserializeObject <PostModelType>(Arguments.GetString("TypePost"));

                InitComponent(view);
                AddOrRemoveEvent(true);

                return(view);
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
                return(null !);
            }
        }
 public void PrepareLink(PostDataObject item)
 {
     try
     {
         switch (string.IsNullOrEmpty(item.PostLink))
         {
         case false:
         {
             var prepareUrl = item.PostLink.Replace("https://", "").Replace("http://", "").Split('/').FirstOrDefault();
             item.PostLink = prepareUrl;
             break;
         }
         }
         switch (string.IsNullOrEmpty(item.PostLinkContent))
         {
         case false:
         {
             var prepareDescription = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.PostLinkContent, 100));
             item.PostLinkContent = prepareDescription;
             break;
         }
         }
         switch (string.IsNullOrEmpty(item.PostLinkTitle))
         {
         case false:
         {
             var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.PostLinkTitle, 100));
             item.PostLinkTitle = prepareTitle;
             break;
         }
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
        public void PrepareTikTokVideo(PostDataObject item)
        {
            try
            {
                switch (string.IsNullOrEmpty(item.PostLink))
                {
                case false:
                {
                    item.PostTikTok = item.PostLink;

                    var prepareUrl = item.PostLink.Replace("https://", "").Replace("http://", "").Split('/').FirstOrDefault();
                    item.PostLink = prepareUrl;
                    break;
                }
                }

                item.PostLinkContent = string.Empty;

                switch (string.IsNullOrEmpty(item.PostLinkTitle))
                {
                case false:
                {
                    var prepareTitle = Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.PostLinkTitle, 100));
                    item.PostLinkTitle = prepareTitle;
                    break;
                }
                }
                if (string.IsNullOrEmpty(item.PostLinkImage))
                {
                    item.PostLinkImage = "default_video_thumbnail.png";
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #43
0
 public void PublishPost(PostDataObject post)
 {
     this.PublishPostWithAsyncDomainEventHandler(post);
 }
Пример #44
0
        public ActionResult CreatePostByCommonForm(PostDataObject post)
        {
            string content = post.Content;

            return View("index");
        }
Пример #45
0
        public ActionResult PublishPostByCommand(int topicId, string content)
        {
            try
            {
                IPostCommandService postCommandService = ServiceLocator.Instance.GetService<IPostCommandService>();

                PostDataObject postDataObject = new PostDataObject();
                postDataObject.Author.Id = GlobalApplication.LoginUser.Id;
                postDataObject.Author.Name = GlobalApplication.LoginUser.Name;
                postDataObject.Topic.Id = topicId;
                postDataObject.Content = content;
                //postDataObject.CreationDateTime = DateTime.Now;

                postCommandService.PublishPost(postDataObject);

                return View("index", postDataObject);

                //return Json(new
                //{
                //    topic = postDataObject.TopicName,
                //    author = postDataObject.AuthorName,
                //    content = postDataObject.Content,
                //    date = postDataObject.CreationDateTime
                //});
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #46
0
        public ActionResult Index()
        {
            this.HttpContext.Session["user"] = new User()
                                               {
                                                   Id = 1000,
                                                   Name = "Philips",
                                                   NickName = "会飞的猪猪",
                                                   Email = "*****@*****.**"
                                               };

            PostDataObject postDataObject = new PostDataObject();
            postDataObject.Author.Name = GlobalApplication.LoginUser.Name;
            postDataObject.Content = "啦啦啦啦啦啦啦啦哈哈哈哈哈哈";
            postDataObject.Topic.Id = 1000;
            postDataObject.Topic.Name = "热门";

            return View(postDataObject);
        }