/// <param name="project">ID projektu</param> /// <param name="year">Rok prognozy</param> /// <param name="variant">Ewentualne ID wariantu</param> /// <param name="model">ID modelu – ma znaczenie dla wydawanych parametrów</param> public DBReaderBatch(BlaRequest request, RoReporter rep = null, byte?connID = null) { Reporter = rep ?? new RoReporter(); Results = new Dictionary <byte, Stream>(); try { Reporter.AddMessage(new RoReMessage { Caller = "Inicjalizacja", EvType = RoReEventType.ModuleCall, Message = "Inicjalizacja systemu" }); __conn = _.SetupConnection(connID); Reporter.AddMessage(new RoReMessage { Caller = "Inicjalizacja", Message = $"DBServer: {__conn.Server}, Database: {__conn.Database}", EvType = RoReEventType.Info }); __storage = new BlaCommonStorage(__conn, request); __storage.Reporter = Reporter; __storage.Variant = new BlaDBVariantDefinition(__conn, request); } catch (Exception e) { Reporter.AddException(e, "Inicjalizacja"); } }
/// <summary> /// Wykonuje opisane w żądaniu operacje, zwracając w nim rezultaty /// </summary> /// <returns></returns> public bool Execute(BlaRequest req, byte?connId = null) { //RoReporter rep = null; //Dictionary<byte, Stream> res = null; DBReaderBatch n = null; try { n = new DBReaderBatch(req, Reporter, connId); //rep = n.Reporter; if (Reporter.IsOK) { n.FragQuellen(req.Reicks); } foreach (var batch in req.Batches) { if (Reporter.IsOK) { n.PerformBatch(batch); } } //if (Reporter.IsOK) //{ // res = new Dictionary<byte, Stream>(); // res.Add(0, n.Log); // foreach (var t in n.Results) // { // res.Add(t.Key, t.Value); // } //} } catch (Exception e) { var q = Reporter == null; if (q) { Reporter = new RoReporter(); } Reporter.AddException(e, "Błąd krytyczny ogólny"); } //if (res == null) //{ // res = new Dictionary<byte, Stream>(); // res.Add(0, Reporter.SaveLog()); //} return(Reporter != null ? n.Reporter.IsOK : false); }
public static void WriteStreamsToFiles(string catalog, BlaRequest request, RoReporter reporter, string caller) { if (!Directory.Exists(catalog)) { reporter.AddMessage(new RoReMessage { Caller = caller, EvType = RoReEventType.Error, Message = string.Format("Katalog {0} nie istnieje", catalog) }); return; } try { foreach (var brs in request.Batches) { if ((brs.Result == null) | string.IsNullOrWhiteSpace(brs.FileName)) { reporter.AddMessage(new RoReMessage { Caller = caller, EvType = RoReEventType.Warning, Message = string.Format("Pomijanie zapisu pliku dla podzlecenia {0}", brs.BatchId) }); continue; } var path = Path.Combine(catalog, brs.FileName); reporter.AddMessage(new RoReMessage { Caller = caller, EvType = RoReEventType.Info, Message = string.Format("Zapis pliku dla podzlecenia {0} [{1}]", brs.BatchId, path) }); if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } WriteStreamToFile(brs.Result, path); } } catch (Exception e) { reporter.AddException(e, caller); } }
public bool LoadXMLRequest() { if (string.IsNullOrWhiteSpace(XMLFile)) { Reporter.AddMessage(new RoReMessage { Caller = "CLI", Message = "Nieprawidłowa nazwa pliku", EvType = RoReEventType.Error }); return(Reporter.IsOK); } if (!File.Exists(XMLFile)) { Reporter.AddMessage(new RoReMessage { Caller = "CLI", Message = "Plik XML nie istnieje", EvType = RoReEventType.Error }); return(Reporter.IsOK); } try { Reporter.AddMessage(new RoReMessage { Caller = "CLI", EvType = RoReEventType.Info, Message = "Odczyt pliku XML" }); Request = BlaRequest.LoadFromFile(XMLFile); Reporter.AddMessage(new RoReMessage { Caller = "CLI", EvType = RoReEventType.Info, Message = "Odczytano pliku XML" }); } catch (Exception e) { Reporter.AddException(e, "CLI"); } return(Reporter.IsOK); }
public IEnumerable <GrWAtt_Definition> OfRequest(BlaRequest req) { //var n = req.EntityIDs; return(this.Join(req.EntityIDs, de => de.EntityID, eid => eid, (de, eid) => de)); }