Example #1
0
        /// <summary>
        /// 记录同步至HC网站redis数据
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="redis"></param>
        /// <param name="dict"></param>
        /// <param name="isSuccess"></param>
        public static void WriteSynchroDataLog(Context ctx, SynchroDataType dataType, IRedisClient redis, Dictionary <string, string> dict, bool isSuccess)
        {
            string sql = string.Empty;

            lock (objLock)
            {
                string insertSql = @"/*dialect*/insert into HS_T_synchroDataLog(SynchroDataType,redisKey,json,redisServerIP,redisDBID,K3CloudDbId
                                    ,createTime,success) values
                        
                                    ";

                if (dict != null && dict.Count > 0)
                {
                    for (int i = 0; i < dict.Count; i++)
                    {
                        if (i < dict.Count - 1)
                        {
                            sql += insertSql + string.Format(@"('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", dataType, dict.ElementAt(i).Key, SQLUtils.DealQuotes(dict.ElementAt(i).Value), redis.Host, redis.Db, ctx.DBId, DateTime.Now, isSuccess ? 1 : 0) + Environment.NewLine;
                        }
                        else
                        {
                            sql += insertSql + string.Format(@"('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", dataType, dict.ElementAt(i).Key, SQLUtils.DealQuotes(dict.ElementAt(i).Value), redis.Host, redis.Db, ctx.DBId, DateTime.Now, isSuccess ? 1 : 0);
                        }
                    }

                    Kingdee.BOS.App.ServiceHelper.GetService <IDBService>().Execute(ctx, sql);
                }
            }
        }