Commit 68283f45 by Pedro Cavaleiro

Project Upload

parent 5812350b
{
"CurrentProjectSetting": null
}
\ No newline at end of file
{
"ExpandedNodes": [
"",
"\\bin",
"\\obj"
],
"SelectedNode": "\\WHMCS API.csproj",
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
File added
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace WHMCS_API
{
public class API
{
private readonly Call _call;
public API(string Username, string Password, string AccessKey, string Url)
{
_call = new Call(Username, Password, AccessKey, Url);
}
/// <summary>
/// Validates a client login
/// </summary>
/// <see cref="https://developers.whmcs.com/api-reference/validatelogin/"/>
/// <param name="Email">Client Email</param>
/// <param name="Password">Client Password (cleartext)</param>
/// <returns>Returns the result of the call
/// The userid string for the session Session["uid"]
/// The passwordhash for the session Session["upw"]</returns>
public ValidateLogin ValidateLogin(string Email, string Password)
{
NameValueCollection data = new NameValueCollection()
{
{ "action", APIEnums.Actions.ValidateLogin.ToString() },
{ EnumUtil.GetString(APIEnums.ValidateLoginParams.Email), Email },
{ EnumUtil.GetString(APIEnums.ValidateLoginParams.Password), Password }
};
return JsonConvert.DeserializeObject<ValidateLogin>(_call.MakeCall(data));
}
/// <summary>
/// Checks if a domain is available to regsiter, if not will return the whois
/// </summary>
/// <see cref="https://developers.whmcs.com/api-reference/domainwhois/"/>
/// <param name="Domain">The domain to be checked</param>
/// <returns>Result of the call, if the domain is registered or not, and if registered the WhoIs</returns>
public DomainWhoIs DomainWhoIs(string Domain)
{
NameValueCollection data = new NameValueCollection()
{
{ "action", APIEnums.Actions.DomainWhois.ToString() },
{ EnumUtil.GetString(APIEnums.DomainWhoisParams.Domain), Domain },
};
return JsonConvert.DeserializeObject<DomainWhoIs>(_call.MakeCall(data));
}
/// <summary>
/// Registers a new client
/// </summary>
/// <remarks>
/// When registerying an exception may occurr. If you get "An API Error Ocurred" read the inner exception
/// </remarks>
/// <example>
/// try { your code } catch (Exception ex) { Console.WriteLine(ex.InnerException.Message); }
/// </example>
/// <see cref="https://developers.whmcs.com/api-reference/addclient/"/>
/// <param name="ClientInfo">The Model of the AddClient action</param>
/// <returns>If success returns the ID of the newly created user otherwise will throw an exception</returns>
public int AddClient(AddClient ClientInfo)
{
NameValueCollection data = new NameValueCollection()
{
{ "action", APIEnums.Actions.AddClient.ToString() }
};
//Processes all the data in ClientInfo model into the data NameValueCollection
foreach (string key in ClientInfo.ClientInfo)
{
data.Add(key, ClientInfo.ClientInfo[key]);
}
JObject result = JObject.Parse(_call.MakeCall(data));
if (result["result"].ToString() == "success")
return Convert.ToInt32(result["clientid"]);
else
throw new Exception("An API Error Ocurred", new Exception(result["message"].ToString()));
}
/// <summary>
/// Gets the client details
/// </summary>
/// <param name="ClientID">The client ID to search</param>
/// <param name="ClientEmail">The client Email to search</param>
/// <param name="Stats">Get extended stats for the client</param>
/// <returns>All details of the client</returns>
public GetClientsDetails GetClientsDetails(int ClientID = -1, string ClientEmail = "", bool Stats = false)
{
if (ClientID == -1 && ClientEmail == "")
throw new Exception("ClientID or ClientEmail needed");
NameValueCollection data = new NameValueCollection()
{
{ "action", APIEnums.Actions.GetClientsDetails.ToString() },
{ EnumUtil.GetString(APIEnums.GetClientsDetailsParams.Stats), Stats.ToString() },
};
if (ClientID != -1)
data.Add(EnumUtil.GetString(APIEnums.GetClientsDetailsParams.ClientID), ClientID.ToString());
if (ClientEmail != "" && ClientID == -1)
data.Add(EnumUtil.GetString(APIEnums.GetClientsDetailsParams.Email), ClientEmail);
string req = _call.MakeCall(data);
JObject result = JObject.Parse(req);
if (result["result"].ToString() == "success")
return JsonConvert.DeserializeObject<GetClientsDetails>(req);
else
throw new Exception("An API Error occurred", new Exception(result["message"].ToString()));
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WHMCS_API
{
/// <summary>
/// Params info @ https://developers.whmcs.com/api-reference/addclient/
/// </summary>
public class AddClient
{
public readonly NameValueCollection ClientInfo;
public AddClient(string Firstname, string Lastname, string Email, string Address1,
string City, string State, string PostCode, string CountryCode, string PhoneNumber,
string Password, bool NoEmail = false, string CompanyName = "", string Address2 = "",
int SecurityQuestionID = -1, string SecurityQuestionAnswer = "", string CardType = "",
string CardNumber = "", string ExpiricyDate = "", string StartDate = "",
string IssueNumber = "", string CVV = "", int Currency = -1, int GroupID = -1,
string CustomFields = "", string Language = "", string ClientIP = "", string Notes = "")
{
ClientInfo = new NameValueCollection()
{
{ EnumUtil.GetString(APIEnums.AddClientParams.Firstname), Firstname },
{ EnumUtil.GetString(APIEnums.AddClientParams.Lastname), Lastname },
{ EnumUtil.GetString(APIEnums.AddClientParams.Email), Email },
{ EnumUtil.GetString(APIEnums.AddClientParams.Address1), Address1 },
{ EnumUtil.GetString(APIEnums.AddClientParams.City), City },
{ EnumUtil.GetString(APIEnums.AddClientParams.State), State },
{ EnumUtil.GetString(APIEnums.AddClientParams.Postcode), PostCode },
{ EnumUtil.GetString(APIEnums.AddClientParams.CountryCode), CountryCode },
{ EnumUtil.GetString(APIEnums.AddClientParams.PhoneNumber), PhoneNumber },
{ EnumUtil.GetString(APIEnums.AddClientParams.Password), Password },
{ EnumUtil.GetString(APIEnums.AddClientParams.NoEmail), NoEmail.ToString() }
};
if (CompanyName != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.CompanyName), CompanyName);
if (Address2 != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.Address2), Address2);
if (SecurityQuestionID != -1)
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.SecurityQuestionID), SecurityQuestionID.ToString());
if (SecurityQuestionAnswer != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.SecurityQuestionAnswer), SecurityQuestionAnswer);
if (CardType != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.CardType), CardType);
if (CardNumber != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.CardNumber), CardNumber);
if (ExpiricyDate != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.ExpiricyDate), ExpiricyDate);
if (StartDate != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.StartDate), StartDate);
if (IssueNumber != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.IssueNumber), IssueNumber);
if (CVV != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.CVV), CVV);
if (Currency != -1)
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.Currency), Currency.ToString());
if(GroupID != -1)
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.GroupID), GroupID.ToString());
if (CustomFields != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.CustomFields), CustomFields);
if (Language != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.Language), Language);
if (ClientIP != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.ClientIP), ClientIP);
if (Notes != "")
ClientInfo.Add(EnumUtil.GetString(APIEnums.AddClientParams.Notes), Notes);
}
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace WHMCS_API
{
public class Client
{
[JsonProperty("userid")]
public int UserID { get; set; }
[JsonProperty("id")]
public int ID { get; set; }
[JsonProperty("uuid")]
public string UUID { get; set; }
[JsonProperty("firstname")]
public string Firstname { get; set; }
[JsonProperty("lastname")]
public string Lastname { get; set; }
[JsonProperty("fullname")]
public string FullName { get; set; }
[JsonProperty("companyname")]
public string CompanyName { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("address1")]
public string Address1 { get; set; }
[JsonProperty("address2")]
public string Address2 { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("fullstate")]
public string FullState { get; set; }
[JsonProperty("state")]
public string State { get; set; }
[JsonProperty("postcode")]
public string PostCode { get; set; }
[JsonProperty("countrycode")]
public string CountryCode { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
[JsonProperty("phonenumber")]
public string PhoneNumber { get; set; }
[JsonProperty("password")]
public string Password { get; set; }
[JsonProperty("statecode")]
public string StateCode { get; set; }
[JsonProperty("countryname")]
public string CountryName { get; set; }
[JsonProperty("phonecc")]
public int PhoneCC { get; set; }
[JsonProperty("phonenumberformatted")]
public string PhoneNumberFormatted { get; set; }
[JsonProperty("billingcid")]
public int BillingCID { get; set; }
[JsonProperty("notes")]
public string Notes { get; set; }
[JsonProperty("twofaenabled")]
public bool TwoFactorEnabled { get; set; }
[JsonProperty("currency")]
public int Currency { get; set; }
[JsonProperty("defaultgateway")]
public string DefaultGateway { get; set; }
[JsonProperty("cctype")]
public string CreditCardType { get; set; }
[JsonProperty("cclastfour")]
public string CreditCardLastFourDigits { get; set; }
[JsonProperty("securityqid")]
public int SecurityQuestionID { get; set; }
[JsonProperty("securityqans")]
public string SecurityQuestionAnswer { get; set; }
[JsonProperty("groupid")]
public int GroupID { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("credit")]
public string Credit { get; set; }
[JsonProperty("taxexempt")]
public bool TexExempt { get; set; }
[JsonProperty("latefeeoveride")]
public bool LateFeeOveride { get; set; }
[JsonProperty("overideduenotices")]
public bool OverideDueNotices { get; set; }
[JsonProperty("separateinvoices")]
public bool SeparateInvoices { get; set; }
[JsonProperty("disableautocc")]
public bool DisableAutoCC { get; set; }
[JsonProperty("emailoptout")]
public bool EmailOptOut { get; set; }
[JsonProperty("overrideautoclose")]
public bool OverideAutoClose { get; set; }
[JsonProperty("allowSingleSignOn")]
public int AllowSingleSignOn { get; set; }
[JsonProperty("language")]
public string Language { get; set; }
[JsonProperty("lastlogin")]
public string LastLogin { get; set; }
[JsonProperty("currency_code")]
public string Currency_Code { get; set; }
}
public class Stats
{
[JsonProperty("numdueinvoices")]
public string NumberDueInvoices { get; set; }
[JsonProperty("dueinvoicesbalance")]
public string DueInvoicesBalance { get; set; }
[JsonProperty("income")]
public string Income { get; set; }
[JsonProperty("incredit")]
public bool InCredit { get; set; }
[JsonProperty("creditbalance")]
public string CreditBalance { get; set; }
[JsonProperty("numoverdueinvoices")]
public string NumberOverdueInvoices { get; set; }
[JsonProperty("overdueinvoicesbalance")]
public string OverudeInvoicesBalance { get; set; }
[JsonProperty("numDraftInvoices")]
public int NumDraftInvoices { get; set; }
[JsonProperty("draftInvoicesBalance")]
public string DraftInvoicesBalance { get; set; }
[JsonProperty("numpaidinvoices")]
public string NumPaidInvoices { get; set; }
[JsonProperty("paidinvoicesamount")]
public string PaidInvoicesAmount { get; set; }
[JsonProperty("numunpaidinvoices")]
public int NumUnpaidInvoices { get; set; }
[JsonProperty("unpaidinvoicesamount")]
public string UnPaidInvoicesAmount { get; set; }
[JsonProperty("numcancelledinvoices")]
public int numcancelledinvoices { get; set; }
[JsonProperty("cancelledinvoicesamount")]
public string CancelledInvoicesAmount { get; set; }
[JsonProperty("numrefundedinvoices")]
public int NumRefundedInvoices { get; set; }
[JsonProperty("refundedinvoicesamount")]
public string RefundedInvoicesAmount { get; set; }
[JsonProperty("numcollectionsinvoices")]
public int NumCollectionsInvoices { get; set; }
[JsonProperty("collectionsinvoicesamount")]
public string CollectionsInvoicesAmount { get; set; }
[JsonProperty("productsnumactivehosting")]
public string ProductsNumActiveHosting { get; set; }
[JsonProperty("productsnumhosting")]
public int ProductsNumHosting { get; set; }
[JsonProperty("productsnumactivereseller")]
public int ProductsNumActiveReseller { get; set; }
[JsonProperty("productsnumreseller")]
public int ProductNumReseller { get; set; }
[JsonProperty("productsnumactiveservers")]
public int ProductsNumActiveServers { get; set; }
[JsonProperty("productsnumservers")]
public int ProductsNumServers { get; set; }
[JsonProperty("productsnumactiveother")]
public int ProductsNumActiveOther { get; set; }
[JsonProperty("productsnumother")]
public int ProductsOther { get; set; }
[JsonProperty("productsnumactive")]
public int ProductsNumActive { get; set; }
[JsonProperty("productsnumtotal")]
public int ProductsNumTotal { get; set; }
[JsonProperty("numactivedomains")]
public string NumActiveDomains { get; set; }
[JsonProperty("numdomains")]
public int NumDomains { get; set; }
[JsonProperty("numacceptedquotes")]
public int NumAcceptedQuotes { get; set; }
[JsonProperty("numquotes")]
public int NumQuotes { get; set; }
[JsonProperty("numtickets")]
public int NumTickets { get; set; }
[JsonProperty("numactivetickets")]
public int NumActiveTickets { get; set; }
[JsonProperty("numaffiliatesignups")]
public string NumAffiliateSignups { get; set; }
[JsonProperty("isAffiliate")]
public bool IsAffiliate { get; set; }
}
public class GetClientsDetails
{
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("client")]
public Client Client { get; set; }
[JsonProperty("stats")]
public Stats Stats { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace WHMCS_API
{
public class Call
{
private readonly string Username;
private readonly string Password;
private readonly string AccessKey;
private readonly string Url;
/// <summary>
/// Prepare the call of the API
/// </summary>
/// <param name="Username">API Username</param>
/// <param name="Password">API Password</param>
/// <param name="AccessKey">API AccessKey (must be set in config.php)</param>
/// <param name="Url">WHMCS User Front End URL (ex: https://example.com/client)</param>
public Call(string Username, string Password, string AccessKey, string Url)
{
this.Username = Username;
this.Password = CalculateMD5Hash(Password);
this.AccessKey = AccessKey;
this.Url = Url + "/includes/api.php";
}
private NameValueCollection BuildRequestData(NameValueCollection data)
{
NameValueCollection request = new NameValueCollection()
{
{ "username", Username},
{ "password", Password},
{ "accesskey", AccessKey },
{ "responsetype", "json"}
};
foreach(string key in data)
{
request.Add(key, data[key]);
}
return request;
}
public string MakeCall(NameValueCollection data)
{
byte[] webResponse;
try
{
webResponse = new WebClient().UploadValues(Url, BuildRequestData(data));
}
catch (Exception ex)
{
throw new Exception("Unable to connect to WHMCS API. " + ex.Message.ToString());
}
return Encoding.ASCII.GetString(webResponse);
}
private string CalculateMD5Hash(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = MD5.Create();
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
foreach (byte t in hash)
{
sb.Append(t.ToString("x2"));
}
return sb.ToString();
}
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WHMCS_API
{
public class DomainWhoIs
{
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("whois")]
public string WhoIs { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace WHMCS_API
{
public static class APIEnums
{
public enum ValidateLoginParams
{
[StringValue("email")] Email,
[StringValue("password2")] Password
}
public enum DomainWhoisParams
{
[StringValue("domain")] Domain
}
public enum AddClientParams
{
[StringValue("firstname")] Firstname,
[StringValue("lastname")] Lastname,
[StringValue("email")] Email,
[StringValue("address1")] Address1,
[StringValue("city")] City,
[StringValue("state")] State,
[StringValue("postcode")] Postcode,
[StringValue("countrycode")] CountryCode,
[StringValue("phonenumber")] PhoneNumber,
[StringValue("password2")] Password,
[StringValue("noemail")] NoEmail,
[StringValue("companyname")] CompanyName,
[StringValue("address2")] Address2,
[StringValue("securityqid")] SecurityQuestionID,
[StringValue("securityqans")] SecurityQuestionAnswer,
[StringValue("cardtype")] CardType,
[StringValue("cardnum")] CardNumber,
[StringValue("expdate")] ExpiricyDate,
[StringValue("startdate")] StartDate,
[StringValue("issuenumber")] IssueNumber,
[StringValue("cvv")] CVV,
[StringValue("currency")] Currency,
[StringValue("groupid")] GroupID,
[StringValue("customfields")] CustomFields,
[StringValue("language")] Language,
[StringValue("clientip")] ClientIP,
[StringValue("notes")] Notes,
[StringValue("skipvalidation")] SkipValidation
}
public enum GetClientsDetailsParams
{
[StringValue("clientid")] ClientID,
[StringValue("email")] Email,
[StringValue("stats")] Stats
}
/// <summary>
/// Actions Supported by the WHMCS API that are implemented in this Wrapper
/// </summary>
public enum Actions
{
[StringValue("ValidateLogin")] ValidateLogin,
[StringValue("DomainWhois")] DomainWhois,
[StringValue("AddClient")] AddClient,
[StringValue("GetClientsDetails")] GetClientsDetails
}
}
/// <summary>
/// Creastes an attribute called StringValue
/// </summary>
public class StringValue : Attribute
{
private readonly string _value;
public StringValue(string value)
{
_value = value;
}
public string Value
{
get { return _value; }
}
}
/// <summary>
/// Used to get the string out of the Enum
/// </summary>
public static class EnumUtil
{
/// <summary>
/// Gets the string out of the enum
/// </summary>
/// <param name="value">The enum from witch will be extracted the string</param>
/// <returns>The string associated with the value enum</returns>
public static string GetString(Enum value)
{
string output = null;
Type type = value.GetType();
FieldInfo fi = type.GetField(value.ToString());
StringValue[] attrs =
fi.GetCustomAttributes(typeof(StringValue),
false) as StringValue[];
if (attrs.Length > 0)
{
output = attrs[0].Value;
}
return output;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// As informações gerais sobre um assembly são controladas por
// conjunto de atributos. Altere estes valores de atributo para modificar as informações
// associada a um assembly.
[assembly: AssemblyTitle("WHMCS API")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WHMCS API")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Definir ComVisible como false torna os tipos neste assembly invisíveis
// para componentes COM. Caso precise acessar um tipo neste assembly de
// COM, defina o atributo ComVisible como true nesse tipo.
[assembly: ComVisible(false)]
// O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM
[assembly: Guid("fae6aaef-4ddf-4f70-9885-a1d58d7e2a74")]
// As informações da versão de um assembly consistem nos quatro valores a seguir:
//
// Versão Principal
// Versão Secundária
// Número da Versão
// Revisão
//
// É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão
// usando o '*' como mostrado abaixo:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WHMCS_API
{
public class ValidateLogin
{
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("userid")]
public int UserID { get; set; }
[JsonProperty("passwordhash")]
public string PasswordHash { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WHMCS_API</RootNamespace>
<AssemblyName>WHMCS API</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
</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="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddClient.cs" />
<Compile Include="AddClientsDetails.cs" />
<Compile Include="API.cs" />
<Compile Include="Call.cs" />
<Compile Include="DomainWhoIs.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ValidateLogin.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26127.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WHMCS API", "WHMCS API.csproj", "{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAE6AAEF-4DDF-4F70-9885-A1D58D7E2A74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This source diff could not be displayed because it is too large. You can view the blob instead.
5eb4fb84540e61ea2545bd966a0bb918182bb6f4
C:\Users\pmcav\Source\Repos\whmcs-api\bin\Release\WHMCS API.dll
C:\Users\pmcav\Source\Repos\whmcs-api\bin\Release\WHMCS API.pdb
C:\Users\pmcav\Source\Repos\whmcs-api\bin\Release\Newtonsoft.Json.dll
C:\Users\pmcav\Source\Repos\whmcs-api\bin\Release\Newtonsoft.Json.xml
C:\Users\pmcav\Source\Repos\whmcs-api\obj\Release\WHMCS API.dll
C:\Users\pmcav\Source\Repos\whmcs-api\obj\Release\WHMCS API.pdb
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
</packages>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
param($installPath, $toolsPath, $package, $project)
# open json.net splash page on package install
# don't open if json.net is installed as a dependency
try
{
$url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
{
# user is installing from VS NuGet console
# get reference to the window, the console host and the input history
# show webpage if "install-package newtonsoft.json" was last input
$consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
$props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
$prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
if ($prop -eq $null) { return }
$hostInfo = $prop.GetValue($consoleWindow)
if ($hostInfo -eq $null) { return }
$history = $hostInfo.WpfConsole.InputHistory.History
$lastCommand = $history | select -last 1
if ($lastCommand)
{
$lastCommand = $lastCommand.Trim().ToLower()
if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
else
{
# user is installing from VS NuGet dialog
# get reference to the window, then smart output console provider
# show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
$instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
[System.Reflection.BindingFlags]::NonPublic)
$consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($instanceField -eq $null -or $consoleField -eq $null) { return }
$instance = $instanceField.GetValue($null)
if ($instance -eq $null) { return }
$consoleProvider = $consoleField.GetValue($instance)
if ($consoleProvider -eq $null) { return }
$console = $consoleProvider.CreateOutputConsole($false)
$messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($messagesField -eq $null) { return }
$messages = $messagesField.GetValue($console)
if ($messages -eq $null) { return }
$operations = $messages -split "=============================="
$lastOperation = $operations | select -last 1
if ($lastOperation)
{
$lastOperation = $lastOperation.ToLower()
$lines = $lastOperation -split "`r`n"
$installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
if ($installMatch)
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
}
catch
{
try
{
$pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
$selection = $pmPane.TextDocument.Selection
$selection.StartOfDocument($false)
$selection.EndOfDocument($true)
if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
{
# don't show on upgrade
if (!$selection.Text.Contains("Removed package"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
catch
{
# stop potential errors from bubbling up
# worst case the splash page won't open
}
}
# still yolo
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment