private static HostedSharePointServer GetHostedSharePointServer(int serviceId) { HostedSharePointServer sps = new HostedSharePointServer(); ServiceProviderProxy.Init(sps, serviceId); return(sps); }
/// <summary> /// Checks for the application update /// </summary> /// <param name="fileName">File name</param> /// <returns>true if update is available for download; otherwise false</returns> internal bool CheckForUpdate(out string fileName) { bool ret = false; fileName = string.Empty; Log.WriteStart("Checking for a new version"); // var webService = ServiceProviderProxy.GetInstallerWebService(); DataSet ds = webService.GetLatestComponentUpdate("cfg core"); // Log.WriteEnd("Checked for a new version"); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; Version currentVersion = GetType().Assembly.GetName().Version; Version newVersion = null; try { newVersion = new Version(row["Version"].ToString()); } catch (FormatException e) { Log.WriteError("Version error", e); return(false); } if (newVersion > currentVersion) { ret = true; fileName = row["UpgradeFilePath"].ToString(); Log.WriteInfo(string.Format("Version {0} is available for download", newVersion)); } } return(ret); }
public static VirtualizationServerProxmox GetVirtualizationProxy(int serviceId) { VirtualizationServerProxmox ws = new VirtualizationServerProxmox(); ServiceProviderProxy.Init(ws, serviceId); return(ws); }
private static OCSEdgeServer[] GetEdgeServers(string edgeServices) { List <OCSEdgeServer> list = new List <OCSEdgeServer>(); if (!string.IsNullOrEmpty(edgeServices)) { string[] services = edgeServices.Split(';'); foreach (string current in services) { string[] data = current.Split(','); try { int serviceId = int.Parse(data[1]); OCSEdgeServer ocs = new OCSEdgeServer(); ServiceProviderProxy.Init(ocs, serviceId); list.Add(ocs); } catch (Exception ex) { TaskManager.WriteError(ex); } } } return(list.ToArray()); }
/// <summary> /// Loads list of available components via web service /// </summary> private void LoadComponents() { try { Log.WriteStart("Loading list of available components"); lblDescription.Text = string.Empty; //load components via web service var webService = ServiceProviderProxy.GetInstallerWebService(); DataSet dsComponents = webService.GetAvailableComponents(); //remove already installed components foreach (DataRow row in dsComponents.Tables[0].Rows) { string componentCode = Utils.GetDbString(row["ComponentCode"]); if (CheckForInstalledComponent(componentCode)) { row.Delete(); } } dsComponents.AcceptChanges(); Log.WriteEnd("Available components loaded"); SetGridDataSource(dsComponents, dsComponents.Tables[0].TableName); AppContext.AppForm.FinishProgress(); } catch (Exception ex) { Log.WriteError("Web service error", ex); AppContext.AppForm.FinishProgress(); AppContext.AppForm.ShowServerError(); } }
private static CRM GetCRMProxy(int packageId) { int crmServiceId = GetCRMServiceId(packageId); CRM ws = new CRM(); ServiceProviderProxy.Init(ws, crmServiceId); return(ws); }
/// <summary> /// Runs application updater /// </summary> /// <param name="fileName">File name</param> /// <returns>true if updater started successfully</returns> internal bool StartUpdateProcess(string fileName) { Log.WriteStart("Starting updater"); string tmpFile = Path.ChangeExtension(Path.GetTempFileName(), ".exe"); using (Stream writeStream = File.Create(tmpFile)) { using (Stream readStream = typeof(Program).Assembly.GetManifestResourceStream("WebsitePanel.Installer.Updater.exe")) { byte[] buffer = new byte[(int)readStream.Length]; readStream.Read(buffer, 0, buffer.Length); writeStream.Write(buffer, 0, buffer.Length); } } string targetFile = GetType().Module.FullyQualifiedName; // var webService = ServiceProviderProxy.GetInstallerWebService(); string url = webService.Url; // string proxyServer = string.Empty; string user = string.Empty; string password = string.Empty; // check if we need to add a proxy to access Internet bool useProxy = AppConfigManager.AppConfiguration.GetBooleanSetting(ConfigKeys.Web_Proxy_UseProxy); if (useProxy) { proxyServer = AppConfigManager.AppConfiguration.Settings[ConfigKeys.Web_Proxy_Address].Value; user = AppConfigManager.AppConfiguration.Settings[ConfigKeys.Web_Proxy_UserName].Value; password = AppConfigManager.AppConfiguration.Settings[ConfigKeys.Web_Proxy_Password].Value; } ProcessStartInfo info = new ProcessStartInfo(); info.FileName = tmpFile; //prepare command line args StringBuilder sb = new StringBuilder(); sb.AppendFormat("\\url:\"{0}\" ", url); sb.AppendFormat("\\target:\"{0}\" ", targetFile); sb.AppendFormat("\\file:\"{0}\" ", fileName); sb.AppendFormat("\\proxy:\"{0}\" ", proxyServer); sb.AppendFormat("\\user:\"{0}\" ", user); sb.AppendFormat("\\password:\"{0}\" ", password); info.Arguments = sb.ToString(); Process process = Process.Start(info); if (process.Handle != IntPtr.Zero) { User32.SetForegroundWindow(process.Handle); } Log.WriteEnd("Updater started"); return(process.Handle != IntPtr.Zero); }
/// <summary> /// Checks for component update /// </summary> private void CheckForUpdate() { Log.WriteStart("Checking for component update"); ComponentConfigElement element = AppContext.ScopeNode.Tag as ComponentConfigElement; string componentName = element.GetStringSetting("ComponentName"); string componentCode = element.GetStringSetting("ComponentCode"); string release = element.GetStringSetting("Release"); // call web service DataSet ds; try { Log.WriteInfo(string.Format("Checking {0} {1}", componentName, release)); // var webService = ServiceProviderProxy.GetInstallerWebService(); ds = webService.GetComponentUpdate(componentCode, release); // Log.WriteEnd("Component update checked"); AppContext.AppForm.FinishProgress(); } catch (Exception ex) { Log.WriteError("Service error", ex); AppContext.AppForm.FinishProgress(); AppContext.AppForm.ShowServerError(); return; } string appName = AppContext.AppForm.Text; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; string newVersion = row["Version"].ToString(); Log.WriteInfo(string.Format("Version {0} is available for download", newVersion)); string message = string.Format("{0} {1} is available now.\nWould you like to install new version?", componentName, newVersion); if (MessageBox.Show(AppContext.AppForm, message, appName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string fileToDownload = row["UpgradeFilePath"].ToString(); string installerPath = row["InstallerPath"].ToString(); string installerType = row["InstallerType"].ToString(); UpdateComponent(fileToDownload, installerPath, installerType, newVersion); } } else { string message = string.Format("Current version of {0} is up to date.", componentName); Log.WriteInfo(message); AppContext.AppForm.ShowInfo(message); } }
private static BlackBerry GetBlackBerryProxy(int itemId) { Organization org = OrganizationController.GetOrganization(itemId); int serviceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.BlackBerry); BlackBerry blackBerry = new BlackBerry(); ServiceProviderProxy.Init(blackBerry, serviceId); return(blackBerry); }
private static OCSServer GetOCSProxy(int itemId) { Organization org = OrganizationController.GetOrganization(itemId); int serviceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.OCS); OCSServer ocs = new OCSServer(); ServiceProviderProxy.Init(ocs, serviceId); return(ocs); }
public static LyncServer GetLyncServer(int lyncServiceId, int organizationServiceId) { LyncServer ws = new LyncServer(); ServiceProviderProxy.Init(ws, lyncServiceId); string[] lyncSettings = ws.ServiceProviderSettingsSoapHeaderValue.Settings; List <string> resSettings = new List <string>(lyncSettings); if (organizationServiceId != -1) { ExtendLyncSettings(resSettings, "primarydomaincontroller", GetProviderProperty(organizationServiceId, "primarydomaincontroller")); ExtendLyncSettings(resSettings, "rootou", GetProviderProperty(organizationServiceId, "rootou")); } ws.ServiceProviderSettingsSoapHeaderValue.Settings = resSettings.ToArray(); return(ws); }
public static string GetDistributiveLocationInfo(string ccode, string cversion) { var service = ServiceProviderProxy.GetInstallerWebService(); // DataSet ds = service.GetReleaseFileInfo(ccode, cversion); // if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { Log.WriteInfo("Component code: {0}; Component version: {1};", ccode, cversion); // throw new ServiceComponentNotFoundException("Seems that the Service has no idea about the component requested."); } // DataRow row = ds.Tables[0].Rows[0]; // return(row["FullFilePath"].ToString()); }
private static string GetProviderProperty(int organizationServiceId, string property) { Organizations orgProxy = new Organizations(); ServiceProviderProxy.Init(orgProxy, organizationServiceId); string[] organizationSettings = orgProxy.ServiceProviderSettingsSoapHeaderValue.Settings; string value = string.Empty; foreach (string str in organizationSettings) { string[] props = str.Split('='); if (props[0].ToLower() == property) { value = str; break; } } return(value); }
/// <summary> /// Deletes SharePoint site collection with given id. /// </summary> /// <param name="itemId">Site collection id within metabase.</param> /// <returns>?</returns> public static int DeleteSiteCollection(int itemId) { // Check account. int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(accountCheck); } // Load original meta item SharePointEnterpriseSiteCollection origItem = (SharePointEnterpriseSiteCollection)PackageController.GetPackageItem(itemId); if (origItem == null) { return(BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND); } // Get service settings. StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(origItem.ServiceId); Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); string siteName = origItem.Name.Replace(String.Format("{0}://", rootWebApplicationUri.Scheme), String.Empty); // Log operation. TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "DELETE_SITE", origItem.Name, itemId); try { // Delete site collection on server. HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); hostedSharePointServer.Enterprise_DeleteSiteCollection(origItem); // Delete record in metabase. PackageController.DeletePackageItem(origItem.Id); int dnsServiceId = PackageController.GetPackageServiceId(origItem.PackageId, ResourceGroups.Dns); if (dnsServiceId > 0) { string[] tmpStr = siteName.Split('.'); string hostName = tmpStr[0]; string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1)); List <GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(origItem.ServiceId); List <DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(dnsRecords, hostName, domainName, ""); DNSServer dns = new DNSServer(); ServiceProviderProxy.Init(dns, dnsServiceId); // add new resource records dns.DeleteZoneRecords(domainName, resourceRecords.ToArray()); } return(0); } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
/// <summary> /// Adds SharePoint site collection. /// </summary> /// <param name="item">Site collection description.</param> /// <returns>Created site collection id within metabase.</returns> public static int AddSiteCollection(SharePointEnterpriseSiteCollection item) { // Check account. int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(accountCheck); } // Check package. int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(packageCheck); } // Check quota. OrganizationStatistics orgStats = OrganizationController.GetOrganizationStatistics(item.OrganizationId); //QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_SITES); if (orgStats.AllocatedSharePointEnterpriseSiteCollections > -1 && orgStats.CreatedSharePointEnterpriseSiteCollections >= orgStats.AllocatedSharePointEnterpriseSiteCollections) { return(BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_QUOTA_LIMIT); } // Check if stats resource is available int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.SharepointEnterpriseServer); if (serviceId == 0) { return(BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_UNAVAILABLE); } StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(serviceId); QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_ENTERPRISE_USESHAREDSSL); Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); Organization org = OrganizationController.GetOrganization(item.OrganizationId); string siteName = item.Name; if (quota.QuotaAllocatedValue == 1) { string sslRoot = hostedSharePointSettings["SharedSSLRoot"]; string defaultDomain = org.DefaultDomain; string hostNameBase = string.Empty; string[] tmp = defaultDomain.Split('.'); if (tmp.Length == 2) { hostNameBase = tmp[0]; } else { if (tmp.Length > 2) { hostNameBase = tmp[0] + tmp[1]; } } int counter = 0; item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot); siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot); while (DataProvider.CheckServiceItemExists(serviceId, item.Name, "WebsitePanel.Providers.SharePoint.SharePointEnterpriseSiteCollection, WebsitePanel.Providers.Base")) { counter++; item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot); siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot); } } else { item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, item.Name); } if (rootWebApplicationUri.Port > 0 && rootWebApplicationUri.Port != 80 && rootWebApplicationUri.Port != 443) { item.PhysicalAddress = String.Format("{0}:{1}", item.Name, rootWebApplicationUri.Port); } else { item.PhysicalAddress = item.Name; } if (Utils.ParseBool(hostedSharePointSettings["LocalHostFile"], false)) { item.RootWebApplicationInteralIpAddress = hostedSharePointSettings["RootWebApplicationInteralIpAddress"]; item.RootWebApplicationFQDN = item.Name.Replace(rootWebApplicationUri.Scheme + "://", ""); } item.MaxSiteStorage = RecalculateMaxSize(org.MaxSharePointEnterpriseStorage, (int)item.MaxSiteStorage); item.WarningStorage = item.MaxSiteStorage == -1 ? -1 : Math.Min((int)item.WarningStorage, item.MaxSiteStorage); // Check package item with given name already exists. if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SharePointEnterpriseSiteCollection)) != null) { return(BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_EXISTS); } // Log operation. TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "ADD_SITE_COLLECTION", item.Name); try { // Create site collection on server. HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId); hostedSharePointServer.Enterprise_CreateSiteCollection(item); // Make record in metabase. item.ServiceId = serviceId; int itemId = PackageController.AddPackageItem(item); hostedSharePointServer.Enterprise_SetPeoplePickerOu(item.Name, org.DistinguishedName); int dnsServiceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Dns); if (dnsServiceId > 0) { string[] tmpStr = siteName.Split('.'); string hostName = tmpStr[0]; string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1)); List <GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(serviceId); List <DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(dnsRecords, hostName, domainName, ""); DNSServer dns = new DNSServer(); ServiceProviderProxy.Init(dns, dnsServiceId); // add new resource records dns.AddZoneRecords(domainName, resourceRecords.ToArray()); } TaskManager.ItemId = itemId; return(itemId); } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
static int Main(string[] args) { // Utils.FixConfigurationSectionDefinition(); // // Ensure arguments supplied for the application if (args.Length == 0) { Log.WriteError(Global.Messages.NoInputParametersSpecified); return(Global.Messages.NoInputParametersSpecifiedError); } // Check user's security permissions if (!Utils.CheckSecurity()) { ShowSecurityError(); return(Global.Messages.NotEnoughPermissionsErrorCode); } // Check administrator permissions if (!Utils.IsAdministrator()) { ShowSecurityError(); return(Global.Messages.NotEnoughPermissionsErrorCode); } // Check for running instance if (!Utils.IsNewInstance()) { ShowInstanceRunningErrorMessage(); return(Global.Messages.AnotherInstanceIsRunningError); } // var cname = GetCommandLineArgumentValue(ComponentNameParam); if (Utils.CheckForInstalledComponent(cname)) { Log.WriteError(Global.Messages.ComponentIsAlreadyInstalled); // return(Global.Messages.ComponentIsAlreadyInstalledError); } try { // Make sure no other installations could be run at the same time Utils.SaveMutex(); // Log.WriteApplicationStart(); //check OS version Log.WriteInfo("{0} detected", Global.OSVersion); //check IIS version if (Global.IISVersion.Major == 0) { Log.WriteError("IIS not found."); } else { Log.WriteInfo("IIS {0} detected", Global.IISVersion); } var service = ServiceProviderProxy.GetInstallerWebService(); var record = default(DataRow); // var ds = service.GetAvailableComponents(); // foreach (DataRow row in ds.Tables[0].Rows) { string componentCode = Utils.GetDbString(row["ComponentCode"]); // if (!String.Equals(componentCode, cname, StringComparison.OrdinalIgnoreCase)) { continue; } // record = row; break; } // if (record == null) { Log.WriteError(String.Format("{0} => {1}", ComponentNameParam, cname)); Log.WriteInfo("Incorrect component name specified"); return(Global.Messages.UnknownComponentCodeError); } // var cli_args = ParseInputFromCLI(cname); // StartInstaller(record, cli_args); // return(Global.Messages.SuccessInstallation); } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return(Global.Messages.InstallationError); } finally { Log.WriteApplicationEnd(); } }