Exemplo n.º 1
0
 public bool UploadIncome(UploadInfo info)
 {
     return svr.UploadIncome(info);
 }
Exemplo n.º 2
0
        public bool VerifyOutcome(UploadInfo info)
        {
            Assert.IsNotNull(info);

            bool result = false;
            var chanel = CreateChannel();
            chanel.Call(p =>
            {
                result = p.VerifyOutcome(info);
            });

            return result;
        }
Exemplo n.º 3
0
 public bool RemoveOutcome(UploadInfo info)
 {
     return svr.RemoveOutcome(info);
 }
Exemplo n.º 4
0
 public bool VerifyOutcome(UploadInfo info)
 {
     return svr.VerifyOutcome(info);
 }
Exemplo n.º 5
0
        public bool UploadIncome(UploadInfo info)
        {
            if (string.IsNullOrEmpty(info.FileUrl))
                throw new Exception("no file provided!");
            var targetState = repoTargetState.Query(o => o.TargetStateId == info.TargetStateId).FirstOrDefault();
            if (targetState == null)
                throw new ArgumentNullException(string.Format("Target with state {0} not found!", info.TargetStateId));
            var tobj = repoTargetIncome.Query(o => o.TargetStateId == info.TargetStateId && o.IncomeId == info.UploadId).FirstOrDefault();
            if (tobj == null)
            {
                var obj = repoFlowIncome.Query(o => o.IncomeId == info.UploadId).FirstOrDefault();
                if (obj == null)
                    throw new ArgumentNullException(string.Format("Income width {0} in state {1} not defined!", info.UploadId, targetState.StateId));

                tobj = new TargetIncome()
                {
                    TargetIncomeId = idGenerator.NewId(),
                    TargetStateId = info.TargetStateId,
                    IncomeId = info.UploadId,
                    Name = obj.Name,
                    Remark = info.Remark,
                    UploadTime = info.OperationTime,
                    FileType = obj.FileType,
                    FileUrl = info.FileUrl,
                    FileStatus = FileStatus.Draft,
                    UploaderId = info.UserId,
                    UploaderName = info.UserName
                };

                bool result = repoTargetIncome.Insert(tobj);

                TargetIncomeChangedMessage msg = new TargetIncomeChangedMessage()
                {
                    TargetIncome = tobj,
                    DataOperation = DataOperation.Insert,
                    OperateTime = info.OperationTime,
                    OperatorId = info.UserId,
                    OperatorName = info.UserName
                };
                try
                {
                    MessageManager.Publish<TargetIncomeChangedMessage>(msg);
                }
                catch (Exception ex)
                {
                    //throw ex;
                }
                return result;
            }
            else
            {
                if (!tobj.Verified.HasValue || !tobj.Verified.Value)
                {
                    tobj.Remark = info.Remark;
                    tobj.FileUrl = info.FileUrl;
                    tobj.UploadTime = info.OperationTime;
                    tobj.Remark = tobj.Remark + Environment.NewLine + info.Remark;

                    tobj.UploaderId = info.UserId;
                    tobj.UploaderName = info.UserName;
                    bool result = repoTargetIncome.Update(tobj);

                    TargetIncomeChangedMessage msg = new TargetIncomeChangedMessage()
                    {
                        TargetIncome = tobj,
                        DataOperation = DataOperation.Insert,
                        OperateTime = info.OperationTime,
                        OperatorId = info.UserId,
                        OperatorName = info.UserName
                    };
                    try
                    {
                        MessageManager.Publish<TargetIncomeChangedMessage>(msg);
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                    }
                    return result;
                }
                else
                {
                    throw new ApplicationException(string.Format("Income {0} has been verified!", tobj.TargetIncomeId));
                }
            }
        }
Exemplo n.º 6
0
        public bool RemoveOutcome(UploadInfo info)
        {
            var tobj = repoTargetOutcome.Query(o => o.TargetStateId == info.TargetStateId && o.OutcomeId == info.UploadId).FirstOrDefault();
            if (tobj == null)
                throw new ArgumentNullException(string.Format("Target outcome {0} not found!", info.UploadId));

            bool result = repoTargetOutcome.Delete(tobj);

            TargetOutcomeChangedMessage msg = new TargetOutcomeChangedMessage()
            {
                TargetOutcome = tobj,
                DataOperation = DataOperation.Delete,
                OperateTime = info.OperationTime,
                OperatorId = info.UserId,
                OperatorName = info.UserName
            };
            try
            {
                MessageManager.Publish<TargetOutcomeChangedMessage>(msg);
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            return result;
        }
Exemplo n.º 7
0
        public bool VerifyOutcome(UploadInfo info)
        {
            if (string.IsNullOrEmpty(info.FileUrl))
                throw new Exception("no file provided!");
            var targetState = repoTargetState.Query(o => o.TargetStateId == info.TargetStateId).FirstOrDefault();
            if (targetState == null)
                throw new ArgumentNullException(string.Format("Target with state {0} not found!", info.TargetStateId));
            var tobj = repoTargetOutcome.Query(o => o.TargetStateId == info.TargetStateId && o.OutcomeId == info.UploadId).FirstOrDefault();
            if (tobj == null)
                throw new ArgumentNullException(string.Format("Outcome {0} in state {1} not found!", info.UploadId, info.TargetStateId));

            tobj.Verified = info.Verified;
            tobj.Remark = tobj.Remark + Environment.NewLine + info.Remark;
            tobj.VerifierId = info.UserId;
            tobj.VerifierName = info.UserName;
            tobj.VerifierTime = info.OperationTime;
            tobj.FileStatus = info.Verified.Value ? FileStatus.Verified : FileStatus.InValid;

            bool result = repoTargetOutcome.Update(tobj);

            TargetOutcomeChangedMessage msg = new TargetOutcomeChangedMessage()
            {
                TargetOutcome = tobj,
                DataOperation = DataOperation.Update,
                OperateTime = info.OperationTime,
                OperatorId = info.UserId,
                OperatorName = info.UserName
            };
            try
            {
                MessageManager.Publish<TargetOutcomeChangedMessage>(msg);
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            return result;
        }