コード例 #1
0
        /// <summary>
        /// Update the existing ExpressionXml with the QuotaRemaining values and insert the updated one in the column QuotaExpressionsXML 
        /// </summary>
        /// <param name="steamStudyObject"></param>
        /// <param name="gmiSampleQuotasObject"></param>
        public void UpdateQuotaExpression(SteamStudyObject steamStudyObject, GMISampleQuotasObject gmiSampleQuotasObject)
        {
            string xml = steamStudyObject.ExpressionsXML;
            int count = -1;
            int quotaIndex = -1;
            var quotaIdVar = "<quotaId>";
            var quotaIdVarEnd = "</quotaId>";
            var quotaRemainingVar = "<quotaRemaining>";
            var quotaRemainingVarEnd = "</quotaRemaining>";

            var quotas = gmiSampleQuotasObject.GMIQuotasList.Where(p => p.SampleId == steamStudyObject.SampleId).ToList();

            foreach (GMIQuotaObject gmiQuotaObject in quotas)
            {

                count = (quotaIdVar + gmiQuotaObject.QuotaId + quotaIdVarEnd).Count();
                quotaIndex = xml.IndexOf(quotaIdVar + gmiQuotaObject.QuotaId + quotaIdVarEnd) + count;
                if (quotaIndex < count)
                    return;
                xml = xml.Insert(quotaIndex, quotaRemainingVar + gmiQuotaObject.QuotaRemaining + quotaRemainingVarEnd);

            }

            steamStudyObject.QuotaExpressionsXML = xml;
        }
コード例 #2
0
        /// <summary>
        /// Fetches the attributes expressions at the quota level from the steam service
        /// </summary>
        /// <param name="studyId"></param>
        /// <param name="sampleId"></param>
        public SteamStudyObject GetQuotasAttributes(int studyId, int sampleId)
        {
            var parameters = new Hashtable { { "study", studyId }, { "sample", sampleId } };
            var headerParameters = new Hashtable { { steamHeader, steamHeaderValue } };
            SteamStudyObject steamStudyObject = new SteamStudyObject();

            string service = "QuotasAttributes";
            LogUtil.CallingService(service, LogUtil.getHashtableString(parameters));

            try
            {
                var result = CallSteamStudyService("quotaExpressions", parameters, headerParameters);
                LogUtil.CallSuccess(service, result.ToString());

                steamStudyObject.SampleId = sampleId;
                steamStudyObject.ExpressionsXML = result.ToString();
            }
            catch (Exception e)
            {
                LogUtil.CallFail(service, e);
                throw;
            }

            return steamStudyObject;
        }
コード例 #3
0
        private bool UpdateQuotaCell(OfferObject offerObject, SteamStudyObject steamStudyObject, QuotasLiveObject quotasLiveObject)
        {
            var sampleId = offerObject.SampleId.Value;
            LoggingUtility log = LoggerFactory.GetLogger();

            try
            {
                QuotaMappingRepository quotaMappingRepository = new QuotaMappingRepository();
                GMISampleObject sampleObject = new SampleMappingRepository().SelectByID(steamStudyObject.SampleId);

                List<GMISampleObject> GMISampleObjectList = new List<GMISampleObject>();
                GMISampleObjectList.Add((sampleObject != null) ? sampleObject : new GMISampleObject());
                List<GMIQuotaObject> GMIQuotasList = quotaMappingRepository.SelectBySampleID(steamStudyObject.SampleId).ToList();

                bool needUpdate = false;
                foreach (GMIQuotaObject gmiQuotaObject in GMIQuotasList)
                {
                    var quota = quotasLiveObject.QuotasLiveList.Where(p => p.InternalQuotaId == gmiQuotaObject.InternalQuotaId).Where(p => p.InternalSampleId == sampleObject.InternalSampleId).ToList();
                    if (quota.Count() > 0 && gmiQuotaObject.QuotaRemaining != quota[0].QuotaRemaining)
                    {
                        gmiQuotaObject.QuotaRemaining = quota[0].QuotaRemaining;
                        quotaMappingRepository.Update(gmiQuotaObject);
                        needUpdate = true;
                    }
                }

                if (needUpdate)
                {
                    // There was a change in quota remaining, update the quota expressions XML to reflect the new values
                    log.Debug("Update the quota remaining for sample: " + sampleId);
                    GMISampleQuotasObject gmiSampleQuotasObject = new GMISampleQuotasObject();
                    gmiSampleQuotasObject.GMIQuotasList = GMIQuotasList;
                    gmiSampleQuotasObject.GMISampleQuotasList = GMISampleObjectList;

                    new SteamStudy().UpdateQuotaExpression(steamStudyObject, gmiSampleQuotasObject);
                    new QuotaExpressionRepository().updateQuotaExpressionsXML(steamStudyObject);
                }
            }
            catch (Exception e)
            {
                log.Error("An error occurred while trying to update the quota cells for offerId " + offerObject.Id.ToString(), e);
                throw;
            }

            return true;
        }