Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Api/CsiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,32 @@ namespace InSiteXmlClient4Core.Api
/// <summary>
/// 连接
/// </summary>
internal class CsiConnection : ICsiConnection
public class CsiConnection : ICsiConnection
{
private Hashtable _sessions = new Hashtable();
private string _host;
private int _port;
private int _timeout;

public CsiConnection(string host, int port)
{
this._host = host;
this._port = port;
this._timeout = 0;
}

/// <summary>
/// 记录会话
/// </summary>
public bool LogSesssion
{
get { return mServerConnection.LogXml; }
set { mServerConnection.LogXml = value; }
}

private ServerConnection mServerConnection = new ServerConnection();



public ICsiSession CreateSession(string userName, string password, string sessionName)
public ICsiSession CreateSession(string userName, string password, string sessionName)
{
lock (this)
{
Expand Down Expand Up @@ -78,7 +86,6 @@ public int SetConnectionTimeout(int timeout)
return _timeout;
}

public string Submit(string requestXml) =>
this.mServerConnection.Submit(this._host, this._port, requestXml);
public string Submit(string requestXml) => this.mServerConnection.Submit(this._host, this._port, requestXml);
}
}
212 changes: 212 additions & 0 deletions Api/CsiRecordset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
using InSiteXmlClient4Core.Exceptions;
using InSiteXmlClient4Core.InterFace;
using System;
using System.Collections;
using System.Xml;

namespace InSiteXmlClient4Core.Api
{
internal class CsiRecordsetField : CsiXmlElement, ICsiRecordsetField, ICsiXmlElement
{
public CsiRecordsetField(ICsiDocument doc, XmlElement element) : base(doc, element)
{

}
public CsiRecordsetField(ICsiDocument doc, string name, ICsiXmlElement parent) : base(doc, name, parent)
{

}

public virtual string GetName()
{
return this.GetElementName();
}

public virtual string GetValue()
{
string result = string.Empty;
try
{
XmlElement element = base.GetDomElement();
if (element.HasChildNodes && element.ChildNodes.Count > 0)
{
string value = element.FirstChild.Value;
result = ((value != null) ? value : "");
}
}
catch (Exception)
{
result = "";
}
return result;
}
}

internal class CsiRecordset : CsiXmlElement, ICsiRecordset, ICsiXmlElement
{
public CsiRecordset(ICsiDocument doc, XmlElement domElement)
: base(doc, domElement)
{

}

public CsiRecordset(ICsiDocument doc, ICsiXmlElement oParent)
: base(doc, "__recordSet", oParent)
{
}

private XmlNode mCurrentElement;

public Array GetFields()
{
Array result;
try
{
ArrayList arrayList = new ArrayList();
bool flag = this.mCurrentElement != null;
if (flag)
{
XmlNodeList childNodes = this.mCurrentElement.ChildNodes;
for (int i = 0; i < childNodes.Count; i++)
{
XmlNode xmlNode = childNodes[i];
bool flag2 = xmlNode.NodeType == XmlNodeType.Element;
if (flag2)
{
arrayList.Add(new CsiRecordsetField(this.GetOwnerDocument(), xmlNode as XmlElement));
}
}
}
result = arrayList.ToArray();
}
catch (Exception exp)
{
throw new CsiClientException(-1L, exp, base.GetType().FullName + ".GetFields()");
}
return result;
}

public virtual long GetRecordCount()
{
return CsiXmlHelper.GetChildCount(base.GetDomElement());
}

private XmlNode GoToNextElementNode(XmlNode element, bool bForward)
{
XmlNode result;
try
{
XmlNode xmlNode = element;
while (xmlNode != null && (xmlNode.NodeType != XmlNodeType.Element || !xmlNode.Name.Equals("__row")))
{
if (bForward)
{
xmlNode = xmlNode.NextSibling;
}
else
{
xmlNode = xmlNode.PreviousSibling;
}
}
result = xmlNode;
}
catch (Exception exp)
{
throw new CsiClientException(-1L, exp, base.GetType().FullName + ".GoToNextElementNode()");
}
return result;
}

public void MoveFirst()
{
try
{
this.mCurrentElement = this.GoToNextElementNode(base.GetDomElement().FirstChild, true);
}
catch (Exception exp)
{
throw new CsiClientException(-1L, exp, base.GetType().FullName + ".MoveFirst()");
}
}

public void MoveLast()
{
try
{
this.mCurrentElement = this.GoToNextElementNode(base.GetDomElement().LastChild, false);
}
catch (Exception exp)
{
throw new CsiClientException(-1L, exp, base.GetType().FullName + ".MoveLast()");
}
}

public void MoveNext()
{
try
{
bool flag = this.mCurrentElement == null;
if (flag)
{
this.MoveFirst();
}
else
{
XmlNode nextSibling = this.mCurrentElement.NextSibling;
bool flag2 = nextSibling == null;
if (flag2)
{
this.MoveFirst();
}
else
{
this.mCurrentElement = this.GoToNextElementNode(nextSibling, true);
bool flag3 = this.mCurrentElement == null;
if (flag3)
{
this.MoveLast();
}
}
}
}
catch (Exception ex)
{
throw new CsiClientException(-1L, ex.Message, base.GetType().FullName + ".MoveNext()");
}
}

public void MovePrevious()
{
try
{
bool flag = this.mCurrentElement == null;
if (flag)
{
this.MoveFirst();
}
else
{
XmlNode previousSibling = this.mCurrentElement.PreviousSibling;
bool flag2 = previousSibling == null;
if (flag2)
{
this.MoveFirst();
}
else
{
this.mCurrentElement = this.GoToNextElementNode(previousSibling, false);
bool flag3 = this.mCurrentElement == null;
if (flag3)
{
this.MoveFirst();
}
}
}
}
catch (Exception exp)
{
throw new CsiClientException(-1L, exp, base.GetType().FullName + ".MovePrevious()");
}
}
}
}
10 changes: 5 additions & 5 deletions Api/CsiSelectionValuesEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public virtual ICsiRecordset GetRecordset()
{
return this.FindChildByName("__recordSet") as ICsiRecordset;
}
catch (Exception ex)
catch (Exception)
{
return (ICsiRecordset)null;
}
Expand All @@ -36,7 +36,7 @@ public virtual ICsiRecordsetHeader GetRecordsetHeader()
{
return this.FindChildByName("__recordSetHeader") as ICsiRecordsetHeader;
}
catch (Exception ex)
catch (Exception)
{
return (ICsiRecordsetHeader)null;
}
Expand All @@ -46,14 +46,14 @@ public virtual long GetRecordCount()
{
long num = 0;
var childByName = this.FindChildByName("__responseData") as CsiDataField;
if ( childByName!=null)
if (childByName != null)
{
ICsiDataField childByNam= childByName .FindChildByName("__recordCount") as ICsiDataField;
ICsiDataField childByNam = childByName.FindChildByName("__recordCount") as ICsiDataField;
try
{
num = long.Parse(childByNam.GetValue());
}
catch (Exception ex)
catch (Exception)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion Api/CsiXmlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static ICsiXmlElement CreateCsiElement(ICsiDocument document, XmlElement
{
typeName = "Camstar.XMLClient.API.CsiXmlElement";
}
Type type = Type.GetType(typeName);
Type type = Type.GetType(typeName, true);
Type type2 = typeof(ICsiDocument);
Type type3 = typeof(XmlElement);
element3 = (ICsiXmlElement)type.GetConstructor(new[] { type2, type3 }).Invoke(new object[] { document, element });
Expand Down
Loading