1: using System;
2: using System.Collections.Generic;
3: using System.Data;
4: using System.Linq;
5:
6: namespace Ia.Ngn.Cl.Model.Nokia.Business
7: {
8: ////////////////////////////////////////////////////////////////////////////
9:
10: /// <summary publish="true">
11: /// Nokia AmsTransaction Entity Framework class for Optical Fiber Network (OFN) business model.
12: /// </summary>
13: ///
14: /// <remarks>
15: /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
16: ///
17: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
18: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
19: ///
20: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22: ///
23: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
24: ///
25: /// Copyright notice: This notice may not be removed or altered from any source distribution.
26: /// </remarks>
27: public class AmsTransaction
28: {
29: ////////////////////////////////////////////////////////////////////////////
30:
31: /// <summary>
32: ///
33: /// </summary>
34: public AmsTransaction() { }
35:
36: ////////////////////////////////////////////////////////////////////////////
37: ////////////////////////////////////////////////////////////////////////////
38:
39: /// <summary>
40: ///
41: /// </summary>
42: public static void Search(string rawInput, out List<Ia.Ngn.Cl.Model.Nokia.AmsTransaction> amsTransactionList, out Ia.Cl.Model.Result result)
43: {
44: bool inputIsValid;
45: string input;
46:
47: result = new Ia.Cl.Model.Result();
48: amsTransactionList = new List<Ia.Ngn.Cl.Model.Nokia.AmsTransaction>();
49:
50: if (!string.IsNullOrEmpty(rawInput))
51: {
52: rawInput = rawInput.Trim();
53: input = rawInput.ToLower();
54:
55: if (input.Length > 0)
56: {
57: inputIsValid = true;
58:
59: input = rawInput.ToLower();
60:
61: try
62: {
63: using (var db = new Ia.Ngn.Cl.Model.Ngn())
64: {
65: amsTransactionList = (from at in db.AmsTransactions
66: where at.EventTime.ToString().Contains(input)
67: || at.User.Contains(input)
68: || at.Application.Contains(input)
69: || at.Operation.Contains(input)
70: || at.Agent.Contains(input)
71: || at.Object.Contains(input)
72: || at.Argument.Contains(input)
73: || at.Session.Contains(input)
74: || at.Result.Contains(input)
75: select at).Take(500).ToList();
76: }
77: }
78: catch (Exception ex)
79: {
80: result.AddError("Exception: Retrieval error of data for \"" + rawInput + "\": " + ex.ToString());
81: }
82:
83: if (inputIsValid)
84: {
85: if (amsTransactionList == null || amsTransactionList != null && amsTransactionList.Count == 0)
86: {
87: if (result.IsSuccessful)
88: {
89: result.AddWarning("No data records were found for \"" + rawInput + "\" (لا توجد معلومات عن القيمة المعطاة). ");
90: }
91: else { };// result.AddError(result.Error);
92: }
93: else
94: {
95: if (result.IsSuccessful)
96: {
97: if (!string.IsNullOrEmpty(result.Message)) result.AddSuccess(result.Message);
98: }
99: //else result.AddError(result.Error);
100: }
101: }
102: else result.AddError("Input format is unknown (قيمة غير مفهومة). ");
103: }
104: else result.AddError("No input was entered (لم يتم إدخال أي شيء). ");
105: }
106: else result.AddError("Input is null or empty (لم يتم إدخال أي شيء). ");
107: }
108:
109: ////////////////////////////////////////////////////////////////////////////
110: ////////////////////////////////////////////////////////////////////////////
111: }
112: }