Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added source of all external libraries used

  • Loading branch information...
commit d2d1cb374c28f46ab779c005a842f221b70958ea 1 parent e69258c
@bricel authored
Showing with 34,782 additions and 1,699 deletions.
  1. +2 −2 Class/Curl.cs
  2. +839 −839 Class/Services.cs
  3. BIN  Dlls/DrutNET.dll
  4. BIN  Dlls/DrutNETSample.exe
  5. 0  Dlls/LibCurlNet.dll
  6. 0  Dlls/LibCurlNet.xml
  7. 0  Dlls/LibCurlShim.dll
  8. 0  Dlls/libcurl.dll
  9. 0  Drupal Module/drutnet_sample/drutnet_sample.defaults.inc
  10. 0  Drupal Module/drutnet_sample/drutnet_sample.features.inc
  11. 0  Drupal Module/drutnet_sample/drutnet_sample.features.node.inc
  12. 0  Drupal Module/drutnet_sample/drutnet_sample.info
  13. 0  Drupal Module/drutnet_sample/drutnet_sample.module
  14. 0  Drupal Module/file_form/file_form.info
  15. 0  Drupal Module/file_form/file_form.module
  16. 0  Drupal Module/readme.txt
  17. +14 −13 DrutNET.csproj
  18. +57 −32 DrutNET.sln
  19. BIN  DrutNET.suo
  20. +103 −96 DrutNETSample/DrutNETSample.csproj
  21. +428 −428 DrutNETSample/Form1.Designer.cs
  22. +167 −167 DrutNETSample/Form1.cs
  23. +122 −122 DrutNETSample/Form1.resx
  24. +130 −0 External_lib/SharpZipLib/AssemblyInfo.cs
  25. +126 −0 External_lib/SharpZipLib/BZip2/BZip2.cs
  26. +197 −0 External_lib/SharpZipLib/BZip2/BZip2Constants.cs
  27. +92 −0 External_lib/SharpZipLib/BZip2/BZip2Exception.cs
  28. +1,008 −0 External_lib/SharpZipLib/BZip2/BZip2InputStream.cs
  29. +1,920 −0 External_lib/SharpZipLib/BZip2/BZip2OutputStream.cs
  30. +237 −0 External_lib/SharpZipLib/Checksums/Adler32.cs
  31. +223 −0 External_lib/SharpZipLib/Checksums/CRC32.cs
  32. +93 −0 External_lib/SharpZipLib/Checksums/IChecksum.cs
  33. +208 −0 External_lib/SharpZipLib/Checksums/StrangeCRC.cs
  34. +516 −0 External_lib/SharpZipLib/Core/FileSystemScanner.cs
  35. +57 −0 External_lib/SharpZipLib/Core/INameTransform.cs
  36. +52 −0 External_lib/SharpZipLib/Core/IScanFilter.cs
  37. +260 −0 External_lib/SharpZipLib/Core/NameFilter.cs
  38. +329 −0 External_lib/SharpZipLib/Core/PathFilter.cs
  39. +216 −0 External_lib/SharpZipLib/Core/StreamUtils.cs
  40. +501 −0 External_lib/SharpZipLib/Encryption/PkzipClassic.cs
  41. +97 −0 External_lib/SharpZipLib/GZip/GZIPConstants.cs
  42. +93 −0 External_lib/SharpZipLib/GZip/GZipException.cs
  43. +365 −0 External_lib/SharpZipLib/GZip/GzipInputStream.cs
  44. +234 −0 External_lib/SharpZipLib/GZip/GzipOutputStream.cs
  45. +116 −0 External_lib/SharpZipLib/ICSharpCode.SharpZLib.csproj
  46. +13 −0 External_lib/SharpZipLib/ICSharpCode.SharpZLib.csproj.user
  47. +88 −0 External_lib/SharpZipLib/ICSharpCode.SharpZLib.prjx
  48. +36 −0 External_lib/SharpZipLib/Main.cs
  49. +94 −0 External_lib/SharpZipLib/SharpZipBaseException.cs
  50. +109 −0 External_lib/SharpZipLib/Tar/InvalidHeaderException.cs
  51. +856 −0 External_lib/SharpZipLib/Tar/TarArchive.cs
  52. +584 −0 External_lib/SharpZipLib/Tar/TarBuffer.cs
  53. +561 −0 External_lib/SharpZipLib/Tar/TarEntry.cs
  54. +93 −0 External_lib/SharpZipLib/Tar/TarException.cs
  55. +1,154 −0 External_lib/SharpZipLib/Tar/TarHeader.cs
  56. +684 −0 External_lib/SharpZipLib/Tar/TarInputStream.cs
  57. +517 −0 External_lib/SharpZipLib/Tar/TarOutputStream.cs
  58. +556 −0 External_lib/SharpZipLib/Zip/Compression/Deflater.cs
  59. +186 −0 External_lib/SharpZipLib/Zip/Compression/DeflaterConstants.cs
  60. +869 −0 External_lib/SharpZipLib/Zip/Compression/DeflaterEngine.cs
  61. +908 −0 External_lib/SharpZipLib/Zip/Compression/DeflaterHuffman.cs
  62. +57 −0 External_lib/SharpZipLib/Zip/Compression/DeflaterPending.cs
  63. +864 −0 External_lib/SharpZipLib/Zip/Compression/Inflater.cs
  64. +215 −0 External_lib/SharpZipLib/Zip/Compression/InflaterDynHeader.cs
  65. +232 −0 External_lib/SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs
  66. +295 −0 External_lib/SharpZipLib/Zip/Compression/PendingBuffer.cs
  67. +561 −0 External_lib/SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs
  68. +724 −0 External_lib/SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs
  69. +235 −0 External_lib/SharpZipLib/Zip/Compression/Streams/OutputWindow.cs
  70. +297 −0 External_lib/SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs
  71. +669 −0 External_lib/SharpZipLib/Zip/FastZip.cs
  72. +84 −0 External_lib/SharpZipLib/Zip/IEntryFactory.cs
  73. +624 −0 External_lib/SharpZipLib/Zip/ZipConstants.cs
  74. +1,128 −0 External_lib/SharpZipLib/Zip/ZipEntry.cs
  75. +413 −0 External_lib/SharpZipLib/Zip/ZipEntryFactory.cs
  76. +94 −0 External_lib/SharpZipLib/Zip/ZipException.cs
  77. +984 −0 External_lib/SharpZipLib/Zip/ZipExtraData.cs
  78. +4,118 −0 External_lib/SharpZipLib/Zip/ZipFile.cs
  79. +623 −0 External_lib/SharpZipLib/Zip/ZipHelperStream.cs
  80. +649 −0 External_lib/SharpZipLib/Zip/ZipInputStream.cs
  81. +255 −0 External_lib/SharpZipLib/Zip/ZipNameTransform.cs
  82. +816 −0 External_lib/SharpZipLib/Zip/ZipOutputStream.cs
  83. +17 −0 External_lib/XML-RPC.net/.svn/all-wcprops
  84. +120 −0 External_lib/XML-RPC.net/.svn/entries
  85. +28 −0 External_lib/XML-RPC.net/.svn/text-base/README.txt.svn-base
  86. +191 −0 External_lib/XML-RPC.net/.svn/text-base/xml-rpc.net.proj.svn-base
  87. +28 −0 External_lib/XML-RPC.net/README.txt
  88. +11 −0 External_lib/XML-RPC.net/bin1_0/.svn/all-wcprops
  89. +69 −0 External_lib/XML-RPC.net/bin1_0/.svn/entries
  90. +5 −0 External_lib/XML-RPC.net/bin1_0/.svn/prop-base/CookComputing.XmlRpc.dll.svn-base
  91. BIN  External_lib/XML-RPC.net/bin1_0/.svn/text-base/CookComputing.XmlRpc.dll.svn-base
  92. BIN  External_lib/XML-RPC.net/bin1_0/CookComputing.XmlRpc.dll
  93. +35 −0 External_lib/XML-RPC.net/interfaces/.svn/all-wcprops
  94. +205 −0 External_lib/XML-RPC.net/interfaces/.svn/entries
  95. +5 −0 External_lib/XML-RPC.net/interfaces/.svn/prop-base/vssver.scc.svn-base
  96. +149 −0 External_lib/XML-RPC.net/interfaces/.svn/text-base/BloggerAPI.cs.svn-base
  97. +73 −0 External_lib/XML-RPC.net/interfaces/.svn/text-base/MeerkatAPI.cs.svn-base
  98. +141 −0 External_lib/XML-RPC.net/interfaces/.svn/text-base/MetaWeblogAPI.cs.svn-base
  99. +102 −0 External_lib/XML-RPC.net/interfaces/.svn/text-base/MovableTypeAPI.cs.svn-base
  100. BIN  External_lib/XML-RPC.net/interfaces/.svn/text-base/vssver.scc.svn-base
  101. +149 −0 External_lib/XML-RPC.net/interfaces/BloggerAPI.cs
  102. +73 −0 External_lib/XML-RPC.net/interfaces/MeerkatAPI.cs
  103. +141 −0 External_lib/XML-RPC.net/interfaces/MetaWeblogAPI.cs
  104. +102 −0 External_lib/XML-RPC.net/interfaces/MovableTypeAPI.cs
  105. BIN  External_lib/XML-RPC.net/interfaces/vssver.scc
  106. +29 −0 External_lib/XML-RPC.net/ntest/.svn/all-wcprops
  107. +164 −0 External_lib/XML-RPC.net/ntest/.svn/entries
  108. +202 −0 External_lib/XML-RPC.net/ntest/.svn/text-base/ServerProtocol.cs.svn-base
  109. +65 −0 External_lib/XML-RPC.net/ntest/.svn/text-base/serializeresponsetest.cs.svn-base
  110. +741 −0 External_lib/XML-RPC.net/ntest/.svn/text-base/serializetest.cs.svn-base
  111. +373 −0 External_lib/XML-RPC.net/ntest/.svn/text-base/serviceinfotest.cs.svn-base
  112. +58 −0 External_lib/XML-RPC.net/ntest/AssemblyInfo.cs
  113. +1,402 −0 External_lib/XML-RPC.net/ntest/Copy of deserializeresponsetest.cs
  114. +57 −0 External_lib/XML-RPC.net/ntest/Listener.cs
