예제 #1
0
 public MetricService(string connectionString)
 {
     _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
     _factory.Run(db => db.CreateTable<Metric>(overwrite: false));
     _factory.Run(db => db.CreateTable<Message>(overwrite: false));
     _factory.Run(db => db.CreateTable<Trend>(overwrite: false));
 }
예제 #2
0
        public FileSystemQueue(string baseDirectory, string connectionString, bool includSubdirectories = true)
        {
            _baseDirectory = baseDirectory;
            _connectionString = connectionString;

            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db => db.CreateTable<WatchedFile>(overwrite: false));
        }
        public QuestionAnswerService(string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db =>
            {
                db.CreateTable<QuestionAnswer>(overwrite: false);
            });

            var svc = new AnswerService(connectionString);
        }
예제 #4
0
 public ProfileService(string connectionString)
 {
     _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
     _factory.Run(db =>
     {
         db.CreateTable<ProfileAuthData>(overwrite: false);
         db.CreateTable<Profile>(overwrite: false);
         db.CreateTable<Position>(overwrite: false);
         db.CreateTable<Company>(overwrite: false);
     });
 }
예제 #5
0
        public SurveyService(string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db =>
            {
                db.CreateTable<Survey>(overwrite: false);

                if (db.Count<Survey>() == 0)
                {
                    db.Insert<Survey>(new Survey { Id = 1, Name = "My First Survey", Description = "This is the first survey.", ButtonText = "Let's Get Started!"});
                }
            });

            var svc = new SegmentService(connectionString);
        }
예제 #6
0
        public SegmentService(string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db =>
            {
                db.CreateTable<Segment>(overwrite: false);

                if (db.Count<Segment>() == 0)
                {
                    db.Insert<Segment>(new Segment { Id = 1, SurveyId = 1, Order = 1, Name = "First Questions", Description = "Answer some simple questions.", ButtonText = "Start" });
                    db.Insert<Segment>(new Segment { Id = 2, SurveyId = 1, Order = 2, Name = "Second Questions", Description = "Answer some more complex questions.", ButtonText = "Start" });
                }
            });

            var svc = new QuestionService(connectionString);
        }
예제 #7
0
        public QuestionService(string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db =>
            {
                db.CreateTable<Question>(overwrite: false);

                if (db.Count<Question>() == 0)
                {
                    db.Insert<Question>(new Question { Id = 1, Order = 1, SegmentId = 1, Text = "What is your favorite color?" });
                    db.Insert<Question>(new Question { Id = 2, Order = 2, SegmentId = 1, Text = "What is your quest?" });

                    db.Insert<Question>(new Question { Id = 3, Order = 1, SegmentId = 2, Text = "One more question?" });
                }
            });

            var svc = new AnswerService(connectionString);
        }
예제 #8
0
        public AnswerService(string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db =>
            {
                db.CreateTable<Answer>(overwrite: false);

                if (db.Count<Answer>() == 0)
                {
                    db.Insert<Answer>(new Answer { Id = 1, QuestionId = 1, Text = "Green" });
                    db.Insert<Answer>(new Answer { Id = 2, QuestionId = 1, Text = "Yellow" });
                    db.Insert<Answer>(new Answer { Id = 3, QuestionId = 2, Text = "I seek the grail." });
                    db.Insert<Answer>(new Answer { Id = 4, QuestionId = 2, Text = "I don't know." });
                    db.Insert<Answer>(new Answer { Id = 5, QuestionId = 3, Text = "Yes" });
                    db.Insert<Answer>(new Answer { Id = 6, QuestionId = 3, Text = "No" });
                }
            });
        }
