コード例 #1
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));
        }
コード例 #2
0
        protected InvoiceItem GetAddonSvcSetupFee(HostingAddonSvc service)
        {
            InvoiceItem line = new InvoiceItem();

            line.ItemName  = service.ServiceName;
            line.Quantity  = service.Quantity;
            line.UnitPrice = service.SetupFee;
            line.TypeName  = "Setup Fee";

            return(line);
        }
コード例 #3
0
        public void LogServiceUsage(ProvisioningContext context)
        {
            // concretize service to be logged
            HostingAddonSvc addonSvc = (HostingAddonSvc)context.ServiceInfo;

            // addon is recurring
            if (addonSvc.Recurring)
            {
                // log service usage
                base.LogServiceUsage(context.ServiceInfo, addonSvc.SvcCycleId,
                                     addonSvc.BillingPeriod, addonSvc.PeriodLength);
            }
        }
コード例 #4
0
        public InvoiceItem[] CalculateInvoiceLines(int serviceId)
        {
            List <InvoiceItem> lines = new List <InvoiceItem>();
            //
            HostingAddonSvc addonSvc = GetHostingAddonSvc(serviceId);

            // addon svc fee
            lines.Add(GetAddonSvcFee(addonSvc));
            // addon svc setup fee
            if (addonSvc.SetupFee > 0M && addonSvc.Status == ServiceStatus.Ordered)
            {
                lines.Add(GetAddonSvcSetupFee(addonSvc));
            }
            //
            return(lines.ToArray());
        }
コード例 #5
0
		protected InvoiceItem GetAddonSvcFee(HostingAddonSvc service)
		{
			InvoiceItem line = new InvoiceItem();

			line.ItemName = service.ServiceName;
			line.ServiceId = service.ServiceId;
			line.Quantity = service.Quantity;
			line.UnitPrice = service.CyclePrice;

			if (service.Recurring && service.Status != ServiceStatus.Ordered)
				line.TypeName = "Recurring Fee";
			else
				line.TypeName = Product.HOSTING_ADDON_NAME;
			
			return line;
		}
コード例 #6
0
        protected InvoiceItem GetAddonSvcFee(HostingAddonSvc service)
        {
            InvoiceItem line = new InvoiceItem();

            line.ItemName  = service.ServiceName;
            line.ServiceId = service.ServiceId;
            line.Quantity  = service.Quantity;
            line.UnitPrice = service.CyclePrice;

            if (service.Recurring && service.Status != ServiceStatus.Ordered)
            {
                line.TypeName = "Recurring Fee";
            }
            else
            {
                line.TypeName = Product.HOSTING_ADDON_NAME;
            }

            return(line);
        }
コード例 #7
0
        protected void RollbackOperation(int packageAddonId)
        {
            // check input parameters first
            if (packageAddonId < 1)
            {
                return;                 // exit
            }
            //
            try
            {
                TaskManager.Write(START_ROLLBACK_MSG);
                // restore service
                HostingAddonSvc  addonSvc  = (HostingAddonSvc)RestoreObjectState(SERVICE_INFO);
                PackageAddonInfo addonInfo = PackageController.GetPackageAddon(addonSvc.PackageAddonId);
                //
                int apiResult = 0;

                // during rollback addon should be reverted to its original state
                // compensation logic - revert back addon status
                switch (addonSvc.Status)
                {
                // Active State
                case ServiceStatus.Active:
                    addonInfo.StatusId = (int)PackageStatus.Active;
                    apiResult          = PackageController.UpdatePackageAddon(addonInfo).Result;
                    break;

                // Suspended State
                case ServiceStatus.Suspended:
                    addonInfo.StatusId = (int)PackageStatus.Suspended;
                    apiResult          = PackageController.UpdatePackageAddon(addonInfo).Result;
                    break;

                // Cancelled State
                case ServiceStatus.Cancelled:
                    addonInfo.StatusId = (int)PackageStatus.Cancelled;
                    apiResult          = PackageController.UpdatePackageAddon(addonInfo).Result;
                    break;

                // service has been just ordered & during rollback should be removed
                case ServiceStatus.Ordered:
                    // compensation logic - remove created package
                    apiResult = PackageController.DeletePackageAddon(packageAddonId);
                    break;
                }
                // check WebsitePanel API result
                if (apiResult < 0)
                {
                    //
                    if (addonSvc.Status == ServiceStatus.Ordered)
                    {
                        TaskManager.WriteError(ERROR_ROLLBACK_ORDER_MSG);
                    }
                    else
                    {
                        TaskManager.WriteError(ERROR_ROLLBACK_MSG);
                    }
                    //
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, apiResult);
                }

                // rollback service changes in EC metabase
                apiResult = UpdateServiceInfo(addonSvc);
                // check API result
                if (apiResult < 0)
                {
                    // LOG ERROR
                    TaskManager.WriteError(ERROR_ROLLBACK_SVC_MSG);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, apiResult);

                    //
                    return;
                }

                //
                TaskManager.Write(ROLLBACK_SUCCEED_MSG);
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex);
            }
        }
