Ejemplo n.º 1
0
        public ResponseContext <AskMomentDetailResponse> AskMomentDetail(Guid applyId, RequestHead head)
        {
            var response  = new ResponseContext <AskMomentDetailResponse>();
            var applyInfo = applyInfoDao.GetByApplyId(applyId);

            if (applyInfo == null)
            {
                return(response);
            }
            var myUserInfo = uerInfoBiz.GetUserInfoByUid(applyInfo.MomentUId);
            var userInfo   = uerInfoBiz.GetUserInfoByUid(applyInfo.UId);
            var moment     = MomentBuilder.GetMoment(applyInfo.MomentId);

            if (myUserInfo == null || userInfo == null || moment == null)
            {
                return(response);
            }
            response.Data = new AskMomentDetailResponse()
            {
                ApplyState     = applyInfo.ApplyState,
                ApplyStateDesc = ApplyStateMap(applyInfo.ApplyState),
                IsOverTime     = MomentContentBuilder.IsOverTime(moment.StopTime),
                MomentId       = moment.MomentId,
                ShareTitle     = MomentContentBuilder.GetShareTitle(moment),
                Address        = moment.Address,
                Latitude       = moment.Latitude,
                Longitude      = moment.Longitude,
                IsOffLine      = moment.IsOffLine,
                TextColor      = ApplyBuilder.TextColorMap(applyInfo.ApplyState),
                UserInfo       = UserInfoBuilder.BuildUserInfo(userInfo, head),
                BtnVisable     = applyInfo.ApplyState == ApplyStateEnum.申请中,
                ApplyList      = ApplyBuilder.GetApplyDetails(applyInfo.ApplyId, head, true)
            };
            return(response);
        }
Ejemplo n.º 2
0
        public void Should_not_create_a_moment_without_user()
        {
            var exception = Assert.Throws <DomainException>(() =>
                                                            MomentBuilder
                                                            .Instance()
                                                            .WithUser(null)
                                                            .Build()
                                                            );

            Assert.Equal("User is required", exception.Message);
        }
Ejemplo n.º 3
0
        public ResponseContext <ApplyMomentListResponse> ApplyMomentList(RequestHead head)
        {
            var response = new ResponseContext <ApplyMomentListResponse>
            {
                Data = new ApplyMomentListResponse()
                {
                    MomentList = new List <ApplyMomentDetailType>()
                }
            };
            var applyList = applyInfoDao.GetListByUId(head.UId);

            if (applyList.IsNullOrEmpty())
            {
                return(response);
            }
            foreach (var apply in applyList)
            {
                var momentUserInfo = uerInfoBiz.GetUserInfoByUid(apply.MomentUId);
                var moment         = MomentBuilder.GetMoment(apply.MomentId);
                if (moment == null || momentUserInfo == null)
                {
                    continue;
                }

                var result = new ApplyMomentDetailType()
                {
                    ApplyId        = apply.ApplyId,
                    ApplyStateDesc = ApplyStateMap(apply.ApplyState),
                    TextColor      = ApplyBuilder.TextColorMap(apply.ApplyState),
                    ShareTitle     = MomentContentBuilder.GetShareTitle(moment),
                    MomentId       = moment.MomentId,
                    Address        = moment.Address,
                    Latitude       = moment.Latitude,
                    Longitude      = moment.Longitude,
                    IsOffLine      = moment.IsOffLine,
                    UserInfo       = UserInfoBuilder.BuildUserInfo(momentUserInfo, head),
                    ContentList    = MomentContentBuilder.BuilderContent2Contact(moment, momentUserInfo, apply.ApplyState == ApplyStateEnum.申请通过)
                };
                var applyDetaiList = applyDetailDao.GetListByApplyId(apply.ApplyId);
                if (applyDetaiList.NotEmpty())
                {
                    //最后一个对话信息
                    var applyDetail = applyDetaiList.OrderByDescending(a => a.CreateTime).First();
                    result.ApplyRemark = applyDetail.Content;
                }
                response.Data.MomentList.Add(result);
            }
            return(response);
        }
Ejemplo n.º 4
0
        public ResponseContext <ApplyMomentDetailResponse> ApplyMomentDetail(Guid applyId, RequestHead head)
        {
            var response  = new ResponseContext <ApplyMomentDetailResponse>();
            var applyInfo = applyInfoDao.GetByApplyId(applyId);

            if (applyInfo == null)
            {
                return(response);
            }
            var userInfo = uerInfoBiz.GetUserInfoByUid(applyInfo.MomentUId);
            var moment   = MomentBuilder.GetMoment(applyInfo.MomentId);

            if (userInfo == null || moment == null)
            {
                return(response);
            }
            string btnText = ApplyBuilder.BtnTextMap(applyInfo.ApplyState);

            response.Data = new ApplyMomentDetailResponse()
            {
                ApplyState     = applyInfo.ApplyState,
                ApplyStateDesc = ApplyStateMap(applyInfo.ApplyState),
                MomentId       = moment.MomentId,
                ShareTitle     = MomentContentBuilder.GetShareTitle(moment),
                BtnText        = btnText,
                Address        = moment.Address,
                Latitude       = moment.Latitude,
                Longitude      = moment.Longitude,
                IsOffLine      = moment.IsOffLine,
                NextAction     = ApplyBuilder.BtnActionMap(applyInfo.ApplyState),
                BtnVisable     = !string.IsNullOrEmpty(btnText),
                TextColor      = ApplyBuilder.TextColorMap(applyInfo.ApplyState),
                UserInfo       = UserInfoBuilder.BuildUserInfo(userInfo, head),
                ContentList    = MomentContentBuilder.BuilderContent2Contact(moment, userInfo, applyInfo.ApplyState == ApplyStateEnum.申请通过),
                ApplyList      = ApplyBuilder.GetApplyDetails(applyInfo.ApplyId, head, false)
            };
            return(response);
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.multi_moment_activity);

            var options = new PlusClass.PlusOptions.Builder().AddActivityTypes(MomentUtil.ACTIONS).Build();

            mGoogleApiClient = new GoogleApiClient.Builder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API, options)
                               .AddScope(PlusClass.ScopePlusLogin)
                               .Build();

            mListAdapter = new ArrayAdapter <string>(
                this, Android.Resource.Layout.SimpleListItem1, MomentUtil.MOMENT_LIST);
            mMomentListView            = FindViewById <ListView>(Resource.Id.moment_list);
            mMomentListView.ItemClick += (sender, e) => {
                if (mGoogleApiClient.IsConnected)
                {
                    var textView   = e.View as TextView;
                    var momentType = textView.Text;
                    var targetUrl  = MomentUtil.MOMENT_TYPES[momentType];

                    var target = new ItemScopeBuilder().SetUrl(targetUrl).Build();

                    var momentBuilder = new MomentBuilder();
                    momentBuilder.SetType("http://schemas.google.com/" + momentType);
                    momentBuilder.SetTarget(target);

                    var result = MomentUtil.GetResultFor(momentType);
                    if (result != null)
                    {
                        momentBuilder.SetResult(result);
                    }

                    PlusClass.MomentsApi.Write(mGoogleApiClient, momentBuilder.Build()).SetResultCallback <Statuses> (status =>
                    {
                        switch (status.StatusCode)
                        {
                        case CommonStatusCodes.Success:
                            Toast.MakeText(this, GetString(Resource.String.plus_write_moment_status_success), ToastLength.Short).Show();
                            break;

                        case CommonStatusCodes.SuccessCache:
                            Toast.MakeText(this, GetString(Resource.String.plus_write_moment_status_cached), ToastLength.Short).Show();
                            break;

                        case CommonStatusCodes.SignInRequired:
                            Toast.MakeText(this, GetString(Resource.String.plus_write_moment_status_auth_error), ToastLength.Short).Show();
                            mGoogleApiClient.Disconnect();
                            mGoogleApiClient.Connect();
                            break;

                        default:
                            Toast.MakeText(this, GetString(Resource.String.plus_write_moment_status_error),
                                           ToastLength.Short).Show();
                            Console.WriteLine("Error when writing moments: " + status);
                            break;
                        }
                    });
                }
            };

            mResolvingError = savedInstanceState != null &&
                              savedInstanceState.GetBoolean(STATE_RESOLVING_ERROR, false);

            var available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != CommonStatusCodes.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
Ejemplo n.º 6
0
        public Response MomentAction(Guid momentId, string action, string remark, long uId)
        {
            var moment = MomentBuilder.GetMoment(momentId);

            if (moment == null)
            {
                return(new Response(ErrCodeEnum.DataIsnotExist));
            }
            string message = "操作成功";

            switch (action)
            {
            case "stop":
                momentDao.UpdateStopTime(momentId);
                message = "已停止活动";
                InsertApplyDetail(momentId, "停止活动", uId);
                break;

            case "delete":
                momentDao.Delete(momentId);
                message = "删除成功";
                break;

            case "complain":
                remark = "申诉理由:" + remark;
                momentDao.UpdateState(momentId, MomentStateEnum.审核中);
                InsertApplyDetail(momentId, remark, uId);
                message = "提交成功";
                break;

            case "black":
            case "pass":
            case "refuse":
                if (moment.State != MomentStateEnum.审核中)
                {
                    return(new Response(ErrCodeEnum.Failure, "用户修改了动态,审核失败"));
                }
                var userInfo = uerInfoBiz.GetUserInfoByUid(uId);
                if (userInfo == null || userInfo.UserType == UserTypeEnum.Default || userInfo.UserType == UserTypeEnum.SimulationUser)
                {
                    return(new Response(ErrCodeEnum.Failure, "权限不足,请联系管理员添加权限"));
                }
                else
                {
                    var momentState = MomentStateEnum.正常发布中;
                    if (action.Equals("pass"))
                    {
                        remark = "审核通过,发布成功";
                    }
                    if (action.Equals("black"))
                    {
                        remark      = "拉黑此活动申请";
                        momentState = MomentStateEnum.被关小黑屋中;
                    }
                    if (action.Equals("refuse"))
                    {
                        remark      = "审核不通过:" + remark;
                        momentState = MomentStateEnum.审核被拒绝;
                    }

                    moment.State = momentState;
                    momentDao.UpdateState(momentId, momentState);

                    var momentUser = uerInfoBiz.GetUserInfoByUid(moment.UId);
                    if (momentUser != null)
                    {
                        //发送通知
                        AppFactory.Factory(momentUser.Platform).Send_Moment_Publish_MsgAsync(moment, momentUser.OpenId, remark);
                    }
                }
                InsertApplyDetail(momentId, remark, uId);
                message = "操作成功";
                break;

            default:
                break;
            }
            return(new Response(ErrCodeEnum.Success, message));
        }
Ejemplo n.º 7
0
        protected override void OnCreate (Bundle savedInstanceState) 
        {
            base.OnCreate (savedInstanceState);

            SetContentView (Resource.Layout.multi_moment_activity);

            var options = new PlusClass.PlusOptions.Builder().AddActivityTypes (MomentUtil.ACTIONS).Build ();
            mGoogleApiClient = new GoogleApiClientBuilder (this)
                .AddConnectionCallbacks(this)
                .AddOnConnectionFailedListener(this)
                .AddApi (PlusClass.API, options)
                .AddScope (PlusClass.ScopePlusLogin)
                .Build ();

            mListAdapter = new ArrayAdapter<string>(
                this, Android.Resource.Layout.SimpleListItem1, MomentUtil.MOMENT_LIST);
            mMomentListView = FindViewById<ListView>(Resource.Id.moment_list);
            mMomentListView.ItemClick += (sender, e) => {
                if (mGoogleApiClient.IsConnected) {
                    var textView = e.View as TextView;
                    var momentType = textView.Text;
                    var targetUrl = MomentUtil.MOMENT_TYPES[momentType];

                    var target = new ItemScopeBuilder ().SetUrl(targetUrl).Build ();

                    var momentBuilder = new MomentBuilder ();
                    momentBuilder.SetType ("http://schemas.google.com/" + momentType);
                    momentBuilder.SetTarget (target);

                    var result = MomentUtil.GetResultFor (momentType);
                    if (result != null)
                        momentBuilder.SetResult (result);

                    PlusClass.MomentsApi.Write (mGoogleApiClient, momentBuilder.Build ()).SetResultCallback<Statuses> (status => 
                    {
                        switch (status.StatusCode) {
                        case CommonStatusCodes.Success:
                            Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_success), ToastLength.Short).Show ();
                            break;

                        case CommonStatusCodes.SuccessCache:
                            Toast.MakeText(this, GetString (Resource.String.plus_write_moment_status_cached), ToastLength.Short).Show ();
                            break;

                        case CommonStatusCodes.SignInRequired:
                            Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_auth_error), ToastLength.Short).Show();
                            mGoogleApiClient.Disconnect();
                            mGoogleApiClient.Connect();
                            break;

                        default:
                            Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_error),
                                ToastLength.Short).Show();
                            Console.WriteLine ("Error when writing moments: " + status);
                            break;
                        }
                    });
                }
            };

            mResolvingError = savedInstanceState != null
                && savedInstanceState.GetBoolean (STATE_RESOLVING_ERROR, false);

            var available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this);
            if (available != CommonStatusCodes.Success) {
                ShowDialog (DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
                ActionBar.SetDisplayHomeAsUpEnabled (true);
            }
        }