示例#1
0
        public static StringArrayResultObject GetCollationNames(int packageId)
        {
            StringArrayResultObject ret = StartTask <StringArrayResultObject>("CRM", "GET_COLLATION_NAMES");

            ret.IsSuccess = true;

            try
            {
                int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedCRM);
                if (serviceId == 0)
                {
                    CompleteTask(ret, CrmErrorCodes.CRM_IS_NOT_SELECTED_IN_HOSTING_PLAN);
                    return(ret);
                }

                CRM crm = new CRM();
                ServiceProviderProxy.Init(crm, serviceId);
                ret.Value = crm.GetSupportedCollationNames();
            }
            catch (Exception ex)
            {
                CompleteTask(ret, CrmErrorCodes.CANNOT_GET_COLLATION_NAMES, ex);
                return(ret);
            }

            CompleteTask();
            return(ret);
        }
        private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB

        private static DatabaseServer GetDatabaseServer(int serviceId)
        {
            DatabaseServer db = new DatabaseServer();

            ServiceProviderProxy.Init(db, serviceId);
            return(db);
        }
示例#3
0
        public ServiceProviderItemBandwidth[] CalculateItems(int serviceId, List<ServiceProviderItem> items,
            DateTime since)
        {
            // convert items to SoapObjects
            List<SoapServiceProviderItem> objItems = new List<SoapServiceProviderItem>();
            foreach (ServiceProviderItem item in items)
                objItems.Add(SoapServiceProviderItem.Wrap(item));

            int attempt = 0;
            int ATTEMPTS = 3;
            while (attempt < ATTEMPTS)
            {
                // increment attempt
                attempt++;

                try
                {
                    // send packet for calculation
                    // invoke service provider
                    //TaskManager.Write(String.Format("{0} - Invoke GetServiceItemsDiskSpace method ('{1}' items) - {2} attempt",
                    //    DateTime.Now, objItems.Count, attempt));

                    ServiceProvider prov = new ServiceProvider();
                    ServiceProviderProxy.Init(prov, serviceId);
                    return prov.GetServiceItemsBandwidth(objItems.ToArray(), since);
                }
                catch (Exception ex)
                {
                    TaskManager.WriteError(ex.ToString());
                }
            }

            throw new Exception("The number of attemtps has been reached. The package calculation has been aborted.");
        }
示例#4
0
        public static void SwithEnginesEnabled(int serviceId, bool enabled)
        {
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            zooServer.SwithEnginesEnabled(enabled);
        }
示例#5
0
        public static FTPServer GetFTPServer(int serviceId)
        {
            FTPServer ftp = new FTPServer();

            ServiceProviderProxy.Init(ftp, serviceId);
            return(ftp);
        }
示例#6
0
        public static FtpSite[] GetFtpSites(int serviceId)
        {
            FTPServer ftp = new FTPServer();

            ServiceProviderProxy.Init(ftp, serviceId);
            return(ftp.GetSites());
        }
示例#7
0
        public static bool IsEnginesEnabled(int serviceId)
        {
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            return(zooServer.IsEnginesEnabled());
        }
示例#8
0
        public static HeliconZooEngine[] GetEngines(int serviceId)
        {
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            return(zooServer.GetEngines());
        }
示例#9
0
        public static void SetWebCosoleEnabled(int serviceId, bool enabled)
        {
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            zooServer.SetWebCosoleEnabled(enabled);
        }
示例#10
0
        public static bool RemoteServerFolderWriteAccessible(int packageId, string path)
        {
            try
            {
                // copy to space folder
                int osServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
                if (osServiceId > 0)
                {
                    OS.OperatingSystem os = new OS.OperatingSystem();
                    ServiceProviderProxy.Init(os, osServiceId);

                    string remoteServerPathCheck = FilesController.GetFullPackagePath(packageId,
                                                                                      Path.Combine(path, "check.txt"));

                    //
                    os.CreateFile(remoteServerPathCheck);
                    os.AppendFileBinaryContent(remoteServerPathCheck, Encoding.UTF8.GetBytes(remoteServerPathCheck));
                    os.DeleteFile(remoteServerPathCheck);
                }
                //
                return(true);
            }
            catch
            {                           //
                return(false);
            }
        }
