private void GiveFeedback(FeedbackCallback feedbackCallback, string message) { if (feedbackCallback != null) { feedbackCallback(message); } }
public void PrepareImport(FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { if (ConfigInstance.Current.LaunchClickFinderBeforeImport) { try { GiveFeedback(feedbackCallback, "Launch ClickFinder to retrieve uptodate data ..."); string tvUptodatePath = ConfigInstance.Current.TvUptodatePath; keepImportServiceAliveCallback(); ProcessStartInfo startInfo = new ProcessStartInfo(tvUptodatePath); startInfo.WorkingDirectory = Path.GetDirectoryName(Path.GetDirectoryName(tvUptodatePath)); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.WindowStyle = ProcessWindowStyle.Hidden; using (Process process = Process.Start(startInfo)) { process.WaitForExit(_timeout); if (!process.HasExited) { EventLogger.WriteEntry("ClickFinder tvuptodate still running, check your config.", EventLogEntryType.Error); } } GiveFeedback(feedbackCallback, "ClickFinder updated successfully !"); keepImportServiceAliveCallback(); } catch (Exception ex) { EventLogger.WriteEntry(ex); } } }
public CommStateMachine(AActionGoal actionGoal, TransitionCallback <ActionSpec> transitionCallback, FeedbackCallback <ActionSpec> feedbackCallback) { UnityEngine.Debug.Assert(actionGoal != null); this.actionGoal = actionGoal; this.transitionCallback = transitionCallback; this.feedbackCallback = feedbackCallback; state = CommState.StateEnum.WAITING_FOR_GOAL_ACK; }
private void GiveFeedback(FeedbackCallback feedbackCallback, string message) { Logger.Write(FormatForLogger(message)); if (feedbackCallback != null) { feedbackCallback(message); } }
public void Import(string pluginName, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { try { LogMessageInArgusTV(String.Format("Guide import, using plugin {0} started.", pluginName), LogSeverity.Information); IGuideImportPlugin plugin = GetPluginByName(pluginName); if (plugin != null) { if (!plugin.IsConfigured()) { LogMessageInArgusTV(String.Format("Plugin {0} is not completely configured, check it's configuration.", pluginName), LogSeverity.Error); } else { plugin.PrepareImport(feedbackCallback, new KeepImportServiceAliveCallback(KeepImportServiceAlive)); using (GuideServiceAgent guideAgent = new GuideServiceAgent()) { guideAgent.StartGuideImport(); try { PluginSetting pluginSetting = GetPluginSetting(pluginName); plugin.Import(pluginSetting.ChannelsToSkip, new ImportDataCallback(SaveGuideDataInArgusTV), progressCallback, feedbackCallback, new KeepImportServiceAliveCallback(KeepImportServiceAlive)); } finally { guideAgent.EndGuideImport(); } } } } else { LogMessageInArgusTV(String.Format("Plugin {0} not found, check your configuration.", pluginName), LogSeverity.Error); } } catch (Exception ex) { LogMessageInArgusTV(String.Format("Guide import using plugin {0} failed, error : {1}", pluginName, ex.Message), LogSeverity.Error); throw; } finally { LogMessageInArgusTV(String.Format("Guide import using plugin {0} ended.", pluginName), LogSeverity.Information); } }
/// <summary> /// Return a list of channels for the GUI to display /// </summary> /// <param name="reload"></param> /// <param name="progressCallback"></param> /// <param name="feedbackCallback"></param> /// <returns></returns> public List <ImportGuideChannel> GetAllImportChannels( bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { List <ImportGuideChannel> ligc = new List <ImportGuideChannel>(); if (reload) { try { GiveFeedback(feedbackCallback, "Calling SchedulesDirect JSON WebService ..."); WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword); List <AssignedLineupsResponse.Lineup> lineups = wc.getAssignedLineups(tr); GiveFeedback(feedbackCallback, "Got the lineups.... " + lineups.Count + " lineup assigned"); foreach (AssignedLineupsResponse.Lineup lu in lineups) { GiveFeedback(feedbackCallback, "Get channels for " + lu.name); LineupInfoResponse liur = wc.getLineupInfo(tr, lu.uri); GiveFeedback(feedbackCallback, "Got a bunch of channels: " + liur.stations.Count); List <ImportGuideChannel> localLigc = ChannelFactory.makeImportChannels(liur, ConfigInstance.Current.ChannelNameFormat); ligc.AddRange(localLigc); } GuideChannelStore.Save(AvailableChannelsConfigFile, ligc); } catch (Exception ex) { Logger.Error("Had a problem importing channels: {0}\n{1}", ex.Message, ex.StackTrace); throw; } } else { // read from file List <ImportGuideChannel> availableGuideChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); ligc.AddRange(availableGuideChannels); } return(ligc); }
public void PrepareImport(FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { }
public void Import(List <ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { keepImportServiceAliveCallback(); DateTime todeey = DateTime.Now; DateTime startDate = todeey; DateTime endDate = todeey.AddDays(ConfigInstance.Current.NrOfDaysToImport); if (ConfigInstance.Current.UpdateMode == Config.UpDateMode.NextDayOnly) { endDate = startDate; DateTime lastImportedDay = ConvertIntAsDateTime(ConfigInstance.Current.LastImportedDay); if (lastImportedDay > startDate) { Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : Calling Import for updates for one day : " + startDate.ToLongTimeString())); Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate, true), ConvertEndDateTimeToString(startDate.AddHours(25), true)); Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : End of one day Import")); startDate = lastImportedDay; } endDate = todeey.AddDays(ConfigInstance.Current.NrOfDaysToImport); if (endDate > startDate) { Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : Calling Import for new data : " + startDate.ToLongTimeString())); Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate), ConvertEndDateTimeToString(endDate)); } } else { Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate), ConvertEndDateTimeToString(endDate)); } Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : End of new data Import")); ConfigInstance.Current.LastImportedDay = ConvertDateTimeAsDateInt(endDate); ConfigInstance.Save(); }
/** * \brief Sends a goal to the ActionServer, and also registers callbacks * \param transitionCallback Callback that gets called on every client state transition * \param feedbackCallback Callback that gets called whenever feedback for this goal is received */ public ClientGoalHandle <ActionSpec> sendGoal <TGoal> (TGoal goal, TransitionCallback <ActionSpec> transitionCallback, FeedbackCallback <ActionSpec> feedbackCallback) where TGoal : AGoal { ROS.Debug("actionlib", "about to start initGoal()"); ClientGoalHandle <ActionSpec> gh = goalManager.initGoal(goal, transitionCallback, feedbackCallback); ROS.Debug("actionlib", "Done with initGoal()"); return(gh); }
/// <summary> /// Do the actual guide update /// </summary> /// <param name="skipChannels"></param> /// <param name="importDataCallback"></param> /// <param name="progressCallback"></param> /// <param name="feedbackCallback"></param> /// <param name="keepImportServiceAliveCallback"></param> public void Import( List <ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { try { GiveFeedback(feedbackCallback, "Staring SD JSON guide data import..."); DateTime importStart = DateTime.Now; if (progressCallback != null) { progressCallback(0); } keepImportServiceAliveCallback(); // get station list List <string> stationIdList = getStationIdList(skipChannels); Logger.Info("Getting guide data for {0} channels", stationIdList.Count); WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword); // make sure SD site is online StatusResponse status = wc.getStatus(tr); if (status != null && status.systemStatus != null) { string st = status.systemStatus[0].status.ToLower(); if (!"online".Equals(st)) { Logger.Error("The SD server is not online: {0} - {1) - {2}", status.serverID, status.systemStatus[0].status, status.systemStatus[0].details); throw new SystemException("The SD Server is not online. See log for details"); } } // get lineup info GiveFeedback(feedbackCallback, "Getting channel information..."); List <LineupInfoResponse> llir = wc.getAssignedLineupInfoList(tr); // map is keyed by stationId or externalId... the number that SD uses to identify the channel Dictionary <string, ImportGuideChannel> digc = ChannelFactory.makeImportChannelMap(llir, ConfigInstance.Current.ChannelNameFormat); // SD asks that no more than 5000 stations be queried at once // ignore this for now as not many will have 5000+ channels GiveFeedback(feedbackCallback, "Getting schedules..."); Logger.Info("Get schedules for {0} days", ConfigInstance.Current.NrOfDaysToImport); // lsr contains the schedules for a station for a single day List <SchedulesResponse> lsr = wc.getSchedules(tr, stationIdList, ConfigInstance.Current.NrOfDaysToImport); // combine all days' schedules into one entry for each station Dictionary <string, SchedulesResponse> srMap = new Dictionary <string, SchedulesResponse>(); // 1) Get all programs at once // make a global HashSet of program IDs and populate ScheduleResponse map HashSet <string> globalProgramSet = new HashSet <string>(); foreach (SchedulesResponse sr in lsr) { if (sr.programs != null) { // make list of program IDs to get foreach (SchedulesResponse.Program pg in sr.programs) { // we only get a programID once, even if it's on multiple schedules globalProgramSet.Add(pg.programID); } // populate map of schedule responses if (srMap.ContainsKey(sr.stationID)) { srMap[sr.stationID].programs.AddRange(sr.programs); } else { srMap.Add(sr.stationID, sr); } } } Logger.Info("There are {0} programs in this timeframe", globalProgramSet.Count); // take the programs in chunks of _programBlockSize... value below 5000 // SD won't allow a query of more than 5000 programs at once int progLoops = globalProgramSet.Count / _programBlockSize; int progsInFinalLoop = globalProgramSet.Count % _programBlockSize; if (progsInFinalLoop > 0) { progLoops++; } // this map will contain *all* program responses across all stations Dictionary <string, ProgramResponseInstance> globalProgramResponseMap = new Dictionary <string, ProgramResponseInstance>(); // keep a list for navigating in for loop List <string> globalProgramList = new List <string>(); globalProgramList.AddRange(globalProgramSet); GiveFeedback(feedbackCallback, "About to get program information for all programs..."); for (int i = 0; i < progLoops; i++) { // is this the last loop? int blockSize = _programBlockSize; if (i == progLoops - 1) { blockSize = progsInFinalLoop; } string message = string.Format("Getting program information for items {0} to {1}", i * _programBlockSize + 1, (i * _programBlockSize) + blockSize); GiveFeedback(feedbackCallback, message); List <string> programSubset = globalProgramList.GetRange(i * _programBlockSize, blockSize); List <ProgramResponseInstance> lpri = wc.getPrograms(tr, programSubset); if (lpri != null) { foreach (ProgramResponseInstance pri in lpri) { globalProgramResponseMap.Add(pri.programID, pri); } } } // tackle each station at a time... int count = 1; foreach (SchedulesResponse sr in srMap.Values) { keepImportServiceAliveCallback(); List <GuideProgram> lgp = new List <GuideProgram>(); try { // take the schedules and programs and create the guide programs to put into Argus // in a try block to catch issues with programfactory lgp = ProgramFactory.makeGuidePrograms(globalProgramResponseMap, sr); } catch (Exception ex) { Logger.Error("Could not extract program information: {0}", ex.StackTrace); throw; } ImportGuideChannel currentGuideChannel = digc[sr.stationID]; double percentDone = 100 * ((double)count / srMap.Values.Count); int percentInt = Convert.ToInt32(percentDone); if (progressCallback != null) { progressCallback(percentInt); } string programMessage = string.Format("Processing station: {0}, ID: {1}, Program Count: {2}, {3} done", digc[sr.stationID].ChannelName, sr.stationID, sr.programs.Count, string.Format("{0}%", percentInt)); GiveFeedback(feedbackCallback, programMessage); // save the programs in the Argus db importDataCallback( currentGuideChannel, ChannelType.Television, lgp.ToArray(), ConfigInstance.Current.UpdateChannelNames); count++; } DateTime endTime = DateTime.Now; TimeSpan ts = endTime.Subtract(importStart); int seconds = ts.Seconds; int minutes = ts.Minutes; int hours = ts.Hours; Logger.Info("Import complete. Took {0} hours, {1} minutes and {2} seconds", hours, minutes, seconds); Logger.Info("Channels processed: {0}", srMap.Values.Count); GiveFeedback(feedbackCallback, "Completed SD JSON guide data import."); } catch (Exception ex) { Logger.Error("There was an error importing the guide data: {0}/n{1}", ex.Message, ex.StackTrace); throw; } }
public static FeedbackCallback SendFeedback(string _eventName, Object _target, Vector3 _eventPosition, Vector3 _eventDirection, Vector3 _eventNormal, bool _onlyFX = false) { //Data initianilisation FeedbackCallback i_callBack = new FeedbackCallback(); FeedbackData i_feedback = GetFeedbackData(_eventName); if (i_feedback == null) { return(i_callBack); } Component target = _target as Component; //Shake camera if (i_feedback.shakeData != null && i_feedback.shakeDataInited && !_onlyFX) { CameraShaker.ShakeCamera(i_feedback.shakeData.intensity, i_feedback.shakeData.duration, i_feedback.shakeData.frequency, i_feedback.shakeData.intensityCurve); } //Vibrate gamepad if (i_feedback.vibrationData != null && i_feedback.vibrationDataInited && !_onlyFX) { switch (i_feedback.vibrationData.target) { case VibrationTarget.TargetedPlayer: if (_target == null) { Debug.LogWarning("Can't make target vibrate"); break; } Component component; target.TryGetComponent(typeof(PlayerController), out component); PlayerController player = (PlayerController)component; if (player != null) { VibrationManager.Vibrate(player.playerIndex, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve); } break; case VibrationTarget.BothPlayers: VibrationManager.Vibrate(PlayerIndex.One, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve); VibrationManager.Vibrate(PlayerIndex.Two, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve); break; } } //Play sound if (i_feedback.soundData != null && i_feedback.soundDataInited && !_onlyFX) { Component newTarget = target; if (newTarget == null) { newTarget = GameManager.mainCamera; } SoundData i_modifiedSoundData = new SoundData(); i_modifiedSoundData.soundName = i_feedback.soundData.soundName; i_modifiedSoundData.soundList = i_feedback.soundData.soundList; i_modifiedSoundData.delay = i_feedback.soundData.delay; i_modifiedSoundData.volumeMultiplier = i_feedback.soundData.volumeMultiplier * PlayerPrefs.GetFloat("REU_SFX Volume", fXVolumeSettingsMod); SoundManager.PlaySound(i_modifiedSoundData, newTarget.transform.position, newTarget.transform); } //Generate FX if (i_feedback.vfxData != null && i_feedback.vfxDataInited && i_feedback.vfxData.vfxPrefab != null) { Vector3 direction = Vector3.zero; switch (i_feedback.vfxData.direction) { case VFXDirection.Default: direction = new Vector3(0, 0, 0); break; case VFXDirection.EventDirection: direction = _eventDirection; break; case VFXDirection.EventNormal: direction = _eventNormal; break; case VFXDirection.LocalForward: direction = target.transform.forward; break; case VFXDirection.WorldUp: direction = new Vector3(0, 1, 0); break; } Transform newParent = null; Vector3 position = _eventPosition; switch (i_feedback.vfxData.position) { case VFXPosition.EventObject: position = target.transform.position; break; } if (i_feedback.vfxData.attachToTarget) { newParent = target.transform; } i_callBack.vfx = FXManager.InstantiateFX(i_feedback.vfxData.vfxPrefab, position + i_feedback.vfxData.offset, false, direction, i_feedback.vfxData.scaleMultiplier, newParent); } return(i_callBack); }
public ClientGoalHandle <ActionSpec> initGoal <TGoal> (TGoal goal, TransitionCallback <ActionSpec> transitionCallback, FeedbackCallback <ActionSpec> feedbackCallback) where TGoal : AGoal { AActionGoal actionGoal = new ActionSpec().NewActionGoal(); // AActionGoal actionGoal = new AActionGoal (); actionGoal.Header.Stamp = ROS.GetTime(); actionGoal.GoalID = idGenerator.generateID(); actionGoal.Goal = goal; // actionGoal.header.Stamp = ROS.GetTime (); // actionGoal.goal_id = idGenerator.generateID (); // actionGoal.goal = goal; CommStateMachine <ActionSpec> commStateMachine = new CommStateMachine <ActionSpec> (actionGoal, transitionCallback, feedbackCallback); lock ( lockObject ) { var handle = list.Add(commStateMachine); if (sendGoalDelegate != null) { sendGoalDelegate(actionGoal); } else { ROS.Warn("actionlib", "Possible coding error: sendGoalDelegate set to NULL. Not going to send goal"); } return(new ClientGoalHandle <ActionSpec> (this, handle, guard)); } }
/// <summary> /// Do the actual guide update /// </summary> /// <param name="skipChannels"></param> /// <param name="importDataCallback"></param> /// <param name="progressCallback"></param> /// <param name="feedbackCallback"></param> /// <param name="keepImportServiceAliveCallback"></param> public void Import( List<ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { try { GiveFeedback(feedbackCallback,"Staring SD JSON guide data import..."); DateTime importStart = DateTime.Now; if (progressCallback != null) { progressCallback(0); } keepImportServiceAliveCallback(); // get station list List<string> stationIdList = getStationIdList(skipChannels); Logger.Info("Getting guide data for {0} channels", stationIdList.Count); WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword); // make sure SD site is online StatusResponse status = wc.getStatus(tr); if (status != null && status.systemStatus != null) { string st = status.systemStatus[0].status.ToLower(); if (!"online".Equals(st)) { Logger.Error("The SD server is not online: {0} - {1) - {2}", status.serverID, status.systemStatus[0].status, status.systemStatus[0].details); throw new SystemException("The SD Server is not online. See log for details"); } } // get lineup info GiveFeedback(feedbackCallback, "Getting channel information..."); List<LineupInfoResponse> llir = wc.getAssignedLineupInfoList(tr); // map is keyed by stationId or externalId... the number that SD uses to identify the channel Dictionary<string,ImportGuideChannel> digc = ChannelFactory.makeImportChannelMap(llir, ConfigInstance.Current.ChannelNameFormat); // SD asks that no more than 5000 stations be queried at once // ignore this for now as not many will have 5000+ channels GiveFeedback(feedbackCallback, "Getting schedules..."); Logger.Info("Get schedules for {0} days", ConfigInstance.Current.NrOfDaysToImport); // lsr contains the schedules for a station for a single day List<SchedulesResponse> lsr = wc.getSchedules(tr, stationIdList, ConfigInstance.Current.NrOfDaysToImport); // combine all days' schedules into one entry for each station Dictionary<string, SchedulesResponse> srMap = new Dictionary<string, SchedulesResponse>(); // 1) Get all programs at once // make a global HashSet of program IDs and populate ScheduleResponse map HashSet<string> globalProgramSet = new HashSet<string>(); foreach (SchedulesResponse sr in lsr) { if (sr.programs != null) { // make list of program IDs to get foreach (SchedulesResponse.Program pg in sr.programs) { // we only get a programID once, even if it's on multiple schedules globalProgramSet.Add(pg.programID); } // populate map of schedule responses if (srMap.ContainsKey(sr.stationID)) { srMap[sr.stationID].programs.AddRange(sr.programs); } else { srMap.Add(sr.stationID, sr); } } } Logger.Info("There are {0} programs in this timeframe", globalProgramSet.Count); // take the programs in chunks of _programBlockSize... value below 5000 // SD won't allow a query of more than 5000 programs at once int progLoops = globalProgramSet.Count / _programBlockSize; int progsInFinalLoop = globalProgramSet.Count % _programBlockSize; if (progsInFinalLoop > 0) { progLoops++; } // this map will contain *all* program responses across all stations Dictionary<string,ProgramResponseInstance> globalProgramResponseMap = new Dictionary<string, ProgramResponseInstance>(); // keep a list for navigating in for loop List<string> globalProgramList = new List<string>(); globalProgramList.AddRange(globalProgramSet); GiveFeedback(feedbackCallback,"About to get program information for all programs..."); for (int i = 0; i < progLoops; i++) { // is this the last loop? int blockSize = _programBlockSize; if (i == progLoops - 1) { blockSize = progsInFinalLoop; } string message = string.Format("Getting program information for items {0} to {1}", i * _programBlockSize + 1, (i * _programBlockSize) + blockSize); GiveFeedback(feedbackCallback, message); List<string> programSubset = globalProgramList.GetRange(i * _programBlockSize, blockSize); List<ProgramResponseInstance> lpri = wc.getPrograms(tr, programSubset); if (lpri != null) { foreach (ProgramResponseInstance pri in lpri) { globalProgramResponseMap.Add(pri.programID, pri); } } } // tackle each station at a time... int count = 1; foreach (SchedulesResponse sr in srMap.Values) { keepImportServiceAliveCallback(); List<GuideProgram> lgp = new List<GuideProgram>(); try { // take the schedules and programs and create the guide programs to put into Argus // in a try block to catch issues with programfactory lgp = ProgramFactory.makeGuidePrograms(globalProgramResponseMap, sr); } catch (Exception ex) { Logger.Error("Could not extract program information: {0}", ex.StackTrace); throw; } ImportGuideChannel currentGuideChannel = digc[sr.stationID]; double percentDone = 100 * ((double)count/srMap.Values.Count); int percentInt = Convert.ToInt32(percentDone); if (progressCallback != null) { progressCallback(percentInt); } string programMessage = string.Format("Processing station: {0}, ID: {1}, Program Count: {2}, {3} done", digc[sr.stationID].ChannelName, sr.stationID, sr.programs.Count, string.Format("{0}%",percentInt)); GiveFeedback(feedbackCallback, programMessage); // save the programs in the Argus db importDataCallback( currentGuideChannel, ChannelType.Television, lgp.ToArray(), ConfigInstance.Current.UpdateChannelNames); count++; } DateTime endTime = DateTime.Now; TimeSpan ts = endTime.Subtract(importStart); int seconds = ts.Seconds; int minutes = ts.Minutes; int hours = ts.Hours; Logger.Info("Import complete. Took {0} hours, {1} minutes and {2} seconds", hours, minutes, seconds); Logger.Info("Channels processed: {0}", srMap.Values.Count); GiveFeedback(feedbackCallback,"Completed SD JSON guide data import."); } catch (Exception ex) { Logger.Error("There was an error importing the guide data: {0}/n{1}", ex.Message, ex.StackTrace); throw; } }
/// <summary> /// Return a list of channels for the GUI to display /// </summary> /// <param name="reload"></param> /// <param name="progressCallback"></param> /// <param name="feedbackCallback"></param> /// <returns></returns> public List<ImportGuideChannel> GetAllImportChannels( bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { List<ImportGuideChannel> ligc = new List<ImportGuideChannel>(); if (reload) { try { GiveFeedback(feedbackCallback, "Calling SchedulesDirect JSON WebService ..."); WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword); List<AssignedLineupsResponse.Lineup> lineups = wc.getAssignedLineups(tr); GiveFeedback(feedbackCallback, "Got the lineups.... " + lineups.Count + " lineup assigned"); foreach (AssignedLineupsResponse.Lineup lu in lineups) { GiveFeedback(feedbackCallback, "Get channels for " + lu.name); LineupInfoResponse liur = wc.getLineupInfo(tr, lu.uri); GiveFeedback(feedbackCallback, "Got a bunch of channels: " + liur.stations.Count); List<ImportGuideChannel> localLigc = ChannelFactory.makeImportChannels(liur, ConfigInstance.Current.ChannelNameFormat); ligc.AddRange(localLigc); } GuideChannelStore.Save(AvailableChannelsConfigFile, ligc); } catch (Exception ex) { Logger.Error("Had a problem importing channels: {0}\n{1}", ex.Message, ex.StackTrace); throw; } } else { // read from file List<ImportGuideChannel> availableGuideChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); ligc.AddRange(availableGuideChannels); } return ligc; }
public void Import(List <ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { List <ImportGuideChannel> channelsToImport = GetAllImportChannels(skipChannels); int importedCount = 0; DateTime _lastKeepAliveTime = DateTime.Now; foreach (ImportGuideChannel channel in channelsToImport) { if (!skipChannels.Contains(channel)) { GiveFeedback(feedbackCallback, String.Format("Importing channel {0}.", channel.ChannelName)); List <GuideProgram> guideData = _dbReader.GetGuideDataByClickFinderChannel(channel); importDataCallback(channel, ChannelType.Television, guideData.ToArray(), false); } importedCount++; int procentDone = ((100 * importedCount) / channelsToImport.Count); if (progressCallback != null) { progressCallback(procentDone); } if ((procentDone % 5) == 0) { Trace.WriteLine(String.Format("Progress : {0} % done.", procentDone)); } if (_lastKeepAliveTime.AddSeconds(_keepAliveIntervalSeconds) <= DateTime.Now) { keepImportServiceAliveCallback(); _lastKeepAliveTime = DateTime.Now; } } }
private void GiveFeedback(FeedbackCallback feedbackCallback, string message) { Logger.Write(FormatForLogger(message)); if(feedbackCallback != null) { feedbackCallback(message); } }
private void Import(List<ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback, string startDate, string endDate ) { GiveFeedback(feedbackCallback, "Calling SchedulesDirect WebService ..."); if (progressCallback != null) { progressCallback(0); } keepImportServiceAliveCallback(); xtvdResponse response = CallSchedulesDirectWebService(startDate, endDate); if (response != null) { GiveFeedback(feedbackCallback, "Processing SchedulesDirect data ..."); //DataDumper.DumpResponse(response, @"d:\steph\temp\response.txt"); keepImportServiceAliveCallback(); // Process results, create dictionaries for easier access // Stations Dictionary<int, ImportGuideChannel> guideChannels = BuildImportGuideChannelDictionary(response, ConfigInstance.Current.ChannelNameFormat); GuideChannelStore.Save(AvailableChannelsConfigFile, new List<ImportGuideChannel>(guideChannels.Values)); // Programs Dictionary<string, Program> programs = BuildProgramsDictionary(response); // Add genres to programs AddGenresToPrograms(response, programs); // Add actors and directors to programs AddActorsAndDirectorsToPrograms(response, programs); // Start the real import : List<GuideProgram> guideData = new List<GuideProgram>(); ImportGuideChannel currentGuideChannel = new ImportGuideChannel(String.Empty, String.Empty); int importedCount = 0; int procentDone = 0; foreach (schedulesSchedule schedule in response.xtvd.schedules) { if (guideChannels.ContainsKey(schedule.station) && !skipChannels.Contains(guideChannels[schedule.station])) { if (!currentGuideChannel.ExternalId.Equals(schedule.station.ToString())) { if (guideData.Count > 0) { GiveFeedback(feedbackCallback, String.Format("Importing channel {0}, {1} schedule(s).", currentGuideChannel.ChannelName, guideData.Count)); importDataCallback(currentGuideChannel, ChannelType.Television, guideData.ToArray(), ConfigInstance.Current.UpdateChannelNames); guideData = new List<GuideProgram>(); } currentGuideChannel = guideChannels[schedule.station]; } if (programs.ContainsKey(schedule.program)) { GuideProgram guideProgram = FillGuideProgram(schedule, programs[schedule.program]); if (guideProgram != null) { guideData.Add(guideProgram); } else { Logger.Write(FormatForLogger("FillGuideProgram returned null for schedule program : " + schedule.program)); } } else { Logger.Write(FormatForLogger("FillGuideProgram : unknown schedule program : " + schedule.program)); } } importedCount++; int currentProcentDone = ((100 * importedCount) / response.xtvd.schedules.Length); if (currentProcentDone != procentDone) { procentDone = currentProcentDone; if (progressCallback != null) { progressCallback(procentDone); } else if ((procentDone % 5) == 0) { Logger.Write(FormatForLogger(String.Format("Progress : {0} % done.", procentDone))); } } } if (guideData.Count > 0) { importDataCallback(currentGuideChannel, ChannelType.Television, guideData.ToArray(), ConfigInstance.Current.UpdateChannelNames); } } }
public List<ImportGuideChannel> GetAllImportChannels(bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { return _dbReader.GetAllImportChannels(); }
public void Import(List<ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { List<ImportGuideChannel> channelsToImport = GetAllImportChannels(skipChannels); int importedCount = 0; DateTime _lastKeepAliveTime = DateTime.Now; foreach (ImportGuideChannel channel in channelsToImport) { if (!skipChannels.Contains(channel)) { GiveFeedback(feedbackCallback, String.Format("Importing channel {0}.", channel.ChannelName)); List<GuideProgram> guideData = _dbReader.GetGuideDataByClickFinderChannel(channel); importDataCallback(channel, ChannelType.Television, guideData.ToArray(), false); } importedCount++; int procentDone = ((100 * importedCount) / channelsToImport.Count); if (progressCallback != null) { progressCallback(procentDone); } if((procentDone % 5)==0) { Trace.WriteLine(String.Format("Progress : {0} % done.", procentDone)); } if (_lastKeepAliveTime.AddSeconds(_keepAliveIntervalSeconds) <= DateTime.Now) { keepImportServiceAliveCallback(); _lastKeepAliveTime = DateTime.Now; } } }
public List<ImportGuideChannel> GetAllImportChannels(bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { if (reload) { GiveFeedback(feedbackCallback, "Calling SchedulesDirect WebService ..."); xtvdResponse response = CallSchedulesDirectWebService(ConvertStartDateTimeToString(DateTime.Now), ConvertEndDateTimeToString(DateTime.Now)); if (response != null) { GiveFeedback(feedbackCallback, "Processing retrieved SchedulesDirect channels ..."); Dictionary<int, ImportGuideChannel> tvGuideChannels = BuildImportGuideChannelDictionary(response, ConfigInstance.Current.ChannelNameFormat); GuideChannelStore.Save(AvailableChannelsConfigFile, new List<ImportGuideChannel>(tvGuideChannels.Values)); } } List<ImportGuideChannel> availableGuideChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); return availableGuideChannels; }
private void Import(List <ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback, string startDate, string endDate) { GiveFeedback(feedbackCallback, "Calling SchedulesDirect WebService ..."); if (progressCallback != null) { progressCallback(0); } keepImportServiceAliveCallback(); xtvdResponse response = CallSchedulesDirectWebService(startDate, endDate); if (response != null) { GiveFeedback(feedbackCallback, "Processing SchedulesDirect data ..."); //DataDumper.DumpResponse(response, @"d:\steph\temp\response.txt"); keepImportServiceAliveCallback(); // Process results, create dictionaries for easier access // Stations Dictionary <int, ImportGuideChannel> guideChannels = BuildImportGuideChannelDictionary(response, ConfigInstance.Current.ChannelNameFormat); GuideChannelStore.Save(AvailableChannelsConfigFile, new List <ImportGuideChannel>(guideChannels.Values)); // Programs Dictionary <string, Program> programs = BuildProgramsDictionary(response); // Add genres to programs AddGenresToPrograms(response, programs); // Add actors and directors to programs AddActorsAndDirectorsToPrograms(response, programs); // Start the real import : List <GuideProgram> guideData = new List <GuideProgram>(); ImportGuideChannel currentGuideChannel = new ImportGuideChannel(String.Empty, String.Empty); int importedCount = 0; int procentDone = 0; foreach (schedulesSchedule schedule in response.xtvd.schedules) { if (guideChannels.ContainsKey(schedule.station) && !skipChannels.Contains(guideChannels[schedule.station])) { if (!currentGuideChannel.ExternalId.Equals(schedule.station.ToString())) { if (guideData.Count > 0) { GiveFeedback(feedbackCallback, String.Format("Importing channel {0}, {1} schedule(s).", currentGuideChannel.ChannelName, guideData.Count)); importDataCallback(currentGuideChannel, ChannelType.Television, guideData.ToArray(), ConfigInstance.Current.UpdateChannelNames); guideData = new List <GuideProgram>(); } currentGuideChannel = guideChannels[schedule.station]; } if (programs.ContainsKey(schedule.program)) { GuideProgram guideProgram = FillGuideProgram(schedule, programs[schedule.program]); if (guideProgram != null) { guideData.Add(guideProgram); } else { Logger.Write(FormatForLogger("FillGuideProgram returned null for schedule program : " + schedule.program)); } } else { Logger.Write(FormatForLogger("FillGuideProgram : unknown schedule program : " + schedule.program)); } } importedCount++; int currentProcentDone = ((100 * importedCount) / response.xtvd.schedules.Length); if (currentProcentDone != procentDone) { procentDone = currentProcentDone; if (progressCallback != null) { progressCallback(procentDone); } else if ((procentDone % 5) == 0) { Logger.Write(FormatForLogger(String.Format("Progress : {0} % done.", procentDone))); } } } if (guideData.Count > 0) { importDataCallback(currentGuideChannel, ChannelType.Television, guideData.ToArray(), ConfigInstance.Current.UpdateChannelNames); } } }
public void Import(List<ImportGuideChannel> skipChannels, ImportDataCallback importDataCallback, ProgressCallback progressCallback, FeedbackCallback feedbackCallback, KeepImportServiceAliveCallback keepImportServiceAliveCallback) { keepImportServiceAliveCallback(); DateTime todeey = DateTime.Now; DateTime startDate = todeey; DateTime endDate = todeey.AddDays(ConfigInstance.Current.NrOfDaysToImport); if (ConfigInstance.Current.UpdateMode == Config.UpDateMode.NextDayOnly) { endDate = startDate; DateTime lastImportedDay = ConvertIntAsDateTime(ConfigInstance.Current.LastImportedDay); if (lastImportedDay > startDate) { Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : Calling Import for updates for one day : " + startDate.ToLongTimeString())); Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate, true), ConvertEndDateTimeToString(startDate.AddHours(25), true)); Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : End of one day Import")); startDate = lastImportedDay; } endDate = todeey.AddDays(ConfigInstance.Current.NrOfDaysToImport); if (endDate > startDate) { Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : Calling Import for new data : " + startDate.ToLongTimeString())); Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate), ConvertEndDateTimeToString(endDate)); } } else { Import(skipChannels, importDataCallback, progressCallback, feedbackCallback, keepImportServiceAliveCallback, ConvertStartDateTimeToString(startDate), ConvertEndDateTimeToString(endDate)); } Logger.Write(FormatForLogger(DateTime.Now.ToLongTimeString() + " : End of new data Import")); ConfigInstance.Current.LastImportedDay = ConvertDateTimeAsDateInt(endDate); ConfigInstance.Save(); }
public List <ImportGuideChannel> GetAllImportChannels(bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { if (reload) { GiveFeedback(feedbackCallback, "Calling SchedulesDirect WebService ..."); xtvdResponse response = CallSchedulesDirectWebService(ConvertStartDateTimeToString(DateTime.Now), ConvertEndDateTimeToString(DateTime.Now)); if (response != null) { GiveFeedback(feedbackCallback, "Processing retrieved SchedulesDirect channels ..."); Dictionary <int, ImportGuideChannel> tvGuideChannels = BuildImportGuideChannelDictionary(response, ConfigInstance.Current.ChannelNameFormat); GuideChannelStore.Save(AvailableChannelsConfigFile, new List <ImportGuideChannel>(tvGuideChannels.Values)); } } List <ImportGuideChannel> availableGuideChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); return(availableGuideChannels); }
public List <ImportGuideChannel> GetAllImportChannels(bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { return(_dbReader.GetAllImportChannels()); }