コード例 #1
0
        /// <summary>
        /// 预测导出--如果需要将入出口数据进行区分,则分别放在两个list的集合中,若不需区分,则将数据放入list1中,list2为空即可
        /// </summary>
        /// <param name="path"></param>
        /// <param name="para"></param>
        /// <param name="forecase"></param>
        /// <param name="list1">出口</param>
        /// <param name="list2">入口</param>
        /// <returns></returns>
        public string ExportExcel(string path, QueryParameters para, IForecast forecase, List <IReportViewModel> list1, List <IReportViewModel> list2)
        {
            string[] num      = path.Split('\\');
            string   filename = num[num.Length - 1].Split('.')[0] + "(预测).xlsx";
            string   savepath = string.Empty;

            try
            {
                if (System.IO.File.Exists(path))
                {
                    using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {
                        IWorkbook readworkbook = new XSSFWorkbook(stream);
                        stream.Close();
                        readworkbook = forecase.GenerateSheet(readworkbook, para, list1, list2);
                        savepath     = SaveFile(readworkbook, filename, para);
                    }
                }
                else
                {
                    SystemLog.GetInstance().Info("导出错误:模板信息不存在!");
                }
            }
            catch (Exception e)
            {
                SystemLog.GetInstance().Error(e);
            }
            return(savepath);
        }
コード例 #2
0
        private static void AnyMethod(IForecast anyClass)
        {
            Console.Write(anyClass.GetType() + " ");
            var value = anyClass.GetForecast(10);

            Console.WriteLine(value);
        }
コード例 #3
0
        static void Main()
        {
            var first  = new First();
            var second = new Second();

            AnyMethod(first);
            AnyMethod(second);
            Console.WriteLine("*************");

            IForecast any;
            var       key = Console.ReadKey(true);

            if (key.Key == ConsoleKey.Enter)
            {
                any = new First();
            }
            else
            {
                any = new Second();
            }
            Console.WriteLine(any.Size);

            var array = new IForecast[2];

            array[0] = new First();
            array[1] = new Second();
            var summ = 0;

            foreach (var forecast in array)
            {
                summ += forecast.Size;
            }
            Console.WriteLine(summ);

            Console.WriteLine("Base class:");

            IForecast frc;

            frc = new Second();
            var frcBase = (BaseClass)frc;
            var result  = frcBase.GetValue(45);

            Console.WriteLine(result);

            Console.WriteLine("two interfeses:");

            var third = new Third {
                Size = 10
            };

            var bad  = (IForecast)third;
            var good = (IForecast2)third;

            var v1 = bad.GetForecast(100);
            var v2 = good.GetForecast(100);

            Console.WriteLine(v1 + v2);

            Console.ReadKey();
        }
コード例 #4
0
        public void ForecastComparisonVehicleSave(IForecast forecastToSave,
                                                  IVehicle vehicleToSave,
                                                  IDbConnection connection,
                                                  IDbTransaction transaction,
                                                  int vehicleIndex)
        {
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    para.Add("@ProgrammeId", vehicleToSave.ProgrammeId, DbType.Int32);
                    para.Add("@VehicleIndex", vehicleIndex, DbType.Int32);
                    para.Add("@ForecastComparisonId", null, DbType.Int32, ParameterDirection.Output);

                    connection.Execute("Fdp_ForecastComparisonVehicle_Save", para, commandType: CommandType.StoredProcedure, transaction: transaction);

                    para.Get <int>("@ForecastComparisonId");
                }
                catch (SqlException sqex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonVehicleSave", sqex.Message, CurrentCDSID);
                    throw new ApplicationException("Data store error", sqex);
                }
                catch (ApplicationException ex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonVehicleSave", ex.Message, CurrentCDSID);
                    throw;
                }
            }
        }
コード例 #5
0
        public IForecast SaveForecast(IForecast forecastToSave)
        {
            var success = _forecastDataSource.ForecastSave(forecastToSave);
            if (!success)
                return null;

            return forecastToSave;
        }
