// 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;
        }
        public static ServiceProviderItem Unwrap(SoapServiceProviderItem sobj)
        {
            Type type = Type.GetType(sobj.TypeName);
            ServiceProviderItem item = (ServiceProviderItem)Activator.CreateInstance(type);

            // get properties
            if (sobj.Properties != null)
            {
                // get type properties and add it to the hash
                Dictionary <string, PropertyInfo> hash = new Dictionary <string, PropertyInfo>();
                PropertyInfo[] propInfos = GetTypeProperties(type);

                foreach (PropertyInfo propInfo in propInfos)
                {
                    hash.Add(propInfo.Name, propInfo);
                }

                // set service item properties
                foreach (string pair in sobj.Properties)
                {
                    int    idx  = pair.IndexOf('=');
                    string name = pair.Substring(0, idx);
                    string val  = pair.Substring(idx + 1);
                    if (hash.ContainsKey(name))
                    {
                        // set value
                        PropertyInfo propInfo = hash[name];
                        propInfo.SetValue(item, Cast(val, propInfo.PropertyType), null);
                    }
                }
            }

            return(item);
        }
        // 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);
        }
 /// <remarks/>
 public void GetServiceItemsBandwidthAsync(SoapServiceProviderItem[] items, System.DateTime since)
 {
     this.GetServiceItemsBandwidthAsync(items, since, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginGetServiceItemsBandwidth(SoapServiceProviderItem[] items, System.DateTime since, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetServiceItemsBandwidth", new object[] {
                 items,
                 since}, callback, asyncState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginChangeServiceItemsState(SoapServiceProviderItem[] items, bool enabled, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("ChangeServiceItemsState", new object[] {
                 items,
                 enabled}, callback, asyncState);
 }
Пример #7
0
 public ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(SoapServiceProviderItem[] items, DateTime since)
 {
     try
     {
         Log.WriteStart("'{0}' GetServiceItemsBandwidth", ProviderSettings.ProviderName);
         return Provider.GetServiceItemsBandwidth(UnwrapServiceProviderItems(items), since);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("Error on GetServiceItemsBandwidth() in '{0}' provider", ProviderSettings.ProviderName), ex);
         throw;
     }
     finally
     {
         Log.WriteEnd("'{0}' GetServiceItemsBandwidth", ProviderSettings.ProviderName);
     }
 }
Пример #8
0
 public void DeleteServiceItems(SoapServiceProviderItem[] items)
 {
     try
     {
         Log.WriteStart("'{0}' DeleteServiceItems", ProviderSettings.ProviderName);
         Provider.DeleteServiceItems(UnwrapServiceProviderItems(items));
         Log.WriteEnd("'{0}' DeleteServiceItems", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("Error on DeleteServiceItems() in '{0}' provider", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
 /// <remarks/>
 public void DeleteServiceItemsAsync(SoapServiceProviderItem[] items, object userState)
 {
     if ((this.DeleteServiceItemsOperationCompleted == null))
     {
         this.DeleteServiceItemsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteServiceItemsOperationCompleted);
     }
     this.InvokeAsync("DeleteServiceItems", new object[] {
                 items}, this.DeleteServiceItemsOperationCompleted, userState);
 }
 /// <remarks/>
 public void DeleteServiceItemsAsync(SoapServiceProviderItem[] items)
 {
     this.DeleteServiceItemsAsync(items, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginDeleteServiceItems(SoapServiceProviderItem[] items, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("DeleteServiceItems", new object[] {
                 items}, callback, asyncState);
 }
 public void DeleteServiceItems(SoapServiceProviderItem[] items)
 {
     this.Invoke("DeleteServiceItems", new object[] {
                 items});
 }
 /// <remarks/>
 public void ChangeServiceItemsStateAsync(SoapServiceProviderItem[] items, bool enabled, object userState)
 {
     if ((this.ChangeServiceItemsStateOperationCompleted == null))
     {
         this.ChangeServiceItemsStateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeServiceItemsStateOperationCompleted);
     }
     this.InvokeAsync("ChangeServiceItemsState", new object[] {
                 items,
                 enabled}, this.ChangeServiceItemsStateOperationCompleted, userState);
 }
 /// <remarks/>
 public void ChangeServiceItemsStateAsync(SoapServiceProviderItem[] items, bool enabled)
 {
     this.ChangeServiceItemsStateAsync(items, enabled, null);
 }
 /// <remarks/>
 public void GetServiceItemsBandwidthAsync(SoapServiceProviderItem[] items, System.DateTime since, object userState)
 {
     if ((this.GetServiceItemsBandwidthOperationCompleted == null))
     {
         this.GetServiceItemsBandwidthOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetServiceItemsBandwidthOperationCompleted);
     }
     this.InvokeAsync("GetServiceItemsBandwidth", new object[] {
                 items,
                 since}, this.GetServiceItemsBandwidthOperationCompleted, userState);
 }
Пример #16
0
 public void ChangeServiceItemsState(SoapServiceProviderItem[] items, bool enabled)
 {
     try
     {
         Log.WriteStart("'{0}' ChangeServiceItemsState", ProviderSettings.ProviderName);
         Provider.ChangeServiceItemsState(UnwrapServiceProviderItems(items), enabled);
         Log.WriteEnd("'{0}' ChangeServiceItemsState", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("Error on ChangeServiceItemsState() in '{0}' provider", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
 public ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(SoapServiceProviderItem[] items)
 {
     object[] results = this.Invoke("GetServiceItemsDiskSpace", new object[] {
                 items});
     return ((ServiceProviderItemDiskSpace[])(results[0]));
 }
Пример #18
0
 public ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(SoapServiceProviderItem[] items)
 {
     try
     {
         Log.WriteStart("'{0}' GetServiceItemsDiskSpace", ProviderSettings.ProviderName);
         return Provider.GetServiceItemsDiskSpace(UnwrapServiceProviderItems(items));
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("Error on GetServiceItemsDiskSpace() in '{0}' provider", ProviderSettings.ProviderName), ex);
         throw;
     }
     finally
     {
         Log.WriteEnd("'{0}' GetServiceItemsDiskSpace", ProviderSettings.ProviderName);
     }
 }
 /// <remarks/>
 public System.IAsyncResult BeginGetServiceItemsDiskSpace(SoapServiceProviderItem[] items, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetServiceItemsDiskSpace", new object[] {
                 items}, callback, asyncState);
 }
Пример #20
0
        private ServiceProviderItem[] UnwrapServiceProviderItems(SoapServiceProviderItem[] soapItems)
        {
            if (soapItems == null)
                return null;
            ServiceProviderItem[] items = new ServiceProviderItem[soapItems.Length];
            for (int i = 0; i < items.Length; i++)
                items[i] = SoapServiceProviderItem.Unwrap(soapItems[i]);

            return items;
        }
 /// <remarks/>
 public void GetServiceItemsDiskSpaceAsync(SoapServiceProviderItem[] items)
 {
     this.GetServiceItemsDiskSpaceAsync(items, null);
 }
 /// <remarks/>
 public void GetServiceItemsDiskSpaceAsync(SoapServiceProviderItem[] items, object userState)
 {
     if ((this.GetServiceItemsDiskSpaceOperationCompleted == null))
     {
         this.GetServiceItemsDiskSpaceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetServiceItemsDiskSpaceOperationCompleted);
     }
     this.InvokeAsync("GetServiceItemsDiskSpace", new object[] {
                 items}, this.GetServiceItemsDiskSpaceOperationCompleted, userState);
 }
 public ServiceProviderItemBandwidth[] GetServiceItemsBandwidth(SoapServiceProviderItem[] items, System.DateTime since)
 {
     object[] results = this.Invoke("GetServiceItemsBandwidth", new object[] {
                 items,
                 since});
     return ((ServiceProviderItemBandwidth[])(results[0]));
 }
        public static ServiceProviderItem Unwrap(SoapServiceProviderItem sobj)
        {
            Type type = Type.GetType(sobj.TypeName);
            ServiceProviderItem item = (ServiceProviderItem)Activator.CreateInstance(type);

            // get properties
            if (sobj.Properties != null)
            {
                // get type properties and add it to the hash
                Dictionary<string, PropertyInfo> hash = new Dictionary<string, PropertyInfo>();
                PropertyInfo[] propInfos = GetTypeProperties(type);

                foreach (PropertyInfo propInfo in propInfos)
                    hash.Add(propInfo.Name, propInfo);

                // set service item properties
                foreach (string pair in sobj.Properties)
                {
                    int idx = pair.IndexOf('=');
                    string name = pair.Substring(0, idx);
                    string val = pair.Substring(idx + 1);
                    if (hash.ContainsKey(name))
                    {
                        // set value
                        PropertyInfo propInfo = hash[name];
                        propInfo.SetValue(item, Cast(val, propInfo.PropertyType), null);
                    }
                }
            }

            return item;
        }
 public void ChangeServiceItemsState(SoapServiceProviderItem[] items, bool enabled)
 {
     this.Invoke("ChangeServiceItemsState", new object[] {
                 items,
                 enabled});
 }