Esempio n. 1
0
        public ActionResult Index()
        {
            _dataModelFactory = new DBModelFactory(cloudStorageAccount.CreateCloudTableClient());

            // Access the Azure Table Storage to access the data related to the AutoCAD plugins
            IEnumerable <DBModel> azuredata = _dataModelFactory.FetchAll();

            // Iterate through the model and populate the collection that we can provide to the view.
            foreach (DBModel adm in azuredata)
            {
                if (adm != null)
                {
                    String   _timeFormat             = "dd-MM-yyyy hh:mm:ss tt";
                    DateTime currentDateTimeStamp    = DateTime.Now;
                    DateTime dbStoredExpiryTimeStamp = DateTime.Now;
                    double   timeRemaining           = 0.0;
                    if (DateTime.TryParseExact(adm.ExpiryDateTimeStamp, _timeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dbStoredExpiryTimeStamp))
                    {
                        if (dbStoredExpiryTimeStamp > currentDateTimeStamp)
                        {
                            timeRemaining = (dbStoredExpiryTimeStamp - currentDateTimeStamp).TotalMinutes;
                        }
                    }

                    DateTime dbStoredStartTimeStamp = DateTime.Now;
                    double   totalTrialDuration     = 0.0;
                    if (DateTime.TryParseExact(adm.StartDateTimeStamp, _timeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dbStoredStartTimeStamp))
                    {
                        totalTrialDuration = (dbStoredExpiryTimeStamp - dbStoredStartTimeStamp).TotalMinutes;
                    }
                }
            }

            return(View());
        }
Esempio n. 2
0
 private void Connect2TableStorage()
 {
     if (_dataModelFactory == null)
     {
         // create data factory to table
         _dataModelFactory = new DBModelFactory(cloudStorageAccount.CreateCloudTableClient());
     }
 }