コード例 #6
0
        public void HydrateComparisonVehicleTrimMappings(IForecast forecast, IVehicle comparisonVehicle)
        {
            //var programme = forecast.ForecastVehicle.Programmes.First();

            //comparisonVehicle.TrimMappings = forecast.ForecastVehicle.Programmes.AllTrims
            //    .Select(t => new TrimMapping() {
            //        ForecastVehicleTrim = t,
            //        ComparisonVehicleTrimMappings = new List<ModelTrim>()
            //    }).ToList();
        }
コード例 #7
0
        private static async Task <IVehicle> InitialiseForecastVehicle(IForecast forecast, IDataContext context)
        {
            if (forecast.ForecastVehicle is EmptyVehicle)
            {
                return(forecast.ForecastVehicle);
            }

            forecast.ForecastVehicle = (Vehicle)(await InitialiseVehicle(forecast.ForecastVehicle, context));
            return(forecast.ForecastVehicle);
        }
コード例 #8
0
        public IForecast SaveForecast(IForecast forecastToSave)
        {
            var success = _forecastDataSource.ForecastSave(forecastToSave);

            if (!success)
            {
                return(null);
            }

            return(forecastToSave);
        }
コード例 #9
0
        public IForecast DeleteForecast(IForecast forecastToDelete)
        {
            if (forecastToDelete == null || !forecastToDelete.Id.HasValue)
                return null;

            var success = _forecastDataSource.ForecastDelete(forecastToDelete.Id.Value);
            if (!success)
                return null;

            return GetForecast(forecastToDelete.Id.Value);
        }
コード例 #10
0
        public void ForecastComparisonVehiclesSave(IForecast forecastToSave,
                                                   IDbConnection connection,
                                                   IDbTransaction transaction)
        {
            var vehicleIndex = 1;

            foreach (var comparisonVehicle in forecastToSave.ComparisonVehicles)
            {
                ForecastComparisonVehicleSave(forecastToSave, comparisonVehicle, connection, transaction, vehicleIndex++);
            }
        }
コード例 #11
0
        public void HydrateComparisonVehiclesTrimMappings(IForecast forecast)
        {
            if (forecast.ComparisonVehicles == null || !forecast.ComparisonVehicles.Any())
            {
                return;
            }

            foreach (var comparisonVehicle in forecast.ComparisonVehicles)
            {
                HydrateComparisonVehicleTrimMappings(forecast, comparisonVehicle);
            }
        }
コード例 #12
0
 public void ForecastComparisonTrimSave(IForecast forecastToSave,
                                        IDbConnection connection,
                                        IDbTransaction transaction)
 {
     //foreach (var mapping in forecastToSave.TrimMappings)
     //{
     //    if (mapping.ComparisonVehicleTrimId.HasValue)
     //    {
     //        ForecastComparisonTrimSave(forecastToSave, mapping, connection, transaction);
     //    }
     //    else
     //    {
     //        ForecastComparisonTrimDelete(forecastToSave, mapping, connection, transaction);
     //    }
     //}
 }
コード例 #13
0
        public IForecast DeleteForecast(IForecast forecastToDelete)
        {
            if (forecastToDelete == null || !forecastToDelete.Id.HasValue)
            {
                return(null);
            }

            var success = _forecastDataSource.ForecastDelete(forecastToDelete.Id.Value);

            if (!success)
            {
                return(null);
            }

            return(GetForecast(forecastToDelete.Id.Value));
        }
コード例 #14
0
        private void GenerateForecast(IUser user)
        {
            IForecast forecast = Sage.Platform.EntityFactory.Create <IForecast>();

            forecast.AssignedTo  = user;
            forecast.BeginDate   = (DateTime)Platform.FirstDayofPeriod(DateTime.Now);
            forecast.EndDate     = (DateTime)Platform.LastDayofPeriod(forecast.BeginDate);
            forecast.Description = forecast.GetFormattedDescription();
            forecast.Active      = true;
            forecast.Save();

            // for some reason, need to requery the record that was just saved.
            forecast = Sage.Platform.EntityFactory.GetById <IForecast>(forecast.Id.ToString());
            forecast.PullInOpportunities();
            forecast.Amount = Convert.ToDecimal(forecast.PeriodClosedWonAmt() + forecast.PeriodPipelineAmt("Avg"));
            forecast.Save();
        }
