Initial project's source code check-in.

This commit is contained in:
ptsurbeleu 2011-07-13 16:07:32 -07:00
commit b03b0b373f
4573 changed files with 981205 additions and 0 deletions

View file

@ -0,0 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Web.UI;
// embedded resources
[assembly: WebResource("WebsitePanel.Ecommerce.Portal.Scripts.EcommerceUtils.js", "application/x-javascript")]

View file

@ -0,0 +1,95 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
using Microsoft.Web.Services3;
using System.Collections.Generic;
using System.Text;
using WebsitePanel.Portal;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class EC : ES
{
public new static EC Services
{
get
{
EC services = (EC)PortalCache.GetObject("ECWebServices");
if (services == null)
{
services = new EC();
PortalCache.SetObject("ESWebServices", services);
}
return services;
}
}
public ecStorefront Storefront
{
get { return GetCachedProxy<ecStorefront>(false); }
}
public ecStorehouse Storehouse
{
get { return GetCachedProxy<ecStorehouse>(true); }
}
public ecServiceHandler ServiceHandler
{
get { return GetCachedProxy<ecServiceHandler>(false); }
}
protected EC()
{
}
protected T GetCachedProxy2<T>(bool secureCalls)
{
Type t = typeof(T);
string key = t.FullName + ".ServiceProxy";
T proxy = (T)HttpContext.Current.Items[key];
if (proxy == null)
{
proxy = (T)Activator.CreateInstance(t);
HttpContext.Current.Items[key] = proxy;
}
object p = proxy;
// configure proxy
ProxyConfigurator.RunServiceAsSpaceOwner((WebServicesClientProtocol)p);
return proxy;
}
}
}

View file

@ -0,0 +1,153 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
using System.Collections;
using WebsitePanel.Portal;
using WebsitePanel.WebPortal;
using WebsitePanel.Ecommerce.EnterpriseServer;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class EcommerceSettings
{
public static string AbsoluteAppPath
{
get
{
Uri baseUri = HttpContext.Current.Request.Url;
string appPath = (HttpContext.Current.Request.ApplicationPath == "/") ? "" : HttpContext.Current.Request.ApplicationPath;
string appPort = (baseUri.Port == 80) ? "" : ":" + baseUri.Port.ToString();
return String.Format("{0}://{1}{2}{3}", baseUri.Scheme, baseUri.Host, appPort, appPath);
}
}
public static string EcommerceRootPath
{
get
{
return PortalUtils.ApplicationPath + "/DesktopModules/Ecommerce/";
}
}
public static string CurrencyCodeISO
{
get
{
string CodeISO = PortalCache.GetString(Keys.CurrencyCodeISO);
if (String.IsNullOrEmpty(CodeISO))
{
int resellerId = 0;
if (ecPanelRequest.ResellerId > 0)
resellerId = ecPanelRequest.ResellerId;
else if (PanelSecurity.SelectedUserId > 0)
resellerId = PanelSecurity.SelectedUser.OwnerId;
CodeISO = StorefrontHelper.GetBaseCurrency(resellerId);
// fallback to usd if currency is empty
if (String.IsNullOrEmpty(CodeISO))
CodeISO = "USD";
PortalCache.SetObject(Keys.CurrencyCodeISO, CodeISO);
}
return CodeISO;
}
}
public static bool UseSSL
{
get { return GetBoolean("UseSSL"); }
}
public static string StorefrontUrl
{
get { return ecUtils.GetStorefrontUrl(); }
}
public static string OrderCompleteUrl
{
get { return ecUtils.GetOrderCompleteUrl(); }
}
public static string ShoppingCartUrl
{
get { return ecUtils.GetShoppingCartUrl(); }
}
public static string RegistrationFormUrl
{
get { return ecUtils.GetRegistrationFormUrl(); }
}
/// <summary>
/// Ctor.
/// </summary>
private EcommerceSettings()
{
}
public static int GetInt(string keyName, int defaultValue)
{
string strValue = GetSetting(keyName);
return ecUtils.ParseInt(strValue, defaultValue);
}
public static int GetInt(string keyName)
{
return GetInt(keyName, Keys.DefaultInt);
}
public static Guid GetGuid(string keyName)
{
string strValue = GetSetting(keyName);
return ecUtils.ParseGuid(strValue);
}
public static bool GetBoolean(string keyName)
{
string strValue = GetSetting(keyName);
return ecUtils.ParseBoolean(strValue, false);
}
/// <summary>
/// Gets value for a particular setting.
/// </summary>
/// <param name="keyName">Setting name</param>
/// <returns></returns>
public static string GetSetting(string keyName)
{
return PortalConfiguration.SiteSettings[keyName];
}
}
}

View file

@ -0,0 +1,150 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel.Ecommerce.EnterpriseServer;
using WebsitePanel.Portal;
namespace WebsitePanel.Ecommerce.Portal
{
public abstract class CheckoutBasePage : Page
{
/// <summary>
/// Order complete uri
/// </summary>
public const string OrderCompleteUri = "/Default.aspx?pid=ecOrderComplete";
/// <summary>
/// Order failed uri
/// </summary>
public const string OrderFailedUri = "/Default.aspx?pid=ecOrderFailed";
private string redirectUrl;
private string methodName;
private int invoiceId;
private string contractKey;
/// <summary>
/// Gets invoice number
/// </summary>
protected int InvoiceId
{
get { return invoiceId; }
set { invoiceId = value; }
}
/// <summary>
/// Gets redirect url
/// </summary>
protected string RedirectUrl
{
get { return redirectUrl; }
}
protected CheckoutBasePage(string methodName, string contractKey)
{
// validate plugin is not empty
if (String.IsNullOrEmpty(methodName))
throw new ArgumentNullException("methodName");
if (String.IsNullOrEmpty(contractKey))
throw new ArgumentNullException("contractKey");
// set plugin name
this.methodName = methodName;
this.contractKey = contractKey;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// start to serve payment processor response
ServeProcessorResponse();
}
protected virtual void ServeProcessorResponse()
{
// create an instance
CheckoutDetails orderDetails = new CheckoutDetails();
// copy whole request keys
foreach (string keyName in Request.Form.AllKeys)
{
orderDetails[keyName] = Request.Form[keyName];
}
// check target_site variable
if (!String.IsNullOrEmpty(orderDetails[CheckoutFormParams.TARGET_SITE]))
redirectUrl = orderDetails[CheckoutFormParams.TARGET_SITE];
else
redirectUrl = EcommerceSettings.AbsoluteAppPath;
// process checkout details
ProcessCheckout(methodName, orderDetails);
}
protected virtual void PreProcessCheckout(CheckoutDetails details)
{
}
protected virtual void ProcessCheckout(string methodName, CheckoutDetails details)
{
try
{
PreProcessCheckout(details);
// perform order payment
CheckoutResult result = StorefrontHelper.CompleteCheckout(details[contractKey], invoiceId, methodName, details);
// post process order result
PostProcessCheckout(result);
}
catch (Exception ex)
{
// Output error message into the trace
Trace.Write("ECOMMERCE", "COMPLETE_CHECKOUT_ERROR", ex);
// display raw stack trace in case of error
Response.Write(PortalUtils.GetSharedLocalizedString("Ecommerce", "Error.CHECKOUT_GENERAL_FAILURE"));
}
}
protected virtual void PostProcessCheckout(CheckoutResult result)
{
// check order payment result status
if (result.Succeed)
// go to the order success page
Response.Redirect(RedirectUrl + OrderCompleteUri);
else
// go to order failed page
Response.Redirect(RedirectUrl + OrderFailedUri);
}
}
}

View file

@ -0,0 +1,168 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Globalization;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebsitePanel.Ecommerce.Portal
{
[ValidationProperty("Checked")]
public class GroupRadioButton : RadioButton, IPostBackDataHandler
{
public GroupRadioButton()
: base()
{
}
#region Properties
public object ControlValue
{
get { return ViewState["ControlValue"]; }
set { ViewState["ControlValue"] = value; }
}
private string Value
{
get
{
string val = Attributes["value"];
if (val == null)
val = UniqueID;
else
val = UniqueID + "_" + val;
return val;
}
}
#endregion
#region Rendering
protected override void Render(HtmlTextWriter output)
{
RenderInputTag(output);
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
}
private void RenderInputTag(HtmlTextWriter htw)
{
htw.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
htw.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
htw.AddAttribute(HtmlTextWriterAttribute.Name, GroupName);
htw.AddAttribute(HtmlTextWriterAttribute.Value, Value);
if (Checked)
htw.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
if (!Enabled)
htw.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
string onClick = Attributes["onclick"];
if (AutoPostBack)
{
if (onClick != null)
onClick = String.Empty;
onClick += Page.ClientScript.GetPostBackEventReference(this, String.Empty);
htw.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
htw.AddAttribute("language", "javascript");
}
else
{
if (onClick != null)
htw.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
}
if (AccessKey.Length > 0)
htw.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
if (TabIndex != 0)
htw.AddAttribute(HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString(NumberFormatInfo.InvariantInfo));
htw.RenderBeginTag(HtmlTextWriterTag.Input);
htw.RenderEndTag();
// add text to the render
if (!String.IsNullOrEmpty(Text))
RenderLabel(htw, Text, ClientID);
}
protected virtual void RenderLabel(HtmlTextWriter writer, string text, string clientID)
{
writer.AddAttribute(HtmlTextWriterAttribute.For, clientID);
if ((LabelAttributes != null) && (LabelAttributes.Count != 0))
{
LabelAttributes.AddAttributes(writer);
}
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write(text);
writer.RenderEndTag();
}
#endregion
#region IPostBackDataHandler Members
void IPostBackDataHandler.RaisePostDataChangedEvent()
{
OnCheckedChanged(EventArgs.Empty);
}
bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
bool result = false;
string value = postCollection[GroupName];
if ((value != null) && (value == Value))
{
if (!Checked)
{
Checked = true;
result = true;
}
}
else
{
if (Checked)
Checked = false;
}
return result;
}
#endregion
}
}

View file

@ -0,0 +1,44 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
using WebsitePanel.Ecommerce.EnterpriseServer;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public interface IPaymentMethod
{
void CheckSupportedItems(string supportedItems);
void LoadContractAccount(ContractAccount account);
CheckoutDetails GetCheckoutDetails();
}
}

View file

@ -0,0 +1,41 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public interface IPluginProperties
{
KeyValueBunch Properties { get; set; }
}
}

View file

@ -0,0 +1,40 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Ecommerce.Portal
{
public interface IViewServiceDetails
{
bool LoadServiceInfo(int serviceId);
void BindServiceHistory(int serviceId);
}
}

View file

@ -0,0 +1,77 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebsitePanel.Ecommerce.Portal
{
public class ManualValidationEventArgs : EventArgs
{
private bool contextIsValid;
public bool ContextIsValid
{
get { return contextIsValid; }
set { contextIsValid = value; }
}
}
public class ManualContextValidator : CustomValidator
{
public event EventHandler<ManualValidationEventArgs> EvaluatingContext;
protected override bool ControlPropertiesValid()
{
return true;
}
protected override bool EvaluateIsValid()
{
//
ManualValidationEventArgs args = new ManualValidationEventArgs();
//
if (EvaluatingContext != null)
{
// trying evaluate manual context
EvaluatingContext(this, args);
//
return args.ContextIsValid;
}
return true;
}
}
}

View file

@ -0,0 +1,73 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebsitePanel.Ecommerce.Portal
{
public class PasswordTextBox : TextBox
{
const string DEFAULT_PWD = "__DefaultPwd";
protected string DefaultPassword
{
get { return GetType().GUID.ToString("P"); }
}
public override TextBoxMode TextMode
{
get { return TextBoxMode.Password; }
set { base.TextMode = TextBoxMode.Password; }
}
public bool PasswordChanged
{
get
{
if (String.Equals(Text, ViewState[DEFAULT_PWD]))
return false;
//
return true;
}
}
public void EnableDefaultPassword()
{
ViewState[DEFAULT_PWD] = DefaultPassword;
Attributes["value"] = DefaultPassword;
}
}
}

View file

@ -0,0 +1,194 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebsitePanel.Ecommerce.Portal
{
public class RadioGroupValidator : CustomValidator
{
private List<RadioButton> components;
private bool buttonsCollected;
public string RadioButtonsGroup
{
get { return (string)ViewState["__RBGroup"]; }
set { ViewState["__RBGroup"] = value; }
}
public string InitialValue
{
get
{
object obj2 = this.ViewState["InitialValue"];
if (obj2 != null)
{
return (string)obj2;
}
return string.Empty;
}
set
{
this.ViewState["InitialValue"] = value;
}
}
public RadioGroupValidator()
{
components = new List<RadioButton>();
}
protected override void OnLoad(EventArgs e)
{
//
base.OnLoad(e);
//
ClientValidationFunction = "RadioCheckedEvaluateIsValid";
//
if (!Page.ClientScript.IsClientScriptIncludeRegistered("EcommerceUtils"))
{
Page.ClientScript.RegisterClientScriptInclude("EcommerceUtils",
Page.ClientScript.GetWebResourceUrl(typeof(RadioGroupValidator),
"WebsitePanel.Ecommerce.Portal.Scripts.EcommerceUtils.js"));
}
}
protected override bool ControlPropertiesValid()
{
//
if (String.IsNullOrEmpty(RadioButtonsGroup))
throw new Exception("'RadioButtonsGroup' property is empty or null");
return true;
}
private void RecursiveRadioButtonsLookup(Control parent, string groupName)
{
foreach (Control ctl in parent.Controls)
{
if (ctl is RadioButton && ((RadioButton)ctl).GroupName == groupName)
{
//
components.Add((RadioButton)ctl);
}
else if (ctl.HasControls())
{
RecursiveRadioButtonsLookup(ctl, groupName);
}
}
}
private void CollectRadioButtons()
{
//
if (!buttonsCollected)
{
// workaround for repeater header or footer
if (Parent is RepeaterItem)
RecursiveRadioButtonsLookup(Parent.Parent, RadioButtonsGroup);
else
RecursiveRadioButtonsLookup(Parent, RadioButtonsGroup);
//
buttonsCollected = true;
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
//
CollectRadioButtons();
//
string array_values = "";
//
foreach (RadioButton rbutton in components)
{
if (array_values.Length == 0)
array_values += String.Format("'{0}'", rbutton.ClientID);
else
array_values += String.Format(",'{0}'", rbutton.ClientID);
}
//
Page.ClientScript.RegisterArrayDeclaration(RadioButtonsGroup, array_values);
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
//
if (RenderUplevel)
{
//
string controlId = this.ClientID;
//
AddExpandoAttribute(writer, controlId, "radiogroup", RadioButtonsGroup, false);
}
}
protected override bool EvaluateIsValid()
{
//
CollectRadioButtons();
//
foreach (RadioButton rbutton in components)
{
//
PropertyDescriptor descriptor = RequiredFieldValidator.GetValidationProperty(rbutton);
//
bool controlChecked = (bool)descriptor.GetValue(rbutton);
//
if (controlChecked)
return true;
}
//
return false;
}
protected void AddExpandoAttribute(HtmlTextWriter writer, string controlId, string attributeName, string attributeValue, bool encode)
{
if (writer != null)
{
writer.AddAttribute(attributeName, attributeValue, encode);
}
else
{
this.Page.ClientScript.RegisterExpandoAttribute(controlId, attributeName, attributeValue, encode);
}
}
}
}

View file

@ -0,0 +1,173 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel;
using WebsitePanel.WebPortal;
using WebsitePanel.Portal;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class ecControlBase : WebsitePanelControlBase
{
protected bool StorefrontRunning
{
get { return true; }/* !ecUtils.IsGuidEmpty(EcommerceSettings.OwnerSpaceId);*/
}
public string EditUrlSecure(string controlKey)
{
string url = EditUrl(controlKey);
if (EcommerceSettings.UseSSL)
url = url.Replace("http://", "https://");
return url;
}
#region ViewState helper routines
protected T GetViewStateObject<T>(string keyName, GetStateObjectDelegate callback)
{
//
object obj = ViewState[keyName];
//
if (obj == null)
{
// obtain object via callback
obj = callback();
// store object
ViewState[keyName] = obj;
}
//
return (T)Convert.ChangeType(obj, typeof(T));
}
#endregion
/// <summary>
/// Returns the switched mode module URL. Also additional parameters can be injected to the URL.
/// </summary>
/// <param name="controlKey">Control key from module definition without the "Mode" suffix. "Mode" suffix used only to visual distinct in controls defintions.</param>
/// <param name="parameters">Additional mode switch parameters</param>
/// <returns></returns>
public string SwitchModuleMode(string controlKey, params string[] parameters)
{
// ensure whether the controlKey is in the correct format
if (controlKey != null && controlKey.EndsWith("Mode"))
controlKey = controlKey.Replace("Mode", string.Empty);
string[] addList = null;
if (parameters.Length > 0)
{
int count = parameters.Length;
addList = new string[count + 2];
Array.Copy(new string[] { String.Concat("mode=", controlKey) }, addList, 1);
Array.Copy(parameters, 0, addList, 1, count);
}
else if (!String.IsNullOrEmpty(controlKey))
addList = new string[] { String.Concat("mode=", controlKey) };
return NavigateURL(
DefaultPage.MODULE_ID_PARAM,
Request[DefaultPage.MODULE_ID_PARAM],
addList
);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!StorefrontRunning)
DisableFormControls(this);
}
public new void LocalizeModuleControls(Control module)
{
base.LocalizeModuleControls(module);
foreach (Control ctrl in module.Controls)
{
if (ctrl is DropDownList)
{
DropDownList ddl = ctrl as DropDownList;
string key = ddl.Attributes["listlabel"];
if (!String.IsNullOrEmpty(key))
{
LocalizeDropDownListLabel(ddl, key);
}
}
else
{
// localize children
foreach (Control childCtrl in ctrl.Controls)
LocalizeModuleControls(childCtrl);
}
}
}
public void LocalizeDropDownListLabel(DropDownList list, string key)
{
if (IsPostBack)
return;
string labelStr = GetLocalizedString(String.Concat("ListLabel.", key));
if (!String.IsNullOrEmpty(labelStr))
list.Items.Insert(0, new ListItem(labelStr));
list.Attributes.Remove("listlabel");
}
protected string GetLocalizedErrorMessage(string resourceKey)
{
return GetLocalizedString(String.Concat(Keys.ErrorMessage, ".", resourceKey));
}
protected override void OnPreRender(EventArgs e)
{
LocalizeModuleControls(this);
// call base handler
base.OnPreRender(e);
}
}
}

View file

@ -0,0 +1,242 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebsitePanel;
using WebsitePanel.Portal;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public delegate object GetStateObjectDelegate();
public class ecModuleBase : WebsitePanelModuleBase
{
private UrlBuilder currentUrl;
private bool showStorefrontWarning = true;
private bool enabledForInactiveStore;
protected bool EnabledForInactiveStore
{
get { return enabledForInactiveStore; }
set { enabledForInactiveStore = value; }
}
protected bool ShowStorefrontWarning
{
get { return showStorefrontWarning; }
set { showStorefrontWarning = value; }
}
protected bool StorefrontRunning
{
get { return true;/*!ecUtils.IsGuidEmpty(EcommerceSettings.OwnerSpaceId)*/ }
}
public UrlBuilder CurrentUrl
{
get
{
if (currentUrl == null)
currentUrl = UrlBuilder.FromCurrentRequest();
return currentUrl;
}
}
#region ViewState helper routines
protected T GetViewStateObject<T>(string keyName, GetStateObjectDelegate callback)
{
//
object obj = ViewState[keyName];
//
if (obj == null)
{
// obtain object via callback
obj = callback();
// store object
ViewState[keyName] = obj;
}
//
return (T)Convert.ChangeType(obj, typeof(T));
}
#endregion
/*public string NavigateURL(string keyName, string keyValue)
{
return DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID,
PortalSettings.ActiveTab.IsSuperTab,
PortalSettings,
string.Empty,
new string[] { keyName, keyValue });
}*/
public override void RedirectToBrowsePage()
{
Response.Redirect(NavigateURL("UserID", PanelSecurity.SelectedUserId.ToString()), true);
}
public string EditUrlSecure(string controlKey)
{
string url = EditUrl(controlKey);
if (EcommerceSettings.UseSSL)
url = url.Replace("http://", "https://");
return url;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!StorefrontRunning && ShowStorefrontWarning)
{
ShowWarningMessage("STOREFRONT_DISABLED");
if (!EnabledForInactiveStore)
DisableFormControls(this);
}
}
public void EnsurePageIsSecured()
{
// read SSL
bool useSSL = StorefrontHelper.GetSecurePayments(ecPanelRequest.ResellerId);
//
if (useSSL && !Request.IsSecureConnection)
{
//
UrlBuilder url = UrlBuilder.FromCurrentRequest();
// change scheme to secure
url.Scheme = "https";
//
url.Navigate();
}
}
protected void EnsureResellerIsCorrect(params Control[] ctlsToHide)
{
// redirect authenticated user to reseller's store
if (Page.User.Identity.IsAuthenticated)
{
if (ecPanelRequest.ResellerId != PanelSecurity.LoggedUser.OwnerId)
{
// build url
UrlBuilder url = UrlBuilder.FromCurrentRequest();
// replace reseller id
url.QueryString["ResellerId"] = PanelSecurity.LoggedUser.OwnerId.ToString();
// navigate back
url.Navigate();
}
}
// user not logged
if (ecPanelRequest.ResellerId == 0)
{
ShowErrorMessage("RESELLER_NOT_SPECIFIED");
ecUtils.ToggleControls(false, ctlsToHide);
}
}
/// <summary>
/// Returns the switched mode module URL. Also additional parameters can be injected to the URL.
/// </summary>
/// <param name="controlKey">Control key from module definition without the "Mode" suffix. "Mode" suffix used only to visual distinct in controls defintions.</param>
/// <param name="parameters">Additional mode switch parameters</param>
/// <returns></returns>
public string SwitchModuleMode(string controlKey, params string[] parameters)
{
// ensure whether the controlKey is in the correct format
if (controlKey != null && controlKey.EndsWith("Mode"))
controlKey = controlKey.Replace("Mode", string.Empty);
string[] addList = null;
if (parameters.Length > 0)
{
int count = parameters.Length;
addList = new string[count + 2];
Array.Copy(new string[] { "mode", controlKey }, addList, 2);
Array.Copy(parameters, 0, addList, 2, count);
}
else if (!string.IsNullOrEmpty(controlKey))
addList = new string[] { "mode", controlKey };
return String.Empty;
}
public override void ShowWarningMessage(string messageKey)
{
base.ShowWarningMessage(Keys.ModuleName, messageKey);
}
public override void ShowSuccessMessage(string messageKey)
{
base.ShowSuccessMessage(Keys.ModuleName, messageKey);
}
public override void ShowErrorMessage(string messageKey, Exception ex, params string[] additionalParameters)
{
base.ShowErrorMessage(Keys.ModuleName, messageKey, ex, additionalParameters);
}
public void LocalizeDropDownListLabel(DropDownList list, string key)
{
string labelStr = GetLocalizedString(string.Concat("ListLabel.", key));
list.Attributes.Remove("listlabel");
if (!String.IsNullOrEmpty(labelStr))
{
// check whether an item is already exists
if (list.Items.Count > 0)
{
ListItem li = list.Items[0];
if (String.IsNullOrEmpty(li.Value) && String.Compare(li.Text, labelStr) == 0)
return;
}
list.Items.Insert(0, new ListItem(labelStr, String.Empty));
}
}
protected override void OnPreRender(EventArgs e)
{
LocalizeModuleControls(this);
// call base handler
base.OnPreRender(e);
}
}
}

