Esempio n. 1
0
        public static DateTime GetSvcsSuspendDateAligned(int[] services, DateTime defaultValue)
        {
            string svcsXml = Utils.BuildIdentityXmlFromArray(services, "Svcs", "Svc");

            return(EcommerceProvider.GetSvcsSuspendDateAligned(ES.SecurityContext.User.UserId,
                                                               svcsXml, defaultValue));
        }
Esempio n. 2
0
        public static int AddInvoice(string contractId, DateTime created, DateTime dueDate,
                                     int taxationId, decimal totalAmount, decimal subTotalAmount, decimal taxAmount, List <InvoiceItem> invoiceLines, KeyValueBunch extraArgs)
        {
            //
            try
            {
                Contract contract = ContractSystem.ContractController.GetContract(contractId);
                //
                ES.TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.TASK_ADD_INVOICE);
                // build xml representation
                string invoiceLinesXml = BuildAddXmlForInvoiceItems(invoiceLines);
                // add invoice
                int result = EcommerceProvider.AddInvoice(contractId, created, dueDate,
                                                          taxationId, totalAmount, subTotalAmount, taxAmount, invoiceLinesXml,
                                                          StorehouseController.GetBaseCurrency(contract.ResellerId));

                // check error
                if (result < 1)
                {
                    return(result); // EXIT
                }
                // build invoice number
                Invoice       invoice  = GetCustomerInvoiceInternally(result);
                StoreSettings settings = StorehouseController.GetStoreSettings(contract.ResellerId, StoreSettings.SYSTEM_SETTINGS);
                if (!String.IsNullOrEmpty(settings["InvoiceNumberFormat"]))
                {
                    Hashtable options = new Hashtable();
                    options["ID"]         = result;
                    invoice.InvoiceNumber = StorehouseController.ApplyStringCustomFormat(
                        settings["InvoiceNumberFormat"], options);
                }
                else
                {
                    invoice.InvoiceNumber = result.ToString();
                }
                // update invoice
                InvoiceController.UpdateInvoice(invoice.InvoiceId, invoice.InvoiceNumber, invoice.DueDate,
                                                invoice.Total, invoice.SubTotal, invoice.TaxationId, invoice.TaxAmount, invoice.Currency);
                //

                Hashtable parameters = new Hashtable();

                parameters.Add(SystemTaskParams.PARAM_CONTRACT, contract);
                parameters.Add(SystemTaskParams.PARAM_INVOICE, invoice);
                parameters.Add(SystemTaskParams.PARAM_INVOICE_LINES, invoiceLines);
                parameters.Add(SystemTaskParams.PARAM_EXTRA_ARGS, extraArgs);

                TaskManager.UpdateParams(parameters);
                //
                return(result);
            }
            catch (Exception ex)
            {
                throw ES.TaskManager.WriteError(ex);
            }
            finally
            {
                ES.TaskManager.CompleteTask();
            }
        }
        public static void ExecuteSystemTrigger(string referenceId, string triggerNamespace, TriggerEventArgs eventArgs)
        {
            //
            IDataReader dr = null;

            try
            {
                ES.TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.TASK_EXEC_SYSTEM_TRIGGER);

                List <ITriggerHandler> triggers = new List <ITriggerHandler>();
                dr = EcommerceProvider.GetSystemTrigger(ES.SecurityContext.User.UserId, referenceId, triggerNamespace);
                //
                while (dr.Read())
                {
                    int    ownerId        = Convert.ToInt32(dr["OwnerID"]);
                    string triggerId      = Convert.ToString(dr["TriggerID"]);
                    string triggerHandler = Convert.ToString(dr["TriggerHandler"]);
                    string triggerStatus  = (dr["Status"] == DBNull.Value) ? null : Convert.ToString(dr["Status"]);
                    // Instantiate trigger handler
                    ITriggerHandler trigger = (ITriggerHandler)Activator.CreateInstance(Type.GetType(triggerHandler));
                    //
                    trigger.TriggerId     = triggerId;
                    trigger.OwnerId       = ownerId;
                    trigger.TriggerStatus = triggerStatus;
                    trigger.ReferenceId   = referenceId;
                    //
                    triggers.Add(trigger);
                    //
                }
                dr.Close();
                //
                foreach (ITriggerHandler trigger in triggers)
                {
                    try
                    {
                        trigger.ExecuteTrigger(eventArgs);
                    }
                    catch (Exception ex)
                    {
                        ES.TaskManager.WriteError(ex);
                        continue;
                    }
                    //
                    DeleteSystemTrigger(trigger.TriggerId);
                }
            }
            catch (Exception ex)
            {
                throw ES.TaskManager.WriteError(ex);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                //
                ES.TaskManager.CompleteTask();
            }
        }
