Пример #1
0
        // 插入一批日志记录
        int AppendOperLogLines(
            SQLiteConnection connection,
            List <OperLogLine> lines,
            out string strError)
        {
            strError = "";

            using (SQLiteCommand command = new SQLiteCommand("",
                                                             connection))
            {
                StringBuilder text = new StringBuilder(4096);
                int           i    = 0;
                foreach (OperLogLine line in lines)
                {
                    text.Append(
                        " INSERT INTO records(operation, action, itembarcode, location, readerbarcode, librarycode, opertime) "
                        + " VALUES(@operation" + i
                        + ", @action" + i
                        + ", @itembarcode" + i
                        + ", @location" + i
                        + ", @readerbarcode" + i
                        + ", @librarycode" + i
                        + ", @opertime" + i + ")"
                        + " ; ");
                    SQLiteUtil.SetParameter(command,
                                            "@operation" + i,
                                            line.Operation);
                    SQLiteUtil.SetParameter(command,
                                            "@action" + i,
                                            line.Action);

                    SQLiteUtil.SetParameter(command,
                                            "@itembarcode" + i,
                                            line.ItemBarcode);

                    SQLiteUtil.SetParameter(command,
                                            "@location" + i,
                                            line.ItemLocation);

                    SQLiteUtil.SetParameter(command,
                                            "@librarycode" + i,
                                            line.LibraryCode);

                    SQLiteUtil.SetParameter(command,
                                            "@opertime" + i,
                                            line.OperTime);

                    i++;
                }

                command.CommandText = text.ToString();
                int nCount = command.ExecuteNonQuery();
            }

            return(0);
        }