View file

@ -0,0 +1,100 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
using WebsitePanel.Portal;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
/// <summary>
/// Summary description for PanelFormatter.
/// </summary>
public class ecPanelFormatter
{
public static string GetBooleanName(bool value)
{
return ecGetLocalizedString(String.Concat("Boolean.", value));
}
public static string GetTransactionStatusName(object status)
{
return ecGetLocalizedString(String.Concat("TransactionStatus.", status));
}
public static string GetSvcItemTypeName(object value)
{
return ecGetLocalizedString(String.Concat("ProductType.", value));
}
public static string GetServiceStatusName(object status)
{
return ecGetLocalizedString(String.Concat("ServiceStatus.", status));
}
public static string GetTaxationType(object value)
{
return ecGetLocalizedString(String.Concat("TaxationType.", ((TaxationType)value).ToString()));
}
public static string GetTaxationFormat(object format, object value)
{
switch ((TaxationType)format)
{
case TaxationType.Fixed:
return String.Format("{0} {1:C}", EcommerceSettings.CurrencyCodeISO, value);
case TaxationType.Percentage:
case TaxationType.TaxIncluded:
return String.Format("{0:0.00}%", value);
}
//
return String.Empty;
}
public static string ecGetLocalizedString(string key)
{
return PortalUtils.GetSharedLocalizedString(Keys.ModuleName, key);
}
public static string GetTaxationStatus(bool value)
{
return ecGetLocalizedString(String.Concat("TaxationStatus.", value.ToString()));
}
public static string GetLastModified(object value)
{
if (DateTime.Equals(value, DateTime.MinValue))
return "&nbsp;";
return Convert.ToString(value);
}
}
}

View file

@ -0,0 +1,46 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Ecommerce.Portal
{
public class ecPanelGlobals
{
public static string ecSharedResourceFile
{
get
{
return WebsitePanel.Portal.PortalUtils.ApplicationPath
+ "/DesktopModules/Ecommerce/App_LocalResources/SharedResources.resx";
}
}
}
}

View file

@ -0,0 +1,152 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
namespace WebsitePanel.Ecommerce.Portal
{
public class ecPanelRequest
{
public static int GetInt(string key)
{
return GetInt(key, 0);
}
public static string GetString(string key)
{
return HttpContext.Current.Request[key];
}
public static int GetInt(string key, int defaultValue)
{
int result = defaultValue;
try { result = Int32.Parse(HttpContext.Current.Request[key]); }
catch { /* do nothing */ }
return result;
}
#region E-Commerce module definitions
public static string ContractId
{
get { return GetString("ContractId"); }
}
public static int TaxationId
{
get { return GetInt("TaxationId"); }
}
public static string PaymentMethod
{
get { return GetString("Method"); }
}
public static int ResellerId
{
get { return GetInt("ResellerID"); }
}
public static int UserId
{
get { return GetInt("UserId"); }
}
public static string TLD
{
get { return HttpContext.Current.Request["TLD"]; }
}
public static int BillingCycleId
{
get { return GetInt("CycleId"); }
}
public static int ServiceId
{
get { return GetInt("ServiceId"); }
}
public static int PluginId
{
get { return GetInt("PluginId"); }
}
public static int ProductTypeID
{
get { return GetInt("TypeId"); }
}
public static int ProductId
{
get { return GetInt("ProductId"); }
}
public static int CategoryId
{
get { return GetInt("CategoryId"); }
}
public static int ParentCategoryId
{
get { return GetInt(Keys.ParentCategoryId); }
}
public static int AddonId
{
get { return GetInt("AddonId"); }
}
public static int CartItemId
{
get { return GetInt("CartItemId"); }
}
public static int GatewayId
{
get { return GetInt(Keys.Gateway, Keys.DefaultInt); }
}
public static int InvoiceId
{
get { return GetInt(Keys.Invoice, Keys.DefaultInt); }
}
public static int ActiveServiceId
{
get { return GetInt(Keys.Service, Keys.DefaultInt); }
}
public static int PaymentId
{
get { return GetInt(Keys.PaymentId, Keys.DefaultInt); }
}
#endregion
}
}

View file

@ -0,0 +1,226 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using WebsitePanel.Portal;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class CategoryHelper
{
public static DataSet GetWholeCategoriesSet()
{
return EC.Services.Storehouse.GetWholeCategoriesSet(
PanelSecurity.SelectedUserId
);
}
public static int GetCategoriesCount()
{
return EC.Services.Storehouse.GetCategoriesCount(
PanelSecurity.SelectedUserId,
ecPanelRequest.CategoryId
);
}
public static Category[] GetCategoriesPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetCategoriesPaged(
PanelSecurity.SelectedUserId,
ecPanelRequest.CategoryId,
maximumRows,
startRowIndex
);
}
public static int AddCategory(string categoryName, string categorySku,
int parentId, string shortDescription, string fullDescription)
{
return EC.Services.Storehouse.AddCategory(
PanelSecurity.SelectedUserId,
categoryName,
categorySku,
parentId,
shortDescription,
fullDescription
);
}
public static int DeleteCategory(int categoryId)
{
return EC.Services.Storehouse.DeleteCategory(
PanelSecurity.SelectedUserId,
categoryId
);
}
public static int UpdateCategory(int categoryId, string categoryName,
string categorySku, int parentId, string shortDescription, string fullDescription)
{
return EC.Services.Storehouse.UpdateCategory(
PanelSecurity.SelectedUserId,
categoryId,
categoryName,
categorySku,
parentId,
shortDescription,
fullDescription
);
}
public static Category GetCategory(int categoryId)
{
return EC.Services.Storehouse.GetCategory(
PanelSecurity.SelectedUserId,
categoryId
);
}
public static void BuildCategoriesIndent(DataView dv)
{
string levelIdent = "...";
// create visual identation
foreach (DataRow row in dv.Table.Rows)
{
int level = (int)row["Level"];
StringBuilder text = new StringBuilder((string)row["CategoryName"]);
text.Insert(0, levelIdent, level);
row["CategoryName"] = text.ToString();
}
}
public static DataView BuildCategoriesIndent(DataSet ds)
{
DataView dv = GetCategoriesTreeView(ds);
BuildCategoriesIndent(dv);
return dv;
}
public static DataView GetCategoriesTreeView(DataSet ds)
{
return GetCategoriesTreeView(ds.Tables[0]);
}
public static DataView GetCategoriesTreeView(DataView dv)
{
return GetCategoriesTreeView(dv.Table);
}
public static DataView GetCategoriesTreeView(DataTable dt)
{
CategoryTreeViewSorting cts = new CategoryTreeViewSorting(dt);
cts.Sort();
return cts.SortedView;
}
}
}
public class CategoryTreeViewSorting
{
private DataTable _originalDt;
private DataTable _resultDt;
private bool _sorted;
public DataView SortedView
{
get
{
if (!_sorted)
Sort();
return _resultDt.DefaultView;
}
}
public DataTable SortedTable
{
get
{
if (!_sorted)
Sort();
return _resultDt;
}
}
public CategoryTreeViewSorting(DataView dv)
: this(dv.Table)
{
}
public CategoryTreeViewSorting(DataSet ds)
: this(ds.Tables[0])
{
}
public CategoryTreeViewSorting(DataTable dt)
{
_originalDt = dt;
// copy table schema to the result table
_resultDt = _originalDt.Clone();
_sorted = false;
}
public void Sort()
{
_originalDt.DefaultView.Sort = "ParentID,CategoryName";
DataRelation r1 = new DataRelation("r1", _originalDt.Columns["CategoryID"], _originalDt.Columns["ParentID"]);
_originalDt.ChildRelations.Add(r1);
DataRow[] rootRows = _originalDt.Select("ISNULL(ParentID, 0) = 0");
foreach (DataRow row in rootRows)
Copy(row);
_sorted = true;
}
private void Copy(DataRow leaf)
{
_resultDt.ImportRow(leaf);
DataRow[] childs = leaf.GetChildRows("r1");
foreach (DataRow child in childs)
{
DataRow[] subChilds = child.GetChildRows("r1");
if (subChilds.Length > 0)
Copy(child);
else
_resultDt.ImportRow(child);
}
}
}

View file