Esempio n. 4
0
 public static int UpdateContract(string contractId, int customerId, string accountName,
                                  ContractStatus status, decimal balance, string firstName, string lastName, string email,
                                  string companyName, string propertyNames, string propertyValues)
 {
     return(EcommerceProvider.UpdateContract(contractId, customerId, accountName, (int)status, balance,
                                             firstName, lastName, email, companyName, propertyNames, propertyValues));
 }
Esempio n. 5
0
 public static DataSet GetWholeCategoriesSet(int userId)
 {
     return(EcommerceProvider.GetWholeCategoriesSet(
                ES.SecurityContext.User.UserId,
                userId
                ));
 }
        protected void LogServiceUsage(Service service, int svcCycleId, string billingPeriod, int periodLength)
        {
            // define start date
            DateTime startDate = ServiceController.GetServiceSuspendDate(service.ServiceId);
            //
            DateTime endDate = startDate;

            //
            switch (billingPeriod)
            {
            case "day":
                endDate = startDate.AddDays(periodLength);
                break;

            case "month":
                endDate = endDate.AddMonths(periodLength);
                break;

            case "year":
                endDate = endDate.AddYears(periodLength);
                break;
            }
            // add service usage record
            EcommerceProvider.AddServiceUsageRecord(SecurityContext.User.UserId, service.ServiceId,
                                                    svcCycleId, startDate, endDate);
        }
        public static PaymentMethod GetContractPaymentMethod(string contractId, string methodName)
        {
            Contract contract = ContractSystem.ContractController.GetContract(contractId);

            return(ES.ObjectUtils.FillObjectFromDataReader <PaymentMethod>(
                       EcommerceProvider.GetResellerPaymentMethod(contract.ResellerId, methodName)));
        }
        public static int LogContractPayment(Contract contract, string methodName, string rawData)
        {
            SupportedPlugin plugin = GetResellerPMPlugin(contract.ResellerId, methodName);

            //
            return(EcommerceProvider.WriteSupportedPluginLog(contract.ContractId, plugin.PluginId, 0, rawData));
        }
Esempio n. 9
0
 public static int GetCategoriesCount(int userId, int parentId)
 {
     return(EcommerceProvider.GetCategoriesCount(
                ES.SecurityContext.User.UserId,
                userId,
                parentId
                ));
 }
Esempio n. 10
0
        public int UpdateServiceInfo(Service service)
        {
            HostingPackageSvc packageSvc = (HostingPackageSvc)service;

            //
            return(EcommerceProvider.UpdateHostingPlanSvc(SecurityContext.User.UserId, packageSvc.ServiceId,
                                                          packageSvc.ProductId, packageSvc.ServiceName, (int)packageSvc.Status, packageSvc.PlanId,
                                                          packageSvc.PackageId, (int)packageSvc.UserRole, (int)packageSvc.InitialStatus));
        }
Esempio n. 11
0
        public static void AddSystemTrigger(string referenceId, string triggerStatus, Type triggerType)
        {
            //
            ITriggerHandler trigger = (ITriggerHandler)Activator.CreateInstance(triggerType);

            //
            EcommerceProvider.AddSystemTrigger(ES.SecurityContext.User.UserId, ES.SecurityContext.User.UserId,
                                               triggerType.AssemblyQualifiedName, referenceId, trigger.TriggerNamespace, triggerStatus);
        }
Esempio n. 12
0
        public int UpdateServiceInfo(Service serviceInfo)
        {
            HostingAddonSvc addonSvc = (HostingAddonSvc)serviceInfo;

            //
            return(EcommerceProvider.UpdateHostingAddonSvc(SecurityContext.User.UserId, addonSvc.ServiceId,
                                                           addonSvc.ProductId, addonSvc.ServiceName, (int)addonSvc.Status, addonSvc.PlanId,
                                                           addonSvc.PackageAddonId, addonSvc.Recurring, addonSvc.DummyAddon));
        }