Sorry, we could not display the entire diff because too many files (570) changed.
View
4 Class/Curl.cs
@@ -117,7 +117,7 @@ public bool DownloadFile(string httpPath, string savePath)
/// <param name="localPath">Local file location</param>
/// <returns></returns>
public int FileUpload(string localPath)
- {
+ {
return FileUpload(localPath, "");
}
/// <summary>
@@ -125,7 +125,7 @@ public int FileUpload(string localPath)
/// </summary>
/// <param name="localPath">Local file location</param>
/// <param name="serverDirectory">Save to a specific directory in drupal</param>
- /// <returns> File ID or -1 if failed to upload</returns>
+ /// <returns> File ID or -1 if failed to upload</returns>
public int FileUpload(string localPath, string serverDirectory)
{
// Use file form module
View
1,678 Class/Services.cs
@@ -1,839 +1,839 @@
-using System;
-using System.Collections.Generic;
-using System.Collections;
-using System.Text;
-using CookComputing.XmlRpc;
-using System.Security.Cryptography;
-using System.Net;
-using DrutNET;
-using System.IO;
-
-
-namespace DrutNET
-{
- // Since we don't want an error to pop up if the returned Drupal user object
- // contains a field which does not map to a field or struct has we need to
- // add the MappingOption.
- [XmlRpcMissingMapping(MappingAction.Ignore)]
- public struct DrupalUser
- {
- // Fields
- public string name;
- public string uid;
- public string mail;
- }
- public struct Drupal
- {
- public string sessid;
- }
- public struct DrupalCon
- {
- public string sessid;
- public DrupalUser user;
- }
- public interface IServiceSystem : IXmlRpcProxy
- {
- [XmlRpcMethod("system.connect")]
- Drupal Connect();
-
- [XmlRpcMethod("user.login")]
- DrupalCon Login(ref string hash, string domain_name, ref string timestamp, string nonce, string sessid, string username, string password);
- [XmlRpcMethod("user.login")]
- DrupalCon Login(string sessid, string username, string password);
- [XmlRpcMethod("user.login")]
- DrupalCon Login( string username, string password);
-
- [XmlRpcMethod("user.logout")]
- bool Logout(string sessid);
- [XmlRpcMethod("user.logout")]
- bool Logout();
-
-
- [XmlRpcMethod("user.get")]
- XmlRpcStruct UserGet(string sessid, int uid);
- [XmlRpcMethod("user.get")]
- XmlRpcStruct UserGet( int uid);
-
- [XmlRpcMethod("node.get")]
- XmlRpcStruct NodeGet(ref string hash,string domain_name,ref string timestamp,string nonce, string sessid, int nid, object fields);
- [XmlRpcMethod("node.get")]
- XmlRpcStruct NodeGet(string sessid, int nid, object fields);
- [XmlRpcMethod("node.get")]
- XmlRpcStruct NodeGet(int nid, object fields);
-
- [XmlRpcMethod("node.save")]
- string NodeSave(string sessid, object fields);
- [XmlRpcMethod("node.save")]
- string NodeSave(object fields);
-
- [XmlRpcMethod("views.get")]
- XmlRpcStruct[] ViewsGet(string sessid, string view_name,string display_id,object arrayfields,
- object arrayargs, int intoffset, int intlimit);
- [XmlRpcMethod("views.get")]
- XmlRpcStruct[] ViewsGet(string view_name, string display_id, object arrayfields,
- object arrayargs, int intoffset, int intlimit);
-
- [XmlRpcMethod("file.save")]
- string FileSave(string sessid, object file);
- [XmlRpcMethod("file.save")]
- string FileSave(object file);
-
- [XmlRpcMethod("file.get")]
- XmlRpcStruct FileGet(string sessid, int fid);
- [XmlRpcMethod("file.get")]
- XmlRpcStruct FileGet(int fid);
-
-
- [XmlRpcMethod("taxonomy.getTree")]
- XmlRpcStruct[] TaxonomyGetTree(string sessid, int vid);
- [XmlRpcMethod("taxonomy.getTree")]
- XmlRpcStruct[] TaxonomyGetTree( int vid);
-
- [XmlRpcMethod("og_vocab.getVocabs")]
- object OGgetVocab(string sessid, int ogID);
- [XmlRpcMethod("og_vocab.getVocabs")]
- object OGgetVocab( int ogID);
-
- }
- /// <summary>
- /// Configuration settings for drupal services module
- /// </summary>
- public class ServicesSettings
- {
- bool _cleanURL = false;
- public bool CleanURL
- {
- get { return _cleanURL; }
- set { _cleanURL = value; }
- }
-
- string _drupalURL="";
- /// <summary>
- /// URL to the drupal site
- /// </summary>
- public string DrupalURL
- {
- get { return _drupalURL; }
- set { _drupalURL = value; }
- }
-
- bool _useSessionID = false;
- /// <summary>
- /// If session ID feature is enabled in services module
- /// </summary>
- public bool UseSessionID
- {
- get { return _useSessionID; }
- set { _useSessionID = value; }
- }
-
- bool _useKeys = false;
- /// <summary>
- /// Specifies is provate key is required
- /// </summary>
- public bool UseKeys
- {
- get { return _useKeys; }
- set
- {
- if (value == true)
- throw new Exception("The private key feature is not supported yet");
- //_useKeys = value;
- }
- }
-
- string _key = "";
- /// <summary>
- /// Private Key, this is acquired from services module settings
- /// </summary>
- public string Key
- {
- get { return _key; }
- set { _key = value; }
- }
- string _domainName = "";
- /// <summary>
- /// Domain restriction used for the private key
- /// </summary>
- public string DomainName
- {
- get { return _domainName; }
- set { _domainName = value; }
- }
-
-
-
- }
- //----------------------------------------------------------------------------------------------------------
- /// <summary>
- /// enable to connect to drupal services using XML RPC
- /// </summary>
- public class Services : DrutNETBase, IConnection
- {
- //privates
-
- IServiceSystem drupalServiceSystem;
- string _sessionID=" ";
- string _uID;
- int _errorCode = 0;
- string _errorMsg = "";
- /// <summary>
- /// last error code return by exeption
- /// </summary>
- public int ErrorCode { get { return _errorCode; } }
- public string ErrorMessage { get { return _errorMsg; } }
- ServicesSettings _settings;
- /// <summary>
- /// Single Tone constructor
- /// </summary>
- public Services(ServicesSettings settings)
- {
- _settings = settings;
- }
-
- private void errorMessage(string msg)
- {
- sendLogEvent(msg, "Services", Enums.MessageType.Error);
- }
- private XmlRpcStruct handleExeption(Exception ex)
- {
- return handleExeption(ex, "");
- }
- private XmlRpcStruct handleExeption(Exception ex,string functionName)
- {
- if (ex is XmlRpcFaultException)
- {
- _errorCode = (ex as XmlRpcFaultException).FaultCode;
- _errorMsg = (ex as XmlRpcFaultException).Message;
- }
- else
- {
- _errorMsg = ex.Message;
- }
- errorMessage(functionName + " - " + ex.Message + "\n");
- return null;
- }
- private string handleExeptionStr(Exception ex, string functionName)
- {
- if (ex is XmlRpcFaultException)
- {
- _errorCode = (ex as XmlRpcFaultException).FaultCode;
- _errorMsg = (ex as XmlRpcFaultException).Message;
- }
- errorMessage(functionName + " - " + ex.Message + "\n");
- return "";
- }
-
- //<summary>
- //User ID of the logged-in user
- //</summary>
- public string UserID
- {
- get { return _uID; }
- }
-
- public XmlRpcStruct OGgetVocab(int ogID)
- {
- try
- {
- object vocabs;
- if (_settings.UseSessionID)
- vocabs = drupalServiceSystem.OGgetVocab(_sessionID, ogID);
- else
- vocabs = drupalServiceSystem.OGgetVocab(ogID);
-
- if (vocabs is XmlRpcStruct)
- return (vocabs as XmlRpcStruct);
- else
- return null;
- }
- catch (Exception ex)
- {
- return handleExeption(ex,"OG Get Vocabulary");
- }
- }
- public XmlRpcStruct[] TaxonomyGetTree(int vid)
- {
-
- try
- {
- if (_settings.UseSessionID)
- return drupalServiceSystem.TaxonomyGetTree(_sessionID, vid);
- else
- return drupalServiceSystem.TaxonomyGetTree(vid);
- }
- catch (Exception ex)
- {
- handleExeption(ex, "Taxonomy Get Tree");
- return null;
- }
- }
-
- /// <summary>
- /// Get file structure information
- /// </summary>
- /// <param name="fid">file id</param>
- /// <returns>File object structure</returns>
- public XmlRpcStruct FileGet(int fid)
- {
- try
- {
- if (_settings.UseSessionID)
- {
- // Use of key together with SID.
- if (_settings.UseKeys)
- {
- /*string hash = GetHMAC("", _settings.Key);
- string timestamp = GetUnixTimestamp();
- string nonce = GetNonce(10);
- return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid, ob);
- */
- throw new NotImplementedException("Private key not implemented yet");
- //return null;
- }
- else
- return drupalServiceSystem.FileGet(_sessionID, fid);
-
- }
- else
- return drupalServiceSystem.FileGet(fid);
- }
- catch (Exception ex)
- {
- return handleExeption(ex, "File Get");
- }
- }
- /// <summary>
- /// Add an already upload file to cck file field, without saving the node
- /// </summary>
- /// <param name="fileFieldName">CCK field name</param>
- /// <param name="fid">File ID to attach</param>
- /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
- /// <param name="node">Node to attach file to (alresdy load with node load)</param>
- public bool AttachFileToNode(string fileFieldName, int fid, int fileIndex, XmlRpcStruct node)
- {
- XmlRpcStruct filenode = this.FileGet(fid);
- if (filenode == null)
- {
- return false;
- }
- else
- {
- if (node[fileFieldName] == null)
- node[fileFieldName] = new object[1];
- // Index is not within range of lenght + 1
- if ((node[fileFieldName] as object[]).Length < fileIndex)
- {
- handleExeption(new IndexOutOfRangeException(), "Attach file to Node");
- return false;
- }
- else
- {
- // index is one bigger than existing array, we need to add one object manually
- List<object> objectList = new List<object>();
- if ((node[fileFieldName] as object[]).Length == fileIndex)
- {
- foreach (object ob in (node[fileFieldName] as object[]))
- objectList.Add(ob);
- objectList.Add(new object());
- node[fileFieldName] = objectList.ToArray();
- // Add index list required for multiple files.
- filenode.Add("list", (fileIndex + 1).ToString());
- }
- else
- {
- filenode.Add("list", (fileIndex + 1).ToString());
- //objectList.Add(new object());
- // node[fileFieldName] = objectList.ToArray();
- }
- (node[fileFieldName] as object[])[fileIndex] = filenode;
- return true;
- }
- }
- }
- /// <summary>
- /// Add an already upload file to cck file field, also saving node
- /// </summary>
- /// <param name="fileFieldName">CCK field name</param>
- /// <param name="fid">File ID to attach</param>
- /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
- /// <param name="node">Node ID attach file to</param>
- public bool AttachFileToNode(string fileFieldName, int fid, int fileIndex, int nid)
- {
- XmlRpcStruct node = this.NodeGet(nid);
- if (node != null)
- {
- AttachFileToNode(fileFieldName, fid, fileIndex, node);
- if (this.NodeSave(node) != 0)
- return true;
- }
- else
- handleExeption(new Exception("Unable to load node " + nid.ToString()), "AttachFileToNode");
- //errorMessage("Unable to load node " + nid.ToString());
- return false;
- }
-
- /// <summary>
- /// Return node structure
- /// </summary>
- /// <param name="nid">Node ID</param>
- /// <returns>Node structure</returns>
- public XmlRpcStruct NodeGet(int nid)
- {
- try
- {
- // Dummy object to send.
- object ob = new object();
- if (_settings.UseSessionID)
- {
- // Use of key together with SID.
- if (_settings.UseKeys)
- {
- string hash = GetHMAC("",_settings.Key);
- string timestamp = GetUnixTimestamp();
- string nonce = GetNonce(10);
- return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid,ob);
-
- }
- else
- return drupalServiceSystem.NodeGet(_sessionID, nid, ob);
-
- }
- else
- return drupalServiceSystem.NodeGet(nid, ob);
- }
- catch (Exception ex)
- {
- return handleExeption(ex, "Node Get");
- }
- }
- public XmlRpcStruct NodeGet(int nid, string[] fields)
- {
- try
- {
- if (_settings.UseSessionID)
- return drupalServiceSystem.NodeGet(_sessionID, nid, fields);
- else
- return drupalServiceSystem.NodeGet(nid, fields);
-
- }
- catch (Exception ex)
- {
- return handleExeption(ex, "Node Get");
- }
- }
-
- public XmlRpcStruct UserGet(int nid)
- {
-
- try
- {
- //get user
- if (_settings.UseSessionID)
- return drupalServiceSystem.UserGet(_sessionID, nid);
- else
- return drupalServiceSystem.UserGet( nid);
-
- }
- catch (Exception ex)
- {
- return handleExeption(ex, "User Get");
- }
- }
- /// <summary>
- /// Get logged in user information
- /// </summary>
- /// <returns></returns>
- public XmlRpcStruct UserGet()
- {
- try
- {
- int userID = Convert.ToInt32(this._uID);
- //get user
- if (_settings.UseSessionID)
- return drupalServiceSystem.UserGet(_sessionID, userID);
- else
- return drupalServiceSystem.UserGet( userID);
-
-
- }
- catch (Exception ex)
- {
- return handleExeption(ex, "User Get");
- }
- }
- /// <summary>
- /// Create a drupal file structure
- /// </summary>
- /// <param name="filePath"></param>
- /// <returns></returns>
- private XmlRpcStruct buildFileStruct(string filePath,string serverPath)
- {
- // Encode file to base64
- FileStream fs = new FileStream(filePath,FileMode.Open,FileAccess.Read);
- byte[] filebytes = new byte[fs.Length];
- fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
- string encodedFile = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);
- System.IO.FileInfo fi = new System.IO.FileInfo(filePath);
-
- CookComputing.XmlRpc.XmlRpcStruct fileStruct = new CookComputing.XmlRpc.XmlRpcStruct();
- fileStruct.Add("file", encodedFile);
- fileStruct.Add("filename", fi.Name);
- fileStruct.Add("filepath", serverPath + fi.Name);
- fileStruct.Add("filesize",fi.Length.ToString());
- fileStruct.Add("timestamp",GetUnixTimestamp());
- fileStruct.Add("uid", this.UserID);//Form Login
-
- return fileStruct;
- }
- /// <summary>
- /// Save file structure
- /// </summary>
- /// <param name="fid">file name</param>
- /// <returns>File ID</returns>
- public string FileSave(string filePath,string serverPath)
- {
- try
- {
- if (_settings.UseSessionID)
- {
- // Use of key together with SID.
- if (_settings.UseKeys)
- {
- /*string hash = GetHMAC("", _settings.Key);
- string timestamp = GetUnixTimestamp();
- string nonce = GetNonce(10);
- return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid, ob);
- */
- throw new NotImplementedException("Private key not implemented yet");
- //return null;
- }
- else
- return drupalServiceSystem.FileSave(_sessionID, buildFileStruct(filePath, serverPath));
-
- }
- else
- return drupalServiceSystem.FileSave(buildFileStruct(filePath, serverPath));
- }
- catch (Exception ex)
- {
- return handleExeptionStr(ex, "File Save");
- }
- }
- public bool FileUpload(string filePath,string fieldName,int fileIndex,int nodeID)
- {
- return FileUpload(filePath, fieldName, fileIndex, nodeID, @"sites/default/files/");
- }
- //
- //</param>
- //</param>
-
- /// <summary>
- /// Upload and attach a file to an existing NODE.
- /// </summary>
- /// <param name="filePath">Local path to file</param>
- /// <param name="fieldName">CCK field name of the file field in the node</param>
- /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
- /// <param name="nodeID">Node ID to attache file to</param>
- /// <param name="serverDirectory">Server directory path e.g: sites/default/files/ </param>
- /// <returns></returns>
- public bool FileUpload(string filePath,string fieldName,int fileIndex,int nodeID, string serverDirectory)
- {
- string fid = FileSave(filePath, serverDirectory);
- if (fid != "")
- {
- int file_id = Convert.ToInt32(fid);
- this.AttachFileToNode(fieldName, file_id, fileIndex, nodeID);
- return true;
- }
- return false;
- }
- public int NodeSave(XmlRpcStruct node)
- {
- try
- {
- string res;
- if (_settings.UseSessionID)
- res = drupalServiceSystem.NodeSave(_sessionID, node);
- else
- res = drupalServiceSystem.NodeSave(node);
-
- return Convert.ToInt32(res);
- }
- catch (Exception ex)
- {
- handleExeption(ex, "Node Save");
- return 0;
- }
- }
- public XmlRpcStruct[] ViewsGet(string viewName, string[] args)
- {
- return this.ViewsGet(viewName, 0, args);
- }
- public XmlRpcStruct[] ViewsGet(string viewName, int limit)
- {
- XmlRpcStruct arrayArgs = new XmlRpcStruct();
- // string[] arrayArgs=null;// = new string[]();
- return this.ViewsGet(viewName, limit, arrayArgs);
- }
- public XmlRpcStruct[] ViewsGet(string viewName, int limit, object args)
- {
- try
- {
- XmlRpcStruct o1 = new XmlRpcStruct();
- if (_settings.UseSessionID)
- return drupalServiceSystem.ViewsGet(_sessionID, viewName, "default", o1, args, 0, limit);
- else
- return drupalServiceSystem.ViewsGet(viewName, "default", o1, args, 0, limit);
- }
- catch (Exception ex)
- {
- _errorCode = 0;
- handleExeption(ex, "View Get");
- return null;
- }
- }
- //--------------------------------------------------------------------------------------
- public string ParseFieldArray(Enum arrayfieldName,Enum fieldName, XmlRpcStruct parentStruct)
- {
- try
- {
- if ((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[]).Length > 0)
- if ((((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[])
- [0] as XmlRpcStruct))!=null)
- return
- (((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[])
- [0] as XmlRpcStruct)[StringEnum.StrVal(fieldName)].ToString());
-
- return "";
- }
- catch
- {
- //errorMessage("Unable to read " + arrayfieldName.ToString());
- handleExeption(new Exception("Unable to read " + arrayfieldName.ToString()), "ParseFieldArray");
-
- return "";
-
- }
- }
- public string ParseField(Enum fieldName, XmlRpcStruct nodeStruct)
- {
- try
- {
- //if ((nodeStruct[StringEnum.StrVal(fieldName)] != null))
- return (nodeStruct[StringEnum.StrVal(fieldName)].ToString());
- }
- catch (Exception ex)
- {
- //errorMessage(ex.Message);
- handleExeption(ex, "ParseField");
-
- return "";
-
- }
- }
- public string ParseField(Enum fieldName, XmlRpcStruct nodeStruct,int arrayIndex )
- {
- try
- {
- //if ((nodeStruct[StringEnum.StrVal(fieldName)] != null))
- return (((nodeStruct[StringEnum.StrVal(fieldName)] as object[])
- [arrayIndex]as XmlRpcStruct)["value"].ToString());
- //((nodeStruct[StringEnum.StrVal(fieldName)]as object[])[0] as XmlRpcStruct)["value"].ToString()
- }
- catch (Exception ex)
- {
- //errorMessage(ex.Message);
- handleExeption(ex, "ParseField");
-
- return "";
-
- }
- }
- public string ParseField(string fieldName, XmlRpcStruct nodeStruct)
- {
- try
- {
- return (nodeStruct[fieldName].ToString());
- }
- catch (Exception ex)
- {
- //errorMessage(ex.Message);
- handleExeption(ex, "ParseField");
-
- return "";
-
- }
- }
- //public XmlRpcStruct FileSave(string sourceFullPath, string targetFolder)
- //{
- // try
- // {
- // return drupalServiceSystem.FileSave(sessionID, sourceFullPath, targetFolder, 1);
-
- // }
- // catch (Exception ex)
- // {
- // errorMessage(ex.Message);
- // return null;
- // }
- //}
- //public bool DownloadFile(string httpPath, string savePAth)
- //{
- // try
- // {
- // WebClient Client = new WebClient();
- // Client.DownloadFile(httpPath, savePAth);
- // return true;
- // }
- // catch (Exception ex)
- // {
- // errorMessage(ex.Message);
- // return false;
- // }
- //}
-
- //----------------------------------------------------------------------------------------------------------
- // Get the current Unix time stamp.
- private string GetUnixTimestamp()
- {
- TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
- return Convert.ToString(Convert.ToUInt64(ts.TotalSeconds));
- }
-
- // Similar to the 'user_password' function Drupal uses.
- private string GetNonce(int length)
- {
- string allowedCharacters = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
- StringBuilder password = new StringBuilder();
- Random rand = new Random();
-
- for (int i = 0; i < length; i++)
- {
- password.Append(allowedCharacters[rand.Next(0, (allowedCharacters.Length - 1))]);
- }
- return password.ToString();
- }
-
- // Compute the hash value.
- private string GetHMAC(string message, string key)
- {
- System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
- byte[] keyByte = encoding.GetBytes(key);
- byte[] messageByte = encoding.GetBytes(message);
-
- HMACSHA256 hmac = new HMACSHA256(keyByte);
- byte[] hashMessageByte = hmac.ComputeHash(messageByte);
-
- string sbinary = String.Empty;
- for (int i = 0; i < hashMessageByte.Length; i++)
- {
- // Converting to hex, but using lowercase 'x' to get lowercase characters
- sbinary += hashMessageByte[i].ToString("x2");
- }
-
- return sbinary;
- }
-
- #region IConnection Members
-
- public bool ReLogin()
- {
- return Login(_username, _password);
- }
- public string Username
- {
- get { return _username; }
- }
- bool _isLoggedIn = false;
- public bool IsLoggedIn
- {
- get { return this._isLoggedIn; }
- }
- string _username;
- string _password;
- public bool Login(string user, string password)
- {
- return Login(user, password, "");
- }
- public bool Login(string user, string password, string debugURL)
- {
- try
- {
- _username = user;
- _password = password;
- drupalServiceSystem = XmlRpcProxyGen.Create<IServiceSystem>();
- string xmlrpcServer;
- // Clean URL pref
- if (!_settings.CleanURL)
- xmlrpcServer = "?q=services/xmlrpc";
- else
- xmlrpcServer = "services/xmlrpc";
-
- drupalServiceSystem.Url = _settings.DrupalURL + xmlrpcServer + debugURL;
- Drupal cnct = drupalServiceSystem.Connect();
- DrupalCon lgn ;
- // SesionID pref
-
- if (_settings.UseSessionID)
- {
- if (_settings.UseKeys)
- {
- string hash = "";// GetHMAC("", _settings.Key);
- string timestamp="";// = GetUnixTimestamp();
- string nonce = GetNonce(10);
- lgn = drupalServiceSystem.Login(ref hash, _settings.DomainName, ref timestamp, nonce, cnct.sessid, user, password);
- }
- else
- lgn = drupalServiceSystem.Login(cnct.sessid, user, password);
-
- }
- else
- lgn = drupalServiceSystem.Login(user, password);
- if (lgn.user.name == _username)
- {
- _sessionID = lgn.sessid;
- _uID = lgn.user.uid; //returned from login
- _isLoggedIn = true;
- }
- else
- {
- _isLoggedIn = false;
- handleExeption(new Exception("Unable to login"), "Login");
- }
-
- }
- catch (Exception ex)
- {
- handleExeption(ex, "Login");
- _isLoggedIn = false;
- }
- return _isLoggedIn;
- }
- public bool Logout()
- {
- try
- {
- if (_settings.UseSessionID)
- drupalServiceSystem.Logout(_sessionID);
- else
- drupalServiceSystem.Logout();
- _isLoggedIn = false;
- return true;
- }
- catch (Exception ex)
- {
- handleExeption(ex, "Logout");
- return false;
- }
- }
- public string ServerURL
- {
- get { return _settings.DrupalURL; }
- }
-
- #endregion
- }
-
-
-}
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Text;
+using CookComputing.XmlRpc;
+using System.Security.Cryptography;
+using System.Net;
+using DrutNET;
+using System.IO;
+
+
+namespace DrutNET
+{
+ // Since we don't want an error to pop up if the returned Drupal user object
+ // contains a field which does not map to a field or struct has we need to
+ // add the MappingOption.
+ [XmlRpcMissingMapping(MappingAction.Ignore)]
+ public struct DrupalUser
+ {
+ // Fields
+ public string name;
+ public string uid;
+ public string mail;
+ }
+ public struct Drupal
+ {
+ public string sessid;
+ }
+ public struct DrupalCon
+ {
+ public string sessid;
+ public DrupalUser user;
+ }
+ public interface IServiceSystem : IXmlRpcProxy
+ {
+ [XmlRpcMethod("system.connect")]
+ Drupal Connect();
+
+ [XmlRpcMethod("user.login")]
+ DrupalCon Login(ref string hash, string domain_name, ref string timestamp, string nonce, string sessid, string username, string password);
+ [XmlRpcMethod("user.login")]
+ DrupalCon Login(string sessid, string username, string password);
+ [XmlRpcMethod("user.login")]
+ DrupalCon Login( string username, string password);
+
+ [XmlRpcMethod("user.logout")]
+ bool Logout(string sessid);
+ [XmlRpcMethod("user.logout")]
+ bool Logout();
+
+
+ [XmlRpcMethod("user.get")]
+ XmlRpcStruct UserGet(string sessid, int uid);
+ [XmlRpcMethod("user.get")]
+ XmlRpcStruct UserGet( int uid);
+
+ [XmlRpcMethod("node.get")]
+ XmlRpcStruct NodeGet(ref string hash,string domain_name,ref string timestamp,string nonce, string sessid, int nid, object fields);
+ [XmlRpcMethod("node.get")]
+ XmlRpcStruct NodeGet(string sessid, int nid, object fields);
+ [XmlRpcMethod("node.get")]
+ XmlRpcStruct NodeGet(int nid, object fields);
+
+ [XmlRpcMethod("node.save")]
+ string NodeSave(string sessid, object fields);
+ [XmlRpcMethod("node.save")]
+ string NodeSave(object fields);
+
+ [XmlRpcMethod("views.get")]
+ XmlRpcStruct[] ViewsGet(string sessid, string view_name,string display_id,object arrayfields,
+ object arrayargs, int intoffset, int intlimit);
+ [XmlRpcMethod("views.get")]
+ XmlRpcStruct[] ViewsGet(string view_name, string display_id, object arrayfields,
+ object arrayargs, int intoffset, int intlimit);
+
+ [XmlRpcMethod("file.save")]
+ string FileSave(string sessid, object file);
+ [XmlRpcMethod("file.save")]
+ string FileSave(object file);
+
+ [XmlRpcMethod("file.get")]
+ XmlRpcStruct FileGet(string sessid, int fid);
+ [XmlRpcMethod("file.get")]
+ XmlRpcStruct FileGet(int fid);
+
+
+ [XmlRpcMethod("taxonomy.getTree")]
+ XmlRpcStruct[] TaxonomyGetTree(string sessid, int vid);
+ [XmlRpcMethod("taxonomy.getTree")]
+ XmlRpcStruct[] TaxonomyGetTree( int vid);
+
+ [XmlRpcMethod("og_vocab.getVocabs")]
+ object OGgetVocab(string sessid, int ogID);
+ [XmlRpcMethod("og_vocab.getVocabs")]
+ object OGgetVocab( int ogID);
+
+ }
+ /// <summary>
+ /// Configuration settings for drupal services module
+ /// </summary>
+ public class ServicesSettings
+ {
+ bool _cleanURL = false;
+ public bool CleanURL
+ {
+ get { return _cleanURL; }
+ set { _cleanURL = value; }
+ }
+
+ string _drupalURL="";
+ /// <summary>
+ /// URL to the drupal site
+ /// </summary>
+ public string DrupalURL
+ {
+ get { return _drupalURL; }
+ set { _drupalURL = value; }
+ }
+
+ bool _useSessionID = false;
+ /// <summary>
+ /// If session ID feature is enabled in services module
+ /// </summary>
+ public bool UseSessionID
+ {
+ get { return _useSessionID; }
+ set { _useSessionID = value; }
+ }
+
+ bool _useKeys = false;
+ /// <summary>
+ /// Specifies is provate key is required
+ /// </summary>
+ public bool UseKeys
+ {
+ get { return _useKeys; }
+ set
+ {
+ if (value == true)
+ throw new Exception("The private key feature is not supported yet");
+ //_useKeys = value;
+ }
+ }
+
+ string _key = "";
+ /// <summary>
+ /// Private Key, this is acquired from services module settings
+ /// </summary>
+ public string Key
+ {
+ get { return _key; }
+ set { _key = value; }
+ }
+ string _domainName = "";
+ /// <summary>
+ /// Domain restriction used for the private key
+ /// </summary>
+ public string DomainName
+ {
+ get { return _domainName; }
+ set { _domainName = value; }
+ }
+
+
+
+ }
+ //----------------------------------------------------------------------------------------------------------
+ /// <summary>
+ /// enable to connect to drupal services using XML RPC
+ /// </summary>
+ public class Services : DrutNETBase, IConnection
+ {
+ //privates
+
+ IServiceSystem drupalServiceSystem;
+ string _sessionID=" ";
+ string _uID;
+ int _errorCode = 0;
+ string _errorMsg = "";
+ /// <summary>
+ /// last error code return by exeption
+ /// </summary>
+ public int ErrorCode { get { return _errorCode; } }
+ public string ErrorMessage { get { return _errorMsg; } }
+ ServicesSettings _settings;
+ /// <summary>
+ /// Single Tone constructor
+ /// </summary>
+ public Services(ServicesSettings settings)
+ {
+ _settings = settings;
+ }
+
+ private void errorMessage(string msg)
+ {
+ sendLogEvent(msg, "Services", Enums.MessageType.Error);
+ }
+ private XmlRpcStruct handleExeption(Exception ex)
+ {
+ return handleExeption(ex, "");
+ }
+ private XmlRpcStruct handleExeption(Exception ex,string functionName)
+ {
+ if (ex is XmlRpcFaultException)
+ {
+ _errorCode = (ex as XmlRpcFaultException).FaultCode;
+ _errorMsg = (ex as XmlRpcFaultException).Message;
+ }
+ else
+ {
+ _errorMsg = ex.Message;
+ }
+ errorMessage(functionName + " - " + ex.Message + "\n");
+ return null;
+ }
+ private string handleExeptionStr(Exception ex, string functionName)
+ {
+ if (ex is XmlRpcFaultException)
+ {
+ _errorCode = (ex as XmlRpcFaultException).FaultCode;
+ _errorMsg = (ex as XmlRpcFaultException).Message;
+ }
+ errorMessage(functionName + " - " + ex.Message + "\n");
+ return "";
+ }
+
+ //<summary>
+ //User ID of the logged-in user
+ //</summary>
+ public string UserID
+ {
+ get { return _uID; }
+ }
+
+ public XmlRpcStruct OGgetVocab(int ogID)
+ {
+ try
+ {
+ object vocabs;
+ if (_settings.UseSessionID)
+ vocabs = drupalServiceSystem.OGgetVocab(_sessionID, ogID);
+ else
+ vocabs = drupalServiceSystem.OGgetVocab(ogID);
+
+ if (vocabs is XmlRpcStruct)
+ return (vocabs as XmlRpcStruct);
+ else
+ return null;
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex,"OG Get Vocabulary");
+ }
+ }
+ public XmlRpcStruct[] TaxonomyGetTree(int vid)
+ {
+
+ try
+ {
+ if (_settings.UseSessionID)
+ return drupalServiceSystem.TaxonomyGetTree(_sessionID, vid);
+ else
+ return drupalServiceSystem.TaxonomyGetTree(vid);
+ }
+ catch (Exception ex)
+ {
+ handleExeption(ex, "Taxonomy Get Tree");
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Get file structure information
+ /// </summary>
+ /// <param name="fid">file id</param>
+ /// <returns>File object structure</returns>
+ public XmlRpcStruct FileGet(int fid)
+ {
+ try
+ {
+ if (_settings.UseSessionID)
+ {
+ // Use of key together with SID.
+ if (_settings.UseKeys)
+ {
+ /*string hash = GetHMAC("", _settings.Key);
+ string timestamp = GetUnixTimestamp();
+ string nonce = GetNonce(10);
+ return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid, ob);
+ */
+ throw new NotImplementedException("Private key not implemented yet");
+ //return null;
+ }
+ else
+ return drupalServiceSystem.FileGet(_sessionID, fid);
+
+ }
+ else
+ return drupalServiceSystem.FileGet(fid);
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex, "File Get");
+ }
+ }
+ /// <summary>
+ /// Add an already upload file to cck file field, without saving the node
+ /// </summary>
+ /// <param name="fileFieldName">CCK field name</param>
+ /// <param name="fid">File ID to attach</param>
+ /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
+ /// <param name="node">Node to attach file to (alresdy load with node load)</param>
+ public bool AttachFileToNode(string fileFieldName, int fid, int fileIndex, XmlRpcStruct node)
+ {
+ XmlRpcStruct filenode = this.FileGet(fid);
+ if (filenode == null)
+ {
+ return false;
+ }
+ else
+ {
+ if (node[fileFieldName] == null)
+ node[fileFieldName] = new object[1];
+ // Index is not within range of lenght + 1
+ if ((node[fileFieldName] as object[]).Length < fileIndex)
+ {
+ handleExeption(new IndexOutOfRangeException(), "Attach file to Node");
+ return false;
+ }
+ else
+ {
+ // index is one bigger than existing array, we need to add one object manually
+ List<object> objectList = new List<object>();
+ if ((node[fileFieldName] as object[]).Length == fileIndex)
+ {
+ foreach (object ob in (node[fileFieldName] as object[]))
+ objectList.Add(ob);
+ objectList.Add(new object());
+ node[fileFieldName] = objectList.ToArray();
+ // Add index list required for multiple files.
+ filenode.Add("list", (fileIndex + 1).ToString());
+ }
+ else
+ {
+ filenode.Add("list", (fileIndex + 1).ToString());
+ //objectList.Add(new object());
+ // node[fileFieldName] = objectList.ToArray();
+ }
+ (node[fileFieldName] as object[])[fileIndex] = filenode;
+ return true;
+ }
+ }
+ }
+ /// <summary>
+ /// Add an already upload file to cck file field, also saving node
+ /// </summary>
+ /// <param name="fileFieldName">CCK field name</param>
+ /// <param name="fid">File ID to attach</param>
+ /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
+ /// <param name="node">Node ID attach file to</param>
+ public bool AttachFileToNode(string fileFieldName, int fid, int fileIndex, int nid)
+ {
+ XmlRpcStruct node = this.NodeGet(nid);
+ if (node != null)
+ {
+ AttachFileToNode(fileFieldName, fid, fileIndex, node);
+ if (this.NodeSave(node) != 0)
+ return true;
+ }
+ else
+ handleExeption(new Exception("Unable to load node " + nid.ToString()), "AttachFileToNode");
+ //errorMessage("Unable to load node " + nid.ToString());
+ return false;
+ }
+
+ /// <summary>
+ /// Return node structure
+ /// </summary>
+ /// <param name="nid">Node ID</param>
+ /// <returns>Node structure</returns>
+ public XmlRpcStruct NodeGet(int nid)
+ {
+ try
+ {
+ // Dummy object to send.
+ object ob = new object();
+ if (_settings.UseSessionID)
+ {
+ // Use of key together with SID.
+ if (_settings.UseKeys)
+ {
+ string hash = GetHMAC("",_settings.Key);
+ string timestamp = GetUnixTimestamp();
+ string nonce = GetNonce(10);
+ return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid,ob);
+
+ }
+ else
+ return drupalServiceSystem.NodeGet(_sessionID, nid, ob);
+
+ }
+ else
+ return drupalServiceSystem.NodeGet(nid, ob);
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex, "Node Get");
+ }
+ }
+ public XmlRpcStruct NodeGet(int nid, string[] fields)
+ {
+ try
+ {
+ if (_settings.UseSessionID)
+ return drupalServiceSystem.NodeGet(_sessionID, nid, fields);
+ else
+ return drupalServiceSystem.NodeGet(nid, fields);
+
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex, "Node Get");
+ }
+ }
+
+ public XmlRpcStruct UserGet(int nid)
+ {
+
+ try
+ {
+ //get user
+ if (_settings.UseSessionID)
+ return drupalServiceSystem.UserGet(_sessionID, nid);
+ else
+ return drupalServiceSystem.UserGet( nid);
+
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex, "User Get");
+ }
+ }
+ /// <summary>
+ /// Get logged in user information
+ /// </summary>
+ /// <returns></returns>
+ public XmlRpcStruct UserGet()
+ {
+ try
+ {
+ int userID = Convert.ToInt32(this._uID);
+ //get user
+ if (_settings.UseSessionID)
+ return drupalServiceSystem.UserGet(_sessionID, userID);
+ else
+ return drupalServiceSystem.UserGet( userID);
+
+
+ }
+ catch (Exception ex)
+ {
+ return handleExeption(ex, "User Get");
+ }
+ }
+ /// <summary>
+ /// Create a drupal file structure
+ /// </summary>
+ /// <param name="filePath"></param>
+ /// <returns></returns>
+ private XmlRpcStruct buildFileStruct(string filePath,string serverPath)
+ {
+ // Encode file to base64
+ FileStream fs = new FileStream(filePath,FileMode.Open,FileAccess.Read);
+ byte[] filebytes = new byte[fs.Length];
+ fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
+ string encodedFile = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);
+ System.IO.FileInfo fi = new System.IO.FileInfo(filePath);
+
+ CookComputing.XmlRpc.XmlRpcStruct fileStruct = new CookComputing.XmlRpc.XmlRpcStruct();
+ fileStruct.Add("file", encodedFile);
+ fileStruct.Add("filename", fi.Name);
+ fileStruct.Add("filepath", serverPath + fi.Name);
+ fileStruct.Add("filesize",fi.Length.ToString());
+ fileStruct.Add("timestamp",GetUnixTimestamp());
+ fileStruct.Add("uid", this.UserID);//Form Login
+
+ return fileStruct;
+ }
+ /// <summary>
+ /// Save file structure
+ /// </summary>
+ /// <param name="fid">file name</param>
+ /// <returns>File ID</returns>
+ public string FileSave(string filePath,string serverPath)
+ {
+ try
+ {
+ if (_settings.UseSessionID)
+ {
+ // Use of key together with SID.
+ if (_settings.UseKeys)
+ {
+ /*string hash = GetHMAC("", _settings.Key);
+ string timestamp = GetUnixTimestamp();
+ string nonce = GetNonce(10);
+ return drupalServiceSystem.NodeGet(ref hash, _settings.DomainName, ref timestamp, nonce, _sessionID, nid, ob);
+ */
+ throw new NotImplementedException("Private key not implemented yet");
+ //return null;
+ }
+ else
+ return drupalServiceSystem.FileSave(_sessionID, buildFileStruct(filePath, serverPath));
+
+ }
+ else
+ return drupalServiceSystem.FileSave(buildFileStruct(filePath, serverPath));
+ }
+ catch (Exception ex)
+ {
+ return handleExeptionStr(ex, "File Save");
+ }
+ }
+ public bool FileUpload(string filePath,string fieldName,int fileIndex,int nodeID)
+ {
+ return FileUpload(filePath, fieldName, fileIndex, nodeID, @"sites/default/files/");
+ }
+ //
+ //</param>
+ //</param>
+
+ /// <summary>
+ /// Upload and attach a file to an existing NODE.
+ /// </summary>
+ /// <param name="filePath">Local path to file</param>
+ /// <param name="fieldName">CCK field name of the file field in the node</param>
+ /// <param name="fileIndex">file index in case of multiple file field, for single file use 0</param>
+ /// <param name="nodeID">Node ID to attache file to</param>
+ /// <param name="serverDirectory">Server directory path e.g: sites/default/files/ </param>
+ /// <returns></returns>
+ public bool FileUpload(string filePath,string fieldName,int fileIndex,int nodeID, string serverDirectory)
+ {
+ string fid = FileSave(filePath, serverDirectory);
+ if (fid != "")
+ {
+ int file_id = Convert.ToInt32(fid);
+ this.AttachFileToNode(fieldName, file_id, fileIndex, nodeID);
+ return true;
+ }
+ return false;
+ }
+ public int NodeSave(XmlRpcStruct node)
+ {
+ try
+ {
+ string res;
+ if (_settings.UseSessionID)
+ res = drupalServiceSystem.NodeSave(_sessionID, node);
+ else
+ res = drupalServiceSystem.NodeSave(node);
+
+ return Convert.ToInt32(res);
+ }
+ catch (Exception ex)
+ {
+ handleExeption(ex, "Node Save");
+ return 0;
+ }
+ }
+ public XmlRpcStruct[] ViewsGet(string viewName, string[] args)
+ {
+ return this.ViewsGet(viewName, 0, args);
+ }
+ public XmlRpcStruct[] ViewsGet(string viewName, int limit)
+ {
+ XmlRpcStruct arrayArgs = new XmlRpcStruct();
+ // string[] arrayArgs=null;// = new string[]();
+ return this.ViewsGet(viewName, limit, arrayArgs);
+ }
+ public XmlRpcStruct[] ViewsGet(string viewName, int limit, object args)
+ {
+ try
+ {
+ XmlRpcStruct o1 = new XmlRpcStruct();
+ if (_settings.UseSessionID)
+ return drupalServiceSystem.ViewsGet(_sessionID, viewName, "default", o1, args, 0, limit);
+ else
+ return drupalServiceSystem.ViewsGet(viewName, "default", o1, args, 0, limit);
+ }
+ catch (Exception ex)
+ {
+ _errorCode = 0;
+ handleExeption(ex, "View Get");
+ return null;
+ }
+ }
+ //--------------------------------------------------------------------------------------
+ public string ParseFieldArray(Enum arrayfieldName,Enum fieldName, XmlRpcStruct parentStruct)
+ {
+ try
+ {
+ if ((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[]).Length > 0)
+ if ((((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[])
+ [0] as XmlRpcStruct))!=null)
+ return
+ (((parentStruct[StringEnum.StrVal(arrayfieldName)] as object[])
+ [0] as XmlRpcStruct)[StringEnum.StrVal(fieldName)].ToString());
+
+ return "";
+ }
+ catch
+ {
+ //errorMessage("Unable to read " + arrayfieldName.ToString());
+ handleExeption(new Exception("Unable to read " + arrayfieldName.ToString()), "ParseFieldArray");
+
+ return "";
+
+ }
+ }
+ public string ParseField(Enum fieldName, XmlRpcStruct nodeStruct)
+ {
+ try
+ {
+ //if ((nodeStruct[StringEnum.StrVal(fieldName)] != null))
+ return (nodeStruct[StringEnum.StrVal(fieldName)].ToString());
+ }
+ catch (Exception ex)
+ {
+ //errorMessage(ex.Message);
+ handleExeption(ex, "ParseField");
+
+ return "";
+
+ }
+ }
+ public string ParseField(Enum fieldName, XmlRpcStruct nodeStruct,int arrayIndex )
+ {
+ try
+ {
+ //if ((nodeStruct[StringEnum.StrVal(fieldName)] != null))
+ return (((nodeStruct[StringEnum.StrVal(fieldName)] as object[])
+ [arrayIndex]as XmlRpcStruct)["value"].ToString());
+ //((nodeStruct[StringEnum.StrVal(fieldName)]as object[])[0] as XmlRpcStruct)["value"].ToString()
+ }
+ catch (Exception ex)
+ {
+ //errorMessage(ex.Message);
+ handleExeption(ex, "ParseField");
+
+ return "";
+
+ }
+ }
+ public string ParseField(string fieldName, XmlRpcStruct nodeStruct)
+ {
+ try
+ {
+ return (nodeStruct[fieldName].ToString());
+ }
+ catch (Exception ex)
+ {
+ //errorMessage(ex.Message);
+ handleExeption(ex, "ParseField");
+
+ return "";
+
+ }
+ }
+ //public XmlRpcStruct FileSave(string sourceFullPath, string targetFolder)
+ //{
+ // try
+ // {
+ // return drupalServiceSystem.FileSave(sessionID, sourceFullPath, targetFolder, 1);
+
+ // }
+ // catch (Exception ex)
+ // {
+ // errorMessage(ex.Message);
+ // return null;
+ // }
+ //}
+ //public bool DownloadFile(string httpPath, string savePAth)
+ //{
+ // try
+ // {
+ // WebClient Client = new WebClient();
+ // Client.DownloadFile(httpPath, savePAth);
+ // return true;
+ // }
+ // catch (Exception ex)
+ // {
+ // errorMessage(ex.Message);
+ // return false;
+ // }
+ //}
+
+ //----------------------------------------------------------------------------------------------------------
+ // Get the current Unix time stamp.
+ private string GetUnixTimestamp()
+ {
+ TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
+ return Convert.ToString(Convert.ToUInt64(ts.TotalSeconds));
+ }
+
+ // Similar to the 'user_password' function Drupal uses.
+ private string GetNonce(int length)
+ {
+ string allowedCharacters = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
+ StringBuilder password = new StringBuilder();
+ Random rand = new Random();
+
+ for (int i = 0; i < length; i++)
+ {
+ password.Append(allowedCharacters[rand.Next(0, (allowedCharacters.Length - 1))]);
+ }
+ return password.ToString();
+ }
+
+ // Compute the hash value.
+ private string GetHMAC(string message, string key)
+ {
+ System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
+ byte[] keyByte = encoding.GetBytes(key);
+ byte[] messageByte = encoding.GetBytes(message);
+
+ HMACSHA256 hmac = new HMACSHA256(keyByte);
+ byte[] hashMessageByte = hmac.ComputeHash(messageByte);
+
+ string sbinary = String.Empty;
+ for (int i = 0; i < hashMessageByte.Length; i++)
+ {
+ // Converting to hex, but using lowercase 'x' to get lowercase characters
+ sbinary += hashMessageByte[i].ToString("x2");
+ }
+
+ return sbinary;
+ }
+
+ #region IConnection Members
+
+ public bool ReLogin()
+ {
+ return Login(_username, _password);
+ }
+ public string Username
+ {
+ get { return _username; }
+ }
+ bool _isLoggedIn = false;
+ public bool IsLoggedIn
+ {
+ get { return this._isLoggedIn; }
+ }
+ string _username;
+ string _password;
+ public bool Login(string user, string password)
+ {
+ return Login(user, password, "");
+ }
+ public bool Login(string user, string password, string debugURL)
+ {
+ try
+ {
+ _username = user;
+ _password = password;
+ drupalServiceSystem = XmlRpcProxyGen.Create<IServiceSystem>();
+ string xmlrpcServer;
+ // Clean URL pref
+ if (!_settings.CleanURL)
+ xmlrpcServer = "?q=services/xmlrpc";
+ else
+ xmlrpcServer = "services/xmlrpc";
+
+ drupalServiceSystem.Url = _settings.DrupalURL + xmlrpcServer + debugURL;
+ Drupal cnct = drupalServiceSystem.Connect();
+ DrupalCon lgn ;
+ // SesionID pref
+
+ if (_settings.UseSessionID)
+ {
+ if (_settings.UseKeys)
+ {
+ string hash = "";// GetHMAC("", _settings.Key);
+ string timestamp="";// = GetUnixTimestamp();
+ string nonce = GetNonce(10);
+ lgn = drupalServiceSystem.Login(ref hash, _settings.DomainName, ref timestamp, nonce, cnct.sessid, user, password);
+ }
+ else
+ lgn = drupalServiceSystem.Login(cnct.sessid, user, password);
+
+ }
+ else
+ lgn = drupalServiceSystem.Login(user, password);
+ if (lgn.user.name == _username)
+ {
+ _sessionID = lgn.sessid;
+ _uID = lgn.user.uid; //returned from login
+ _isLoggedIn = true;
+ }
+ else
+ {
+ _isLoggedIn = false;
+ handleExeption(new Exception("Unable to login"), "Login");
+ }
+
+ }
+ catch (Exception ex)
+ {
+ handleExeption(ex, "Login");
+ _isLoggedIn = false;
+ }
+ return _isLoggedIn;
+ }
+ public bool Logout()
+ {
+ try
+ {
+ if (_settings.UseSessionID)
+ drupalServiceSystem.Logout(_sessionID);
+ else
+ drupalServiceSystem.Logout();
+ _isLoggedIn = false;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ handleExeption(ex, "Logout");
+ return false;
+ }
+ }
+ public string ServerURL
+ {
+ get { return _settings.DrupalURL; }
+ }
+
+ #endregion
+ }
+
+
+}
View
BIN  Dlls/DrutNET.dll
Binary file not shown
View
BIN  Dlls/DrutNETSample.exe
Binary file not shown
View
0  Dlls/LibCurlNet.dll 100755 → 100644
File mode changed
View
0  Dlls/LibCurlNet.xml 100755 → 100644
File mode changed
View
0  Dlls/LibCurlShim.dll 100755 → 100644
File mode changed
View
0  Dlls/libcurl.dll 100755 → 100644
File mode changed
View
0  Drupal Module/drutnet_sample/drutnet_sample.defaults.inc 100755 → 100644
File mode changed
View
0  Drupal Module/drutnet_sample/drutnet_sample.features.inc 100755 → 100644
File mode changed
View
0  Drupal Module/drutnet_sample/drutnet_sample.features.node.inc 100755 → 100644
File mode changed
View
0  Drupal Module/drutnet_sample/drutnet_sample.info 100755 → 100644
File mode changed
View
0  Drupal Module/drutnet_sample/drutnet_sample.module 100755 → 100644
File mode changed
View
0  Drupal Module/file_form/file_form.info 100755 → 100644
File mode changed
View
0  Drupal Module/file_form/file_form.module 100755 → 100644
File mode changed
View
0  Drupal Module/readme.txt 100755 → 100644
File mode changed
View
27 DrutNET.csproj
@@ -31,19 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="CookComputing.XmlRpcV2, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>Dlls\CookComputing.XmlRpcV2.dll</HintPath>
- </Reference>
- <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>Dlls\ICSharpCode.SharpZipLib.dll</HintPath>
- </Reference>
- <Reference Include="LibCurlNet, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dfa5e73bd1f79635, processorArchitecture=MSIL" />
- <Reference Include="LumenWorks.Framework.IO, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>Dlls\LumenWorks.Framework.IO.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
@@ -107,6 +94,20 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="External_lib\cURL.net\src\LibCurlNet.csproj">
+ <Project>{AEF8DC8B-814F-4C03-B048-55EE0F093496}</Project>
+ <Name>LibCurlNet</Name>
+ </ProjectReference>
+ <ProjectReference Include="External_lib\SharpZipLib\ICSharpCode.SharpZLib.csproj">
+ <Project>{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}</Project>
+ <Name>ICSharpCode.SharpZLib</Name>
+ </ProjectReference>
+ <ProjectReference Include="External_lib\XML-RPC.net\src\xmlrpc.csproj">
+ <Project>{1B4B0A58-0AFB-4090-91DD-18912CC7DE65}</Project>
+ <Name>xmlrpc</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
<Folder Include="Class\Properties\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
View
89 DrutNET.sln
@@ -1,32 +1,57 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrutNET", "DrutNET.csproj", "{CB90E82C-7972-4565-B020-E7C84B91ECA1}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrutNETSample", "DrutNETSample\DrutNETSample.csproj", "{32495194-2194-4D17-A374-1BE81D0A7D40}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileSaveWithServices", "..\FileSaveWithServices\FileSaveWithServices.csproj", "{D10E0FC3-252B-4670-A90F-DD71E6319D26}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Release|Any CPU.Build.0 = Release|Any CPU
- {32495194-2194-4D17-A374-1BE81D0A7D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {32495194-2194-4D17-A374-1BE81D0A7D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {32495194-2194-4D17-A374-1BE81D0A7D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {32495194-2194-4D17-A374-1BE81D0A7D40}.Release|Any CPU.Build.0 = Release|Any CPU
- {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrutNET", "DrutNET.csproj", "{CB90E82C-7972-4565-B020-E7C84B91ECA1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrutNETSample", "DrutNETSample\DrutNETSample.csproj", "{32495194-2194-4D17-A374-1BE81D0A7D40}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileSaveWithServices", "..\FileSaveWithServices\FileSaveWithServices.csproj", "{D10E0FC3-252B-4670-A90F-DD71E6319D26}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibCurlNet", "External_lib\cURL.net\src\LibCurlNet.csproj", "{AEF8DC8B-814F-4C03-B048-55EE0F093496}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpZLib", "External_lib\SharpZipLib\ICSharpCode.SharpZLib.csproj", "{0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xmlrpc", "External_lib\XML-RPC.net\src\xmlrpc.csproj", "{1B4B0A58-0AFB-4090-91DD-18912CC7DE65}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{D8FE8D3E-1113-4177-905B-5B2BD6B88742}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CB90E82C-7972-4565-B020-E7C84B91ECA1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32495194-2194-4D17-A374-1BE81D0A7D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32495194-2194-4D17-A374-1BE81D0A7D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32495194-2194-4D17-A374-1BE81D0A7D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32495194-2194-4D17-A374-1BE81D0A7D40}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D10E0FC3-252B-4670-A90F-DD71E6319D26}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AEF8DC8B-814F-4C03-B048-55EE0F093496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AEF8DC8B-814F-4C03-B048-55EE0F093496}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AEF8DC8B-814F-4C03-B048-55EE0F093496}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AEF8DC8B-814F-4C03-B048-55EE0F093496}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1B4B0A58-0AFB-4090-91DD-18912CC7DE65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1B4B0A58-0AFB-4090-91DD-18912CC7DE65}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1B4B0A58-0AFB-4090-91DD-18912CC7DE65}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1B4B0A58-0AFB-4090-91DD-18912CC7DE65}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {AEF8DC8B-814F-4C03-B048-55EE0F093496} = {D8FE8D3E-1113-4177-905B-5B2BD6B88742}
+ {0E7413FF-EB9E-4714-ACF2-BE3A6A7B2FFD} = {D8FE8D3E-1113-4177-905B-5B2BD6B88742}
+ {1B4B0A58-0AFB-4090-91DD-18912CC7DE65} = {D8FE8D3E-1113-4177-905B-5B2BD6B88742}
+ EndGlobalSection
+EndGlobal
View
BIN  DrutNET.suo
Binary file not shown
View
199 DrutNETSample/DrutNETSample.csproj
@@ -1,103 +1,110 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{32495194-2194-4D17-A374-1BE81D0A7D40}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>DrutNETSample</RootNamespace>
- <AssemblyName>DrutNETSample</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <StartupObject>DrutNETSample.Program</StartupObject>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="CookComputing.XmlRpcV2, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
- <Reference Include="System" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.DirectoryServices" />
- <Reference Include="System.Xml.Linq">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data.DataSetExtensions">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Deployment" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Form1.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="Form1.Designer.cs">
- <DependentUpon>Form1.cs</DependentUpon>
- </Compile>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <EmbeddedResource Include="Form1.resx">
- <DependentUpon>Form1.cs</DependentUpon>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- <EmbeddedResource Include="Properties\Resources.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
- <None Include="Properties\Settings.settings">
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- <Compile Include="Properties\Settings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DependentUpon>Settings.settings</DependentUpon>
- <DesignTimeSharedInput>True</DesignTimeSharedInput>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\DrutNET.csproj">
- <Project>{CB90E82C-7972-4565-B020-E7C84B91ECA1}</Project>
- <Name>DrutNET</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{32495194-2194-4D17-A374-1BE81D0A7D40}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DrutNETSample</RootNamespace>
+ <AssemblyName>DrutNETSample</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <StartupObject>DrutNETSample.Program</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.DirectoryServices" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Form1.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form1.Designer.cs">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Form1.resx">
+ <DependentUpon>Form1.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\DrutNET.csproj">
+ <Project>{CB90E82C-7972-4565-B020-E7C84B91ECA1}</Project>
+ <Name>DrutNET</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\External_lib\cURL.net\src\LibCurlNet.csproj">
+ <Project>{AEF8DC8B-814F-4C03-B048-55EE0F093496}</Project>
+ <Name>LibCurlNet</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\External_lib\XML-RPC.net\src\xmlrpc.csproj">
+ <Project>{1B4B0A58-0AFB-4090-91DD-18912CC7DE65}</Project>
+ <Name>xmlrpc</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
- -->
- <PropertyGroup>
- <PostBuildEvent>copy $(TargetPath) $(ProjectDir)\..\Dlls</PostBuildEvent>
- </PropertyGroup>
+ -->
+ <PropertyGroup>
+ <PostBuildEvent>copy $(TargetPath) $(ProjectDir)\..\Dlls</PostBuildEvent>
+ </PropertyGroup>
</Project>
View
856 DrutNETSample/Form1.Designer.cs
@@ -27,438 +27,438 @@ protected override void Dispose(bool disposing)
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
- {
- this.button_save = new System.Windows.Forms.Button();
- this.button_load = new System.Windows.Forms.Button();
- this.label_nid = new System.Windows.Forms.Label();
- this.textBox_nodeID = new System.Windows.Forms.TextBox();
- this.tabControl1 = new System.Windows.Forms.TabControl();
- this.tabPage1 = new System.Windows.Forms.TabPage();
- this.label2 = new System.Windows.Forms.Label();
- this.webBrowser1 = new System.Windows.Forms.WebBrowser();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.tabPage2 = new System.Windows.Forms.TabPage();
- this.progressBar1 = new System.Windows.Forms.ProgressBar();
- this.textBox_fieldName = new System.Windows.Forms.TextBox();
- this.label8 = new System.Windows.Forms.Label();
- this.textBox_fileNode = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.button_upload = new System.Windows.Forms.Button();
- this.button_browse = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
- this.button_logout_curl = new System.Windows.Forms.Button();
- this.button_login_curl = new System.Windows.Forms.Button();
- this.richTextBox_messages = new System.Windows.Forms.RichTextBox();
- this.textBox_userName = new System.Windows.Forms.TextBox();
- this.textBox_password = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.textBox_url = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.checkBox_sessionID = new System.Windows.Forms.CheckBox();
- this.button_login_services = new System.Windows.Forms.Button();
- this.button_logout_services = new System.Windows.Forms.Button();
- this.tabControl1.SuspendLayout();
- this.tabPage1.SuspendLayout();
- this.tabPage2.SuspendLayout();
- this.SuspendLayout();
- //
- // button_save
- //
- this.button_save.Location = new System.Drawing.Point(230, 20);
- this.button_save.Name = "button_save";
- this.button_save.Size = new System.Drawing.Size(75, 23);
- this.button_save.TabIndex = 1;
- this.button_save.Text = "Save";
- this.button_save.UseVisualStyleBackColor = true;
- this.button_save.Click += new System.EventHandler(this.button_save_Click);
- //
- // button_load
- //
- this.button_load.Location = new System.Drawing.Point(149, 20);
- this.button_load.Name = "button_load";
- this.button_load.Size = new System.Drawing.Size(75, 23);
- this.button_load.TabIndex = 1;
- this.button_load.Text = "Load node";
- this.button_load.UseVisualStyleBackColor = true;
- this.button_load.Click += new System.EventHandler(this.button_load_Click);
- //
- // label_nid
- //
- this.label_nid.AutoSize = true;
- this.label_nid.Location = new System.Drawing.Point(28, 26);
- this.label_nid.Name = "label_nid";
- this.label_nid.Size = new System.Drawing.Size(26, 13);
- this.label_nid.TabIndex = 3;
- this.label_nid.Text = "NID";
- //
- // textBox_nodeID
- //
- this.textBox_nodeID.Location = new System.Drawing.Point(60, 23);
- this.textBox_nodeID.Name = "textBox_nodeID";
- this.textBox_nodeID.Size = new System.Drawing.Size(83, 20);
- this.textBox_nodeID.TabIndex = 4;
- //
- // tabControl1
- //
- this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tabControl1.Controls.Add(this.tabPage1);
- this.tabControl1.Controls.Add(this.tabPage2);
- this.tabControl1.Location = new System.Drawing.Point(1, 71);
- this.tabControl1.Name = "tabControl1";
- this.tabControl1.SelectedIndex = 0;
- this.tabControl1.Size = new System.Drawing.Size(707, 330);
- this.tabControl1.TabIndex = 10;
- //
- // tabPage1
- //
- this.tabPage1.Controls.Add(this.label2);
- this.tabPage1.Controls.Add(this.webBrowser1);
- this.tabPage1.Controls.Add(this.richTextBox1);
- this.tabPage1.Controls.Add(this.textBox_nodeID);
- this.tabPage1.Controls.Add(this.button_save);
- this.tabPage1.Controls.Add(this.label_nid);
- this.tabPage1.Controls.Add(this.button_load);
- this.tabPage1.Location = new System.Drawing.Point(4, 22);
- this.tabPage1.Name = "tabPage1";
- this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
- this.tabPage1.Size = new System.Drawing.Size(699, 304);
- this.tabPage1.TabIndex = 0;
- this.tabPage1.Text = "Node load/save";
- this.tabPage1.UseVisualStyleBackColor = true;
- //
- // label2
- //
- this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(9, 158);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(45, 13);
- this.label2.TabIndex = 7;
- this.label2.Text = "Preview";
- //
- // webBrowser1
- //
- this.webBrowser1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.webBrowser1.Location = new System.Drawing.Point(6, 174);
- this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
- this.webBrowser1.Name = "webBrowser1";
- this.webBrowser1.Size = new System.Drawing.Size(685, 119);
- this.webBrowser1.TabIndex = 5;
- //
- // richTextBox1
- //
- this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.richTextBox1.Location = new System.Drawing.Point(6, 53);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(686, 102);
- this.richTextBox1.TabIndex = 0;
- this.richTextBox1.Text = "";
- this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChan