Ejemplo n.º 1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Expenses.Clear();
                var etems = await DataStores.GetItemsAsynce(true);

                foreach (var etem in etems)
                {
                    Expenses.Add(etem);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public FirstUseLanguage_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new Settings_ViewModel(Navigation, datastore);
        }
Ejemplo n.º 3
0
        public Units_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new Units_ViewModel(Navigation, datastore);
        }
Ejemplo n.º 4
0
        public Edit_Profil_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new Profil_Info_ViewModel(datastore, Navigation);
        }
        public Objectivs_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new Objectifs_ViewModel(datastore, Navigation);
        }
Ejemplo n.º 6
0
        public ExpenseViewModel()
        {
            Title            = "Expense";
            Expenses         = new ObservableCollection <Expense>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewExpensePage, Expense>(this, "AddExpense", async(obj, expense) =>
            {
                var _etem = expense as Expense;
                Expenses.Add(_etem);
                await DataStores.AddItemAsynce(_etem);
            });
            MessagingCenter.Subscribe <ExpenseDetailPage, Expense>(this, "UpdateExpense", async(obj, expense) =>
            {
                var expUp  = expense as Expense;
                var expDel = Expenses.Where((Expense arg) => arg.ExpenseId == expUp.ExpenseId).FirstOrDefault();
                Expenses.Remove(expDel);
                Expenses.Add(expUp);
                await DataStores.UpdateItemAsynce(expUp);
            });

            MessagingCenter.Subscribe <ExpenseDetailPage, Expense>(this, "DeleteExpense", async(obj, expense) =>
            {
                var expDel = expense as Expense;
                var id     = expDel.ExpenseId.ToString();
                var eDel   = Expenses.Where((Expense arg) => arg.ExpenseId == id).FirstOrDefault();
                Expenses.Remove(eDel);
                await DataStores.DeleteItemAsynce(id);
            });
        }
Ejemplo n.º 7
0
        public Logbook_page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new LogBook_ViewModel(datastore, Navigation);
        }
        public AddDrugs_View(Drugs_Model drug = null)
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new AddDrugs_ViewModel(Navigation, datastore, drug);
        }
Ejemplo n.º 9
0
        public SingUp_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new SignUp_ViewModel(Navigation, datastore, "SignUp", string.Empty);
        }
Ejemplo n.º 10
0
        private async Task GetObjectifs()
        {
            var Result = await RestApi.GetObjectifs();

            if (Result.Item1)
            {
                var Objectifs = JsonConvert.DeserializeObject <List <Objectifs_Upload_Model> >(Result.Item2);
                var item      = DataStores.GetObjectifAsync().First();
                foreach (var objectif in Objectifs)
                {
                    if (objectif.type == "glucose")
                    {
                        item.Max_Glycemia = objectif.greater;
                        item.Min_Glycemia = objectif.less;
                        DataStores.UpdateObjectif(item);
                    }
                    if (objectif.type == "weight")
                    {
                        item.Weight_Objectif = objectif.greater;

                        DataStores.UpdateObjectif(item);
                    }
                    if (objectif.type == "walk")
                    {
                        item.Steps_Objectif = int.Parse(objectif.greater.ToString());
                        DataStores.UpdateObjectif(item);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public Parameter(APEIPC instance, DataStores param, ParameterType apeParameterType, string parameterType)
        {
            Message *PtrMessage = instance.GetPointerToNextMessage();

            PtrMessage->Parameter.Int32[PtrMessage->NumberOfParameters]         = (Int32)param;
            PtrMessage->Parameter.TypeCode[PtrMessage->NumberOfParameters]      = (int)ApeTypeCode.DataStore;
            PtrMessage->Parameter.ParameterType[PtrMessage->NumberOfParameters] = (int)apeParameterType;
            PtrMessage->TypeCodeKey += ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + (int)ApeTypeCode.DataStore) + ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + OneLargerThanApeTypeCodeEnumMax + (int)apeParameterType);

            if (apeParameterType == ParameterType.Out)
            {
                int length = parameterType.Length * 2;    //UTF16 charcter: For a 4 byte surrogate pair, length actually returns 2 somewhat confusingly although its convenient for us here, so we can just use length * 2
                CheckSize(instance, length);
                fixed(void *PtrString = parameterType)
                {
                    NM.CopyMemory(instance.m_IntPtrMemoryMappedFileViewStringStore + instance.m_StringStoreOffset, (IntPtr)PtrString, (UIntPtr)(length));
                }

                PtrMessage->Parameter.StringOffset[PtrMessage->NumberOfParameters] = instance.m_StringStoreOffset;
                PtrMessage->Parameter.StringLength[PtrMessage->NumberOfParameters] = parameterType.Length;
                instance.m_StringStoreOffset = instance.m_StringStoreOffset + (parameterType.Length * 2);
            }

            PtrMessage->NumberOfParameters++;
        }
Ejemplo n.º 12
0
        public GlucoseStatistique_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new GlucoseStatistique_ViewModel(Navigation, datastore);
            NumericalStripLine stripLine1 = new NumericalStripLine()
            {
                Start = 0,
                Width = (BindingContext as GlucoseStatistique_ViewModel).Min_Glycemia,

                FillColor = Color.FromHex("#50f1c40f")
            };
            NumericalStripLine stripLine2 = new NumericalStripLine()
            {
                Start = (BindingContext as GlucoseStatistique_ViewModel).Min_Glycemia,
                Width = (BindingContext as GlucoseStatistique_ViewModel).Good_Wigh,

                FillColor = Color.FromHex("#502ecc71")
            };
            NumericalStripLine stripLine3 = new NumericalStripLine()
            {
                Start = (BindingContext as GlucoseStatistique_ViewModel).Max_Glycemia,
                Width = (BindingContext as GlucoseStatistique_ViewModel).Max_Widh,

                FillColor = Color.FromHex("#50e74c3c")
            };

            Numerical.StripLines.Add(stripLine1);
            Numerical.StripLines.Add(stripLine2);
            Numerical.StripLines.Add(stripLine3);
        }
        public PressionStatistique_Page()
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new PressionStatistique_ViewModel(Navigation, datastore);
        }
Ejemplo n.º 14
0
        private void ProcessDataRequest(DataRequest dataRequest, IClient client)
        {
            DataStore dataStore;

            lock (DataStores)
            {
                var fullTypeName = dataRequest.FullTypeName;

                if (!DataStores.ContainsKey(fullTypeName))
                {
                    throw new NotSupportedException("Not registered type : " + fullTypeName);
                }

                dataStore = DataStores[fullTypeName];
            }

            Dbg.Trace($"begin processing {dataRequest.AccessType} request on server {ShardIndex}");

            if (dataRequest.AccessType == DataAccessType.Write)
            {
                if (dataStore.Lock.TryEnterWriteLock(-1))
                {
                    try
                    {
                        dataStore.ProcessRequest(dataRequest, client, PersistTransaction);
                    }
                    finally
                    {
                        dataStore.Lock.ExitWriteLock();
                    }
                }
                else
                {
                    Dbg.Trace(
                        $"failed to acquire read-only lock on server {ShardIndex} for type {dataRequest.FullTypeName}");
                }
            }
            else
            {
                if (dataStore.Lock.TryEnterReadLock(-1))
                {
                    try
                    {
                        dataStore.ProcessRequest(dataRequest, client, PersistTransaction);
                    }
                    finally
                    {
                        dataStore.Lock.ExitReadLock();
                    }
                }
                else
                {
                    Dbg.Trace(
                        $"failed to acquire write lock on server {ShardIndex} for type {dataRequest.FullTypeName}");
                }
            }

            Dbg.Trace($"end processing {dataRequest.AccessType} request on server {ShardIndex}");
        }
Ejemplo n.º 15
0
        public Add_Data_Page(string source, Settings_Model profil)
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext  = new AddData_ViewModel(source, Navigation, datastore, profil);
            TimePicker.Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
        }
Ejemplo n.º 16
0
        public Home_Page()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new HomePage_ViewModel(Navigation, datastore);
        }
Ejemplo n.º 17
0
        public Profil_Base_Page(string source, string password, string facebook_id = null)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new SignUp_ViewModel(Navigation, datastore, source, password, facebook_id);
        }
Ejemplo n.º 18
0
        public AddHb1Ac_View(string source, Settings_Model profil, object data)
        {
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext         = new AddData_ViewModel(source, Navigation, datastore, profil, data);
            TimePicker.Time        = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            DatePicker.MaximumDate = DateTime.Now.Date;
        }
Ejemplo n.º 19
0
        public Parameter(APEIPC instance, DataStores param)
        {
            Message *PtrMessage = instance.GetPointerToNextMessage();

            PtrMessage->Parameter.Int32[PtrMessage->NumberOfParameters]         = (Int32)param;
            PtrMessage->Parameter.TypeCode[PtrMessage->NumberOfParameters]      = (int)ApeTypeCode.DataStore;
            PtrMessage->Parameter.ParameterType[PtrMessage->NumberOfParameters] = (int)ParameterType.In;
            PtrMessage->TypeCodeKey += ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + (int)ApeTypeCode.DataStore) + ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + OneLargerThanApeTypeCodeEnumMax + (int)ParameterType.In);
            PtrMessage->NumberOfParameters++;
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Creates the associated <see cref="DataStore" /> for new cacheable type
        /// </summary>
        /// <param name="request"></param>
        /// <param name="client"></param>
        private void RegisterType(RegisterTypeRequest request, IClient client)
        {
            try
            {
                var typeDescription = request.CollectionSchema;

                var collectionName = typeDescription.CollectionName;

                var dataStore = DataStores.TryGetValue(collectionName);


                if (ShardCount == 0) // not initialized
                {
                    ShardIndex = request.ShardIndex;
                    ShardCount = request.ShardsInCluster;
                }
                else // check it didn't change
                {
                    if (ShardIndex != request.ShardIndex || ShardCount != request.ShardsInCluster)
                    {
                        throw new NotSupportedException(
                                  $"Cluster configuration changed. This node was shard {ShardIndex} / {ShardCount} and now is {request.ShardIndex} / {request.ShardsInCluster}");
                    }
                }

                if (dataStore != null) //type already registered
                {
                    //if the type description changed reindex
                    if (!typeDescription.Equals(dataStore.CollectionSchema))
                    {
                        var newDataStore = DataStore.Reindex(dataStore, typeDescription);

                        DataStores[collectionName] = newDataStore;

                        _serviceContainer.SchemaPersistence.SaveSchema(GenerateSchema());
                    }
                }
                else // new type, store it in the type dictionary and initialize its DataStore
                {
                    var newDataStore =
                        new DataStore(typeDescription, new NullEvictionPolicy(), _serviceContainer.NodeConfig.FullTextConfig);


                    DataStores.Add(collectionName, newDataStore);

                    _serviceContainer.SchemaPersistence.SaveSchema(GenerateSchema());
                }

                client?.SendResponse(new NullResponse());
            }
            catch (Exception e)
            {
                client?.SendResponse(new ExceptionResponse(e));
            }
        }
Ejemplo n.º 21
0
        public Login_Page()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            var datastore = new DataStores();

            BindingContext = new Login_ViewModel(Navigation, datastore);
            TapGestureRecognizer Tap_SignUp = new TapGestureRecognizer();

            Tap_SignUp.Tapped += SignUp_Clicked;
            SignUp_Label.GestureRecognizers.Add(Tap_SignUp);
        }
Ejemplo n.º 22
0
        unsafe public void AddFirstMessageGetInvokeFormActiveX(DataStores destinationStore)
        {
            FirstMessageInitialise();

            Message *ptrMessage = GetPointerToNextMessage();

            ptrMessage->DestinationStore = destinationStore;
            ptrMessage->Action           = MessageAction.GetInvokeFormActiveX;

            m_PtrMessageStore->NumberOfMessages++;
            m_DoneFind = true;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the object currently stored in the specified datastore number
        /// </summary>
        /// <param name="sourceStore">The datastore to get the object from</param>
        /// <returns>The object contained in the datastore</returns>
        private object GetObjectFromDatastore(DataStores sourceStore)
        {
            object sourceObject;

            switch (sourceStore)
            {
            case DataStores.Store0:
                sourceObject = tempStore0;
                break;

            case DataStores.Store1:
                sourceObject = tempStore1;
                break;

            case DataStores.Store2:
                sourceObject = tempStore2;
                break;

            case DataStores.Store3:
                sourceObject = tempStore3;
                break;

            case DataStores.Store4:
                sourceObject = tempStore4;
                break;

            case DataStores.Store5:
                sourceObject = tempStore5;
                break;

            case DataStores.Store6:
                sourceObject = tempStore6;
                break;

            case DataStores.Store7:
                sourceObject = tempStore7;
                break;

            case DataStores.Store8:
                sourceObject = tempStore8;
                break;

            case DataStores.Store9:
                sourceObject = tempStore9;
                break;

            default:
                throw new Exception("Unsupported SourceStore " + sourceStore.ToString());
            }

            return(sourceObject);
        }
Ejemplo n.º 24
0
        //
        //  GetTabRect
        //

        unsafe public void AddQueryMessageGetTabRect(DataStores sourceStore)
        {
            Message *ptrMessage = GetPointerToNextMessage();

            ptrMessage->SourceStore = sourceStore;

            ptrMessage->Action = MessageAction.GetTabRect;

            m_PtrMessageStore->NumberOfMessages++;
            m_DoneFind  = true;
            m_DoneQuery = true;
            m_DoneGet   = true;
        }
Ejemplo n.º 25
0
        private void InternalProcessRegisterType(RegisterTypeRequest request)
        {
            var typeDescription = request.TypeDescription;

            if (ShardCount == 0) // not initialized
            {
                ShardIndex = request.ShardIndex;
                ShardCount = request.ShardsInCluster;
            }
            else // check it didn't change
            {
                if (ShardIndex != request.ShardIndex || ShardCount != request.ShardsInCluster)
                {
                    throw new NotSupportedException(
                              $"Cluster configuration changed. This node was shard {ShardIndex} / {ShardCount} and now is {request.ShardIndex} / {request.ShardsInCluster}");
                }
            }

            if (_knownTypes.ContainsKey(typeDescription.FullTypeName)) //type already registered
            {
                //check that the type description is the same
                if (!typeDescription.Equals(_knownTypes[typeDescription.FullTypeName]))
                {
                    var message =
                        $"The type {typeDescription.FullTypeName} is already registered but the type description is different";
                    throw new NotSupportedException(message);
                }
            }
            else // new type, store it in the type dictionary and initialize its DataStore
            {
                _knownTypes.Add(typeDescription.FullTypeName, typeDescription);

                PersistenceEngine?.UpdateSchema(GenerateSchema());


                var cfg = Config.ConfigByType.ContainsKey(typeDescription.FullTypeName)
                    ? Config.ConfigByType[typeDescription.FullTypeName]
                    : new ServerDatastoreConfig();

                var evictionPolicy = EvictionPolicyFactory.CreateEvictionPolicy(cfg.Eviction);

                var newDataStore =
                    new DataStore(typeDescription, evictionPolicy);


                Dbg.CheckThat(Profiler != null);

                newDataStore.Profiler = Profiler;
                DataStores.Add(typeDescription.FullTypeName, newDataStore);
            }
        }
Ejemplo n.º 26
0
        //
        //  AddMouseClickHandler
        //

        /// <summary>
        /// Calls into the AUT to add a mouse click handler to the specific control
        /// </summary>
        /// <param name="sourceStore">The datastore which contains the control object</param>
        unsafe public void AddQueryMessageAddMouseClickHandler(DataStores sourceStore)
        {
            if (!m_DoneFind)
            {
                throw new Exception("Must locate the dictionary before trying to use it");
            }

            Message *ptrMessage = GetPointerToNextMessage();

            ptrMessage->SourceStore = sourceStore;
            ptrMessage->Action      = MessageAction.AddMouseClickHandler;
            m_PtrMessageStore->NumberOfMessages++;
            m_DoneQuery = true;
        }
Ejemplo n.º 27
0
        //
        //  FlexgridGetCellRange
        //

        /// <summary>
        /// Calls into the AUT to iterate over every cell in the grid returning a \t \r separated string of the
        /// required property of the cells
        /// </summary>
        /// <param name="sourceStore">The datastore which contains the grid object</param>
        /// <param name="destinationStore">The datastore to put the resultant string into</param>
        /// <param name="row1">The start row of the range</param>
        /// <param name="column1">The start column of the range</param>
        /// <param name="row2">The end row of the range</param>
        /// <param name="column2">The end column of the range</param>
        unsafe public void AddQueryMessageFlexgridGetCellRange(DataStores sourceStore, DataStores destinationStore, int row1, int column1, int row2, int column2, CellProperty property)
        {
            if (!m_DoneFind)
            {
                throw new Exception("Must locate the flexgrid before trying to use it");
            }

            Message *ptrMessage = GetPointerToNextMessage();

            ptrMessage->SourceStore      = sourceStore;
            ptrMessage->DestinationStore = destinationStore;

            switch (property)
            {
            case CellProperty.BackColourName:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeBackColourName;
                break;

            case CellProperty.ForeColourName:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeForeColourName;
                break;

            case CellProperty.DataType:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeDataType;
                break;

            case CellProperty.CheckBox:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeCheckBox;
                break;

            case CellProperty.Image:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeImage;
                break;

            case CellProperty.BackgroundImage:
                ptrMessage->Action = MessageAction.FlexgridGetCellRangeBackgroundImage;
                break;

            default:
                throw new Exception("Implement support for getting cell property " + property.ToString());
            }

            Parameter row1Parameter    = new Parameter(this, row1);
            Parameter column1Parameter = new Parameter(this, column1);
            Parameter row2Parameter    = new Parameter(this, row2);
            Parameter column2Parameter = new Parameter(this, column2);

            m_PtrMessageStore->NumberOfMessages++;
            m_DoneQuery = true;
        }
Ejemplo n.º 28
0
        public Parameter(APEIPC instance, DataStores param, ParameterType apeParameterType)
        {
            if (apeParameterType == ParameterType.Out)
            {
                throw new Exception("Must specifiy the parameter type when using out datastore parameters");
            }

            Message *PtrMessage = instance.GetPointerToNextMessage();

            PtrMessage->Parameter.Int32[PtrMessage->NumberOfParameters]         = (Int32)param;
            PtrMessage->Parameter.TypeCode[PtrMessage->NumberOfParameters]      = (int)ApeTypeCode.DataStore;
            PtrMessage->Parameter.ParameterType[PtrMessage->NumberOfParameters] = (int)apeParameterType;
            PtrMessage->TypeCodeKey += ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + (int)ApeTypeCode.DataStore) + ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + OneLargerThanApeTypeCodeEnumMax + (int)apeParameterType);
            PtrMessage->NumberOfParameters++;
        }
        private ManagedObjectReference getDataStore(DataStores datastore)
        {
            ManagedObjectReference[] datastores = VimHelper.GetDynamicProperty <ManagedObjectReference[]>(VimHelper.DataCenterMOB, "datastore");

            for (int i = 0; i < datastores.Length; i++)
            {
                ManagedObjectReference curDatastore = datastores[i];
                string name = VimHelper.GetDynamicProperty <string>(curDatastore, "name");
                if (name == datastore.ToString())
                {
                    return(curDatastore);
                }
            }
            return(null);
        }
