Esempio n. 1
0
//getrecPayload to generate the recording payload in JSON using the post value from the form
func getrecPayload(r *http.Request) (comdef.RecordReq, int) {

	var recData comdef.RecordReq

	r.ParseForm()
	recordingID = fmt.Sprintf("XRID-%d-%d", nowTime.Unix(), recEntries)
	ScheduledTime := genCurentTime()

	slice := make([]comdef.RecordData, 1) //Created a slice only for one entry

	slice[0].RecordingID = recordingID
	slice[0].Action = r.PostFormValue("Action")
	slice[0].ScheduledTime = ScheduledTime
	slice[0].AccountID = r.PostFormValue("AccountID")
	slice[0].StartTime = r.PostFormValue("StartTime") //nowTime.Add(time.Duration(1*30) * time.Second).Format(comdef.TimeFrmtStr) //r.PostFormValue("StartTime")
	slice[0].EndTime = r.PostFormValue("EndTime")     //nowTime.Add(time.Duration((2)*30) * time.Second).Format(comdef.TimeFrmtStr)
	slice[0].StreamID = r.PostFormValue("StreamID")
	slice[0].AdZone = r.PostFormValue("azone")
	slice[0].StationID = r.PostFormValue("StationID")
	slice[0].UpdateURL = updateURL //hard coded the scheduler to localhost
	slice[0].ListingID = r.PostFormValue("ListingID")

	numRec, _ = strconv.Atoi(r.PostFormValue("NoOfRec")) //To get the no of recordings to be scheduled

	recData.RequestID = fmt.Sprintf("xxxxxxxx-aaaa-bbbb-cccc-%v", time.Now().UnixNano)
	recData.Entries = slice
	writeRecordData(recData)
	return recData, numRec
}
Esempio n. 2
0
func getstopPayload(stpRecid string) comdef.RecordReq {

	var stpData comdef.RecordReq
	slice := make([]comdef.RecordData, 1)
	nwTime := time.Now()
	for i := range recDataGlb {
		if stpRecid == recDataGlb[i].RecordingID {
			slice[0].Action = "SET"
			slice[0].RecordingID = stpRecid
			slice[0].ScheduledTime = recDataGlb[i].ScheduledTime
			slice[0].AccountID = recDataGlb[i].AccountID
			slice[0].StartTime = recDataGlb[i].StartTime //nowTime.Add(time.Duration(1*30) * time.Second).Format(comdef.TimeFrmtStr) //r.PostFormValue("StartTime")
			slice[0].EndTime = nwTime.Format(comdef.TimeFrmtStr)
			slice[0].StreamID = recDataGlb[i].StreamID
			slice[0].AdZone = recDataGlb[i].AdZone
			slice[0].StationID = recDataGlb[i].StationID
			slice[0].UpdateURL = updateURL //hard coded the scheduler to localhost
			slice[0].ListingID = recDataGlb[i].ListingID

		}
	}
	stpData.RequestID = fmt.Sprintf("xxxxxxxx-aaaa-bbbb-cccc-%v", time.Now().UnixNano)
	stpData.Entries = slice
	return stpData
}
Esempio n. 3
0
func getdelPayload(delRecid string) comdef.RecordReq {
	var delData comdef.RecordReq
	slice := make([]comdef.RecordData, 1)

	for i := range recDataGlb {
		if delRecid == recDataGlb[i].RecordingID {
			slice[0].Action = "REMOVE"
			slice[0].RecordingID = delRecid
			slice[0].ScheduledTime = recDataGlb[i].ScheduledTime
			slice[0].AccountID = recDataGlb[i].AccountID

		}
	}
	delData.RequestID = fmt.Sprintf("xxxxxxxx-aaaa-bbbb-cccc-%v", time.Now().UnixNano)
	delData.Entries = slice
	return delData
}