public Results SetStationInformation(StationInformation information) { return(WebClientRequest <Results>( path: "api/SetStationInformationEx", setSession: true, queryParams: $"&Infromation={information}", disableLog: false)); }
// GET: Interactive //Use As public ActionResult StationInformation(string cityName) { StationInformation stationInfo = GetStationInformation(cityName); JsonResult result = new JsonResult(); result = Json(stationInfo, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; result.RecursionLimit = int.MaxValue; return(Json(new { result = result }, JsonRequestBehavior.AllowGet)); }
public Task StartPolling( StationInformation initialState, IEnumerable <PriceInfo> initialPricesInfo, CancellationToken cancellationToken) { _stationInformation = initialState; _pricesInfo = initialPricesInfo.ToList(); var result = Polling(cancellationToken); _logger.Info("Starting polling..."); return(result); }
static async Task Main(string[] args) { //Итентификатор АЗС в системе Benzuber var stationId = 0; //Hardware ID - идентификатор аппаратной составляющей ПК, HEX строка 32 символа var hwid = "1415D518C428500F70F688CE04D8EA47"; //Адрес сервера var server = "https://test-as-apiazs.benzuber.ru"; client = new Client(new Configuration(stationId, hwid, server, Logger.LogLevels.Debug)); InitializeCallback(); //Создаем базовые значения для поллинга //Начальные цены на топливо var pricesInfo = CreatePricesInfo(); //Начальные статусы ТРК var stationInformation = new StationInformation(CreatePumpStates()); //Создаем объект источника токен отмены var cts = new CancellationTokenSource(); //Запускаем поллинг сервера var polling = client.StartPolling(stationInformation, pricesInfo, cts.Token); //Иммитируем работу АСУ АЗС var fakeStationControl = FakeControlSystem(cts.Token); Console.ReadLine(); Console.WriteLine("Closing client..."); //Перез давершением приложения: останавливаем поллинг, через токен отмены cts.Cancel(); //Дожидаемся завершения поллинга await polling.ConfigureAwait(false); Console.WriteLine("Client closed"); Console.ReadLine(); }
//[HttpPost] //public ActionResult StationInformation() //{ // stationInformation_AllType modelFull = GetAllStationInformation(); // return Json(modelFull); //} //public List<Models.StationInformation> /*stationInformation_AllType*/ GetAllStationInformation() //{ // // stationInformation_AllType allType = new stationInformation_AllType(); // //allType.stationInformation_All = new List<Models.StationInformation>(); // List<Models.StationInformation> allType = new List<Models.StationInformation>(); // //Database master = Sitecore.Configuration.Factory.GetDatabase("master"); // Database DB = Sitecore.Context.Database; // Sitecore.Data.Items.Item stationInfo_Item = DB.GetItem("/sitecore/content/Home/iMap/Configuration/Station Information/"); // foreach (Sitecore.Data.Items.Item child in stationInfo_Item.Children) // { // Sitecore.Data.Fields.Field temp = child.Fields[Templates.StationInformation.StationName]; // StationInformation stationInfoAll = new StationInformation(); // stationInfoAll.stationName = child.Fields[Templates.StationInformation.StationName].ToString(); // stationInfoAll.CRSCode = child.Fields[Templates.StationInformation.CRSCode].ToString(); // //stationInfoAll.stationAddress = child.Fields[Templates.StationInformation.StationAddress].ToString(); // stationInfoAll.xPos = child.Fields[Templates.StationInformation.XPox].ToString(); // stationInfoAll.yPox = child.Fields[Templates.StationInformation.YPos].ToString(); // stationInfoAll.status = child.Fields[Templates.StationInformation.StationStatus].ToString(); // //stationInfoAll.startDate = child.Fields[Templates.StationInformation.ValidFrom];//.Value.ToString(); // //stationInfoAll.endDate = child.Fields[Templates.StationInformation.ValidTo];//.Value.ToString(); // //station status // if (stationInfoAll.status == null || stationInfoAll.status == "") // { // //default status // //stationInfoAll.statusIcon = ""; // //stationInfo.statusTitle = null; // //stationInfo.statusMessage = null; // } // else // { // Sitecore.Data.Items.Item stationStatusDetails = DB.GetItem("/sitecore/content/Home/iMap/Configuration/Station Status/" + stationInfoAll.status); // //stationInfoAll.statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; // Sitecore.Data.Fields.ImageField statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; // stationInfoAll.imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(statusIcon.MediaItem); // //stationInfoAll.statusTitle = stationStatusDetails.Fields[Templates.StationStatus.StationStatusTitle].Value; // //stationInfoAll.statusMessage = stationStatusDetails.Fields[Templates.StationStatus.StationStatusDetails].Value.Replace("startDate", stationInfoAll.startDate.ToString()); // //stationInfoAll.statusMessage = stationInfoAll.statusMessage.Replace("endDate", stationInfoAll.endDate.ToString()); // //Legends legendInfoAll = new Legends(); // //legendInfoAll.icon = stationStatusDetails.Fields[Templates.LegendInformation.LegendIcon]; // //legendInfoAll.imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(legendInfoAll.icon.MediaItem); // //legendInfoAll.subtitle = child.Fields[Templates.LegendInformation.LegendSubtitle].ToString(); // //stationInfoAll.statusTitle = stationStatusDetails.Fields[Templates.StationStatus.StationStatusTitle].ToString(); // //stationInfoAll.statusMessage = stationStatusDetails.Fields[Templates.StationStatus.StationStatusDetails].ToString(); // } // allType.Add(stationInfoAll); // } // return allType; //} public StationInformation GetStationInformation(string city) { StationInformation stationInfo = new StationInformation(); //Database master = Sitecore.Configuration.Factory.GetDatabase("master"); Database DB = Sitecore.Context.Database; Sitecore.Data.Items.Item stationInfo_Item = DB.GetItem("/sitecore/content/Home/iMap/Configuration/Station Information/" + city); if (stationInfo_Item != null) { stationInfo.stationName = stationInfo_Item.Fields[Templates.StationInformation.StationName].ToString(); stationInfo.CRSCode = stationInfo_Item.Fields[Templates.StationInformation.CRSCode].ToString(); if (stationInfo_Item.Fields[Templates.StationInformation.StationAddress].ToString() != null || stationInfo_Item.Fields[Templates.StationInformation.StationAddress].ToString() != "") { stationInfo.stationAddress = stationInfo_Item.Fields[Templates.StationInformation.StationAddress].ToString(); } stationInfo.xPos = stationInfo_Item.Fields[Templates.StationInformation.XPox].ToString(); stationInfo.yPox = stationInfo_Item.Fields[Templates.StationInformation.YPos].ToString(); stationInfo.status = stationInfo_Item.Fields[Templates.StationInformation.StationStatus].ToString(); //stationInfo.startDate = stationInfo_Item.Fields[Templates.StationInformation.ValidFrom];//.ToString(); //stationInfo.endDate = stationInfo_Item.Fields[Templates.StationInformation.ValidTo];//.Value.ToString(); Sitecore.Data.Fields.DateField startDate = stationInfo_Item.Fields[Templates.StationInformation.ValidFrom]; //.ToString(); Sitecore.Data.Fields.DateField endDate = stationInfo_Item.Fields[Templates.StationInformation.ValidTo]; //.Value.ToString(); //station status if (stationInfo.status == null || stationInfo.status == "" || (StatusValid(endDate.DateTime) || startValid(startDate.DateTime))) { //default status //stationInfo.statusIcon = null; //stationInfo.statusTitle = null; //stationInfo.statusMessage = null; } else { Sitecore.Data.Items.Item stationStatusDetails = DB.GetItem("/sitecore/content/Home/iMap/Configuration/Station Status/" + stationInfo.status); //stationInfo.statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; Sitecore.Data.Fields.ImageField statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; if (statusIcon.MediaItem != null) { stationInfo.imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(statusIcon.MediaItem); } stationInfo.statusTitle = stationStatusDetails.Fields[Templates.StationStatus.StationStatusTitle].ToString(); stationInfo.statusMessage = stationStatusDetails.Fields[Templates.StationStatus.StationStatusDetails].ToString(); stationInfo.statusMessage = stationStatusDetails.Fields[Templates.StationStatus.StationStatusDetails].Value.Replace("startDate", startDate.ToString()); stationInfo.statusMessage = stationInfo.statusMessage.Replace("endDate", endDate.ToString()); //Sitecore.Data.Items.Item stationStatusDetails = DB.GetItem("/sitecore/content/Home/iMap/Configuration/Station Status/" + stationInfo.status); //stationInfo.statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; //stationInfo.imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(stationInfo.statusIcon.MediaItem); //stationInfo.statusIcon = stationStatusDetails.Fields[Templates.StationStatus.StationStatusIcon]; //stationInfo.statusTitle = stationStatusDetails.Fields[Templates.StationStatus.StationStatusTitle].Value; //stationInfo.statusMessage = stationStatusDetails.Fields[Templates.StationStatus.StationStatusDetails].Value.Replace("startDate", stationInfo.startDate.ToString()); //stationInfo.statusMessage = stationInfo.statusMessage.Replace("endDate", stationInfo.endDate.ToString()); } } return(stationInfo); }