예제 #9
0
        public FileSystemMonitor(string baseDirectory, string connectionString)
        {
            _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
            _factory.Run(db => db.CreateTable<WatchedFile>(overwrite: false));

            _watcher = new FileSystemWatcher();
            _watcher.Path = baseDirectory;
            _watcher.IncludeSubdirectories = true;

            // we only care about file changes, not directories and we only care about size changes and writes
            _watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.FileName;

            //// Only watch text files.
            //_watcher.Filter = "*.txt";

            _watcher.Changed += new FileSystemEventHandler(OnChanged);
            _watcher.Created += new FileSystemEventHandler(OnCreated);
            _watcher.Deleted += new FileSystemEventHandler(OnDeleted);
            _watcher.Renamed += new RenamedEventHandler(OnRenamed);

            _watcher.EnableRaisingEvents = true;
        }
        public void Save(string ticker, string source, bool quarterly, string description)
        {
            var factory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["StockScreenerConnection"].ConnectionString, SqlServerDialect.Provider);
            factory.Run(db => db.CreateTable<DiscountCashFlowHeader>(overwrite: false));
            factory.Run(db => db.CreateTable<DiscountCashFlowYear>(overwrite: false));

            using (IDbConnection db = factory.OpenDbConnection())
            {
                var headers = db.Select<DiscountCashFlowHeader>(h => h.Ticker == ticker && h.Source == source && h.IsQuarterly == quarterly);
                db.Delete<DiscountCashFlowHeader>(h => h.Ticker == ticker && h.Source == source && h.IsQuarterly == quarterly);

                if (null != headers)
                {
                    foreach (var h in headers)
                    {
                        db.Delete<DiscountCashFlowYear>(y => y.DiscoutCashFlowHeaderId == h.Id);
                    }
                }

                // create header
                DiscountCashFlowHeader header = new DiscountCashFlowHeader
                {
                    Ticker = ticker,
                    IsQuarterly = quarterly,
                    Source = source,
                    Description = description,
                    StartingFcF = this.FreeCashFlow,
                    GrowthRate = this.GrowthRate,
                    DiscountRate = this.DiscountRate,
                    TerminalGrowthRate = this.TerminalGrowthRate,
                    NetDebt = this.NetDebt,
                    SharesOutstanding = this.SharesOutstanding,
                    GrowthTerminalValue = this.GrowthTerminalValue,
                    TenYearTerminalValue = this.TenYearTerminalValue,
                    GrowthEnterpriseValue = this.GrowthEnterpriseValue,
                    TenYearEnterpriseValue = this.TenYearEnterpriseValue
                };
                db.Insert(header);
                header.Id = (int) db.GetLastInsertId();

                // create yearly records
                foreach (int i in this.FutureFreeCashFlow.Keys)
                {
                    DiscountCashFlowYear dcfy = new DiscountCashFlowYear
                    {
                        DiscoutCashFlowHeaderId = header.Id,
                        FutureFreeCashFlow = this.FutureFreeCashFlow[i],
                        PresentFreeCashFlow = this.PresentFreeCashFlow[i],
                        TerminalFreeCashFlow = this.TerminalFreeCashFlow[i],
                        TerminalPresentFreeCashFlow = this.TerminalPresentFreeCashFlow[i]
                    };

                    db.Insert(dcfy);
                }
            }
        }
 public FinancialModelService()
 {
     _factory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["StockScreenerConnection"].ConnectionString, SqlServerDialect.Provider);
     _factory.Run(db => db.CreateTable<GrahamAnalysis>(overwrite: false));
     _metricService = new FinancialMetricService();
 }
예제 #12
0
 public PluginSettingsService(string connectionString)
 {
     _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
     _factory.Run(db => db.CreateTable<PluginSettings>(overwrite: false));
 }
예제 #13
0
파일: Main.cs 프로젝트: aicl/Cayita.Tools
		public static void Main (string[] args)
		{
			var strCon = ConfigUtils.GetConnectionString("ApplicationDb");

			string tmp = strCon;
			Console.WriteLine("Digite la cadena de conexion  [{0}] Enter para continuar", strCon);
			strCon= Console.ReadLine();
			if(strCon.IsNullOrEmpty()) strCon=tmp;

			OrmLiteConfig.DialectProvider = MySqlDialect.Provider;

			var dbFactory = new OrmLiteConnectionFactory(strCon);
									
			OrmLiteAuthRepository authRepo = new OrmLiteAuthRepository(	dbFactory);

			AuthRepoProxy rp = new AuthRepoProxy(dbFactory, null);

			rp.CreateAuthTables(authRepo,false);

			rp.SetEngine (authRepo);

			string password = rp.CreateRandomPassword(8);

			tmp = password;
			Console.WriteLine("Digite la clave para {0} [{1}] Enter para continuar", "admin", password);
			password= Console.ReadLine();
			if(password.IsNullOrEmpty()) password=tmp;

			password= rp.CreateAdminUser(authRepo, "Admin", "App", "*****@*****.**", password);


			//

			password = rp.CreateRandomPassword(8);
			
			tmp = password;
			Console.WriteLine("Digite la clave para {0} [{1}] Enter para continuar", "user", password);
			password= Console.ReadLine();
			if(password.IsNullOrEmpty()) password=tmp;
			UserAuth user = new UserAuth{ UserName="******", Email="*****@*****.**"};

			password= rp.CreateUser (authRepo, user,password);
			Console.WriteLine(password);


			dbFactory.Run (c => {
				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Radicar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Radicar", Title = "Recepcionista"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Asignar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Asignar", Title = "Secretario General"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Solucionar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Solucionar", Title = "Abogado"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Firmar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Firmar", Title = "Abogado"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="RegistrarFirmar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "RegistrarFirmar", Title = "Recepcionista"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Alistar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Alistar", Title = "Recepcionista"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Entregar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Entregar", Title = "Mensajero"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Cerrar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Cerrar", Title = "Recepcionista"});

				if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Consultar")==default(AuthRole))
					c.Insert<AuthRole>(new AuthRole{Name = "Consultar", Title = "Público"});


			});

		}
예제 #14
0
 public SubscriberService(string connectionString)
 {
     _factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
     _factory.Run(db => db.CreateTable<Subscriber>(overwrite: false));
 }