@ -0,0 +1,206 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Ecommerce.EnterpriseServer;
using WebsitePanel.Portal;
namespace WebsitePanel.Ecommerce.Portal
{
public class StorefrontHelper
{
private StorefrontHelper()
{
}
#region Ecommerce v 2.1.0
public static bool UsernameExists(string username)
{
return EC.Services.Storefront.UsernameExists(username);
}
public static ContractAccount GetContractAccount(string contractId)
{
return EC.Services.Storefront.GetContractAccount(contractId);
}
public static Product[] GetStorefrontProductsByType(int resellerId, int typeId)
{
return EC.Services.Storefront.GetStorefrontProductsByType(resellerId, typeId);
}
public static HostingPlanCycle[] GetHostingPlanCycles(int resellerId, int productId)
{
return EC.Services.Storefront.GetHostingPlanCycles(resellerId, productId);
}
public static HostingPlanCycle[] GetHostingAddonCycles(int resellerId, int addonId)
{
return EC.Services.Storefront.GetHostingAddonCycles(resellerId, addonId);
}
public static HostingPlan GetHostingPlan(int resellerId, int productId)
{
return EC.Services.Storefront.GetHostingPlan(resellerId, productId);
}
public static DomainNameCycle[] GetTopLevelDomainCycles(int resellerId, int productId)
{
return EC.Services.Storefront.GetTopLevelDomainCycles(resellerId, productId);
}
public static GenericResult AddContract(ContractAccount accountSettings)
{
return EC.Services.Storefront.AddContract(ecPanelRequest.ResellerId, accountSettings);
}
public static GenericResult AddContract(int resellerId, ContractAccount accountSettings)
{
return EC.Services.Storefront.AddContract(resellerId, accountSettings);
}
public static OrderResult SubmitCustomerOrder(string contractId,
OrderItem[] orderItems, KeyValueBunch extraArgs)
{
//
return EC.Services.Storefront.SubmitCustomerOrder(contractId, orderItems, extraArgs);
}
public static PaymentMethod[] GetResellerPaymentMethods(int resellerId)
{
return EC.Services.Storefront.GetResellerPaymentMethods(resellerId);
}
public static PaymentMethod GetContractPaymentMethod(string contractId, string methodName)
{
return EC.Services.Storefront.GetContractPaymentMethod(contractId, methodName);
}
public static string GetContractInvoiceTemplated(string contractId, int invoiceId)
{
return EC.Services.Storefront.GetContractInvoiceFormatted(contractId, invoiceId, PortalUtils.CurrentUICulture.Name);
}
public static CheckoutFormParams GetCheckoutFormParams(string contractId, int invoiceId,
string methodName, KeyValueBunch options)
{
return EC.Services.Storefront.GetCheckoutFormParams(contractId, invoiceId, methodName, options);
}
public static CheckoutResult CompleteCheckout(string contractId, int invoiceId,
string methodName, CheckoutDetails details)
{
return EC.Services.Storefront.CompleteCheckout(contractId, invoiceId, methodName, details);
}
public static string[] GetProductHighlights(int resellerId, int productId)
{
return EC.Services.Storefront.GetProductHighlights(resellerId, productId);
}
public static KeyValueBunch GetHostingPlanQuotas(int resellerId, int planId)
{
return EC.Services.Storefront.GetHostingPlanQuotas(resellerId, planId);
}
public static CheckDomainResult CheckDomain(int resellerId, string domain, string tld)
{
return EC.Services.Storefront.CheckDomain(resellerId, domain, tld);
}
public static Category[] GetStorefrontPath(int categoryId)
{
return EC.Services.Storefront.GetStorefrontPath(ecPanelRequest.ResellerId, categoryId);
}
public static Category[] GetStorefrontCategories(int parentId)
{
return EC.Services.Storefront.GetStorefrontCategories(
ecPanelRequest.ResellerId,
parentId
);
}
public static Category GetStorefrontCategory(int categoryId)
{
return EC.Services.Storefront.GetStorefrontCategory(
ecPanelRequest.ResellerId,
categoryId
);
}
public static Product[] GetProductsInCategory(int resellerId, int categoryId)
{
return EC.Services.Storefront.GetProductsInCategory(resellerId, categoryId);
}
public static Product GetStorefrontProduct(int resellerId, int productId)
{
return EC.Services.Storefront.GetStorefrontProduct(resellerId, productId);
}
public static HostingAddon[] GetHostingPlanAddons(int resellerId, int planId)
{
return EC.Services.Storefront.GetHostingPlanAddons(resellerId, planId);
}
public static string GetBaseCurrency(int resellerId)
{
return EC.Services.Storefront.GetBaseCurrency(resellerId);
}
public static string GetTermsAndConditions(int resellerId)
{
return EC.Services.Storefront.GetStorefrontTermsAndConditions(resellerId);
}
public static string GetWelcomeMessage(int resellerId)
{
return EC.Services.Storefront.GetStorefrontWelcomeMessage(resellerId);
}
public static bool HasTopLevelDomainsInStock(int resellerId)
{
return EC.Services.Storefront.HasTopLeveDomainsInStock(resellerId);
}
public static bool GetSecurePayments(int resellerId)
{
return EC.Services.Storefront.GetStorefrontSecurePayments(resellerId);
}
#endregion
}
}

View file

@ -0,0 +1,619 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Portal;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class StorehouseHelper
{
public static void VoidCustomerInvoice(int invoiceId)
{
EC.Services.Storehouse.VoidCustomerInvoice(invoiceId);
}
public static Contract GetCustomerContract(int customerId)
{
return EC.Services.Storehouse.GetCustomerContract(customerId);
}
public static bool CheckCustomerContractExists()
{
return EC.Services.Storehouse.CheckCustomerContractExists();
}
public static bool PaymentProfileExists(string contractId)
{
return EC.Services.Storehouse.PaymentProfileExists(contractId);
}
public static CheckoutDetails GetPaymentProfile(string contractId)
{
return EC.Services.Storehouse.GetPaymentProfile(contractId);
}
public static void SetPaymentProfile(string contractId, CheckoutDetails profile)
{
EC.Services.Storehouse.SetPaymentProfile(contractId, profile);
}
public static int DeletePaymentProfile(string contractId)
{
return EC.Services.Storehouse.DeletePaymentProfile(contractId);
}
public static int AddBillingCycle(string cycleName, string billingPeriod, int periodLength)
{
return EC.Services.Storehouse.AddBillingCycle(
PanelSecurity.SelectedUserId,
cycleName,
billingPeriod,
periodLength
);
}
public static int UpdateBillingCycle(int cycleId, string cycleName, string billingPeriod, int periodLength)
{
return EC.Services.Storehouse.UpdateBillingCycle(
PanelSecurity.SelectedUserId,
cycleId,
cycleName,
billingPeriod,
periodLength
);
}
public static int DeleteBillingCycle(int cycleId)
{
return EC.Services.Storehouse.DeleteBillingCycle(PanelSecurity.SelectedUserId, cycleId);
}
public static BillingCycle GetBillingCycle(int cycleId)
{
return EC.Services.Storehouse.GetBillingCycle(PanelSecurity.SelectedUserId, cycleId);
}
public static int GetBillingCyclesCount()
{
return EC.Services.Storehouse.GetBillingCyclesCount(PanelSecurity.SelectedUserId);
}
public static BillingCycle[] GetBillingCyclesPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetBillingCyclesPaged(
PanelSecurity.SelectedUserId,
maximumRows,
startRowIndex
);
}
public static BillingCycle[] GetBillingCyclesFree(int[] cyclesTaken)
{
return EC.Services.Storehouse.GetBillingCyclesFree(PanelSecurity.SelectedUserId, cyclesTaken);
}
public static int AddHostingPlan(string planName, string productSku, bool taxInclusive, int planId,
int userRole, int initialStatus, int domainOption, bool enabled, string planDescription,
HostingPlanCycle[] planCycles, string[] planHighlights, int[] planCategories)
{
return EC.Services.Storehouse.AddHostingPlan(
PanelSecurity.SelectedUserId,
planName,
productSku,
taxInclusive,
planId,
userRole,
initialStatus,
domainOption,
enabled,
planDescription,
planCycles,
planHighlights,
planCategories
);
}
public static int AddTopLevelDomain(string topLevelDomain, string productSku, bool taxInclusive, int pluginId,
bool enabled, bool whoisEnabled, DomainNameCycle[] domainCycles)
{
return EC.Services.Storehouse.AddTopLevelDomain(PanelSecurity.SelectedUserId,
topLevelDomain, productSku, taxInclusive, pluginId, enabled, whoisEnabled, domainCycles);
}
public static int AddHostingAddon(string addonName, string productSku, bool taxInclusive, int planId, bool recurring,
bool dummyAddon, bool countable, bool enabled, string description, HostingPlanCycle[] addonCycles, int[] addonProducts)
{
return EC.Services.Storehouse.AddHostingAddon(
PanelSecurity.SelectedUserId,
addonName,
productSku,
taxInclusive,
planId,
recurring,
dummyAddon,
countable,
enabled,
description,
addonCycles,
addonProducts
);
}
public static int GetHostingPlansCount()
{
return EC.Services.Storehouse.GetProductsCountByType(
PanelSecurity.SelectedUserId,
Product.HOSTING_PLAN
);
}
public static Product[] GetHostingPlansPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetProductsPagedByType(
PanelSecurity.SelectedUserId,
Product.HOSTING_PLAN,
maximumRows,
startRowIndex
);
}
public static int GetTopLevelDomainsCount()
{
return EC.Services.Storehouse.GetProductsCountByType(
PanelSecurity.SelectedUserId,
Product.TOP_LEVEL_DOMAIN
);
}
public static TopLevelDomain[] GetTopLevelDomainsPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetTopLevelDomainsPaged(
PanelSecurity.SelectedUserId,
maximumRows,
startRowIndex
);
}
public static TopLevelDomain GetTopLevelDomain(int productId)
{
return EC.Services.Storehouse.GetTopLevelDomain(
PanelSecurity.SelectedUserId,
productId
);
}
public static HostingAddon GetHostingAddon(int productId)
{
return EC.Services.Storehouse.GetHostingAddon(
PanelSecurity.SelectedUserId,
productId
);
}
public static DomainNameCycle[] GetTopLevelDomainCycles(int productId)
{
return EC.Services.Storehouse.GetTopLevelDomainCycles(
PanelSecurity.SelectedUserId,
productId
);
}
public static int[] GetHostingPlansTaken()
{
return EC.Services.Storehouse.GetHostingPlansTaken(
PanelSecurity.SelectedUserId
);
}
public static int[] GetHostingAddonsTaken()
{
return EC.Services.Storehouse.GetHostingAddonsTaken(
PanelSecurity.SelectedUserId
);
}
public static HostingPlan GetHostingPlan(int productId)
{
return EC.Services.Storehouse.GetHostingPlan(PanelSecurity.SelectedUserId, productId);
}
public static Category[] GetProductCategories(int productId)
{
return EC.Services.Storehouse.GetProductCategories(
PanelSecurity.SelectedUserId,
productId
);
}
public static int[] GetProductCategoriesIds(int productId)
{
return EC.Services.Storehouse.GetProductCategoriesIds(
PanelSecurity.SelectedUserId,
productId
);
}
public static string[] GetProductHighlights(int productId)
{
return EC.Services.Storehouse.GetProductHighlights(PanelSecurity.SelectedUserId, productId);
}
public static HostingPlanCycle[] GetHostingPlanCycles(int productId)
{
return EC.Services.Storehouse.GetHostingPlanCycles(PanelSecurity.SelectedUserId, productId);
}
public static HostingPlanCycle[] GetHostingAddonCycles(int productId)
{
return EC.Services.Storehouse.GetHostingAddonCycles(
PanelSecurity.SelectedUserId,
productId
);
}
public static int UpdateHostingPlan(int productId, string planName, string productSku, bool taxInclusive,
int planId, int userRole, int initialStatus, int domainOption, bool enabled, string planDescription,
HostingPlanCycle[] planCycles, string[] planHighlights, int[] planCategories)
{
return EC.Services.Storehouse.UpdateHostingPlan(
PanelSecurity.SelectedUserId,
productId,
planName,
productSku,
taxInclusive,
planId,
userRole,
initialStatus,
domainOption,
enabled,
planDescription,
planCycles,
planHighlights,
planCategories
);
}
public static int UpdateHostingAddon(int productId, string addonName, string productSku, bool taxInclusive, int planId, bool recurring,
bool dummyAddon, bool countable, bool enabled, string description, HostingPlanCycle[] addonCycles, int[] addonProducts)
{
return EC.Services.Storehouse.UpdateHostingAddon(PanelSecurity.SelectedUserId, productId, addonName, productSku,
taxInclusive, planId, recurring, dummyAddon, countable, enabled, description, addonCycles, addonProducts);
}
public static int UpdateTopLevelDomain(int productId, string topLevelDomain, string productSku,
bool taxInclusive, int pluginId, bool enabled, bool whoisEnabled, DomainNameCycle[] domainCycles)
{
return EC.Services.Storehouse.UpdateTopLevelDomain(PanelSecurity.SelectedUserId,
productId, topLevelDomain, productSku, taxInclusive, pluginId, enabled, whoisEnabled, domainCycles);
}
public static int DeleteProduct(int productId)
{
return EC.Services.Storehouse.DeleteProduct(
PanelSecurity.SelectedUserId,
productId
);
}
public static Product[] GetProductsByType(int typeId)
{
return EC.Services.Storehouse.GetProductsByType(
PanelSecurity.SelectedUserId,
typeId
);
}
public static Product[] GetAddonProducts(int productId)
{
return EC.Services.Storehouse.GetAddonProducts(
PanelSecurity.SelectedUserId,
productId
);
}
public static int[] GetAddonProductsIds(int productId)
{
return EC.Services.Storehouse.GetAddonProductsIds(
PanelSecurity.SelectedUserId,
productId
);
}
public static int GetHostingAddonsCount()
{
return EC.Services.Storehouse.GetProductsCountByType(
PanelSecurity.SelectedUserId,
Product.HOSTING_ADDON
);
}
public static Product[] GetHostingAddonsPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetProductsPagedByType(
PanelSecurity.SelectedUserId,
Product.HOSTING_ADDON,
maximumRows,
startRowIndex
);
}
public static SupportedPlugin[] GetSupportedPluginsByGroup(string groupName)
{
return EC.Services.Storehouse.GetSupportedPluginsByGroup(
PanelSecurity.SelectedUserId, groupName);
}
public static PaymentMethod GetPaymentMethod(string methodName)
{
return EC.Services.Storehouse.GetPaymentMethod(
PanelSecurity.SelectedUserId, methodName);
}
public static KeyValueBunch GetPluginProperties(int pluginId)
{
return EC.Services.Storehouse.GetPluginProperties(
PanelSecurity.SelectedUserId, pluginId);
}
public static int SetPluginProperties(int pluginId, KeyValueBunch props)
{
return EC.Services.Storehouse.SetPluginProperties(
PanelSecurity.SelectedUserId, pluginId, props);
}
public static int SetPaymentMethod(string methodName, string displayName, int pluginId)
{
return EC.Services.Storehouse.SetPaymentMethod(PanelSecurity.SelectedUserId, methodName,
displayName, pluginId);
}
public static int DeletePaymentMethod(string methodName)
{
return EC.Services.Storehouse.DeletePaymentMethod(PanelSecurity.SelectedUserId, methodName);
}
public static int AddTaxation(string country, string state, string description, int typeId,
decimal amount, bool active)
{
return EC.Services.Storehouse.AddTaxation(PanelSecurity.SelectedUserId, country, state,
description, typeId, amount, active);
}
public static int UpdateTaxation(int taxationId, string country, string state, string description, int typeId,
decimal amount, bool active)
{
return EC.Services.Storehouse.UpdateTaxation(PanelSecurity.SelectedUserId, taxationId,
country, state, description, typeId, amount, active);
}
public static int DeleteTaxation(int taxationId)
{
return EC.Services.Storehouse.DeleteTaxation(PanelSecurity.SelectedUserId, taxationId);
}
public static int GetTaxationsCount()
{
return EC.Services.Storehouse.GetTaxationsCount(PanelSecurity.SelectedUserId);
}
public static Taxation[] GetTaxationsPaged(int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetTaxationsPaged(PanelSecurity.SelectedUserId,
maximumRows, startRowIndex);
}
public static Taxation GetTaxation(int taxationId)
{
return EC.Services.Storehouse.GetTaxation(PanelSecurity.SelectedUserId, taxationId);
}
public static StoreSettings GetStoreSettings(string settingsName)
{
return EC.Services.Storehouse.GetStoreSettings(PanelSecurity.SelectedUserId, settingsName);
}
public static int SetStoreSettings(string settingsName, StoreSettings settings)
{
return EC.Services.Storehouse.SetStoreSettings(PanelSecurity.SelectedUserId, settingsName,
settings);
}
public static RoutineResult SetInvoiceNotification(string fromEmail, string ccEmail, string subject,
string htmlBody, string textBody)
{
return EC.Services.Storehouse.SetInvoiceNotification(PanelSecurity.SelectedUserId, fromEmail, ccEmail,
subject, htmlBody, textBody);
}
public static RoutineResult SetPaymentReceivedNotification(string fromEmail, string ccEmail, string subject,
string htmlBody, string textBody)
{
return EC.Services.Storehouse.SetPaymentReceivedNotification(PanelSecurity.SelectedUserId, fromEmail, ccEmail,
subject, htmlBody, textBody);
}
public static RoutineResult SetServiceActivatedNotification(string fromEmail, string ccEmail, string subject,
string htmlBody, string textBody)
{
return EC.Services.Storehouse.SetServiceActivatedNotification(PanelSecurity.SelectedUserId, fromEmail, ccEmail,
subject, htmlBody, textBody);
}
public static RoutineResult SetServiceSuspendedNotification(string fromEmail, string ccEmail, string subject,
string htmlBody, string textBody)
{
return EC.Services.Storehouse.SetServiceSuspendedNotification(PanelSecurity.SelectedUserId, fromEmail, ccEmail,
subject, htmlBody, textBody);
}
public static RoutineResult SetServiceCancelledNotification(string fromEmail, string ccEmail, string subject,
string htmlBody, string textBody)
{
return EC.Services.Storehouse.SetServiceCancelledNotification(PanelSecurity.SelectedUserId, fromEmail, ccEmail,
subject, htmlBody, textBody);
}
public static bool IsSupportedPluginActive(int pluginId)
{
return EC.Services.Storehouse.IsSupportedPluginActive(PanelSecurity.SelectedUserId, pluginId);
}
public static Category[] GetStorehousePath(int categoryId)
{
return EC.Services.Storefront.GetStorefrontPath(PanelSecurity.SelectedUserId, categoryId);
}
public static int GetCustomersPaymentsCount(bool isReseller)
{
return EC.Services.Storehouse.GetCustomersPaymentsCount(PanelSecurity.SelectedUserId, isReseller);
}
public static CustomerPayment[] GetCustomersPaymentsPaged(bool isReseller, int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetCustomersPaymentsPaged(PanelSecurity.SelectedUserId, isReseller,
maximumRows, startRowIndex);
}
public static int GetCustomersInvoicesCount(bool isReseller)
{
return EC.Services.Storehouse.GetCustomersInvoicesCount(PanelSecurity.SelectedUserId, isReseller);
}
public static Invoice[] GetCustomersInvoicesPaged(bool isReseller, int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetCustomersInvoicesPaged(PanelSecurity.SelectedUserId, isReseller,
maximumRows, startRowIndex);
}
public static int DeleteCustomerPayment(int paymentId)
{
return EC.Services.Storehouse.DeleteCustomerPayment(paymentId);
}
public static int ChangeCustomerPaymentStatus(int paymentId, TransactionStatus status)
{
return EC.Services.Storehouse.ChangeCustomerPaymentStatus(paymentId, status);
}
public static string GetCustomerInvoiceFormatted(int invoiceId)
{
return EC.Services.Storehouse.GetCustomerInvoiceFormatted(invoiceId, PortalUtils.CurrentCulture.Name);
}
public static Invoice GetCustomerInvoice(int invoiceId)
{
return EC.Services.Storehouse.GetCustomerInvoice(invoiceId);
}
public static int AddCustomerPayment(string contractId, int invoiceId, string transactionId,
decimal amount, string currency, string methodName, TransactionStatus status)
{
return EC.Services.Storehouse.AddCustomerPayment(contractId, invoiceId, transactionId, amount, currency,
methodName, status);
}
public static int GetCustomersServicesCount(bool isReseller)
{
return EC.Services.Storehouse.GetCustomersServicesCount(PanelSecurity.SelectedUserId, isReseller);
}
public static Service[] GetCustomersServicesPaged(bool isReseller, int maximumRows, int startRowIndex)
{
return EC.Services.Storehouse.GetCustomersServicesPaged(PanelSecurity.SelectedUserId, isReseller,
maximumRows, startRowIndex);
}
public static DomainNameSvc GetDomainNameService(int serviceId)
{
return EC.Services.Storehouse.GetDomainNameService(serviceId);
}
public static HostingPackageSvc GetHostingPackageService(int serviceId)
{
return EC.Services.Storehouse.GetHostingPackageService(serviceId);
}
public static HostingAddonSvc GetHostingAddonService(int serviceId)
{
return EC.Services.Storehouse.GetHostingAddonService(serviceId);
}
public static Service GetRawCustomerService(int serviceId)
{
return EC.Services.Storehouse.GetRawCustomerService(serviceId);
}
public static ServiceHistoryRecord[] GetServiceHistory(int serviceId)
{
return EC.Services.Storehouse.GetServiceHistory(serviceId);
}
public static GenericSvcResult ActivateService(int serviceId, bool sendMail)
{
return EC.Services.Storehouse.ActivateService(serviceId, sendMail);
}
public static GenericSvcResult SuspendService(int serviceId, bool sendMail)
{
return EC.Services.Storehouse.SuspendService(serviceId, sendMail);
}
public static GenericSvcResult CancelService(int serviceId, bool sendMail)
{
return EC.Services.Storehouse.CancelService(serviceId, sendMail);
}
public static GenericSvcResult[] ActivateInvoice(int invoiceId)
{
return EC.Services.Storehouse.ActivateInvoice(invoiceId);
}
public static bool IsInvoiceProcessed(int invoiceId)
{
return EC.Services.Storehouse.IsInvoiceProcessed(invoiceId);
}
public static int DeleteCustomerService(int serviceId)
{
return EC.Services.Storehouse.DeleteCustomerService(serviceId);
}
}
}