コード例 #15
0
        public async Task <IForecast> GetForecast(ForecastFilter filter)
        {
            IForecast forecast = null;

            if (!filter.ForecastId.HasValue)
            {
                throw new ArgumentNullException("ForecastId not specified");
            }

            forecast = await Task.FromResult <IForecast>(_forecastDataStore.ForecastGet(filter.ForecastId.Value));

            if (forecast == null)
            {
                throw new ArgumentException(string.Format("Forecast {0} not found", filter.ForecastId.Value));
            }

            //await HydrateForecast(forecast);

            return(forecast);
        }
コード例 #16
0
        //public Forecast ForecastTrimMappingGet(int forecastId)
        //{
        //    using (IDbConnection conn = DbHelper.GetDBConnection())
        //    {
        //        try
        //        {
        //            var para = new DynamicParameters();
        //            para.Add("@ForecastId", forecastId, dbType: DbType.Int32);

        //            var results = conn.QueryMultiple("dbo.Fdp_ForecastMappedTrim_Get", para, commandType: CommandType.StoredProcedure);

        //            // First resultset represents forecast vehicle trim information

        //            forecast = results.Read<Forecast>().FirstOrDefault();

        //            // Second resultset represents the comparison vehicles trim and any mapping information

        //            if (forecast != null)
        //            {
        //                forecast.ForecastVehicle = results.Read<Vehicle>().FirstOrDefault();
        //            }

        //            // Final resultset represents the comparison vehicles

        //            if (forecast != null)
        //            {
        //                forecast.ComparisonVehicles = results.Read<Vehicle>();
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            AppHelper.LogError("ForecastDataStore.ForecastGet", ex.Message, CurrentCDSID);
        //            throw;
        //        }
        //    }
        //}

        public IForecast ForecastSave(IForecast forecastToSave)
        {
            try
            {
                using (var connection = DbHelper.GetDBConnection())
                {
                    var para = new DynamicParameters();

                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32, ParameterDirection.InputOutput);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    para.Add("@ProgrammeId", forecastToSave.ForecastVehicle.ProgrammeId, DbType.Int32);
                    para.Add("@Gateway", forecastToSave.ForecastVehicle.Gateway, DbType.String, size: 50);

                    var trans = connection.BeginTransaction();

                    connection.Execute("Fdp_Forecast_Save", para, commandType: CommandType.StoredProcedure, transaction: trans);

                    if (!forecastToSave.ForecastId.HasValue)
                    {
                        forecastToSave.ForecastId = para.Get <int>("@ForecastId");
                    }

                    ForecastComparisonVehiclesSave(forecastToSave, connection, trans);
                    ForecastComparisonTrimSave(forecastToSave, connection, trans);

                    trans.Commit();
                }
            }
            catch (SqlException sqex)
            {
                AppHelper.LogError("ForecastDataStore.ForecastSave", sqex.Message, CurrentCDSID);
                throw new ApplicationException("Database store error", sqex);
            }
            catch (ApplicationException ex)
            {
                AppHelper.LogError("ForecastDataStore.ForecastSave", ex.Message, CurrentCDSID);
                throw;
            }

            return(forecastToSave);
        }
コード例 #17
0
        /// <summary>
        /// Initialises the comparison vehicles.
        /// The list is re-ordered, placing empty vehicles at the end of the list
        /// </summary>
        private static async void InitialiseComparisonVehicles(IForecast forecast, IDataContext context)
        {
            var newComparisonVehicles = EmptyVehicleList.CreateEmptyVehicleList();
            var nonEmptyVehicles      = new List <IVehicle>();

            foreach (var comparisonVehicle in forecast.ComparisonVehicles)
            {
                if (comparisonVehicle is EmptyVehicle)
                {
                    continue;
                }
                nonEmptyVehicles.Add(await InitialiseVehicle(comparisonVehicle, context));
            }

            for (var i = 0; i < nonEmptyVehicles.Count(); i++)
            {
                newComparisonVehicles[i] = nonEmptyVehicles[i];
            }

            forecast.ComparisonVehicles = newComparisonVehicles.Cast <Vehicle>();
        }
コード例 #18
0
        public void ForecastComparisonTrimSave(IForecast forecastToSave,
                                               ForecastTrimMapping mappingToSave,
                                               IDbConnection connection,
                                               IDbTransaction transaction)
        {
            using (DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    //para.Add("@ForecastVehicleTrimId", mappingToSave.ForecastVehicleTrimId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleProgrammeId", mappingToSave.ComparisonVehicleProgrammeId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleTrimId", mappingToSave.ComparisonVehicleTrimId.Value, dbType: DbType.Int32);
                    para.Add("@ForecastComparisonTrimId", null, DbType.Int32, ParameterDirection.Output);

                    connection.Execute("Fdp_ForecastComparisonTrim_Save", para, commandType: CommandType.StoredProcedure, transaction: transaction);

                    //if (!mappingToSave.Id.HasValue)
                    //{
                    //    mappingToSave.Id = para.Get<int>("@ForecastComparisonTrimId");
                    //}
                }
                catch (SqlException sqex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimSave", sqex.Message, CurrentCDSID);
                    throw new ApplicationException("Data store error", sqex);
                }
                catch (ApplicationException ex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimSave", ex.Message, CurrentCDSID);
                    throw;
                }
            }
        }
コード例 #19
0
        public void ForecastComparisonTrimDelete(IForecast forecastToSave,
                                                 ForecastTrimMapping mappingToDelete,
                                                 IDbConnection connection,
                                                 IDbTransaction transaction)
        {
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    //para.Add("@ForecastVehicleTrimId", mappingToDelete.ForecastVehicleTrimId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleProgrammeId", mappingToDelete.ComparisonVehicleProgrammeId, dbType: DbType.Int32);

                    connection.Execute("Fdp_ForecastComparisonTrim_Delete", para, commandType: CommandType.StoredProcedure, transaction: transaction);
                }
                catch (Exception ex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimDelete", ex.Message, CurrentCDSID);
                    throw;
                }
            }
        }
コード例 #20
0
        public void HydrateComparisonVehiclesTrimMappings(IForecast forecast)
        {
            if (forecast.ComparisonVehicles == null || !forecast.ComparisonVehicles.Any())
                return;

            foreach (var comparisonVehicle in forecast.ComparisonVehicles)
            {
                HydrateComparisonVehicleTrimMappings(forecast, comparisonVehicle);
            }
        }
コード例 #21
0
 public Task<IForecast> DeleteForecastAsync(IForecast forecastToDelete)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
 public IForecast DeleteForecast(IForecast forecastToDelete)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 public Task<IForecast> SaveForecastAsync(IForecast forecastToSave)
 {
     throw new NotImplementedException();
 }
コード例 #24
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IForecast forecast)
 {
     _logger    = logger;
     m_forecast = forecast;
 }
コード例 #25
0
        /// <summary>
        /// 预测导出--如果需要将入出口数据进行区分,则分别放在两个list的集合中,若不需区分,则将数据放入list1中,list2为空即可
        /// </summary>
        /// <param name="path"></param>
        /// <param name="para"></param>
        /// <param name="forecase"></param>
        /// <param name="list1">出口</param>
        /// <param name="list2">入口</param>
        /// <returns></returns>
        public string ExportExcel(string path, QueryParameters para, IForecast forecase, List<IReportViewModel> list1, List<IReportViewModel> list2)
        {
            string[] num = path.Split('\\');
            string filename = num[num.Length - 1].Split('.')[0] + "(预测).xlsx";
            string savepath = string.Empty;
            try
            {

                if (System.IO.File.Exists(path))
                {
                    using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {

                        IWorkbook readworkbook = new XSSFWorkbook(stream);
                        stream.Close();
                        readworkbook = forecase.GenerateSheet(readworkbook, para, list1, list2);
                        savepath = SaveFile(readworkbook, filename, para);
                    }
                }
                else
                {
                    SystemLog.GetInstance().Info("导出错误:模板信息不存在!");
                }
            }
            catch (Exception e)
            {
                SystemLog.GetInstance().Error(e);
            }
            return savepath;
        }
コード例 #26
0
        public void ForecastComparisonTrimSave( IForecast forecastToSave, 
												ForecastTrimMapping mappingToSave,
												IDbConnection connection,
												IDbTransaction transaction)
        {
            using (DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    //para.Add("@ForecastVehicleTrimId", mappingToSave.ForecastVehicleTrimId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleProgrammeId", mappingToSave.ComparisonVehicleProgrammeId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleTrimId", mappingToSave.ComparisonVehicleTrimId.Value, dbType: DbType.Int32);
                    para.Add("@ForecastComparisonTrimId", null, DbType.Int32, ParameterDirection.Output);

                    connection.Execute("Fdp_ForecastComparisonTrim_Save", para, commandType: CommandType.StoredProcedure, transaction: transaction);

                    //if (!mappingToSave.Id.HasValue)
                    //{
                    //    mappingToSave.Id = para.Get<int>("@ForecastComparisonTrimId");
                    //}
                }
                catch (SqlException sqex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimSave", sqex.Message, CurrentCDSID);
                    throw new ApplicationException("Data store error", sqex);
                }
                catch (ApplicationException ex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimSave", ex.Message, CurrentCDSID);
                    throw;
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// Initialises the comparison vehicles.
        /// The list is re-ordered, placing empty vehicles at the end of the list
        /// </summary>
        private static async void InitialiseComparisonVehicles(IForecast forecast, IDataContext context)
        {
            var newComparisonVehicles = EmptyVehicleList.CreateEmptyVehicleList();
            var nonEmptyVehicles = new List<IVehicle>();

            foreach (var comparisonVehicle in forecast.ComparisonVehicles)
            {
                if (comparisonVehicle is EmptyVehicle)
                {
                    continue;
                }
                nonEmptyVehicles.Add(await InitialiseVehicle(comparisonVehicle, context));
            }

            for (var i = 0; i < nonEmptyVehicles.Count(); i++)
            {
                newComparisonVehicles[i] = nonEmptyVehicles[i];
            }

            forecast.ComparisonVehicles = newComparisonVehicles.Cast<Vehicle>();
        }
コード例 #28
0
	    public void ForecastComparisonTrimDelete(   IForecast forecastToSave, 
												    ForecastTrimMapping mappingToDelete,
												    IDbConnection connection,
												    IDbTransaction transaction)
        {
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
                    para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
                    //para.Add("@ForecastVehicleTrimId", mappingToDelete.ForecastVehicleTrimId, dbType: DbType.Int32);
                    //para.Add("@ComparisonVehicleProgrammeId", mappingToDelete.ComparisonVehicleProgrammeId, dbType: DbType.Int32);

                    connection.Execute("Fdp_ForecastComparisonTrim_Delete", para, commandType: CommandType.StoredProcedure, transaction: transaction);
                }
                catch (Exception ex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonTrimDelete", ex.Message, CurrentCDSID);
                    throw;
                }
            }
        }
コード例 #29
0
		public void ForecastComparisonVehicleSave(  IForecast forecastToSave, 
												    IVehicle vehicleToSave,
												    IDbConnection connection,
												    IDbTransaction transaction,
												    int vehicleIndex)
		{
			using (var conn = DbHelper.GetDBConnection())
			{
				try
				{
				    var para = new DynamicParameters();
					para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32);
					para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
					para.Add("@ProgrammeId", vehicleToSave.ProgrammeId, DbType.Int32);
					para.Add("@VehicleIndex", vehicleIndex, DbType.Int32);
                    para.Add("@ForecastComparisonId", null, DbType.Int32, ParameterDirection.Output);

					connection.Execute("Fdp_ForecastComparisonVehicle_Save", para, commandType: CommandType.StoredProcedure, transaction: transaction);

                    para.Get<int>("@ForecastComparisonId");
				}
                catch (SqlException sqex)
                {
                    AppHelper.LogError("ForecastDataStore.ForecastComparisonVehicleSave", sqex.Message, CurrentCDSID);
                    throw new ApplicationException("Data store error", sqex);
                }
				catch (ApplicationException ex)
				{
					AppHelper.LogError("ForecastDataStore.ForecastComparisonVehicleSave", ex.Message, CurrentCDSID);
					throw;
				}
			}
		}
コード例 #30
0
 public Task <IForecast> DeleteForecastAsync(IForecast forecastToDelete)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
 public Task <IForecast> SaveForecastAsync(IForecast forecastToSave)
 {
     throw new NotImplementedException();
 }
コード例 #32
0
        public void ForecastComparisonVehiclesSave( IForecast forecastToSave,
                                                    IDbConnection connection,
												    IDbTransaction transaction)
        {
            var vehicleIndex = 1;
            foreach (var comparisonVehicle in forecastToSave.ComparisonVehicles)
            {
                ForecastComparisonVehicleSave(forecastToSave, comparisonVehicle, connection, transaction, vehicleIndex++);
            }
        }
コード例 #33
0
		//public Forecast ForecastTrimMappingGet(int forecastId)
		//{
		//    using (IDbConnection conn = DbHelper.GetDBConnection())
		//    {
		//        try
		//        {
		//            var para = new DynamicParameters();
		//            para.Add("@ForecastId", forecastId, dbType: DbType.Int32);

		//            var results = conn.QueryMultiple("dbo.Fdp_ForecastMappedTrim_Get", para, commandType: CommandType.StoredProcedure);

		//            // First resultset represents forecast vehicle trim information

		//            forecast = results.Read<Forecast>().FirstOrDefault();

		//            // Second resultset represents the comparison vehicles trim and any mapping information

		//            if (forecast != null)
		//            {
		//                forecast.ForecastVehicle = results.Read<Vehicle>().FirstOrDefault();
		//            }

		//            // Final resultset represents the comparison vehicles

		//            if (forecast != null)
		//            {
		//                forecast.ComparisonVehicles = results.Read<Vehicle>();
		//            }
		//        }
		//        catch (Exception ex)
		//        {
		//            AppHelper.LogError("ForecastDataStore.ForecastGet", ex.Message, CurrentCDSID);
		//            throw;
		//        }
		//    }
		//}

		public IForecast ForecastSave(IForecast forecastToSave)
		{
			try
			{
				using (var connection = DbHelper.GetDBConnection())
				{
					var para = new DynamicParameters();

					para.Add("@ForecastId", forecastToSave.ForecastId, DbType.Int32, ParameterDirection.InputOutput);
					para.Add("@SystemUser", CurrentCDSID, DbType.String, size: 16);
					para.Add("@ProgrammeId", forecastToSave.ForecastVehicle.ProgrammeId, DbType.Int32);
					para.Add("@Gateway", forecastToSave.ForecastVehicle.Gateway, DbType.String, size: 50);

					var trans = connection.BeginTransaction();

					connection.Execute("Fdp_Forecast_Save", para, commandType: CommandType.StoredProcedure, transaction: trans);

					if (!forecastToSave.ForecastId.HasValue)
					{
						forecastToSave.ForecastId = para.Get<int>("@ForecastId");
					}

                    ForecastComparisonVehiclesSave(forecastToSave, connection, trans);
                    ForecastComparisonTrimSave(forecastToSave, connection, trans);

					trans.Commit();
				}
			}
            catch (SqlException sqex)
            {
                AppHelper.LogError("ForecastDataStore.ForecastSave", sqex.Message, CurrentCDSID);
                throw new ApplicationException("Database store error", sqex);
            }
            catch (ApplicationException ex)
            {
                AppHelper.LogError("ForecastDataStore.ForecastSave", ex.Message, CurrentCDSID);
                throw;
            }

			return forecastToSave;
		}