示例#11
0
        private static DNSServer GetDNSServer(int serviceId)
        {
            DNSServer dns = new DNSServer();

            ServiceProviderProxy.Init(dns, serviceId);
            return(dns);
        }
示例#12
0
        public static CurrencyArrayResultObject GetCurrency(int packageId)
        {
            CurrencyArrayResultObject ret = StartTask <CurrencyArrayResultObject>("CRM", "GET_CURRENCY");

            ret.IsSuccess = true;
            try
            {
                int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedCRM);
                if (serviceId == 0)
                {
                    CompleteTask(ret, CrmErrorCodes.CRM_IS_NOT_SELECTED_IN_HOSTING_PLAN, null, "CRM is not selected in hosting plan.");
                    return(ret);
                }

                CRM crm = new CRM();
                ServiceProviderProxy.Init(crm, serviceId);
                ret.Value = crm.GetCurrencyList();
            }
            catch (Exception ex)
            {
                CompleteTask(ret, CrmErrorCodes.CANNOT_GET_CURRENCY_LIST, ex);
                return(ret);
            }
            CompleteTask();

            return(ret);
        }
        public static ExchangeServerHostedEdition GetExchangeService(int serviceId)
        {
            ExchangeServerHostedEdition ws = new ExchangeServerHostedEdition();

            ServiceProviderProxy.Init(ws, serviceId);
            return(ws);
        }
        public static StatisticsServer GetStatisticsServer(int serviceId)
        {
            StatisticsServer stats = new StatisticsServer();

            ServiceProviderProxy.Init(stats, serviceId);
            return(stats);
        }
        private static WindowsServer GetServerService(int serverId)
        {
            WindowsServer winServer = new WindowsServer();

            ServiceProviderProxy.ServerInit(winServer, serverId);
            return(winServer);
        }
        public void ImportItem(int packageId, int itemTypeId, Type itemType,
                               ResourceGroupInfo group, string itemName)
        {
            // get service id
            int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);

            if (serviceId == 0)
            {
                return;
            }

            StatisticsServer stats = new StatisticsServer();

            ServiceProviderProxy.Init(stats, serviceId);

            if (itemType == typeof(StatsSite))
            {
                // import statistics site
                StatsSite site = new StatsSite();
                site.ServiceId = serviceId;
                site.PackageId = packageId;
                site.Name      = itemName;
                site.GroupName = group.GroupName;

                // load site id
                site.SiteId = stats.GetSiteId(itemName);

                PackageController.AddPackageItem(site);
            }
        }
示例#17
0
        private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB

        private static SharePointServer GetSharePoint(int serviceId)
        {
            SharePointServer sps = new SharePointServer();

            ServiceProviderProxy.Init(sps, serviceId);
            return(sps);
        }
示例#18
0
        public List <string> GetImportableItems(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group)
        {
            List <string> items = new List <string>();

            // get service id
            int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);

            if (serviceId == 0)
            {
                return(items);
            }

            // FTP provider
            FTPServer ftp = new FTPServer();

            ServiceProviderProxy.Init(ftp, serviceId);

            FtpAccount[] accounts = ftp.GetAccounts();

            foreach (FtpAccount account in accounts)
            {
                items.Add(account.Name);
            }

            return(items);
        }
示例#19
0
        public List <string> GetImportableItems(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group)
        {
            List <string> items = new List <string>();

            // get service id
            int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);

            if (serviceId == 0)
            {
                return(items);
            }

            // Mail provider
            DNSServer dns = new DNSServer();

            ServiceProviderProxy.Init(dns, serviceId);

            // IDN: The list of importable names is populated with unicode names, to make it easier for the user
            var idn = new IdnMapping();

            if (itemType == typeof(DnsZone))
            {
                items.AddRange(dns.GetZones());
            }

            return(items);
        }