Esempio n. 13
0
 public static Category GetCategory(int userId, int categoryId)
 {
     return(ES.ObjectUtils.FillObjectFromDataReader <Category>(
                EcommerceProvider.GetCategory(
                    ES.SecurityContext.User.UserId,
                    userId,
                    categoryId
                    )
                ));
 }
Esempio n. 14
0
        public int AddServiceInfo(string contractId, string currency, OrderItem orderItem)
        {
            string propertyNames  = null;
            string propertyValues = null;

            // deserialize
            SecurityUtils.SerializeGenericProfile(ref propertyNames, ref propertyValues, orderItem);
            //
            return(EcommerceProvider.AddDomainNameSvc(contractId, orderItem.ParentSvcId,
                                                      orderItem.ProductId, orderItem.ItemName, orderItem.BillingCycle, currency, propertyNames, propertyValues));
        }
Esempio n. 15
0
        protected DomainNameSvc GetDomainNameSvc(int serviceId)
        {
            // assemble svc instance
            DomainNameSvc domainSvc = ObjectUtils.FillObjectFromDataReader <DomainNameSvc>(
                EcommerceProvider.GetDomainNameSvc(SecurityContext.User.UserId, serviceId));

            // deserialize svc properties
            SecurityUtils.DeserializeGenericProfile(domainSvc.PropertyNames, domainSvc.PropertyValues, domainSvc);
            // return result
            return(domainSvc);
        }
Esempio n. 16
0
        public ServiceHistoryRecord[] GetServiceHistory(int serviceId)
        {
            List <ServiceHistoryRecord> history = ObjectUtils.CreateListFromDataReader <ServiceHistoryRecord>(
                EcommerceProvider.GetHostingPackageSvcHistory(SecurityContext.User.UserId, serviceId));

            if (history != null)
            {
                return(history.ToArray());
            }

            return(new ServiceHistoryRecord[] { });
        }
Esempio n. 17
0
        public int AddServiceInfo(string contractId, string currency, OrderItem orderItem)
        {
            // get hosting addon product
            HostingAddon addon = StorehouseController.GetHostingAddon(SecurityContext.User.UserId,
                                                                      orderItem.ProductId);
            // uncountable addons always have 1 for quantity
            int quantity = addon.Countable ? orderItem.Quantity : 1;

            // add hosting addon
            return(EcommerceProvider.AddHostingAddonSvc(contractId, orderItem.ParentSvcId, orderItem.ProductId,
                                                        quantity, orderItem.ItemName, orderItem.BillingCycle, currency));
        }
Esempio n. 18
0
        public static int DeleteCustomerService(int serviceId)
        {
            SecurityResult result = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }
            //
            return(EcommerceProvider.DeleteCustomerService(ES.SecurityContext.User.UserId, serviceId));
        }
Esempio n. 19
0
 public static List <Category> GetCategoriesPaged(int userId, int parentId, int maximumRows, int startRowIndex)
 {
     return(ES.ObjectUtils.CreateListFromDataReader <Category>(
                EcommerceProvider.GetCategoriesPaged(
                    ES.SecurityContext.User.UserId,
                    userId,
                    parentId,
                    maximumRows,
                    startRowIndex
                    )
                ));
 }
        public static int SetPluginProperties(int userId, int pluginId, KeyValueBunch props)
        {
            string xmlText = String.Empty;

            string[][]     pluginProps = null;
            SecurityResult result      = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }
            if (props != null)
            {
                // create system plugin
                SystemPluginBase pluginObj = GetSystemPluginInstance(userId, pluginId, false);
                // crypt sensitive data
                foreach (string keyName in props.GetAllKeys())
                {
                    //
                    string keyValue = props[keyName];
                    //
                    if (pluginObj.SecureSettings != null)
                    {
                        int indexOf = Array.IndexOf(pluginObj.SecureSettings, keyName);
                        // crypt sensitive data
                        if (indexOf > -1)
                        {
                            keyValue = CryptoUtils.Encrypt(keyValue);
                        }
                    }
                    //
                    props[keyName] = keyValue;
                }

                // load old properties
                KeyValueBunch oldProps = GetPluginPropertiesInternal(userId, pluginId,
                                                                     false, pluginObj.SecureSettings);
                // merge old props with new props
                foreach (string keyName in props.GetAllKeys())
                {
                    // copy
                    oldProps[keyName] = props[keyName];
                }
                //
                pluginProps = oldProps.KeyValueArray;
            }
            // build update xml
            xmlText = SettingsHelper.ConvertObjectSettings(pluginProps, "properties", "property");
            //
            return(EcommerceProvider.SetPluginProperties(SecurityContext.User.UserId, userId, pluginId, xmlText));
        }
