Пример #1
0
        public int SaveLog(List <CoetLogInfoEntity> logInfoList)
        {
            try
            {
                string tableName = LogTable.GetCurrentLogTName();

                int executeCount = 0;
                int levelCount   = 200;
                int partCount    = 1;

                if (logInfoList.Count > levelCount)
                {
                    partCount = logInfoList.Count / levelCount;
                }
                List <List <CoetLogInfoEntity> > partList = CoetArry.splitList(logInfoList, partCount);

                foreach (var part in partList)
                {
                    StringBuilder sb = new StringBuilder();

                    foreach (var item in part)
                    {
                        sb.AppendFormat(@"insert into {0}(Type, JsonInfo, SendIP, SendName, IdentificationId, Createdt) value('{1}', '{2}', '{3}', '{4}', '{5}', now());",
                                        tableName, item.Type, item.JsonInfo, item.SendIP, item.SendName, Guid.NewGuid().ToString());
                    }

                    executeCount += DBOperate.ExecuteNonQuery(sb.ToString(), new { });
                }

                return(executeCount);
            }
            catch (Exception ex)
            {
                CoetLocalLog.Error(ex.ToString());
                return(0);
            }
        }