예제 #1
0
        public GetItemListResult GetCustomFormList(GetCustomFormListArgs args)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            parameterList.Add(new CommandParameter("@name", args.Name));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCustomFormList", parameterList, new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetCustomFormList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalCount = totalCount;
            result.TotalPage  = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }
예제 #2
0
        public List <MovieEntity> GetMovieTimes(Guid domainId, string appId, DateTime date)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", domainId));
            parameterList.Add(new CommandParameter("@appId", appId));
            parameterList.Add(new CommandParameter("@date", date));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetMovieTimes", parameterList, new string[] { "movies", "times" });

            DataTable dtMovies = dsResult.Tables["movies"];
            DataTable dtTimes  = dsResult.Tables["times"];

            List <MovieEntity> list = RelationalMappingUnity.Select <MovieEntity>(dtMovies);

            if (list == null)
            {
                list = new List <MovieEntity>();
                return(list);
            }

            foreach (MovieEntity item in list)
            {
                item.TimesList = RelationalMappingUnity.Select <MovieTimesEntity>(dtTimes.Select("Movie = '" + item.Id + "'"));
            }

            return(list);
        }
        /// <summary>
        /// 获取指定活动的引导落地页面,如果没有设置,则获取域下的引导关注页面
        /// 再没有,就返回默认引导关注页面
        /// </summary>
        /// <param name="campaignId"></param>
        /// <returns></returns>
        //public string GetGuideSubscribeUrl(Guid campaignId, DomainContext domainContext)
        //{
        //    List<CommandParameter> parameterList = new List<CommandParameter>();
        //    parameterList.Add(new CommandParameter("@campaignId", campaignId));

        //    string url = null;
        //    _dataBase.ExecuteScalar<string>("SELECT [GuideSubscribeUrl] FROM [Campaign] WHERE [Id] = @campaignId",
        //        parameterList, (scalarString) => { url = scalarString; });

        //    if (String.IsNullOrEmpty(url) == false)
        //        return url;
        //    else
        //        return domainContext.GuideSubscribeUrl;
        //}

        public GetItemListResult GetCampaignList(GetCampaignListArgs args)
        {
            if (RelationalMappingUnity.IsValidFieldName(args.OrderBy) == false)
            {
                args.OrderBy = GetCampaignListArgs.DefaultOrderBy;
            }

            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            parameterList.Add(new CommandParameter("@type", args.Type));
            parameterList.Add(new CommandParameter("@status", args.Status));
            parameterList.Add(new CommandParameter("@orderby", args.OrderBy));
            parameterList.Add(new CommandParameter("@sort", args.Sort.ToString()));

            DataSet dsResult =
                DataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCampaignList", parameterList, new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetCampaignList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalPage = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }
        public GetItemListResult GetMessageList(GetMessageListArgs args)
        {
            string receivingMessageType = null;

            if (args.ReceivingMessageType.HasValue)
            {
                receivingMessageType = EnumHelper.GetEnumMemberValue(args.ReceivingMessageType);
            }

            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            parameterList.Add(new CommandParameter("@receivingMessageType", receivingMessageType));
            parameterList.Add(new CommandParameter("@content", args.Content));
            parameterList.Add(new CommandParameter("@memberOpenId", args.MemberOpenId));
            parameterList.Add(new CommandParameter("@memberNickName", args.MemberNickName));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetMessageList", parameterList, new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetMessageList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalPage = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }
예제 #5
0
        public OperationData GetOperationData(Guid domainId, string appId, DateTime date)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", domainId));
            parameterList.Add(new CommandParameter("@appId", appId));
            parameterList.Add(new CommandParameter("@date", date));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetOperationData", parameterList,
                                         new string[] { "newAttentionCount", "totalAttentionCount" });

            OperationData result = new OperationData();

            if (dsResult.Tables["newAttentionCount"].Rows.Count > 0)
            {
                string strNewAttentionCount = dsResult.Tables["newAttentionCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strNewAttentionCount) == false)
                {
                    result.NewAttentionCount = int.Parse(strNewAttentionCount);
                }
            }

            if (dsResult.Tables["totalAttentionCount"].Rows.Count > 0)
            {
                string strTotalAttentionCount = dsResult.Tables["totalAttentionCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strTotalAttentionCount) == false)
                {
                    result.TotalAttentionCount = int.Parse(strTotalAttentionCount);
                }
            }

            return(result);
        }
        /// <summary>
        /// 根据授权码开始维护一个新的公众号Token
        /// 此方法在 Container 中调用
        /// </summary>
        /// <param name="domainId"></param>
        /// <param name="authCode"></param>
        /// <returns></returns>
        public RequestApiResult <WeixinThirdPartyGetAuthorizationInfoResult> CreateAuthorizer(Guid domainId, string authCode)
        {
            RequestApiResult <WeixinThirdPartyGetAuthorizationInfoResult> authorizationInfoResult =
                ThirdPartyApiWrapper.GetAuthorizationInfo(authCode);

            if (authorizationInfoResult.Success == false)
            {
                return(authorizationInfoResult);
            }

            WeixinThirdPartyAuthorizationInfo info = authorizationInfoResult.ApiResult.AuthorizationInfo;

            //一个公众号不能同时授权给两个帐户,因为微信在推送数据时只带一个APPID,我无法判断其属于哪个Domain
            //但是允许其在解除授权后得新授权给另一个帐户
            //所以首先判断有没有已经授权过的且online的domain,如果有,先解除原有授权
            //解除的办法直接更新原domain的lastDockingDate,并把Online置为0,
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", domainId));
            parameterList.Add(new CommandParameter("@appId", info.AppId));

            DataTable dt = _dataBase.ExecuteDataSet(
                "SELECT [Domain] FROM [Authorizer] WHERE [Online] = 1 AND [AppId] = @appId AND [Domain] <> @domainId",
                parameterList, new string[] { "table" }).Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                //解除授权
                Unauthorized(Guid.Parse(dr["Domain"].ToString()), info.AppId);
            }


            //还有可能是同一个Domain以前授权过的,这种情况直接更新即可
            AuthorizerEntity entity = new AuthorizerEntity();

            entity.AppId  = info.AppId;
            entity.Domain = domainId;

            bool exist = _dataBase.Fill <AuthorizerEntity>(entity);

            //保存RefreshToken到数据库
            //非常重要,一旦丢失则需要公众号重新授权
            entity.AccessToken           = info.AccessToken;
            entity.AccessTokenExpiryTime = DateTime.Now.AddSeconds(info.ExpiresIn);
            entity.RefreshToken          = info.RefreshToken;
            entity.RefreshTokenGetTime   = DateTime.Now;
            ////////////

            entity.AuthorizationTime = DateTime.Now;
            entity.Online            = true;
            entity.FuncScopeCategory = info.FuncScopeCategoryList.ToString();

            if (exist)
            {
                _dataBase.Update(entity);
            }
            else
            {
                _dataBase.Insert(entity);
            }

            //更新LastDockingTime
            DomainManager.Instance.UpdateLastDockingTime(domainId);

            return(authorizationInfoResult);
        }
        public MemberStatisticData GetMemberStatisticData(Guid domainId, string appId, DateTime startDate, DateTime endDate)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", domainId));
            parameterList.Add(new CommandParameter("@appId", appId));
            parameterList.Add(new CommandParameter("@startDate", startDate));
            parameterList.Add(new CommandParameter("@endDate", endDate));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetMemberStatisticData", parameterList,
                                         new string[] { "subscribeCount", "unsubscribeCount", "newAttentionCount", "totalAttentionCount", "todaySigninCount" });

            MemberStatisticData result = new MemberStatisticData();

            if (dsResult.Tables["subscribeCount"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["subscribeCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.SubscribeCount = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["unsubscribeCount"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["unsubscribeCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.UnsubscribeCount = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["newAttentionCount"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["newAttentionCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.NewAttentionCount = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["totalAttentionCount"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["totalAttentionCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.TotalAttentionCount = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["todaySigninCount"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["todaySigninCount"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.TodaySigninCount = int.Parse(strCount);
                }
            }

            return(result);
        }
        public PointCommodityOrderStatisticData GetPointCommodityOrderStatisticData(Guid domainId, string appId, DateTime startDate, DateTime endDate)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", domainId));
            parameterList.Add(new CommandParameter("@appId", appId));
            parameterList.Add(new CommandParameter("@startDate", startDate));
            parameterList.Add(new CommandParameter("@endDate", endDate));

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetPointCommodityOrderStatisticData", parameterList,
                                         new string[] { "totalOrder", "noPayment", "paid", "deal", "canceled" });

            PointCommodityOrderStatisticData result = new PointCommodityOrderStatisticData();

            if (dsResult.Tables["totalOrder"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["totalOrder"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.TotalOrder = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["noPayment"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["noPayment"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.NoPayment = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["paid"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["paid"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.Paid = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["deal"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["deal"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.Deal = int.Parse(strCount);
                }
            }

            if (dsResult.Tables["canceled"].Rows.Count > 0)
            {
                string strCount = dsResult.Tables["canceled"].Rows[0][0].ToString();

                if (string.IsNullOrEmpty(strCount) == false)
                {
                    result.Canceled = int.Parse(strCount);
                }
            }

            return(result);
        }
예제 #9
0
        private void Consume(DatabaseSyncConfig_Consumer consumer, DatabaseSyncConfig_Producer producer, DatabaseSyncCommand command)
        {
            DatabaseWrapper consumerDatabase = _dataBaseList[consumer.Connection];
            DatabaseWrapper producerDatabase = _dataBaseList[producer.Connection];

            List <SqlExpression> sqlExpressionList = new List <SqlExpression>();

            foreach (DatabaseSyncItem syncItem in command.SyncItemList)
            {
                List <DatabaseSyncConfig_Table> tableList = (from c in producer.TableDefinition.TableList
                                                             where c.Name == syncItem.Table
                                                             select c).ToList();

                foreach (DatabaseSyncConfig_Table table in tableList)
                {
                    List <CommandParameter> parameterList = new List <CommandParameter>();
                    parameterList.Add(new CommandParameter("@primaryKeyValue", syncItem.PrimaryKeyValue));

                    DataSet dataSet = producerDatabase.ExecuteDataSet(
                        $"SELECT * FROM [{table.Name}] WHERE [{table.PrimaryKey}] = @primaryKeyValue",
                        parameterList, new string[] { table.Name });

                    if (dataSet.Tables[0].Rows.Count == 0)
                    {
                        continue;
                    }

                    foreach (DataRow row in dataSet.Tables[0].Rows)
                    {
                        SqlStructureBuild sqlStructureBuild = new SqlStructureBuild();
                        sqlStructureBuild.Table = table.ConsumerTable;

                        switch (syncItem.Action)
                        {
                        case DatabaseSyncAction.Add:
                            sqlStructureBuild.Type = SqlExpressionType.Insert;
                            break;

                        case DatabaseSyncAction.Update:
                            sqlStructureBuild.Type = SqlExpressionType.Update;
                            break;

                        case DatabaseSyncAction.Delete:
                            sqlStructureBuild.Type = SqlExpressionType.Delete;
                            break;

                        default:
                            break;
                        }

                        foreach (DatabaseSyncConfig_Field field in table.Field)
                        {
                            sqlStructureBuild.AddParameter(field.ConsumerField, row[field.Name],
                                                           field.ConsumerField == table.ConsumerTablePrimaryKey);
                        }

                        SqlExpression sqlExpression = sqlStructureBuild.GetSqlExpression();
                        sqlExpressionList.Add(sqlExpression);
                    }
                }
            }

            consumerDatabase.ExcuteSqlExpression(sqlExpressionList);
        }