Ejemplo n.º 30
0
        public static string UploadFile(DataStores datastore, FileInfo fi)
        {
            // used to build entire input
            StringBuilder sb = new StringBuilder();

            // used on each read operation
            byte[] buf = new byte[8192];

            // prepare the web page we will be asking for
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://" + AppConfig.VSphereHost + "/folder/" + fi.Name + "?dcPath=ha-datacenter&dsName=" + datastore.ToString());

            request.Credentials = new NetworkCredential(AppConfig.VSphereUser, AppConfig.VSpherePass);

            request.ContentType   = "application/octet-stream";
            request.Method        = "POST";
            request.Accept        = "100-continue";
            request.ContentLength = fi.Length;

            // allows for validation of SSL conversations
            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateRemoteCertificate);

            Stream s = request.GetRequestStream();

            using (FileStream fileStream = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read))
            {
                // used on each read operation
                byte[] buffer = new byte[1024];
                int    len    = 0;
                while ((len = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    s.Write(buffer, 0, len);
                }
            }

            s.Close();

            // execute the request
            WebResponse response = request.GetResponse();

            string result = String.Empty;

            using (TextReader tr = new StreamReader(response.GetResponseStream()))
            {
                result = tr.ReadToEnd();
            }

            return(result);
        }
Ejemplo n.º 31
0
        public static string UploadFile(DataStores datastore, FileInfo fi)
        {
            // used to build entire input
            StringBuilder sb = new StringBuilder();

            // used on each read operation
            byte[] buf = new byte[8192];

            // prepare the web page we will be asking for
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://" + AppConfig.VSphereHost + "/folder/" + fi.Name + "?dcPath=ha-datacenter&dsName=" + datastore.ToString());
            request.Credentials = new NetworkCredential(AppConfig.VSphereUser, AppConfig.VSpherePass);

            request.ContentType = "application/octet-stream";
            request.Method = "POST";
            request.Accept = "100-continue";
            request.ContentLength = fi.Length;

            // allows for validation of SSL conversations
            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateRemoteCertificate);

            Stream s = request.GetRequestStream();

            using (FileStream fileStream = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read))
            {
                // used on each read operation
                byte[] buffer = new byte[1024];
                int len = 0;
                while ((len = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    s.Write(buffer, 0, len);
                }
            }

            s.Close();

            // execute the request
            WebResponse response = request.GetResponse();

            string result = String.Empty;

            using(TextReader tr = new StreamReader(response.GetResponseStream()))
            {
                result = tr.ReadToEnd();
            }

            return result;
        }
        private ManagedObjectReference getDataStore(DataStores datastore)
        {
            ManagedObjectReference[] datastores = VimHelper.GetDynamicProperty<ManagedObjectReference[]>(VimHelper.DataCenterMOB, "datastore");

            for (int i = 0; i < datastores.Length; i++)
            {
                ManagedObjectReference curDatastore = datastores[i];
                string name = VimHelper.GetDynamicProperty<string>(curDatastore, "name");
                if (name == datastore.ToString())
                {
                    return curDatastore;
                }
            }
            return null;
        }