Esempio n. 1
0
 public bool CanCancelEmbargo(Embargo embargo, Entity entity)
 {
     if (embargo.CreatorCountry.PresidentID == entity.EntityID)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
        public void CancelEmbargo(Embargo embargo)
        {
            var message = string.Format("You no longer have embargo with {0}", embargo.CreatorCountry.Entity.Name);

            warningService.AddWarning(embargo.EmbargoedCountryID, message);

            embargo.Active  = false;
            embargo.EndDay  = GameHelper.CurrentDay;
            embargo.EndTime = DateTime.Now;

            embargoRepository.SaveChanges();
        }
Esempio n. 3
0
        public EmbargoViewModel(Embargo embargo, IEmbargoService embargoService)
        {
            EmbargoID = embargo.ID;

            CountryName = embargo.EmbargoedCountry.Entity.Name;
            CountryID   = embargo.EmbargoedCountryID;
            CountryFlag = Images.GetCountryFlag(CountryID).VM;

            CreatorCountryName = embargo.CreatorCountry.Entity.Name;
            CreatorID          = embargo.CreatorCountryID;
            CreatorFlag        = Images.GetCountryFlag(CreatorID).VM;

            StartDateTime = string.Format("day {0} {1}", embargo.StartDay, embargo.StartTime.ToShortTimeString());

            Upkeep = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)embargoService.GetEmbargoCost(embargo.CreatorCountry, embargo.EmbargoedCountry));
        }
Esempio n. 4
0
        public void DeclareEmbargo(Country declaringCountry, Country embargoedCountry)
        {
            using (var trs = transactionScopeProvider.CreateTransactionScope())
            {
                var embargo = new Embargo()
                {
                    Active             = true,
                    CreatorCountryID   = declaringCountry.ID,
                    EmbargoedCountryID = embargoedCountry.ID,
                    StartDay           = GameHelper.CurrentDay,
                    StartTime          = DateTime.Now
                };

                embargoRepository.Add(embargo);
                embargoRepository.SaveChanges();

                string message = string.Format("Your country was embargoed by {0}", declaringCountry.Entity.Name);
                warningService.AddWarning(embargoedCountry.ID, message);

                MakeEmbargoCostTransaction(embargo, false);
                trs.Complete();
            }
        }
Esempio n. 5
0
        public TransactionResult MakeEmbargoCostTransaction(Embargo embargo, bool useSqlTransaction = false)
        {
            var cost = GetEmbargoCost(embargo);

            var payingEntity = embargo.CreatorCountry.Entity;

            var money = new Money()
            {
                Amount   = (decimal)cost,
                Currency = Persistent.Currencies.GetById((int)CurrencyTypeEnum.Gold)
            };

            var transaction = new Transaction()
            {
                Arg1            = "Embargo upkeep",
                Arg2            = string.Format("{0}({1}) paid embargo upkeep", payingEntity.Name, payingEntity.EntityID),
                Money           = money,
                SourceEntityID  = payingEntity.EntityID,
                TransactionType = TransactionTypeEnum.Embargo
            };

            return(transactionService.MakeTransaction(transaction, useSqlTransaction));
        }
