Exemplo n.º 1
0
        public InvokeResult AuthServeMan(AuthServeManParam param)
        {
            InvokeResult result = new InvokeResult();

            try
            {
                var requests = BuilderFactory.DefaultBulder().List <WXStationAuthRequest>(new WXStationAuthRequest {
                    OpenId = param.OpenId, StationId = param.StationId, DoStatus = 1
                }.ToStringObjectDictionary(false));
                bool addNew = false;
                if (requests.Count == 0)
                {
                    //新申请
                    addNew = true;
                }
                else
                {
                    if (requests.Any(item => item.DoStatus == 0 || item.DoStatus == 1))
                    {
                        //已经存在或还在等待审核,则忽略
                    }
                    else if (requests.Any(item => item.DoStatus == 2))
                    {
                        //重新申请
                        addNew = true;
                    }
                }

                if (addNew)
                {
                    WXStationAuthRequest wxRequest = new WXStationAuthRequest {
                        OpenId = param.OpenId, StationId = param.StationId
                    };
                    string sourceKey = TypeConverter.ChangeString(BuilderFactory.DefaultBulder().Create <WXStationAuthRequest>(wxRequest.ToStringObjectDictionary(false)));
                    //提醒记录

                    int reminderId = Convert.ToInt32(BuilderFactory.DefaultBulder().Create <Reminder>(new Reminder {
                        SourceTable = wxRequest.GetMappingTableName(), SourceColumn = "Id", SourceKey = sourceKey, SourceType = "B0101", RemindTime = DateTime.Now, RemindContent = "您有一条微信服务人员资格申请等待审核"
                    }.ToStringObjectDictionary(false)));
                    BuilderFactory.DefaultBulder().Create <ReminderObject>(new ReminderObject {
                        ReminderId = reminderId, ObjectType = "Merchant", ObjectKey = param.StationId.ToString()
                    }.ToStringObjectDictionary(false));
                }
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public InvokeResult AuditSelected(string doStatus, string strIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new WXStationAuthRequest().GetUpdateMethodName();
                foreach (string strId in arrIds)
                {
                    /***********************begin 自定义代码*******************/
                    /***********************end 自定义代码*********************/
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = new { Id = int.Parse(strId), DoStatus = byte.Parse(doStatus) }.ToStringObjectDictionary(), Type = SqlExecuteType.UPDATE
                    });

                    //设置提醒标志已响应
                    WXStationAuthRequest wxStationAuthRequest = BuilderFactory.DefaultBulder().Load <WXStationAuthRequest, WXStationAuthRequestPK>(new WXStationAuthRequestPK {
                        Id = int.Parse(strId)
                    });
                    if (wxStationAuthRequest.Id != null)
                    {
                        statements.Add(new IBatisNetBatchStatement {
                            StatementName = "ReponseReminder", ParameterObject = new { ResponseAppType = GlobalManager.DIKey_01004_Web, ObjectType = "Merchant", ObjectKey = wxStationAuthRequest.StationId, SourceTable = wxStationAuthRequest.GetMappingTableName(), SourceColumn = "Id", SourceType = "B0101", SourceKey = strId }.ToStringObjectDictionary(), Type = SqlExecuteType.UPDATE
                        });
                    }
                }


                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }