Visual Basic
C#
C# | Copy Code |
---|---|
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Netcad.Netigma; using Netcad.Data.Filtering; using System.ComponentModel; using Netcad.Data; using System.Data; using HelpDocumentExamples.IQueryEventServiceProvider; namespace QueryWebServiceExample { /// <summary> /// This class demonstrates a sample service execution before IQuery execution to the db server. /// </summary> public class SampleServiceExecution : IQueryEventServiceProvider { #region IQueryEventServiceProvider Members [Browsable(false)] public string Name { get { return "Example Web Service"; } } public string DisplayName { get { return Name; } } /// <summary> /// in minutes /// </summary> [DisplayName("Zaman aşımı (sn.)")] public int CacheTimeOut { get; set; } public GenericEventServiceResult OnPostExecute(QueryEventServiceEventArgs args) { //throw new NotImplementedException(); return new GenericEventServiceResult() { ServiceMessage = "hello world! i am from post execute." }; } public GenericEventServiceResult OnPreExecute(QueryEventServiceEventArgs args) { GenericEventServiceResult result = new GenericEventServiceResult(); result.ServiceMessage = "hi there! i am from pre execute"; ////object tmp = this.GetFieldValue(args.Criteria, "MUHTARKIMLIKNO"); ////if (tmp != null) //{ // INetcadTable table = args.Domain.FindTable("TEST123"); // if (table != null) // { // //ClearDbCache(table); // //if (!isRecordExist(table, tmp.ToString())) // { // try // { // SampleWebService service = new SampleWebService(); // //Person[] persons = service.GetPersonByName(tmp.ToString()); // //foreach (Person p in persons) // { // DataRow dr = table.NewRow(); // dr["TARIH"] = DateTime.Now; // dr["OLAY"] = "OnPreExecute"; // table.Rows.Add(dr); // } // table.Update(); // result.RowsAffected = 1; // } // catch (Exception ex) // { // result.ServiceMessage = ex.ToString(); // } // } // } // else // { // result.ServiceMessage = "Table does not found"; // } //} //OgcBinaryOperator bin = new OgcBinaryOperator(); //bin.LeftOperand.PropertyName = "TEST123.OBJECTID"; //bin.RightOperand.Value = 250; //bin.OperatorType = OgcBinaryOperatorType.PropertyIsGreaterThan; //args.Criteria = bin; return result; } #endregion public SampleServiceExecution() { CacheTimeOut = 2; } bool isRecordExist(INetcadTable table,string KimlikNo) { string sql = string.Format("select count(*) from {0} where KIMLIKNO = '{1}'", table.TableName,KimlikNo); object o = table.DataHelper.ExecuteScalar(sql, KimlikNo); return o != null && Convert.ToInt32(o) > 0; } /// <summary> /// Clears the expired database records by CacheTimeOut duration /// </summary> /// <param name="table">INetcadTable related table</param> void ClearDbCache(INetcadTable table) { //table.DataHelper.Execute(string.Format("DELETE FROM {0} WHERE (TARIH < DATEADD(minute, -{1}, GETDATE())) ", table.TableName, CacheTimeOut)); table.DataHelper.Execute(string.Format("DELETE FROM {0};", table.TableName)); } public object Clone() { return MemberwiseClone() as SampleServiceExecution; } public string CustomParameters { get; set; } } } |
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family