Esempio n. 6
0
        /// <summary>
        /// Retrieve Embargo infromation from database
        /// </summary>
        /// <param name="recordID">Record id according to which touple is to be retrieved</param>
        /// <returns></returns>
        public Embargo GetEmbargoRecord(string recordID, string UserSNo)
        {
            SqlDataReader dr = null;

            try
            {
                Embargo        emb        = new Embargo();
                SqlParameter[] Parameters = { new SqlParameter("@SNo", Convert.ToInt32(recordID)), new SqlParameter("@UserID", Convert.ToInt32(UserSNo)) };

                dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordEmbargo", Parameters);

                if (dr.Read())
                {
                    emb.SNo             = Convert.ToInt32(dr["SNo"]);
                    emb.ConfigType      = Convert.ToBoolean(dr["ConfigType"]);
                    emb.Text_ConfigType = dr["Text_ConfigType"].ToString();
                    emb.EmbargoName     = dr["EmbargoName"].ToString().ToUpper();

                    emb.OriginCountrySNo      = string.IsNullOrEmpty(dr["OriginCountrySNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["OriginCountrySNo"]);
                    emb.Text_OriginCountrySNo = dr["OriginCountry"].ToString().ToUpper();

                    emb.DestinationCountrySNo      = string.IsNullOrEmpty(dr["DestinationCountrySNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["DestinationCountrySNo"]);
                    emb.Text_DestinationCountrySNo = dr["DestinationCountry"].ToString().ToUpper();

                    emb.OriginAirportSNo      = string.IsNullOrEmpty(dr["OriginAirportSNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["OriginAirportSNo"]);
                    emb.DestinationAirportSNo = string.IsNullOrEmpty(dr["DestinationAirportSNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["DestinationAirportSNo"]);
                    emb.FreightType           = String.IsNullOrEmpty(dr["FreightType"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["FreightType"]);
                    //emb.OriginLocalZoneSNo = Convert.ToInt32(dr["OriginLocalZoneSNo"]);
                    //emb.DestinationLocalZoneSNo = Convert.ToInt32(dr["DestinationLocalZoneSNo"]);

                    emb.Text_OriginAirportSNo      = dr["OriginAirport"] == null ? string.Empty : (dr["OriginAirport"].ToString());
                    emb.Text_DestinationAirportSNo = dr["DestinationAirport"] == null ? string.Empty : (dr["DestinationAirport"].ToString());

                    //emb.Text_OriginLocalZoneSNo = dr["OriginLocalZoneName"] == null ? string.Empty : (dr["OriginLocalZoneName"].ToString());
                    //emb.Text_DestinationLocalZoneSNo = dr["DestinationLocalZoneName"] == null ? string.Empty : (dr["DestinationLocalZoneName"].ToString());

                    emb.OriginCitySNo      = string.IsNullOrEmpty(dr["OriginCitySNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["OriginCitySNo"]);
                    emb.Text_OriginCitySNo = dr["OriginCity"].ToString().ToUpper();

                    emb.DestinationCitySNo      = string.IsNullOrEmpty(dr["DestinationCitySNo"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["DestinationCitySNo"]);
                    emb.Text_DestinationCitySNo = dr["DestinationCity"].ToString().ToUpper();

                    emb.ValidFrom     = Convert.ToDateTime(dr["ValidFrom"]);
                    emb.ValidTo       = Convert.ToDateTime(dr["ValidTo"]);
                    emb.LimitOn       = String.IsNullOrEmpty(dr["LimitOn"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["LimitOn"]);
                    emb.Text_LimitOn  = dr["Text_LimitOn"].ToString().ToUpper();
                    emb.Period        = String.IsNullOrEmpty(dr["Period"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["Period"]);
                    emb.Text_Period   = dr["Text_Period"].ToString().ToUpper();
                    emb.MaxWeight     = Convert.ToDouble(dr["MaxWeight"]);
                    emb.AllowedWeight = Convert.ToDouble(dr["AllowedWeight"]);
                    emb.Reason        = dr["Reason"].ToString().ToUpper();

                    emb.IsActive = Convert.ToBoolean(dr["IsActive"]);
                    emb.Active   = dr["ACTIVE"].ToString();
                    //added by tarun kumar singh
                    // emb.FreightType = Convert.ToBoolean(dr["FreightType"]);
                    emb.Text_FreightType = dr["Text_FreightType"].ToString();
                    //emb.IsExcludeSHC =Convert.ToBoolean(dr["IsExcludeSHC"]);
                    //emb.Text_IsExcludeSHC = Convert.ToString(dr["Text_IsExcludeSHC"]);//== true ? "Exclude" : "Include";
                    //emb.IsExcludeCommodity = Convert.ToBoolean(dr["IsExcludeCommodity"]);
                    //emb.Text_IsExcludeCommodity = Convert.ToString(dr["Text_IsExcludeCommodity"]);// == true ? "Exclude" : "Include";
                    //emb.IsExcludeFlight = Convert.ToBoolean(dr["IsExcludeFlight"]);
                    //emb.Text_IsExcludeFlight = Convert.ToString(dr["Text_IsExcludeFlight"]);// == true ? "Exclude" : "Include";
                    //emb.IsExcludeProduct = Convert.ToBoolean(dr["IsExcludeProduct"]);
                    //emb.Text_IsExcludeProduct = Convert.ToString(dr["Text_IsExcludeProduct"]);// == true ? "Exclude" : "Include";
                    //emb.IsExcludeAircraft = Convert.ToBoolean(dr["IsExcludeAircraft"]);
                    //emb.Text_IsExcludeAircraft = Convert.ToString(dr["Text_IsExcludeAircraft"]);// == true ? "Exclude" : "Include";
                    emb.IsSoftEmbargo = Convert.ToBoolean(dr["IsSoftEmbargo"]);
                    emb.EmbargoType   = dr["EmbargoType"].ToString();

                    emb.SHC            = dr["SHCSNo"].ToString();
                    emb.Text_SHC       = dr["SHC"].ToString().ToUpper() == "" ? dr["SHC"].ToString().ToUpper() : dr["SHC"].ToString().ToUpper().Remove(dr["SHC"].ToString().Length - 1);
                    emb.Commodity      = dr["CommoditySNo"].ToString();
                    emb.Text_Commodity = dr["Commodity"].ToString().ToUpper() == "" ? dr["Commodity"].ToString().ToUpper() : dr["Commodity"].ToString().ToUpper().Remove(dr["Commodity"].ToString().Length - 1);
                    emb.Aircraft       = dr["AircraftSNo"].ToString();
                    emb.Text_Aircraft  = dr["Aircraft"].ToString().ToUpper() == "" ? dr["Aircraft"].ToString().ToUpper() : dr["Aircraft"].ToString().ToUpper().Remove(dr["Aircraft"].ToString().Length - 1);
                    emb.Flight         = dr["FlightSNo"].ToString();
                    emb.Text_Flight    = dr["Flight"].ToString().ToUpper() == "" ? dr["Flight"].ToString().ToUpper() : dr["Flight"].ToString().ToUpper().Remove(dr["Flight"].ToString().Length - 1);
                    emb.Product        = dr["ProductSNo"].ToString();
                    emb.Text_Product   = dr["Product"].ToString().ToUpper() == "" ? dr["Product"].ToString().ToUpper() : dr["Product"].ToString().ToUpper().Remove(dr["Product"].ToString().Length - 1);

                    emb.AirlineSNo            = Convert.ToInt32(dr["AirlineSNo"]);
                    emb.Text_AirlineSNo       = dr["Airline"].ToString().ToUpper();
                    emb.AccountSNo            = dr["AccountSNo"].ToString();
                    emb.Text_AccountSNo       = dr["Text_AccountSNo"].ToString().ToUpper();
                    emb.ApplicableOn          = Convert.ToInt32(dr["ApplicableOn"]);
                    emb.Text_ApplicableOn     = dr["Text_ApplicableOn"].ToString().ToUpper();
                    emb.DaysOfOps             = dr["DaysOfOps"].ToString();
                    emb.Text_DaysOfOps        = dr["Text_DaysOfOps"].ToString().ToUpper();
                    emb.CreatedBy             = dr["CreatedUser"].ToString();
                    emb.UpdatedBy             = dr["UpdatedUser"].ToString();
                    emb.ExcludeCommodity      = dr["ExcludeCommodity"].ToString();
                    emb.Text_ExcludeCommodity = dr["Text_ExcludeCommodity"].ToString().ToUpper();
                    /**********************************************************/
                    emb.ExcludeSHC      = dr["ExcludeSHC"].ToString();
                    emb.Text_ExcludeSHC = dr["Text_ExcludeSHC"].ToString().ToUpper();

                    emb.ExcludeProduct      = dr["ExcludeProduct"].ToString();
                    emb.Text_ExcludeProduct = dr["Text_ExcludeProduct"].ToString().ToUpper();

                    emb.ExcludeAircraft      = dr["ExcludeAircraft"].ToString();
                    emb.Text_ExcludeAircraft = dr["Text_ExcludeAircraft"].ToString().ToUpper();

                    emb.ExcludeAccountSNo      = dr["ExcludeAccountSNo"].ToString();
                    emb.Text_ExcludeAccountSNo = dr["Text_ExcludeAccountSNo"].ToString().ToUpper();

                    emb.ExcludeFlight = dr["ExcludeFlight"].ToString();

                    emb.Text_ExcludeFlight = dr["Text_ExcludeFlight"].ToString().ToUpper();
                    emb.RefNo = dr["RefNo"].ToString().ToUpper();
                    emb.Text_AgentsAirline = dr["Text_AgentsAirline"].ToString().ToUpper();
                    emb.AgentsAirline      = dr["AgentsAirline"].ToString();
                    /**********************************************************/
                }
                dr.Close();
                return(emb);
            }
            catch (Exception ex)//
            {
                dr.Close();
                throw ex;
            }
        }
Esempio n. 7
0
 public double GetEmbargoCost(Embargo embargo)
 {
     return(GetEmbargoCost(embargo.CreatorCountry, embargo.EmbargoedCountry));
 }
Esempio n. 8
0
        public bool CanUpkeepEmbargo(Embargo embargo)
        {
            var cost = GetEmbargoCost(embargo);

            return(CanUpkeepEmbargo(cost, embargo.CreatorCountry.Entity.WalletID));
        }
        public void Map(CatalogRecord record, StudyUnit study)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }

            if (study == null)
            {
                throw new ArgumentNullException("study");
            }

            if (record.LastUpdatedDate.HasValue)
            {
                study.VersionDate = record.LastUpdatedDate.Value;
            }

            study.SetUserAttribute("CreatedDate", record.CreatedDate);
            study.SetUserAttribute("ArchiveDate", record.ArchiveDate);
            study.SetUserAttribute("PublishDate", record.PublishDate);
            study.DublinCoreMetadata.Date = record.PublishDate;
            study.SetUserAttribute("CertifiedDate", record.CertifiedDate);

            study.SetUserAttribute("DepositAgreement", record.DepositAgreement);
            study.SetUserAttribute("AccessStatement", record.AccessStatement);
            study.SetUserAttribute("ConfidentialityStatement", record.ConfidentialityStatement);

            study.SetUserAttribute("RelatedDatabase", record.RelatedDatabase);
            study.SetUserAttribute("RelatedPublications", record.RelatedPublications);
            study.SetUserAttribute("RelatedProjects", record.RelatedProjects);

            study.SetUserAttribute("ReviewType", record.ReviewType);
            study.SetUserAttribute("OrganizationName", record.Organization?.Name);


            study.DublinCoreMetadata.Title.Current = record.Title;
            study.SetUserId("StudyId", record.StudyId);
            study.SetUserId("StudyNumber", record.Number?.ToString());

            study.DublinCoreMetadata.Creator.Current     = record.AuthorsText;
            study.DublinCoreMetadata.Description.Current = record.Description;

            if (record.Keywords != null)
            {
                string[] keywords = record.Keywords.Split(new char[] { ',' });
                foreach (string kw in keywords)
                {
                    study.Coverage.TopicalCoverage.Keywords.Add(kw);
                }
            }

            if (record.CreatedBy != null)
            {
                study.DublinCoreMetadata.Contributor.Current = record.CreatedBy.FullName;
            }

            if (record.Owner != null)
            {
                study.DublinCoreMetadata.Publisher.Current = record.Owner.FullName;
            }

            study.SetUserId("Handle", record.PersistentId);

            var fundingInfo = new FundingInformation();

            fundingInfo.Description.Current = record.Funding;
            study.FundingSources.Add(fundingInfo);

            if (!string.IsNullOrWhiteSpace(record.EmbargoStatement))
            {
                var embargo = new Embargo();
                embargo.Description.Current = record.EmbargoStatement;
                study.Embargos.Add(embargo);
            }

            study.SetMethodology(record.ResearchDesign);
            study.SetModeOfDataCollection(record.ModeOfDataCollection);
            study.SetDataCollectionDate(record.FieldDates);

            var dateSpec = FormMappingHelper.GetDateFromJson(record.StudyTimePeriod);

            if (dateSpec != null)
            {
                study.Coverage.TemporalCoverage.Dates.Add(dateSpec);
            }
            else
            {
                study.Coverage.TemporalCoverage.Dates.Clear();
            }

            study.Coverage.SpatialCoverage.HighestLevel        = record.Location;
            study.Coverage.SpatialCoverage.Description.Current = record.LocationDetails;
            study.AnalysisUnit = record.UnitOfObservation;
            study.SetUserAttribute("SampleSize", record.SampleSize);
            study.SetSamplingProcedure(record.InclusionExclusionCriteria);
            study.SetUserAttribute("RandomizationProcedure", record.RandomizationProcedure);
            study.SetUserAttribute("UnitOfRandomization", record.UnitOfRandomization);
            study.SetUserAttribute("Treatment", record.Treatment);
            study.SetUserAttribute("TreatmentAdministration", record.TreatmentAdministration);
            study.SetUserAttribute("OutcomeMeasures", record.OutcomeMeasures);
        }