Beispiel #1
0
func GetMobileClientId(db autorc.Conn, sqlstr string) int {

	println(sqlstr)

	var cliID int

	if stmt, err := db.Prepare(sqlstr); err != nil {

		println(err.Error())

	} else {

		if rows, res, err := stmt.Exec(); err != nil {

			println(err.Error())

		} else {

			for _, row := range rows {

				cliID = row.Int(res.Map("id"))

			}

		}

	}

	println(cliID)

	return cliID

}
Beispiel #2
0
func GetMapAclients(db autorc.Conn, sqlstr string, makeFlag string, golog syslog.Writer) []d.Aclient {

	var aclientsmap []d.Aclient

	if stmt, err := db.Prepare(sqlstr); err != nil {

		golog.Err(err.Error())

	} else {

		if rows, res, err := stmt.Exec(); err != nil {

			golog.Err(err.Error())

		} else {

			aclientsmap = make([]d.Aclient, len(rows))

			for i, row := range rows {

				aclientsmap[i].Id = row.Int(res.Map("id"))
				aclientsmap[i].Phone = row.Str(res.Map("phone"))
				aclientsmap[i].Opcode = row.Str(res.Map("opcode"))
				aclientsmap[i].Nmake = makeFlag
				aclientsmap[i].Nupdatemake = row.Localtime(res.Map("nupdate_make"))

			}

		}
	}

	return aclientsmap

}
Beispiel #3
0
func CheckAclientSql(db autorc.Conn, sqlstr string) []d.AclientCheck {

	fmt.Println(sqlstr)

	var aclientCheck []d.AclientCheck
	if stmt, err := db.Prepare(sqlstr); err != nil {

		fmt.Println(err.Error())
	} else {

		if rows, res, err := stmt.Exec(); err != nil {
			fmt.Println(err.Error())

		} else {

			aclientCheck = make([]d.AclientCheck, len(rows))

			for i, row := range rows {

				aclientCheck[i].Block = row.Int(res.Map("block"))
				aclientCheck[i].Calls = row.Int(res.Map("calls"))
				aclientCheck[i].Ennu = row.Int(res.Map("ennu"))
				aclientCheck[i].Sulje = row.Int(res.Map("sulje"))

			}

		}

	}
	return aclientCheck
}
Beispiel #4
0
func prepareOnce(db *autorc.Conn, stmt *autorc.Stmt, sql string) bool {
	err := db.PrepareOnce(stmt, sql)
	if err == nil {
		return true
	}
	log.Printf("Can't prepare `%s`: %s", sql, err)
	if !autorc.IsNetErr(err) {
		os.Exit(1)
	}
	return false
}
Beispiel #5
0
func InsertSmsRecord(db autorc.Conn, sqlstr string, golog syslog.Writer) {

	if stmt, err := db.Prepare(sqlstr); err != nil {

		golog.Err(err.Error())

	} else {
		if _, _, err := stmt.Exec(); err != nil {

			golog.Err(err.Error())

		}

	}

}
Beispiel #6
0
func InsertMobileClient(db autorc.Conn, sqlstr string) {

	if stmt, err := db.Prepare(sqlstr); err != nil {

		println(err.Error())

	} else {

		if _, _, err := stmt.Exec(); err != nil {

			println(err.Error())

		} else {

			println("New Client arrived!!!")

		}

	}

}
func (self mysqlStorageProvider) get(conn *autorc.Conn, group string) (*GroupInfo, error) {
	errorMsgPrefix := fmt.Sprintf("Occur error when get group info (group=%v)", group)
	rawSql := "select `start`, `step`, `count`, `begin`, `end`, `last_modified` from `%s` where `name`='%s'"
	sql := fmt.Sprintf(rawSql, TABLE_NAME, group)
	row, _, err := conn.QueryFirst(sql)
	if err != nil {
		errorMsg := fmt.Sprintf("%s (sql=%s): %s", errorMsgPrefix, sql, err)
		Logger().Errorln(errorMsg)
		return nil, errors.New(errorMsg)
	}
	if row == nil {
		return nil, nil
	}
	start := row.Uint64(0)
	step := uint32(row.Uint(1))
	count := row.Uint64(2)
	begin := row.Uint64(3)
	end := row.Uint64(4)
	lastModified := row.Time(5, time.Local)
	idRange := IdRange{Begin: begin, End: end}
	groupInfo := GroupInfo{Name: group, Start: start, Step: step, Count: count, Range: idRange, LastModified: lastModified}
	return &groupInfo, nil
}