/// <summary> /// Checks for a condition and displays a message if the condition is false. /// </summary> /// <param name="edc">The <see cref="Entities"/> object.</param> /// <param name="condition"> <c>true</c> to prevent a message being displayed; otherwise, false.</param> /// <param name="source">The source of the assertion.</param> /// <param name="message">The message to log.</param> public static void Assert(Entities edc, bool condition, string source, string message) { if (condition) { return; } ActivityLogCT.WriteEntry(edc, source, message); }
/// <summary> /// Gets the IPR material. /// </summary> /// <param name="edc">The edc.</param> /// <returns></returns> internal protected override bool?GetIPRMaterial(Entities edc) { if (String.IsNullOrEmpty(this.PrimeMarket)) { ActivityLogCT.WriteEntry(edc, m_Source, string.Format(m_PMTemplate, this.Title)); return(new Nullable <bool>()); } return(!CustomsUnion.CheckIfUnion(this.PrimeMarket, edc)); }
internal bool Validate(Entities edc, Dictionary <string, IGrouping <string, IPR> > _accountGroups, StockLib library) { ActivityLogCT.WriteEntry(m_ActivityLogEntryName, "Starting stock inventory validation."); int _problems = 0; Dictionary <string, Batch> _batches = new Dictionary <string, Batch>(); foreach (StockEntry _sex in this.AllIPRFinishedGoods(edc)) { Batch _batchLookup = Batch.FindStockToBatchLookup(edc, _sex.Batch); if (_batchLookup != null) { if (!_batches.ContainsKey(_batchLookup.Batch0)) { _batches.Add(_batchLookup.Batch0, _batchLookup); } _sex.BatchIndex = _batchLookup; continue; } ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _sex.NoMachingBatchWarningMessage); _problems++; } foreach (StockEntry _sex in this.AllIPRTobacco(edc)) { if (_accountGroups.ContainsKey(_sex.Batch)) { continue; } ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _sex.NoMachingTobaccoWarningMessage); _problems++; } List <string> _warnings = new List <string>(); foreach (Batch _senbx in _batches.Values) { _senbx.CheckQuantity(edc, _warnings, library); } foreach (string _msg in _warnings) { ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _msg); _problems++; } foreach (Batch _btx in DanglingBatches(edc, _batches, library)) { ActivityLogCT.WriteEntry(edc, m_ActivityLogEntryName, _btx.DanglingBatchWarningMessage); _problems++; } string _mtmplt = "Stock inventory validation passed successfully."; if (_problems > 0) { _mtmplt = "Stock inventory validation failed. There are problems reported that must be resolved to start calculation procedure."; } ActivityLogCT.WriteEntry(m_ActivityLogEntryName, _mtmplt); return(_problems == 0); }
/// <summary> /// Writes an entry with the given message text and application-defined event identifier to the event log list. /// </summary> /// <param name="entities">Provides LINQ (Language Integrated Query) access to, and change tracking for, /// the lists and document libraries of a Windows SharePoint Services "14" Web site.</param> /// <param name="source">The source denominator of the message.</param> /// <param name="message">The string to write to the event log.</param> public static void WriteEntry(Entities entities, string source, string message) { if (entities == null) { EventLog.WriteEntry("CAS.SmartFactory", "Cannot open \"Event Log List\" list", EventLogEntryType.Error, 114); return; } ActivityLogCT log = new ActivityLogCT(source, message, TraceLevel.Error, "ActivityLogCT"); entities.ActivityLog.InsertOnSubmit(log); entities.SubmitChangesSilently(Microsoft.SharePoint.Linq.RefreshMode.OverwriteCurrentValues); }
/// <summary> /// Reports the action result. /// </summary> /// <param name="url">The _url.</param> public void ReportActionResult(string url) { if (this.Count == 0) { return; } try { using (Entities _edc = new Entities(url)) { foreach (string _msg in this) { ActivityLogCT _entry = new ActivityLogCT() { Title = "ReportActionResult", Body = _msg, Expires = DateTime.Now + new TimeSpan(2, 0, 0, 0) }; _edc.ActivityLog.InsertOnSubmit(_entry); } _edc.SubmitChanges(); } } catch (Exception) { } }
/// <summary> /// Updates the balance report. /// </summary> /// <param name="edc">The <see cref="Entities" /> representing data model.</param> /// <param name="getOutboundQuantity">Delegate to get outbound quantity.</param> /// <param name="batches">The batches.</param> /// <param name="trace">The trace action.</param> /// <returns><c>true</c> if the stock is valid (consistent), <c>false</c> otherwise.</returns> internal bool UpdateBalanceReport(Entities edc, GetOutboundQuantity getOutboundQuantity, List <BalanceBatchWrapper> batches, NamedTraceLogger.TraceAction trace) { trace("Entering JSOXLib.UpdateBalanceReport", 43, TraceSeverity.Verbose); bool _validated = false; StockDictionary _balanceStock = new StockDictionary(); Dictionary <string, IGrouping <string, IPR> > _accountGroups = Linq.IPR.GetAllOpen4JSOXGroups(edc).ToDictionary(x => x.Key); Linq.StockLib _stock = Stock(edc); if (_stock != null) { _validated = _stock.Validate(edc, _accountGroups, _stock); _stock.GetInventory(edc, _balanceStock); _stock.Stock2JSOXLibraryIndex = this; } else { ActivityLogCT.WriteEntry(edc, "Balance report", "Cannot find stock report - only preliminary report will be created"); } List <string> _processed = new List <string>(); IEnumerable <BalanceBatch> _existingBatches = this.BalanceBatch(edc); foreach (BalanceBatch _bbx in _existingBatches) { if (_accountGroups.ContainsKey(_bbx.Batch)) { List <BalanceIPR> _is = new List <BalanceIPR>(); _bbx.Update(edc, _accountGroups[_bbx.Batch], _balanceStock.GetOrDefault(_bbx.Batch), _is, trace); batches.Add(new BalanceBatchWrapper() { batch = _bbx, iprCollection = _is.ToArray <BalanceIPR>() }); } else { edc.BalanceBatch.DeleteOnSubmit(_bbx); } _processed.Add(_bbx.Batch); } foreach (string _btchx in _processed) { _accountGroups.Remove(_btchx); } foreach (var _grpx in _accountGroups) { batches.Add(Linq.BalanceBatch.Create(edc, _grpx.Value, this, _balanceStock.GetOrDefault(_grpx.Key), trace)); } //Introducing DateTime _thisIntroducingDateStart = LinqIPRExtensions.DateTimeMaxValue; DateTime _thisIntroducingDateEnd = LinqIPRExtensions.DateTimeMinValue; decimal _introducingQuantity = Linq.IPR.GetIntroducingData(edc, this, out _thisIntroducingDateStart, out _thisIntroducingDateEnd); this.IntroducingDateStart = _thisIntroducingDateStart; this.IntroducingDateEnd = _thisIntroducingDateEnd; this.IntroducingQuantity = Convert.ToDouble(_introducingQuantity); //Outbound DateTime _thisOutboundDateEnd = LinqIPRExtensions.DateTimeMinValue; DateTime _thisOutboundDateStart = LinqIPRExtensions.DateTimeMaxValue; decimal _outQuantity = getOutboundQuantity(edc, this, out _thisOutboundDateStart, out _thisOutboundDateEnd); this.OutboundQuantity = _outQuantity.Convert2Double2Decimals(); this.OutboundDateEnd = _thisOutboundDateEnd; this.OutboundDateStart = _thisOutboundDateStart; //Balance decimal _thisBalanceQuantity = Convert.ToDecimal(this.PreviousMonthQuantity) + _introducingQuantity - _outQuantity; this.BalanceQuantity = _thisBalanceQuantity.Convert2Double2Decimals(); //Situation at decimal _thisSituationQuantity = batches.Select <BalanceBatchWrapper, BalanceBatch>(x => x.batch).Sum <BalanceBatch>(x => x.IPRBookDecimal); this.SituationQuantity = Convert.ToDouble(_thisSituationQuantity); //Reassign this.ReassumeQuantity = (_thisBalanceQuantity - _thisSituationQuantity).Convert2Double2Decimals(); return(_validated); }
/// <summary> /// Writes an entry with the given message text and application-defined event identifier to the event log list. /// </summary> /// <param name="source">The source denominator of the message.</param> /// <param name="message">The string to write to the event log.</param> /// <param name="url">The URL.</param> public static void WriteEntry(string source, string message, string url) { using (Entities edc = new Entities(url)) ActivityLogCT.WriteEntry(edc, source, message); }