コード例 #8
0
        public GenericSvcResult CancelService(ProvisioningContext context)
        {
            GenericSvcResult result = new GenericSvcResult();

            //
            SaveObjectState(SERVICE_INFO, context.ServiceInfo);
            // concretize service to be provisioned
            HostingAddonSvc addonSvc = (HostingAddonSvc)context.ServiceInfo;

            //
            try
            {
                //
                TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.SVC_CANCEL);
                // LOG INFO
                TaskManager.Write(START_CANCELLATION_MSG);
                TaskManager.WriteParameter(CONTRACT_PARAM, addonSvc.ContractId);
                TaskManager.WriteParameter(SVC_PARAM, addonSvc.ServiceName);
                TaskManager.WriteParameter(SVC_ID_PARAM, addonSvc.ServiceId);

                // 0. Do security checks
                if (!CheckOperationClientPermissions(result))
                {
                    // LOG ERROR
                    TaskManager.WriteError(ERROR_CLIENT_OPERATION_PERMISSIONS);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);
                    // EXIT
                    return(result);
                }
                //
                if (!CheckOperationClientStatus(result))
                {
                    // LOG ERROR
                    TaskManager.WriteError(ERROR_CLIENT_OPERATION_STATUS);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);
                    // EXIT
                    return(result);
                }

                // dummy addon should be just updated in metabase
                if (addonSvc.DummyAddon)
                {
                    goto UpdateSvcMetaInfo;
                }

                PackageAddonInfo addonInfo = PackageController.GetPackageAddon(addonSvc.PackageAddonId);
                addonInfo.StatusId = (int)PackageStatus.Cancelled;
                // cancel hosting addon
                int apiResult = PackageController.UpdatePackageAddon(addonInfo).Result;

                // check WebsitePanel API result
                if (apiResult < 0)
                {
                    result.ResultCode = apiResult;
                    //
                    result.Succeed = false;

                    // LOG ERROR
                    TaskManager.WriteError(ERROR_CANCEL_ADDON_MSG);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                    // exit
                    return(result);
                }

UpdateSvcMetaInfo:
                // change addon status to Cancelled
                addonSvc.Status = ServiceStatus.Cancelled;
                // put data into metabase
                int svcResult = UpdateServiceInfo(addonSvc);
                //
                if (svcResult < 0)
                {
                    result.ResultCode = svcResult;
                    //
                    result.Succeed = false;

                    // LOG ERROR
                    TaskManager.WriteError(ERROR_SVC_UPDATE_MSG);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                    // ROLLBACK CHANGES
                    RollbackOperation(addonSvc.PackageAddonId);

                    // EXIT
                    return(result);
                }
                //
                SetOutboundParameters(context);
                // LOG INFO
                TaskManager.Write(ADDON_PROVISIONED_MSG);
                //
                result.Succeed = true;
            }
            catch (Exception ex)
            {
                //
                TaskManager.WriteError(ex);

                // ROLLBACK CHANGES
                RollbackOperation(addonSvc.PackageAddonId);

                //
                result.Succeed = false;
                //
                result.Error = ex.Message;
            }
            finally
            {
                // complete task
                TaskManager.CompleteTask();
            }

            //
            return(result);
        }