View file

@ -0,0 +1,347 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Ecommerce.Portal
{
public abstract class PagesKeys
{
public const string ADDONS = "ecAddons";
public const string ORDER_CHECKOUT = "ecOrderCheckout";
}
public abstract class ModulesKeys
{
public const string EDIT_ITEM = "EditItem";
public const string ADD_ITEM = "AddItem";
public const string CONFIGURE_ITEM = "ConfigItem";
}
public abstract class RequestKeys
{
public const string CONTRACT_ID = "ContractId";
public const string PRODUCT_ID = "ProductId";
public const string PRODUCT_TYPE_ID = "TypeId";
public const string PLUGIN_ID = "PluginId";
public const string RESELLER_ID = "ResellerId";
public const string USER_ID = "UserId";
public const string INVOICE_ID = "InvoiceId";
public const string PAYMENT_METHOD = "Method";
}
public abstract class MessagesKeys
{
public const string ADD_PRODUCT_ADDON = "ADD_PRODUCT_ADDON";
public const string EDIT_PRODUCT_ADDON = "EDIT_PRODUCT_ADDON";
public const string DELETE_PRODUCT_ADDON = "DELETE_PRODUCT_ADDON";
public const string ADD_CATEGORY = "ADD_CATEGORY";
public const string EDIT_CATEGORY = "EDIT_CATEGORY";
public const string DELETE_CATEGORY = "DELETE_CATEGORY";
public const string ADD_PRODUCT = "ADD_PRODUCT";
public const string EDIT_PRODUCT = "EDIT_PRODUCT";
public const string DELETE_PRODUCT = "DELETE_PRODUCT";
public const string ADD_PRODUCT_TYPE = "ADD_PRODUCT_TYPE";
public const string EDIT_PRODUCT_TYPE = "EDIT_PRODUCT_TYPE";
public const string DELETE_PRODUCT_TYPE = "DELETE_PRODUCT_TYPE";
public const string LOAD_PRODUCT_TYPE_CONTROLS = "LOAD_PRODUCT_TYPE_CONTROLS";
public const string LOAD_PRODUCT_TYPE_DEFINITION = "LOAD_PRODUCT_TYPE_DEFINITION";
public const string ADD_PLUGIN = "ADD_PLUGIN";
public const string EDIT_PLUGIN = "EDIT_PLUGIN";
public const string DELETE_PLUGIN = "DELETE_PLUGIN";
public const string LOAD_PLUGIN = "LOAD_PLUGIN";
public const string LOAD_PLUGIN_SETTINGS_CONTROL = "LOAD_PLUGIN_SETTINGS_CONTROL";
public const string SAVE_PLUGIN_SETTINGS = "SAVE_PLUGIN_SETTINGS";
public const string ADD_TLD_EXTENSION = "ADD_TLD_EXTENSION";
public const string EDIT_TLD_EXTENSION = "EDIT_TLD_EXTENSION";
public const string DELETE_TLD_EXTENSION = "DELETE_TLD_EXTENSION";
public const string LOAD_TLD_EXTENSION = "LOAD_TLD_EXTENSION";
public const string LOAD_TLD_REGISTRARS = "LOAD_TLD_REGISTRARS";
public const string ACTIVATE_SERVICE = "ACTIVATE_SERVICE";
public const string SUSPEND_SERVICE = "SUSPEND_SERVICE";
public const string CANCEL_SERVICE = "CANCEL_SERVICE";
public const string SAVE_NOTIFICATION_TEMPLATE = "SAVE_NOTIFICATION_TEMPLATE";
public const string LOAD_NOTIFICATION_TEMPLATE = "LOAD_NOTIFICATION_TEMPLATE";
public const string SAVE_SYSTEM_SETTINGS = "SAVE_SYSTEM_SETTINGS";
public const string SAVE_SIGNUP_SETTINGS = "SAVE_SIGNUP_SETTINGS";
public const string LOAD_SPACE_SETTINGS = "LOAD_SPACE_SETTINGS";
public const string CREATE_SHOPPING_SPACE = "CREATE_SHOPPING_SPACE";
public const string EMPTY_STORE_OWNER = "EMPTY_STORE_OWNER";
public const string STORE_OWNER_ROLE_MISMATCH = "STORE_OWNER_ROLE_MISMATCH";
public const string SAVE_INVOICE_TEMPLATE = "SAVE_INVOICE_TEMPLATE";
public const string LOAD_INVOICE_TEMPLATE = "LOAD_INVOICE_TEMPLATE";
public const string SAVE_TERMS_AND_CONDS = "SAVE_TERMS_AND_CONDS";
public const string LOAD_TERMS_AND_CONDS = "LOAD_TERMS_AND_CONDS";
public const string ADD_INVOICE_PAYMENT = "ADD_INVOICE_PAYMENT";
public const string ACTIVATE_INVOICE_SERVICES = "ACTIVATE_INVOICE_SERVICES";
}
public class Keys
{
public const string INVOICE_DIRECT_URL = "InvoiceDirectURL";
public const string CurrencyCodeISO = "CurrencyCodeISO";
public const string CurrencySymbol = "CurrencySymbol";
public const string CustomerProfile = "CustomerProfile";
#region Action keys
public const string AddItem = "AddItem";
public const string DeleteItem = "DeleteItem";
public const string EditItem = "EditItem";
public const string GetItem = "GetItem";
public const string ConfigItem = "ConfigItem";
#endregion
#region Product Type keys
public const string CartExtension = "CartControl";
public const string ProductExtension = "ProductControl";
public const string TypeExtension = "TypeControl";
public const string ControllerExtension = "Controller";
#endregion
#region Email Notification settings keys
public const string FromField = "FromField";
public const string BccField = "BccField";
public const string SmtpServer = "SmtpServer";
public const string SmtpAuthentication = "SmtpAuthentication";
public const string SmtpUsername = "SmtpUsername";
public const string SmtpPassword = "SmtpPassword";
#endregion
#region Payment keys
public const string AddPayment = "AddOfflineMode";
#endregion
#region Service keys
public const string ServiceEdit = "EditServiceMode";
#endregion
#region Invoice keys
public const string InvoiceEdit = "EditInvoiceMode";
#endregion
#region Gateway Log keys
public const string GatewayLogEntry = "GatewayLogEntry";
#endregion
#region OrderCheckout module keys
public const string PerformPayment = "PerformPayment";
public const string PaymentSucceed = "PaymentSucceed";
public const string PaymentFailed = "PaymentFailed";
public const string PaymentId = "PaymentId";
#endregion
public const string ErrorMessage = "ErrorMessage";
public const string ParentCategoryId = "ParentCategoryId";
public const string CacheCryptoKey = "CacheCryptoKey";
public const string Service = "ServiceId";
public const string Invoice = "InvoiceId";
public const string InvoiceDetailsMode = "InvoiceDetailsMode";
public const string DisplayMode = "DisplayMode";
public const string InvoiceMode = "InvoiceMode";
public const string PaymentMode = "PaymentMode";
public const string ServiceMode = "ServiceMode";
public const string CartPage = "CartPageTabID";
public const string CheckoutPage = "CheckoutPage";
public const string CartModuleMode = "CartMode";
public const string esOwner = "OwnerID";
public const string OwnerSpaceId = "OwnerSpaceID";
public const string OwnerSpace = "OwnerSpace";
public const string CustomerCart = "CustomerCartID";
public const string PaymentProvider = "PaymentProvID";
public const string RegistrationPage = "RegistrationPageTabID";
public const string UserInfo = "UserInfo";
public const string UserInfoTemp = "UserInfo_Temp";
public const string PanelLogin = "WebsitePanelLogin";
public const string ContactInfo = "ContactInfo";
public const string SignInMode = "SignInMode";
public const string CreateAccountMode = "CreateAccountMode";
public const string CheckoutMode = "CheckoutMode";
public const string AddGateway = "AddGateway";
public const string EditGateway = "EditGateway";
public const string ConfigureGateway = "ConfigGateway";
public const string Gateway = "GatewayId";
public const string ModuleName = "Ecommerce";
public const int DefaultInt = -1;
#region Payment Processor's key set
public const string Processor = "PaymentProcessor";
#endregion
private Keys()
{
}
}
/// <summary>
/// Authorize.NET Payment Provider keys set
/// </summary>
public class AuthNetKeys
{
/// <summary>
/// 3.1
/// </summary>
public const string Version = "x_version";
/// <summary>
/// True
/// </summary>
public const string DelimData = "x_delim_data";
/// <summary>
/// False
/// </summary>
public const string RelayResponse = "x_relay_response";
/// <summary>
/// API login ID for the payment gateway account
/// </summary>
public const string Account = "x_login";
/// <summary>
/// Transaction key obtained from the Merchant Interface
/// </summary>
public const string TransactionKey = "x_tran_key";
/// <summary>
/// Amount of purchase inclusive of tax
/// </summary>
public const string Amount = "x_amount";
/// <summary>
/// Customer's card number
/// </summary>
public const string CardNumber = "x_card_num";
/// <summary>
/// Customer's card expiration date
/// </summary>
public const string ExpirationDate = "x_exp_date";
/// <summary>
/// Type of transaction (AUTH_CAPTURE, AUTH_ONLY, CAPTURE_ONLY, CREDIT, VOID, PRIOR_AUTH_CAPTURE)
/// </summary>
public const string TransactType = "x_type";
/// <summary>
///
/// </summary>
public const string DemoMode = "x_test_request";
public const string DelimiterChar = "x_delim_char";
public const string EncapsulationChar = "x_encap_char";
public const string DuplicateWindow = "x_duplicate_window";
public const string FirstName = "x_first_name";
public const string LastName = "x_last_name";
public const string Company = "x_company";
public const string Address = "x_address";
public const string City = "x_city";
public const string State = "x_state";
public const string Zip = "x_zip";
public const string Country = "x_country";
public const string Phone = "x_phone";
public const string Fax = "x_fax";
public const string CustomerId = "x_cust_id";
public const string CustomerIP = "x_customer_ip";
public const string CustomerTax = "x_customer_tax_id";
public const string CustomerEmail = "x_email";
public const string SendConfirmation = "x_email_customer";
public const string MerchantEmail = "x_merchant_email";
public const string InvoiceNumber = "x_invoice_num";
public const string TransDescription = "x_description";
public const string CurrencyCode = "x_currency_code";
public const string PaymentMethod = "x_method";
public const string RecurringBilling = "x_recurring_billing";
public const string VerificationCode = "x_card_code";
public const string AuthorizationCode = "x_auth_code";
public const string AuthenticationIndicator = "x_authentication_indicator";
public const string PurchaseOrder = "x_po_num";
public const string Tax = "x_tax";
public const string FpHash = "x_fp_hash";
public const string FpSequence = "x_fp_sequence";
public const string FpTimestamp = "x_fp_timestamp";
public const string RelayUrl = "x_relay_url";
public const string TransactId = "x_trans_id";
public const string AuthCode = "x_auth_code";
public const string MD5HashValue = "MD5HashValue";
public const string ShipToFirstName = "x_ship_to_first_name";
public const string ShipToLastName = "x_ship_to_last_name";
public const string ShipToCompany = "x_ship_to_company";
public const string ShipToAddress = "x_ship_to_address";
public const string ShipToCity = "x_ship_to_city";
public const string ShipToState = "x_ship_to_state";
public const string ShipToZip = "x_ship_to_zip";
public const string ShipToCountry = "x_ship_to_country";
private AuthNetKeys()
{
}
}
}

