public void EndApply(string sender, ApplyResponse response)
        {
            try
            {
                if (!Cache.TryGetValue(sender, out KXTUserAppliesFile file))
                {
                    file = new KXTUserAppliesFile
                           (
                        RootPath + "\\" + sender + ".json"
                           );
                    Cache.TryAdd(sender, file);
                }

                if ("" == response.TargetID)
                {
                    file.EndApply(response.ApplierID);
                }
                else
                {
                    file.EndApply(response.ApplierID, response.TargetID);
                }

                file.Flush();
            }
            catch
            {
                Notify(LogLevel.Warning, "用户申请数据操作异常:文件异常");
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var proxy = new LoanServiceClient();

            ApplyResponse resp = proxy.Apply(6000, 60);

            Console.WriteLine("{0} : {1}", resp.ApplicationId, resp.MonthlyRepayment);

            Console.WriteLine("Loan approved: {0}", proxy.Confirm(resp.ApplicationId));
        }
Example #3
0
        public static ApplyResponseDto ToResponseDto(this ApplyResponse model)
        {
            var b = new ApplyResponseDto()
            {
                AuditingUserRealName = model?.AuditingBy?.BaseInfo?.RealName,
                AuditingUserId       = model?.AuditingBy?.Id,
                Index       = model.StepIndex,
                HandleStamp = model.HandleStamp,
                Remark      = model.Remark,
                Status      = model.Status
            };

            return(b);
        }
Example #4
0
        //[AllowAnonymous]
        public async Task <ActionResult <ApplyResponse> > ProManageApp(ManageApplyRequest request)
        {
            var pro_id = Int32.Parse(User.Identity.Name);

            if (await UserAccessor.CheckRole(pro_id) == Role.Student)
            {
                return(BadRequest(new { message = "Students cannot manage application." }));
            }

            ApplyEntity ae = await ApplyAccessor.Read(request.apply_id);

            if (ae == null)
            {
                return(BadRequest(new { message = "Apply id not found." }));
            }
            if (ae.status != Constants.ApplyStatus.Applying)
            {
                return(BadRequest(new { message = "Application have been managed." }));
            }
            var success_change = await ApplyAccessor.SetApplyStatus(request.apply_id, request.status);

            if (success_change > 0)
            {
                ae.status = request.status; //减少查询
                ApplyResponse ar = _mapper.Map <ApplyResponse>(ae);
                // 未检查id是否存在
                ar.student_name = await UserAccessor.GetUserName(ae.student_id);

                ar.teacher_name = await UserAccessor.GetUserName(ae.teacher_id);

                ar.work_name = await WorkAccessor.GetWorkName(ae.work_id);

                if (request.status == Constants.ApplyStatus.Accepted)
                {
                    // 录用,创建takes
                    var take = new TakesEntity
                    {
                        work_name  = ar.work_name,
                        student_id = ae.student_id,
                        work_id    = ae.work_id,
                        work_time  = await WorkAccessor.GetWorkTotalTime(ae.work_id)
                    };
                    await TakesAccessor.Create(take);
                }

                return(ar);
            }

            return(BadRequest(new { message = "Update failed" }));
        }
Example #5
0
        void IDataSender.ApplyUserRes(ApplyResponse response)
        {
            Datagram datagram = new Datagram
            {
                DataType    = DatagramType.Login,
                MessageType = LoginMessageType.ApplyUserRes,
                Datas       = response.ToByteArray()
            };

            if (!Send(datagram))
            {
                RunningDatas.InfoNotify("网络连接失败 请重启软件后重试");
            }
        }
Example #6
0
        //[AllowAnonymous]
        public async Task <ActionResult <ApplyItemResponse> > ProViewApps([FromBody] ViewAppRequest request)
        {
            var pro_id = Int32.Parse(User.Identity.Name);

            if (await UserAccessor.CheckRole(pro_id) == Role.Student)
            {
                return(BadRequest(new { message = "ProViewApps is not for students." }));
            }

            var apps = new ApplyItemResponse();

            //apps.totalpage=0;
            apps.pagenum = request.pagenum;
            var start = (request.pagenum - 1) * request.pagesize;
            var end   = request.pagenum * request.pagesize;

            if (start < 0)
            {
                return(BadRequest(new { message = "Page num error" }));
            }

            apps.applist = new System.Collections.Generic.List <ApplyResponse>();
            var provide_list = await ApplyAccessor.ProViewApps(pro_id);

            if (provide_list != null)
            {
                for (int i = start; i < end && i < provide_list.total; i++)
                {
                    ApplyResponse ar = _mapper.Map <ApplyResponse>(provide_list.ApplyItem[i]);
                    // 未检查id是否存在
                    ar.student_name = await UserAccessor.GetUserName(provide_list.ApplyItem[i].student_id);

                    ar.teacher_name = await UserAccessor.GetUserName(provide_list.ApplyItem[i].teacher_id);

                    ar.work_name = await WorkAccessor.GetWorkName(provide_list.ApplyItem[i].work_id);

                    apps.applist.Add(ar);
                }
                apps.totalpage = provide_list.total;
                return(Ok(apps));
            }
            return(Ok(-1)); // Never arrive there
        }
Example #7
0
        private Packet Apply(ApplyRequest req)
        {
            Log(0, "Outlook更新開始");
            var res = new ApplyResponse()
            {
                CalendarItems = new CalendarItemCollection()
            };

            foreach (var calendarItem in req.CalendarItems)
            {
                try
                {
                    if (calendarItem.Changed == false)
                    {
                        res.CalendarItems.Add(calendarItem);
                    }
                    else if (calendarItem.Cancelled)
                    {
                        DeleteItem(calendarItem);
                    }
                    else if (calendarItem.ID == string.Empty)
                    {
                        CreateItem(calendarItem);
                        res.CalendarItems.Add(calendarItem);
                    }
                    else
                    {
                        UpdateItem(calendarItem);
                        res.CalendarItems.Add(calendarItem);
                    }
                }
                catch (Exception ex)
                {
                    Log(0, ex);
                }
            }
            Log(0, "Outlook更新完了");
            return(res);
        }