コード例 #34
0
        public void ForecastComparisonTrimSave( IForecast forecastToSave,
                                                IDbConnection connection,
												IDbTransaction transaction)
        {
            //foreach (var mapping in forecastToSave.TrimMappings)
            //{
            //    if (mapping.ComparisonVehicleTrimId.HasValue)
            //    {
            //        ForecastComparisonTrimSave(forecastToSave, mapping, connection, transaction);
            //    }
            //    else
            //    {
            //        ForecastComparisonTrimDelete(forecastToSave, mapping, connection, transaction);
            //    }
            //}
        }
コード例 #35
0
        public void HydrateComparisonVehicleTrimMappings(IForecast forecast, IVehicle comparisonVehicle)
        {
            //var programme = forecast.ForecastVehicle.Programmes.First();

            //comparisonVehicle.TrimMappings = forecast.ForecastVehicle.Programmes.AllTrims
            //    .Select(t => new TrimMapping() {
            //        ForecastVehicleTrim = t,
            //        ComparisonVehicleTrimMappings = new List<ModelTrim>()
            //    }).ToList();
        }
コード例 #36
0
        public IForecast SaveForecast(IForecast forecastToSave)
        {
            forecastToSave = _forecastDataStore.ForecastSave(forecastToSave);

            return forecastToSave;
        }
コード例 #37
0
        public IForecast SaveForecast(IForecast forecastToSave)
        {
            forecastToSave = _forecastDataStore.ForecastSave(forecastToSave);

            return(forecastToSave);
        }
コード例 #38
0
        private static async void InitialiseForecast(IForecast forecast, IDataContext context)
        {
            await InitialiseForecastVehicle(forecast, context);

            InitialiseComparisonVehicles(forecast, context);
        }
コード例 #39
0
 public IForecast DeleteForecast(IForecast forecastToDelete)
 {
     throw new NotImplementedException();
 }
コード例 #40
0
ファイル: Smart.cs プロジェクト: Inumedia/Smart
 public Smart(IForecast weather, IGeoTranslate geo)
 {
     this.geo = geo;
     this.weather = weather;
 }
コード例 #41
0
 private static async void InitialiseForecast(IForecast forecast, IDataContext context)
 {
     await InitialiseForecastVehicle(forecast, context);
     InitialiseComparisonVehicles(forecast, context);
 }
コード例 #42
0
        private static async Task<IVehicle> InitialiseForecastVehicle(IForecast forecast, IDataContext context)
        {
            if (forecast.ForecastVehicle is EmptyVehicle)
            {
                return forecast.ForecastVehicle;
            }

            forecast.ForecastVehicle = (Vehicle)(await InitialiseVehicle(forecast.ForecastVehicle, context));
            return forecast.ForecastVehicle;
        }
コード例 #43
0
        /// <summary>
        /// Sends the forecast.
        /// </summary>
        /// <param name="targets">The targets.</param>
        /// <param name="messageFormat">The message format.</param>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="forecast">The forecast.</param>
        /// <returns>
        /// The forecasts.
        /// </returns>
        private static IEnumerable<IResponse> CreateForecastResponses(IEnumerable<string> targets, MessageFormat messageFormat, MessageType messageType, IForecast forecast)
        {
            try
            {
                var responses = new List<IResponse>();

                foreach (var day in forecast.TextualForecast.ForecastDays)
                {
                    responses.Add(new Response(day.ForecastTextMetric, targets, messageFormat, messageType));
                }

                return responses;
            }
            catch (Exception e)
            {
                Trace.TraceError(e.TargetSite.Name);
                Trace.TraceError(e.Message);
            }

            return Enumerable.Empty<IResponse>();
        }
コード例 #44
0
 public Smart(IForecast weather, IGeoTranslate geo)
 {
     this.geo     = geo;
     this.weather = weather;
 }