View file

@ -0,0 +1,128 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.Ecommerce.Portal
{
public class PortalCache
{
protected PortalCache()
{
}
public static string GetString(string keyName)
{
object keyValue = GetObject(keyName);
if (keyValue == null)
return string.Empty;
return Convert.ToString(keyValue);
}
public static int GetInt(string keyName, int defaultValue)
{
return ecUtils.ParseInt(GetObject(keyName), defaultValue);
}
public static int GetInt(string keyName)
{
return GetInt(keyName, Keys.DefaultInt);
}
public static Guid GetGuid(string keyName)
{
object keyValue = GetObject(keyName);
if (keyValue != null)
return (Guid)keyValue;
return Guid.Empty;
}
public static void SetObject(string keyName, object keyValue)
{
if (!HttpContext.Current.Items.Contains(keyName))
HttpContext.Current.Items.Add(keyName, keyValue);
else
HttpContext.Current.Items[keyName] = keyValue;
}
public static object GetObject(string keyName)
{
return HttpContext.Current.Items[keyName];
}
}
public class CryptoCache
{
private static readonly string CacheCryptoKey;
static CryptoCache()
{
CacheCryptoKey = EcommerceSettings.GetSetting(Keys.CacheCryptoKey);
}
private CryptoCache() { }
public static int GetInt(string keyName)
{
string keyValue = GetObject(keyName);
return ecUtils.ParseInt(keyValue, Keys.DefaultInt);
}
protected static string GetObject(string keyName)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[keyName];
if (cookie != null)
return cookie.Value;
return null;
}
public static void RemoveObject(string keyName)
{
HttpContext.Current.Request.Cookies.Remove(keyName);
}
public static void SetObject(string keyName, object keyValue)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[keyName];
if (cookie == null)
cookie = new HttpCookie(keyName);
cookie.Value = keyValue.ToString();
HttpContext.Current.Response.Cookies.Add(cookie);
}
}
}

View file

@ -0,0 +1,92 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using Microsoft.Web.Services3;
using System.Collections.Generic;
using System.Text;
using System.Web;
using WebsitePanel.Portal;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class ProxyConfigurator
{
public static void Configure(WebServicesClientProtocol proxy)
{
Configure(proxy, true);
}
public static void RunServiceAsSpaceOwner(WebServicesClientProtocol proxy)
{
// impersonate as space owner
string username = EcommerceSettings.GetSetting("OwnerUsername");
string password = EcommerceSettings.GetSetting("OwnerPassword");
if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
{
EnterpriseServerProxyConfigurator config = new EnterpriseServerProxyConfigurator();
config.EnterpriseServerUrl = EcommerceSettings.GetSetting("EnterpriseServer");
config.Username = username;
config.Password = password;
config.Configure(proxy);
}
else
throw new Exception("Ecommerce doesn't configured correctly, please review SitesSettings/Ecommerce section");
}
public static void Configure(WebServicesClientProtocol proxy, bool applyPolicy)
{
if (applyPolicy && !HttpContext.Current.Request.IsAuthenticated)
{
// impersonate as space owner
string username = EcommerceSettings.GetSetting("OwnerUsername");
string password = EcommerceSettings.GetSetting("OwnerPassword");
if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
{
EnterpriseServerProxyConfigurator config = new EnterpriseServerProxyConfigurator();
config.EnterpriseServerUrl = EcommerceSettings.GetSetting("EnterpriseServer");
config.Username = username;
config.Password = password;
config.Configure(proxy);
return;
}
}
PortalUtils.ConfigureEnterpriseServerProxy(proxy, applyPolicy);
}
}
}

View file

@ -0,0 +1,66 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace WebsitePanel.WebPortal.Services.Ecommerce
{
public class _2Checkout : ServiceHandlerBase
{
public _2Checkout()
: base("6A847B61-6178-445d-93FC-1929E86984DF", false)
{
PreProcessRequest += new EventHandler(ServiceHandler_PreProcessRequest);
PostProcessRequest += new EventHandler(ServiceHandler_PostProcessRequest);
}
private void ServiceHandler_PreProcessRequest(object sender, EventArgs e)
{
HttpContext context = (HttpContext)sender;
//
SetProperty(CONTRACT_ID, context.Request.Form["contract_id"]);
//
SetProperty(INVOICE_ID, context.Request.Form["merchant_order_id"]);
}
private void ServiceHandler_PostProcessRequest(object sender, EventArgs e)
{
HttpContext context = (HttpContext)sender;
// 2Checkout workaround for Direct Return = Yes
context.Response.Clear();
// write refresh html
context.Response.Write("<html><head><META http-equiv=\"refresh\" content=\"0;" +
"URL=" + GetProperty<string>(REDIRECT_URL) + "\"></head></html>");
}
}
}

View file

@ -0,0 +1,55 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace WebsitePanel.WebPortal.Services.Ecommerce
{
public class PayPalIPN : ServiceHandlerBase
{
public PayPalIPN()
: base("C7EA147E-880D-46f4-88C0-90A9D58BB8C0", false)
{
PreProcessRequest += new EventHandler(ServiceHandler_PreProcessRequest);
}
private void ServiceHandler_PreProcessRequest(object sender, EventArgs e)
{
HttpContext context = (HttpContext)sender;
//
SetProperty(CONTRACT_ID, context.Request.Form["custom"]);
//
SetProperty(INVOICE_ID, context.Request.Form["invoice"]);
}
}
}

View file

@ -0,0 +1,183 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using WebsitePanel.Ecommerce.EnterpriseServer;
using WebsitePanel.Portal;
using WebsitePanel.Ecommerce.Portal;
namespace WebsitePanel.WebPortal.Services.Ecommerce
{
/// <summary>
/// Summary description for $codebehindclassname$
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public abstract class ServiceHandlerBase : IHttpHandler
{
#region Variables
private string ServiceHandlerName;
private bool RedirectRequired;
private KeyValueBunch handlerSettings;
#endregion
#region Constants
/// <summary>
/// Order complete uri
/// </summary>
public const string ORDER_COMPLETE_URI = "/Default.aspx?pid=ecOrderComplete";
public const string REDIRECT_URL = "RedirectUrl";
public const string CONTRACT_ID = "ContractId";
public const string INVOICE_ID = "InvoiceId";
#endregion
#region Properties
public virtual bool IsReusable
{
get { return true; }
}
#endregion
#region Events
public event EventHandler PreProcessRequest;
public event EventHandler PostProcessRequest;
#endregion
protected ServiceHandlerBase(string serviceHandlerName, bool redirectRequired)
{
//
if (String.IsNullOrEmpty(serviceHandlerName))
throw new ArgumentNullException("serviceHandlerName");
//
RedirectRequired = redirectRequired;
//
ServiceHandlerName = serviceHandlerName;
//
handlerSettings = new KeyValueBunch();
}
protected void RaisePreProcessRequestEvent(HttpContext sender)
{
if (PreProcessRequest != null)
PreProcessRequest(sender, EventArgs.Empty);
}
protected void RaisePostProcessRequestEvent(HttpContext sender)
{
if (PostProcessRequest != null)
PostProcessRequest(sender, EventArgs.Empty);
}
protected virtual string ProcessServiceHandlerRequest(HttpContext context)
{
//
string serviceResponse = String.Empty;
//
using (StreamReader sr = new StreamReader(context.Request.InputStream))
{
serviceResponse = sr.ReadToEnd();
}
// Decode service response
return HttpUtility.UrlDecode(serviceResponse);
}
private void InitializeServiceHandler(HttpContext context)
{
string targetSite = context.Request.Form[CheckoutFormParams.TARGET_SITE];
// check target_site variable
if (!String.IsNullOrEmpty(targetSite))
targetSite = String.Concat(targetSite, ORDER_COMPLETE_URI);
else
targetSite = EcommerceSettings.AbsoluteAppPath;
//
SetProperty(REDIRECT_URL, targetSite);
}
protected virtual void DoTargetSiteRedirect(HttpContext context)
{
string targetSite = GetProperty<string>(REDIRECT_URL);
//
if (!String.IsNullOrEmpty(targetSite))
context.Response.Redirect(targetSite);
}
public T GetProperty<T>(string name)
{
return (T)Convert.ChangeType(handlerSettings[name], typeof(T));
}
public void SetProperty(string name, object value)
{
handlerSettings[name] = Convert.ToString(value);
}
public void ProcessRequest(HttpContext context)
{
// Do service handler initialization
InitializeServiceHandler(context);
// Do request pre-processing
RaisePreProcessRequestEvent(context);
// Do service handler processing
string dataReceived = ProcessServiceHandlerRequest(context);
string contractId = GetProperty<string>(CONTRACT_ID);
int invoiceId = GetProperty<int>(INVOICE_ID);
//
if (String.IsNullOrEmpty(contractId))
contractId = null;
// Do service response submit
EC.Services.ServiceHandler.AddServiceHandlerTextResponse(
ServiceHandlerName, contractId, invoiceId, dataReceived);
// Do request post-processing
RaisePostProcessRequestEvent(context);
// Do redirect if required
if (RedirectRequired)
DoTargetSiteRedirect(context);
}
}
}