示例#20
0
        public void ImportItem(int packageId, int itemTypeId,
                               Type itemType, ResourceGroupInfo group, string itemName)
        {
            // get service id
            int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);

            if (serviceId == 0)
            {
                return;
            }

            // FTP provider
            FTPServer ftp = new FTPServer();

            ServiceProviderProxy.Init(ftp, serviceId);

            if (itemType == typeof(FtpAccount))
            {
                // load FTP account
                FtpAccount account = ftp.GetAccount(itemName);
                account.Folder = FilesController.GetFullPackagePath(packageId, "\\");     // root space folder

                // update FTP account
                ftp.UpdateAccount(account);

                // save account
                account.ServiceId = serviceId;
                account.PackageId = packageId;
                PackageController.AddPackageItem(account);
            }
        }
        public static RemoteDesktopServices GetRemoteDesktopServices(int serviceId)
        {
            var rds = new RemoteDesktopServices();

            ServiceProviderProxy.Init(rds, serviceId);

            return(rds);
        }
示例#22
0
        private static CRM GetCRMProxy(int packageId)
        {
            int crmServiceId = GetCRMServiceId(packageId);
            CRM ws           = new CRM();

            ServiceProviderProxy.Init(ws, crmServiceId);
            return(ws);
        }
示例#23
0
        public static StorageSpaceServices GetStorageSpaceService(int serviceId)
        {
            var ss = new StorageSpaceServices();

            ServiceProviderProxy.Init(ss, serviceId);

            return(ss);
        }
示例#24
0
        public static CrmUserResult GetCrmUser(int itemId, int accountId)
        {
            CrmUserResult res = StartTask <CrmUserResult>("CRM", "GET_CRM_USER");

            try
            {
                Guid crmUserId = GetCrmUserId(accountId);

                Organization org;

                try
                {
                    org = OrganizationController.GetOrganization(itemId);
                }
                catch (Exception ex)
                {
                    CompleteTask(res, ErrorCodes.CANNOT_GET_ORGANIZATION_BY_ITEM_ID, ex);
                    return(res);
                }


                int serviceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.HostedCRM);
                if (serviceId == 0)
                {
                    CompleteTask(res, CrmErrorCodes.CRM_IS_NOT_SELECTED_IN_HOSTING_PLAN, null,
                                 "CRM is not selected in hosting plan.");
                    return(res);
                }

                try
                {
                    CRM crm = new CRM();
                    ServiceProviderProxy.Init(crm, serviceId);
                    CrmUserResult user = crm.GetCrmUserById(crmUserId, org.OrganizationId);
                    res.ErrorCodes.AddRange(user.ErrorCodes);
                    if (!user.IsSuccess)
                    {
                        CompleteTask(res);
                        return(res);
                    }
                    res.Value = user.Value;
                }
                catch (Exception ex)
                {
                    CompleteTask(res, CrmErrorCodes.CANONT_GET_CRM_USER_BY_ID, ex);
                    return(res);
                }
            }
            catch (Exception ex)
            {
                CompleteTask(res, CrmErrorCodes.CANONT_GET_CRM_USER_GENERAL_ERROR, ex);
                return(res);
            }
            CompleteTask();
            return(res);
        }
示例#25
0
        public static void SetEnabledEnginesForSite(string siteId, int packageId, string[] engines)
        {
            int serviceId = GetHeliconZooServiceIdByPackageId(packageId);

            // tell Server to enable engines for site
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            zooServer.SetEnabledEnginesForSite(siteId, engines);
        }
示例#26
0
        public static void SetEngines(int serviceId, HeliconZooEngine[] userEngines)
        {
            // update applicationHost.config
            HeliconZoo zooServer = new HeliconZoo();

            ServiceProviderProxy.Init(zooServer, serviceId);
            zooServer.SetEngines(userEngines);

            // update Helicon Zoo quotas in Quotas table
            UpdateQuotas(serviceId, userEngines);
        }