コード例 #9
0
        public GenericSvcResult ActivateService(ProvisioningContext context)
        {
            GenericSvcResult result = new GenericSvcResult();

            // remeber svc state
            SaveObjectState(SERVICE_INFO, context.ServiceInfo);

            // concretize service to be provisioned
            HostingAddonSvc addonSvc = (HostingAddonSvc)context.ServiceInfo;
            // concretize parent svc
            HostingPackageSvc packageSvc = (HostingPackageSvc)context.ParentSvcInfo;

            //
            try
            {
                //
                TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.SVC_ACTIVATE);

                // LOG INFO
                TaskManager.Write(START_ACTIVATION_MSG);
                TaskManager.WriteParameter(CONTRACT_PARAM, addonSvc.ContractId);
                TaskManager.WriteParameter(SVC_PARAM, addonSvc.ServiceName);
                TaskManager.WriteParameter(SVC_ID_PARAM, addonSvc.ServiceId);

                // 0. Do security checks
                if (!CheckOperationClientPermissions(result))
                {
                    // LOG ERROR
                    TaskManager.WriteError(ERROR_CLIENT_OPERATION_PERMISSIONS);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);
                    // EXIT
                    return(result);
                }
                //
                if (!CheckOperationClientStatus(result))
                {
                    // LOG ERROR
                    TaskManager.WriteError(ERROR_CLIENT_OPERATION_STATUS);
                    TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);
                    // EXIT
                    return(result);
                }

                // dummy addon should be just updated in metabase
                if (addonSvc.DummyAddon)
                {
                    goto UpdateSvcMetaInfo;
                }

                if (addonSvc.Status == ServiceStatus.Ordered)
                {
                    // error: hosting addon should have parent svc assigned
                    if (packageSvc == null || packageSvc.PackageId == 0)
                    {
                        result.Succeed = false;
                        //
                        result.Error = PARENT_SVC_NOT_FOUND_MSG;
                        //
                        result.ResultCode = EcommerceErrorCodes.ERROR_PARENT_SVC_NOT_FOUND;

                        // LOG ERROR
                        TaskManager.WriteError(result.Error);
                        TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                        // EXIT
                        return(result);
                    }

                    // fill package add-on fields
                    PackageAddonInfo addon = new PackageAddonInfo();
                    //
                    addon.PackageId = packageSvc.PackageId;
                    //
                    addon.PlanId = addonSvc.PlanId;
                    // set addon quantity
                    addon.Quantity = addonSvc.Quantity;
                    //
                    addon.StatusId = (int)PackageStatus.Active;
                    //
                    addon.PurchaseDate = DateTime.Now;

                    // Create hosting addon through WebsitePanel API
                    PackageResult apiResult = PackageController.AddPackageAddon(addon);
                    // Failed to create addon
                    if (apiResult.Result < 1)
                    {
                        result.Succeed = false;
                        //
                        result.ResultCode = apiResult.Result;

                        // LOG ERROR
                        TaskManager.WriteError(ERROR_CREATE_ADDON_MSG);
                        TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                        // EXIT
                        return(result);
                    }
                    // store package id
                    addonSvc.PackageAddonId = apiResult.Result;
                }
                else
                {
                    // load package addon
                    PackageAddonInfo addonInfo = PackageController.GetPackageAddon(addonSvc.PackageAddonId);
                    // package addon not found
                    if (addonInfo == null)
                    {
                        result.Succeed = false;
                        //
                        result.ResultCode = EcommerceErrorCodes.ERROR_PCKG_ADDON_NOT_FOUND;
                        //
                        result.Error = ADDON_NOT_FOUND_MSG;

                        // LOG ERROR
                        TaskManager.WriteError(result.Error);
                        TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                        // EXIT
                        return(result);
                    }

                    // workaround for bug in GetPackageAddon routine
                    //addonInfo.PackageAddonId = addonSvc.PackageAddonId;
                    // change package add-on status
                    addonInfo.StatusId = (int)PackageStatus.Active;

                    // save hosting addon changes
                    PackageResult apiResult = PackageController.UpdatePackageAddon(addonInfo);
                    // check returned result
                    if (apiResult.Result < 0)
                    {
                        result.Succeed = false;
                        //
                        result.ResultCode = apiResult.Result;

                        // LOG ERROR
                        TaskManager.WriteError(ERROR_ACTIVATE_ADDON_MSG);
                        TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                        // EXIT
                        return(result);
                    }
                }

UpdateSvcMetaInfo:
                // update status only if necessary
                if (addonSvc.Status != ServiceStatus.Active)
                {
                    // change service status to active
                    addonSvc.Status = ServiceStatus.Active;
                    // put data into metabase
                    int svcResult = UpdateServiceInfo(addonSvc);
                    // failed to update metabase
                    if (svcResult < 0)
                    {
                        result.ResultCode = svcResult;
                        //
                        result.Succeed = false;
                        //
                        result.Error = ERROR_SVC_UPDATE_MSG;

                        // LOG ERROR
                        TaskManager.WriteError(result.Error);
                        TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode);

                        // ROLLBACK CHANGES
                        RollbackOperation(addonSvc.PackageAddonId);

                        // EXIT
                        return(result);
                    }
                }
                //
                SetOutboundParameters(context);
                // LOG INFO
                TaskManager.Write(ADDON_PROVISIONED_MSG);
                //
                result.Succeed = true;
            }
            catch (Exception ex)
            {
                //
                TaskManager.WriteError(ex);

                // ROLLBACK CHANGES
                RollbackOperation(addonSvc.PackageAddonId);

                //
                result.Succeed = false;
                //
                result.Error = ex.Message;
            }
            finally
            {
                // complete task
                TaskManager.CompleteTask();
            }

            //
            return(result);
        }
コード例 #10
0
		protected InvoiceItem GetAddonSvcSetupFee(HostingAddonSvc service)
		{
			InvoiceItem line = new InvoiceItem();

			line.ItemName = service.ServiceName;
			line.Quantity = service.Quantity;
			line.UnitPrice = service.SetupFee;
			line.TypeName = "Setup Fee";

			return line;
		}