View file

@ -0,0 +1,234 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Collections.Specialized;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebsitePanel.Ecommerce.Portal
{
public class UrlBuilder : UriBuilder
{
NameValueCollection queryString = null;
#region Properties
public NameValueCollection QueryString
{
get
{
if (queryString == null)
{
queryString = new NameValueCollection();
}
return queryString;
}
}
public string PageName
{
get
{
string path = base.Path;
return path.Substring(path.LastIndexOf("/") + 1);
}
set
{
string path = base.Path;
path = path.Substring(0, path.LastIndexOf("/"));
base.Path = string.Concat(path, "/", value);
}
}
#endregion
public static UrlBuilder FromCurrentRequest()
{
return new UrlBuilder(
HttpContext.Current.Request.Url.AbsoluteUri
);
}
public static UrlBuilder FromScratch()
{
UrlBuilder builder = FromCurrentRequest();
builder.QueryString.Clear();
return builder;
}
public static UrlBuilder FromSpecifiedString(string uri)
{
return new UrlBuilder(uri);
}
public static UrlBuilder FromSpecifiedPage(System.Web.UI.Page page)
{
return new UrlBuilder(page.Request.Url.AbsoluteUri);
}
#region Constructor overloads
private UrlBuilder()
{
}
private UrlBuilder(string uri)
: base(uri)
{
PopulateQueryString();
}
private UrlBuilder(Uri uri)
: base(uri)
{
PopulateQueryString();
}
private UrlBuilder(string schemeName, string hostName)
: base(schemeName, hostName)
{
}
private UrlBuilder(string scheme, string host, int portNumber)
: base(scheme, host, portNumber)
{
}
private UrlBuilder(string scheme, string host, int port, string pathValue)
: base(scheme, host, port, pathValue)
{
}
private UrlBuilder(string scheme, string host, int port, string path, string extraValue)
: base(scheme, host, port, path, extraValue)
{
}
private UrlBuilder(System.Web.UI.Page page)
: base(page.Request.Url.AbsoluteUri)
{
PopulateQueryString();
}
#endregion
#region Public methods
public new string ToString()
{
GetQueryString();
if (Port == 80 || Port == 443)
return Uri.AbsoluteUri.Replace(String.Concat(":", Port), String.Empty);
return Uri.AbsoluteUri;
}
public void Navigate()
{
_Navigate(true);
}
public void Navigate(bool endResponse)
{
_Navigate(endResponse);
}
private void _Navigate(bool endResponse)
{
string uri = this.ToString();
HttpContext.Current.Response.Redirect(uri, endResponse);
}
#endregion
#region Private methods
private void PopulateQueryString()
{
string query = base.Query;
if (queryString == null)
queryString = new NameValueCollection();
else
queryString.Clear();
if (String.IsNullOrEmpty(query))
{
/*foreach (string key in HttpContext.Current.Request.Params)
{
queryString[key] = HttpContext.Current.Request.Params[key];
}*/
}
else
{
query = query.Substring(1); //remove the ?
string[] pairs = query.Split(new char[] { '&' });
foreach (string s in pairs)
{
string[] pair = s.Split(new char[] { '=' });
queryString[pair[0]] = (pair.Length > 1) ? pair[1] : string.Empty;
}
}
}
private void GetQueryString()
{
int count = queryString.Count;
if (count == 0)
{
base.Query = string.Empty;
return;
}
string[] pairs = new string[count];
for (int i = 0; i < count; i++)
{
pairs[i] = String.Concat(queryString.AllKeys[i], "=", queryString[i]);
}
base.Query = string.Join("&", pairs);
}
#endregion
}
}

View file

@ -0,0 +1,298 @@
// Copyright (c) 2011, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.IO;
using System.Data;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Text;
using System.Globalization;
using System.Text.RegularExpressions;
using WebsitePanel.WebPortal;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Ecommerce.EnterpriseServer;
namespace WebsitePanel.Ecommerce.Portal
{
public class ecUtils
{
public static ContractAccount GetContractAccountFromUserInfo(UserInfo user)
{
string mailFormat = user.HtmlMail ? "HTML" : "Text";
//
ContractAccount account = GetContractAccountFromInput(user.Username, null, user.FirstName, user.LastName,
user.Email, user.CompanyName, user.Address, user.City, user.Country, user.State, user.Zip,
user.PrimaryPhone, user.Fax, user.InstantMessenger, mailFormat);
//
account[ContractAccount.CUSTOMER_ID] = Convert.ToString(user.UserId);
//
return account;
}
public static ContractAccount GetContractAccountFromInput(string username, string password, string firstName,
string lastName, string email, string companyName, string address, string city, string country, string state,
string zip, string phoneNumber, string faxNumber, string instantMessenger, string mailFormat)
{
ContractAccount account = new ContractAccount();
account[ContractAccount.USERNAME] = username;
account[ContractAccount.PASSWORD] = password;
account[ContractAccount.FIRST_NAME] = firstName;
account[ContractAccount.LAST_NAME] = lastName;
account[ContractAccount.EMAIL] = email;
account[ContractAccount.COMPANY_NAME] = companyName;
account[ContractAccount.ADDRESS] = address;
account[ContractAccount.CITY] = city;
account[ContractAccount.COUNTRY] = country;
account[ContractAccount.STATE] = state;
account[ContractAccount.ZIP] = zip;
account[ContractAccount.PHONE_NUMBER] = phoneNumber;
account[ContractAccount.FAX_NUMBER] = faxNumber;
account[ContractAccount.INSTANT_MESSENGER] = instantMessenger;
account[ContractAccount.MAIL_FORMAT] = mailFormat;
//
return account;
}
public static void ToggleControls(bool turnOn, params Control[] ctrls)
{
foreach (Control ctrl in ctrls)
ctrl.Visible = turnOn;
}
public static void SelectListItem(DropDownList ctrl, object value)
{
// unselect currently selected item
ctrl.SelectedIndex = -1;
string val = (value != null) ? value.ToString() : "";
ListItem item = ctrl.Items.FindByValue(val);
if (item != null)
ctrl.SelectedIndex = ctrl.Items.IndexOf(item);
}
public static void SelectListItemByText(DropDownList ctrl, object value)
{
// unselect currently selected item
ctrl.SelectedIndex = -1;
string val = (value != null) ? value.ToString() : "";
ListItem item = ctrl.Items.FindByText(val);
if (item != null)
ctrl.SelectedIndex = ctrl.Items.IndexOf(item);
}
public static T FindControl<T>(Control parent, string id)
{
return (T)Convert.ChangeType(parent.FindControl(id), typeof(T));
}
public static int ParseInt(object value, int defaultValue)
{
try { return Int32.Parse(value.ToString()); }
catch { return defaultValue; }
}
public static bool ParseBoolean(object value, bool defaultValue)
{
bool result = defaultValue;
try { result = Convert.ToBoolean(value); }
catch { /* do nothing*/ }
return result;
}
public static Guid ParseGuid(object value)
{
Guid result = Guid.Empty;
try
{
result = new Guid(Convert.ToString(value));
}
catch { }
return result;
}
public static decimal ParseDecimal(string val, decimal defaultValue)
{
decimal result = defaultValue;
try { result = Decimal.Parse(val); }
catch { /* do nothing */ }
return result;
}
public static void InsertLocalizedListMessage(ListControl list, string key)
{
key = string.Concat("ListMessage.", key);
//string localizedMessage = DotNetNuke.Services.Localization.Localization.GetString(key, ecPanelGlobals.ecSharedResourceFile);
string localizedMessage = "";
if (!String.IsNullOrEmpty(localizedMessage))
{
bool firstSelected = list.SelectedIndex == 0;
list.Items.Insert(0, new ListItem(localizedMessage, string.Empty));
// restore default selection
if (firstSelected)
list.SelectedIndex = 0;
}
}
public static bool IsGuidEmpty(Guid guid)
{
return guid.Equals(Guid.Empty);
}
public static string EnsurePathWithQuestionMark(string path)
{
if (!path.EndsWith("?"))
return string.Concat(path, "?");
return path;
}
#region Navigate url wrappers
public static string GetOrderCompleteUrl()
{
return GetNavigateUrl("ecOrderComplete", false);
}
public static string GetStorefrontUrl()
{
return GetNavigateUrl("ecOnlineStore", false);
}
public static string GetShoppingCartUrl()
{
return GetNavigateUrl("ecMyShoppingCart", false);
}
public static string GetRegistrationFormUrl()
{
return GetNavigateUrl("ecUserSignup", true);
}
#endregion
#region Jump wrappers
public static void JumpToShoppingCart()
{
Navigate("ecMyShoppingCart", false);
}
public static void JumpToOrderCheckout(bool secure)
{
Navigate("ecOrderCheckout", secure);
}
public static void JumpToCustomerSignup(bool secure)
{
Navigate("ecCustomerSignup", secure);
}
#endregion
#region Navigation helper routines
public static void NavigateToPageModule(string pageKey, string controlKey, params string[] additionalParams)
{
PortalPage page = PortalConfiguration.Site.Pages[pageKey];
ModuleDefinition moduleDef = PortalConfiguration.ModuleDefinitions[controlKey];
UrlBuilder url = UrlBuilder.FromScratch();
url.QueryString[DefaultPage.PAGE_ID_PARAM] = pageKey;
url.QueryString[DefaultPage.MODULE_ID_PARAM] = moduleDef.Id;
}
public static string GetNavigateUrl(string pageId, bool secure, params string[] extraParams)
{
UrlBuilder url = UrlBuilder.FromScratch();
url.QueryString[DefaultPage.PAGE_ID_PARAM] = pageId;
if (secure && EcommerceSettings.UseSSL)
url.Scheme = "https";
//
if (extraParams != null)
{
foreach (string extraParam in extraParams)
{
string[] data = extraParam.Split('=');
if (data.Length == 2)
url.QueryString.Add(data[0].Trim(), data[1].Trim());
}
}
return url.ToString();
}
public static void Navigate(string pageId, bool secure)
{
UrlBuilder url = UrlBuilder.FromScratch();
url.QueryString[DefaultPage.PAGE_ID_PARAM] = pageId;
if (secure && EcommerceSettings.UseSSL)
url.Scheme = "https";
url.Navigate();
}
public static void Navigate(string pageId, bool secure, params string[] parameters)
{
//
bool useSSL = StorefrontHelper.GetSecurePayments(ecPanelRequest.ResellerId);
//
UrlBuilder url = UrlBuilder.FromScratch();
url.QueryString[DefaultPage.PAGE_ID_PARAM] = pageId;
if (secure && useSSL)
url.Scheme = "https";
// copy query params
foreach (string parameter in parameters)
{
string[] parts = parameter.Split('=');
url.QueryString[parts[0]] = parts[1];
}
url.Navigate();
}
#endregion
}
}