示例#27
0
        public static int UpdateSite(StatsSite item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);

            if (accountCheck < 0)
            {
                return(accountCheck);
            }

            // load original meta item
            StatsSite origItem = (StatsSite)PackageController.GetPackageItem(item.Id);

            if (origItem == null)
            {
                return(BusinessErrorCodes.ERROR_STATS_PACKAGE_ITEM_NOT_FOUND);
            }

            // check package
            int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive);

            if (packageCheck < 0)
            {
                return(packageCheck);
            }

            // update statistics site
            item.Name   = origItem.Name;
            item.SiteId = origItem.SiteId;

            // place log record
            TaskManager.StartTask("STATS_SITE", "UPDATE", origItem.Name);
            TaskManager.ItemId = origItem.Id;

            try
            {
                StatisticsServer stats = new StatisticsServer();
                ServiceProviderProxy.Init(stats, origItem.ServiceId);
                stats.UpdateSite(item);

                // update service item
                PackageController.UpdatePackageItem(item);

                return(0);
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
示例#28
0
        public static ResultObject ChangeUserState(int itemId, int accountId, bool disable)
        {
            CrmRolesResult res = StartTask <CrmRolesResult>("CRM", "CHANGER_USER_STATE");

            Organization org;

            try
            {
                try
                {
                    org = OrganizationController.GetOrganization(itemId);
                    if (org == null)
                    {
                        throw new ApplicationException("Org is null.");
                    }
                }
                catch (Exception ex)
                {
                    CompleteTask(res, ErrorCodes.CANNOT_GET_ORGANIZATION_BY_ITEM_ID, ex);
                    return(res);
                }

                int serviceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.HostedCRM);
                if (serviceId == 0)
                {
                    CompleteTask(res, CrmErrorCodes.CRM_IS_NOT_SELECTED_IN_HOSTING_PLAN, null,
                                 "CRM is not selected in hosting plan.");
                    return(res);
                }

                CRM crm = new CRM();
                ServiceProviderProxy.Init(crm, serviceId);

                Guid crmUserId = GetCrmUserId(accountId);

                ResultObject changeStateRes = crm.ChangeUserState(disable, org.OrganizationId, crmUserId);

                if (!changeStateRes.IsSuccess)
                {
                    res.IsSuccess = false;
                }

                res.ErrorCodes.AddRange(changeStateRes.ErrorCodes);
            }
            catch (Exception ex)
            {
                CompleteTask(res, CrmErrorCodes.CANNOT_CHANGE_USER_STATE_GENERAL_ERROR, ex);
                return(res);
            }

            CompleteTask();
            return(res);
        }
示例#29
0
        public static ResultObject SetUserRoles(int itemId, int accountId, int packageId, Guid[] roles)
        {
            CrmRolesResult res = StartTask <CrmRolesResult>("CRM", "GET_CRM_ROLES");

            try
            {
                int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedCRM);
                if (serviceId == 0)
                {
                    CompleteTask(res, CrmErrorCodes.CRM_IS_NOT_SELECTED_IN_HOSTING_PLAN, null,
                                 "CRM is not selected in hosting plan.");
                    return(res);
                }

                CRM crm = new CRM();
                ServiceProviderProxy.Init(crm, serviceId);

                Organization org;

                try
                {
                    org = OrganizationController.GetOrganization(itemId);
                    if (org == null)
                    {
                        throw new ApplicationException("Org is null.");
                    }
                }
                catch (Exception ex)
                {
                    CompleteTask(res, ErrorCodes.CANNOT_GET_ORGANIZATION_BY_ITEM_ID, ex);
                    return(res);
                }

                Guid crmUserId = GetCrmUserId(accountId);

                ResultObject rolesRes = crm.SetUserRoles(org.OrganizationId, crmUserId, roles);
                res.ErrorCodes.AddRange(rolesRes.ErrorCodes);
                if (!rolesRes.IsSuccess)
                {
                    CompleteTask(res);
                    return(res);
                }
            }
            catch (Exception ex)
            {
                CompleteTask(res, CrmErrorCodes.CANNOT_SET_CRM_USER_ROLES_GENERAL_ERROR, ex);
                return(res);
            }
            CompleteTask();
            return(res);
        }
示例#30
0
        public static OS.OperatingSystem GetOS(int packageId)
        {
            int sid = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);

            if (sid <= 0)
            {
                return(null);
            }

            OS.OperatingSystem os = new OS.OperatingSystem();
            ServiceProviderProxy.Init(os, sid);

            return(os);
        }