本文整理汇总了C#中ServiceProviderItem类的典型用法代码示例。如果您正苦于以下问题:C# ServiceProviderItem类的具体用法?C# ServiceProviderItem怎么用?C# ServiceProviderItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceProviderItem类属于命名空间,在下文中一共展示了ServiceProviderItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertItemToMailAccount
private static MailAccount ConvertItemToMailAccount(ServiceProviderItem item)
{
MailAccount account = (MailAccount)item;
account.Password = CryptoUtils.Decrypt(account.Password);
return account;
}
示例2: Wrap
// static methods
public static SoapServiceProviderItem Wrap(ServiceProviderItem item)
{
if (item == null)
return null;
// wrap only "persistent" properties
SoapServiceProviderItem sobj = new SoapServiceProviderItem();
sobj.TypeName = item.GetType().AssemblyQualifiedName;
// add common properties
Hashtable props = GetObjectProperties(item, true);
props.Add("Id", item.Id.ToString());
props.Add("Name", item.Name);
props.Add("ServiceId", item.ServiceId.ToString());
props.Add("PackageId", item.PackageId.ToString());
List<string> wrProps = new List<string>();
foreach (string key in props.Keys)
{
wrProps.Add(key + "=" + props[key].ToString());
}
sobj.Properties = wrProps.ToArray();
return sobj;
}
示例3: ConvertItemToFtpAccount
private static FtpAccount ConvertItemToFtpAccount(ServiceProviderItem item)
{
FtpAccount account = (FtpAccount)item;
string homeFolder = FilesController.GetHomeFolder(account.PackageId);
if(!String.IsNullOrEmpty(account.Folder) && account.Folder.IndexOf(":") != -1)
account.Folder = account.Folder.Substring(homeFolder.Length);
account.Folder = (account.Folder == "") ? "\\" : account.Folder;
// decode password
account.Password = CryptoUtils.Decrypt(account.Password);
return account;
}
示例4: DeleteServiceItems
public override void DeleteServiceItems(ServiceProviderItem[] items)
{
foreach (ServiceProviderItem item in items)
{
try
{
if (item is HomeFolder)
// delete home folder
FileUtils.DeleteFile(item.Name);
}
catch (Exception ex)
{
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
}
}
}
示例5: GetServiceItemsBandwidth
public virtual ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(ServiceProviderItem[] items, DateTime since)
{
// don't calculate bandwidth
return null;
}
示例6: GetServiceItemsDiskSpace
public virtual ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(ServiceProviderItem[] items)
{
// don't calculate disk space
return null;
}
示例7: BackupItem
public int BackupItem(string tempFolder, System.Xml.XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
{
if (item is HomeFolder)
{
// backup home folder files
string backupName = String.Format("SpaceFiles_{0}_{1}.zip",
item.Id, DateTime.Now.Ticks);
// get the list of remote files
List<SystemFile> files = FilesController.GetFiles(item.PackageId, "\\", true);
string[] zipFiles = new string[files.Count];
for(int i = 0; i < zipFiles.Length; i++)
zipFiles[i] = files[i].Name;
// zip remote files
FilesController.ZipFiles(item.PackageId, zipFiles, backupName);
// download zipped file
string localBackupPath = Path.Combine(tempFolder, backupName);
byte[] buffer = null;
FileStream stream = new FileStream(localBackupPath, FileMode.Create, FileAccess.Write);
int offset = 0;
long length = 0;
do
{
// read remote content
buffer = FilesController.GetFileBinaryChunk(item.PackageId, backupName, offset, FILE_BUFFER_LENGTH);
// write remote content
stream.Write(buffer, 0, buffer.Length);
length += buffer.Length;
offset += FILE_BUFFER_LENGTH;
}
while (buffer.Length == FILE_BUFFER_LENGTH);
stream.Close();
// delete zipped file
if (FilesController.FileExists(item.PackageId, backupName))
FilesController.DeleteFiles(item.PackageId, new string[] { backupName });
// add file pointer
BackupController.WriteFileElement(writer, "SpaceFiles", backupName, length);
// store meta item
XmlSerializer serializer = new XmlSerializer(typeof(HomeFolder));
serializer.Serialize(writer, item);
}
else if (item is SystemDSN)
{
// backup ODBC DSN
OS.OperatingSystem os = GetOS(item.ServiceId);
// read DSN info
SystemDSN itemDsn = item as SystemDSN;
SystemDSN dsn = os.GetDSN(item.Name);
dsn.DatabasePassword = itemDsn.DatabasePassword;
XmlSerializer serializer = new XmlSerializer(typeof(SystemDSN));
serializer.Serialize(writer, dsn);
}
return 0;
}
示例8: BackupItem
public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
{
if (!(item is DnsZone))
return 0;
// DNS provider
DNSServer dns = GetDNSServer(item.ServiceId);
// zone records serialized
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
try
{
// get zone records
DnsRecord[] records = dns.GetZoneRecords(item.Name);
// serialize zone records
foreach (DnsRecord record in records)
serializer.Serialize(writer, record);
}
catch (Exception ex)
{
TaskManager.WriteError(ex, "Could not read zone records");
}
return 0;
}
示例9: ChangeServiceItemsState
public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
{
foreach (ServiceProviderItem item in items)
{
try
{
if (item is Organization)
{
Organization org = item as Organization;
ChangeOrganizationState(org, enabled);
}
}
catch (Exception ex)
{
HostedSolutionLog.LogError(
String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
}
}
}
示例10: DeleteServiceItems
public override void DeleteServiceItems(ServiceProviderItem[] items)
{
foreach (ServiceProviderItem item in items)
{
if (item is StatsSite)
{
try
{
DeleteSite(((StatsSite)item).SiteId);
}
catch (Exception ex)
{
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
}
}
}
}
示例11: ConvertItemToWebSite
private static WebSite ConvertItemToWebSite(ServiceProviderItem item)
{
return (WebSite)item;
}
示例12: DeleteServiceItems
public override void DeleteServiceItems(ServiceProviderItem[] items)
{
foreach (ServiceProviderItem item in items)
{
if (item is VirtualMachine)
{
// delete virtual machine
VirtualMachine vm = item as VirtualMachine;
DeleteVirtualMachineServiceItem(vm);
}
else if (item is VirtualSwitch)
{
// delete switch
VirtualSwitch vs = item as VirtualSwitch;
DeleteVirtualSwitchServiceItem(vs);
}
}
}
示例13: DeleteServiceItems
public override void DeleteServiceItems(ServiceProviderItem[] items)
{
foreach (ServiceProviderItem item in items)
{
if (item is DnsZone)
{
try
{
// delete DNS zone
DeleteZone(item.Name);
}
catch (Exception ex)
{
Log.WriteError(String.Format("Error deleting '{0}' Power DNS zone", item.Name), ex);
}
}
}
}
示例14: ChangeServiceItemsState
public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
{
foreach (ServiceProviderItem item in items)
{
if (item is VirtualMachine)
{
// start/stop virtual machine
VirtualMachine vm = item as VirtualMachine;
ChangeVirtualMachineServiceItemState(vm, enabled);
}
}
}
示例15: DeleteServiceItems
public override void DeleteServiceItems(ServiceProviderItem[] items)
{
foreach (ServiceProviderItem item in items)
{
if (item is FtpAccount)
{
try
{
// delete FTP account
DeleteAccount(item.Name);
}
catch (Exception ex)
{
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
}
}
}
}