- from System.Threading.Tasks import Task
- from System.Collections import Hashtable
- import AthletesHelper
- def __afterProgram(graphicOnAirItem, momentExecution):
- if "CurrentEvent" not in graphicOnAirItem.ContextObjects:
- # AthletesHelper.SetMomentExecutionWarning(momentExecution, "No Event Selected!")
- return
- if "Events" not in graphicOnAirItem.ContextObjects:
- # AthletesHelper.SetMomentExecutionWarning(momentExecution, "No Event Selected!")
- return
- if "Header" not in graphicOnAirItem.ContextObjects["CurrentEvent"]:
- # AthletesHelper.SetMomentExecutionWarning(momentExecution, "Event has no Header!")
- return
- if "DocumentCode" not in graphicOnAirItem.ContextObjects["CurrentEvent"]["Header"]:
- # AthletesHelper.SetMomentExecutionWarning(momentExecution, "Event has no DocumentCode!")
- return
- # OBTER TIPO DE PROVA
- documentCode = graphicOnAirItem.ContextObjects["CurrentEvent"]["Header"]["DocumentCode"]
- eventType = None
- if documentCode != "":
- documentCode = documentCode.ToString()
- if documentCode.Contains("HALFMARA"):
- code = "Half-Marathon"
- eventType = "HALFMARA"
- elif documentCode.Contains("MARATHON"):
- code = "Marathon"
- eventType = "MARATHON"
- else:
- # AthletesHelper.SetMomentExecutionWarning(momentExecution, "Event DocumentCode is empty!")
- return
- results = next((dt for dt in DataSourceManager.DataSources if dt.Name == "DT_RESULT"), None)
- if not results:
- return
- allEvents = [(x["Code"].ToString(), x["Gender"].ToString()) for x in graphicOnAirItem.ContextObjects["Events"] if "Code" in x and "Gender" in x and x["Code"].ToString().Contains(eventType)]
- competitionCode = graphicOnAirItem.ContextObjects["CurrentEvent"]["Header"]["CompetitionCode"].ToString()
- allResults = {}
- # IR A TODOS OS DT_RESULT DE TODAS AS PROVAS
- # CRIA DICIONÁRIO COM RESULTS POR GÉNERO
- for evt in allEvents:
- dict = {'CompetitionCode': competitionCode, 'Source': '', 'DocumentCode': evt[0]}
- try:
- genderResults = results.GetData(dict)
- except Exception as e:
- return
- allResults[evt[1]] = genderResults
- # IR A TODOS OS RESULTADOS E PROCURAR O 1º LUGAR NO SPLIT "F" E RETIRAR O TEMPO
- firstPlaces = {}
- for g, result in allResults.items():
- firstPlaces[g] = None
- if "ResultsByRank" not in result: continue
- first = next((x for x in result["ResultsByRank"] if "Stats" in x and "Items" in x["Stats"] and ((y for y in x["Stats"]["Items"] if "Pos" in y and "Rank" in y and y["Rank"].ToString() == "1" and y["Pos"].ToString().upper() == "F"), None)), None)
- if first:
- time = [x["Value"].ToString() for x in first["Stats"]["Items"] if "Value" in x and x["Rank"].ToString() == "1" and x["Pos"].ToString().upper() == "F"]
- if time:
- firstPlaces[g] = time[0]
- if "Gender" not in graphicOnAirItem.ContextObjects["CurrentEvent"]:
- AthletesHelper.SetMomentExecutionWarning(momentExecution, "Unable to get event gender!")
- return
- gender = graphicOnAirItem.ContextObjects["CurrentEvent"]["Gender"]
- if not gender:
- AthletesHelper.SetMomentExecutionWarning(momentExecution, "Gender is empty!")
- return
- gender = gender.ToString()
- extradata = graphicOnAirItem.ExtraData
- extradata["Gender"] = gender
- extradata["Code"] = code
- if "ResultsByRank" not in graphicOnAirItem.ContextObjects["CurrentEvent"] or len(graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"]) < 0:
- AthletesHelper.SetMomentExecutionWarning(momentExecution, "No Results by Rank found in Selected Event!")
- return
- ath = graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"][0]
- if "Stats" in graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"][0]:
- if "Items" in graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"][0]["Stats"] and len(graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"][0]["Stats"]["Items"]) != 0:
- inter = graphicOnAirItem.ContextObjects["CurrentEvent"]["ResultsByRank"][0]["Stats"]["Items"]
- for i in inter:
- pos = i["Pos"]
- value = i["Value"]
- else:
- AthletesHelper.SetMomentExecutionWarning(momentExecution, "Athlete has no splits")
- return
- else:
- AthletesHelper.SetMomentExecutionWarning(momentExecution, "Couldn't read any splits!")
- return
- if "M" in firstPlaces:
- graphicM = "CL FINISH M"
- graphicM = GraphicTemplatesManager.GetGraphicByName(graphicM)
- if not graphicM: return
- if IntelliflowController.IsGraphicOnAir(graphicM, OutputManager.ActiveChannelOutput): return
- dicValuesM = Hashtable()
- dicValuesM.Add("value", firstPlaces["M"])
- TakeIn = lambda: IntelliflowController.TakeIn(graphicM, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program, extraData = dicValuesM)
- if "W" in firstPlaces:
- graphic = "CL FINISH W"
- graphic = GraphicTemplatesManager.GetGraphicByName(graphic)
- if not graphic: return
- if IntelliflowController.IsGraphicOnAir(graphic, OutputManager.ActiveChannelOutput): return
- dicValues = Hashtable()
- dicValues.Add("value", firstPlaces["W"])
- if TakeIn:
- Task.Run(action = TakeIn).ContinueWith(lambda x: IntelliflowController.TakeIn(graphic, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program, extraData = dicValues))
- else:
- Task.Run(action = lambda: IntelliflowController.TakeIn(graphic, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program, extraData = dicValues))
- def __getData(graphicOnAirItem, viewBag, momentExecution):
- extradata = graphicOnAirItem.ExtraData
- AthletesHelper.SetExtraData(extradata, "STOP UPDATE", False)
- def corte(clockName, clock, gender):
- print "CORTE CLOCK"
- graphic = GraphicTemplatesManager.GetGraphicByName(Script.Name)
- if graphic:
- graphicOnAirItems = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput)
- extradata = graphicOnAirItems[0].ExtraData
- # gender = extradata["Gender"]
- gender = gender
- code = extradata["Code"]
- dicValues = Hashtable()
- dicValues.Add("value", clock.ToString())
- codeName = "%s %s" % (code, gender)
- print "b if -> gender %s" % gender
- if clockName.endswith(gender) or clockName.endswith("A"):
- AthletesHelper.SetExtraData(extradata, "STOP UPDATE", True)
- graphic2 = "CL FINISH W" if gender != "M" else "CL FINISH M"
- graphic2 = GraphicTemplatesManager.GetGraphicByName(graphic2)
- if not graphic2: return
- if IntelliflowController.IsGraphicOnAir(graphic2, OutputManager.ActiveChannelOutput): return
- Task.Run(action = lambda: IntelliflowController.TakeIn(graphic2, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program, extraData = dicValues))
- def corteManual(clockVal, gender):
- print "corteManual -> %s" % gender
- graphic = GraphicTemplatesManager.GetGraphicByName(Script.Name)
- if graphic:
- graphicOnAirItems = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput)
- dicValues = Hashtable()
- dicValues.Add("value", clockVal.ToString())
- graphic2 = "CL FINISH W" if gender != "M" else "CL FINISH M"
- graphic2 = GraphicTemplatesManager.GetGraphicByName(graphic2)
- if not graphic2: return
- if IntelliflowController.IsGraphicOnAir(graphic2, OutputManager.ActiveChannelOutput): return
- Task.Run(action = lambda: IntelliflowController.TakeIn(graphic2, OutputManager.ActiveChannelOutput, workflowType = IntelliflowController.EWorkflowType.Program, extraData = dicValues))
Untitled
From Ivory Pintail, 2 Weeks ago, written in Plain Text, viewed 7 times.
This paste will run down the curtain in 1 Week.
URL https://paste.afonso.co/view/b2b553c0
Embed
Download Paste or View Raw
— Expand Paste to full width of browser