Esempio n. 21
0
        public static int VoidCustomerInvoice(int invoiceId)
        {
            SecurityResult result = StorehouseController.CheckAccountIsAdminOrReseller();

            if (!result.Success)
            {
                return(result.ResultCode);
            }
            // void
            EcommerceProvider.VoidCustomerInvoice(ES.SecurityContext.User.UserId, invoiceId);
            //
            return(0);
        }
Esempio n. 22
0
        public int UpdateServiceInfo(Service serviceInfo)
        {
            DomainNameSvc domainSvc = (DomainNameSvc)serviceInfo;
            // serialize props & values
            string propertyNames  = null;
            string propertyValues = null;

            SecurityUtils.SerializeGenericProfile(ref propertyNames, ref propertyValues, domainSvc);
            // update svc
            return(EcommerceProvider.UpdateDomainNameSvc(SecurityContext.User.UserId, domainSvc.ServiceId,
                                                         domainSvc.ProductId, (int)domainSvc.Status, domainSvc.DomainId, domainSvc.Fqdn,
                                                         propertyNames, propertyValues));
        }
        internal static SupportedPlugin GetResellerPMPlugin(int resellerId, string methodName)
        {
            SupportedPlugin plugin = ObjectUtils.FillObjectFromDataReader <SupportedPlugin>(
                EcommerceProvider.GetResellerPMPlugin(resellerId, methodName));

            //
            if (plugin == null)
            {
                throw new Exception("RESELLER_PM_PLUGIN_NOT_FOUND");
            }
            //
            return(plugin);
        }
Esempio n. 24
0
        public static Contract GetCustomerContract(int customerId)
        {
            Contract contractInfo = ES.ObjectUtils.FillObjectFromDataReader <Contract>(
                EcommerceProvider.GetCustomerContract(customerId));

            //
            if (contractInfo == null)
            {
                throw new Exception("Could not find customer contract.");
            }
            //
            return(contractInfo);
        }
Esempio n. 25
0
        public static DateTime GetServiceSuspendDate(int serviceId)
        {
            // get service suspend date
            DateTime date = EcommerceProvider.GetServiceSuspendDate(ES.SecurityContext.User.UserId, serviceId);

            // check returned result
            if (date == DateTime.MinValue)
            {
                date = DateTime.UtcNow;
            }

            // return service suspend date
            return(date);
        }
Esempio n. 26
0
        public static int DeleteCategory(int userId, int categoryId)
        {
            SecurityResult result = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }

            return(EcommerceProvider.DeleteCategory(
                       ES.SecurityContext.User.UserId,
                       userId,
                       categoryId
                       ));
        }
Esempio n. 27
0
        public static int AddCategory(int userId, string categoryName, string categorySku, int parentId, string shortDescription, string fullDescription)
        {
            SecurityResult result = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }
            //
            return(EcommerceProvider.AddCategory(
                       ES.SecurityContext.User.UserId,
                       userId,
                       categoryName,
                       categorySku,
                       parentId,
                       shortDescription,
                       fullDescription
                       ));
        }
        internal static KeyValueBunch GetPluginPropertiesInternal(int userId, int pluginId, bool skipSensitive,
                                                                  string[] secureSettings)
        {
            // load plugin settings
            KeyValueBunch properties = SettingsHelper.FillProperties(EcommerceProvider.GetPluginProperties(
                                                                         SecurityContext.User.UserId, userId, pluginId));

            // cleanup plugin settings
            if (skipSensitive && secureSettings != null)
            {
                // iterate through secure settings
                foreach (string keyName in secureSettings)
                {
                    // remove secure setting
                    properties.RemoveKey(keyName);
                }
            }
            // return plugin settings
            return(properties);
        }
 public static SupportedPlugin GetSupportedPluginById(int pluginId)
 {
     return(ObjectUtils.FillObjectFromDataReader <SupportedPlugin>(
                EcommerceProvider.GetSupportedPluginById(pluginId)));
 }
 public static SupportedPlugin GetSupportedPlugin(string pluginName, string groupName)
 {
     return(ObjectUtils.FillObjectFromDataReader <SupportedPlugin>(
                EcommerceProvider.GetSupportedPlugin(pluginName, groupName)));
 }