Exemplo n.º 1
0
        public static bool GetCheckUser(string UserCode, string UserPass)
        {
            string sSql = @"";

            sSql += "   SELECT  COUNT(*) ";
            sSql += "   FROM    USER_MST";
            sSql += "   WHERE   USER_CODE = '" + UserCode + "'";
            sSql += "   AND     PASSWORD  = '******'";

            DataSet ds;

            using (var db = new MSSQLDB())
            {
                ds = db.Query(sSql);

                if (ds.Tables[0].Rows[0][0].ToString() == "0")
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public static DataSet GetSearchReg(string Search_name, string Search_class)
        {
            string sSql = @"";

            sSql += "   SELECT  STOCK_CODE, STOCK_NAME, STOCK_CLASS1, STOCK_CLASS2, STOCK_REMARK ";
            sSql += "   FROM    STOCK_CLASS";
            sSql += "   WHERE   1   =   1 ";
            if (string.IsNullOrEmpty(Search_name) && string.IsNullOrEmpty(Search_class))
            {
                sSql += "   AND 1   =   2 ";
            }
            else
            {
                sSql += "   AND  ( STOCK_CODE LIKE '%" + Search_name + "%'" + " OR STOCK_NAME LIKE '%" + Search_name + "%')";
                sSql += "   AND  ( STOCK_CLASS1 LIKE '%" + Search_class + "%'" + " OR STOCK_CLASS2 LIKE '%" + Search_class + "%')";
            }
            sSql += "   ORDER BY STOCK_NAME";


            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
Exemplo n.º 3
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _SREP      = new StudentRepository(conection);
            _encryptor = new Encryptor();
            handler    = new StudentQueryHandler(_SREP);

            var db = conection.GetCon();

            // Create Course
            course = new Course(Guid.NewGuid(), "LTP5");
            var sql = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, @Name)";

            db.Execute(sql, param: new { Id = course.CourseId, Name = course.Name });

            var    cpf      = "964.377.278-02";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            student = new Student(course, DateTime.Now, "Abmael", "Araujo", cpf, "*****@*****.**", "(86) 2802-4826", "M", "Brasil", "Araguaina", "Centro", password, salt);
            _SREP.Create(student);

            commandGetById = new StudentInputGetById()
            {
                StudentId = student.Id
            };

            commandList = new StudentInputList();

            commandGetByCPF = new StudentInputGetByCPF()
            {
                StudentCPF = student.CPF.Number
            };
        }
Exemplo n.º 4
0
 public JournalController(MSSQLDB db, IConfiguration configuration, IMemoryCache memoryCache, MinioClient minioClient)
 {
     _db            = db;
     _configuration = configuration;
     _memoryCache   = memoryCache;
     _minioClient   = minioClient;
 }
        public static async Task InitializeJournalDownloadersAsync(PerformContext context)
        {
            context.WriteLine("Looking for journals do download!");

            using (var scope = Startup.ServiceProvider.CreateScope())
            {
                MSSQLDB db = scope.ServiceProvider.GetRequiredService<MSSQLDB>();
                IConfiguration configuration = scope.ServiceProvider.GetRequiredService<IConfiguration>();

                var usersToDownloadJournalsFor = await db.ExecuteListAsync<Shared.Models.User.Profile>(
    @"SELECT *
FROM user_profile
WHERE DATEDIFF(MINUTE, GETUTCDATE(), CAST(JSON_VALUE(user_settings, '$.TokenExpiration') as DATETIMEOFFSET)) > 10
AND last_notification_mail IS NULL
AND skip_download = 0
AND deleted = 0"
                );

                if (usersToDownloadJournalsFor.Count > 0)
                {
                    await SSEActivitySender.SendGlobalActivityAsync("Fetching journals from Elite", $"Downloading journals for {usersToDownloadJournalsFor.Count} users");
                }

                foreach (var user in usersToDownloadJournalsFor)
                {
                    if (RedisJobLock.IsLocked($"JournalDownloader.DownloadJournal.{user.UserIdentifier}")) continue;
                    BackgroundJob.Schedule(() => JournalDownloader.DownloadJournalAsync(user.UserIdentifier, null), TimeSpan.Zero);
                }
            }

            context.WriteLine("All done!");
        }
Exemplo n.º 6
0
        public static bool SetRegDelete(string Stock_Code, string User_ID)
        {
            string sSql = @"";

            sSql += "   DELETE FROM USER_STOCK ";
            sSql += "   WHERE STOCK_CODE = '" + Stock_Code + "'";
            sSql += "   AND   USER_ID = " + User_ID;

            int Result;

            using (var db = new MSSQLDB())
            {
                Result = db.Execute(sSql);
            }


            if (Result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public static DataSet GetSearchData2(
            string Search_name, string Search_class, string Search_per, string Search_gap
            , string Search_sa_rate, string Search_bp_rate, string Search_np_rate
            , string List_Type, string User_ID
            )
        {
            string sSql = @"";

            sSql += "   SELECT  A.STOCK_CODE, A.STOCK_NAME, STOCK_URL, TOTAL_AMT, SALES_AMT, BIZ_PROFIT, NET_PROFIT, PER, EST_PER, BIZ_PER, STOCK_PRICE, NAVER_PRICE, ";
            sSql += "           CAL_PSR, CAL_POR, CAL_PER, BIZ_RATE, NET_RATE, ";
            sSql += "           SA_Y3, SA_Y2, SA_Y1, SA_Y0, BP_Y3, BP_Y2, BP_Y1, BP_Y0, NP_Y3, NP_Y2, NP_Y1, NP_Y0, ";
            sSql += "           SA_RATE, BP_RATE, NP_RATE, ";
            sSql += "           B.STOCK_REMARK, ISNULL(LEN(B.STOCK_REMARK),0) as REMARK_LEN ";
            sSql += "   FROM    STOCK_INFO  A";
            sSql += "       ,   STOCK_CLASS B";
            sSql += "   WHERE   A.STOCK_CODE = B.STOCK_CODE ";
            sSql += "   AND   ( A.STOCK_CODE LIKE '%" + Search_name + "%'" + " OR A.STOCK_NAME LIKE '%" + Search_name + "%')";
            sSql += "   AND   ( A.STOCK_CLASS1 LIKE '%" + Search_class + "%'" + " OR A.STOCK_CLASS2 LIKE '%" + Search_class + "%')";
            //User별
            if (List_Type == "User")
            {
                sSql += "   AND   A.STOCK_CODE IN  ( SELECT C.STOCK_CODE FROM USER_STOCK C WHERE C.USER_ID = " + User_ID + " )";
            }

            if (!string.IsNullOrEmpty(Search_per) && Search_per != "")
            {
                sSql += "   AND     CAL_PER   <= " + Search_per;
            }

            if (!string.IsNullOrEmpty(Search_gap) && Search_gap != "")
            {
                sSql += "   AND  (  (NAVER_PRICE - STOCK_PRICE) / NAVER_PRICE * 100  >= " + Search_gap + " OR  (NAVER_PRICE - STOCK_PRICE) / NAVER_PRICE * 100 <=  (" + Search_gap + "*-1)  )";
                sSql += "   AND   NAVER_PRICE <> 0 ";
            }

            if (!string.IsNullOrEmpty(Search_sa_rate) && Search_sa_rate != "")
            {
                sSql += "   AND     SA_RATE   >= " + Search_sa_rate;
            }
            if (!string.IsNullOrEmpty(Search_bp_rate) && Search_bp_rate != "")
            {
                sSql += "   AND     BP_RATE   >= " + Search_bp_rate;
            }
            if (!string.IsNullOrEmpty(Search_np_rate) && Search_np_rate != "")
            {
                sSql += "   AND     NP_RATE   >= " + Search_np_rate;
            }
            sSql += "   ORDER BY TOTAL_AMT DESC";


            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
Exemplo n.º 8
0
 public async static Task <bool> UpdateJournalIntegrationDataAsync(MSSQLDB db, long journalId, string integrationKey, IntegrationJournalData integrationJournalData)
 {
     return((await db.ExecuteNonQueryAsync(
                 "UPDATE user_journal SET integration_data = JSON_MODIFY(ISNULL(integration_data, JSON_QUERY('{}')), '$.\"" + integrationKey + "\"', JSON_QUERY(@integration_data)) WHERE journal_id = @journal_id",
                 new SqlParameter("journal_id", journalId),
                 new SqlParameter("integration_data", JsonSerializer.Serialize(integrationJournalData))
                 )) > 0);
 }
Exemplo n.º 9
0
        public static DataSet GetSearchData3(
            string Search_name, string Search_class, string Search_buy_gap, string Search_sell_gap
            , string List_Type, string User_ID
            )
        {
            string sSql = @"";

            sSql += "   SELECT  A.STOCK_CODE, B.STOCK_NAME, B.STOCK_URL, B.STOCK_CLASS1, B.STOCK_PRICE, B.NAVER_PRICE, ";
            sSql += "           A.BUY_PRICE, A.SELL_PRICE, A.AVG_PRICE,  ";
            sSql += "           A.STOCK_REMARK, ISNULL(LEN(A.STOCK_REMARK),0) as REMARK_LEN, ";
            sSql += "           A.BUY_PRICE - B.STOCK_PRICE as BUY_GAP, ";
            sSql += "           ROUND(CASE A.BUY_PRICE WHEN 0 THEN 0 ELSE (A.BUY_PRICE - B.STOCK_PRICE) / A.BUY_PRICE * 100 END, 2) as BUY_GAP_RATE, ";
            sSql += "           A.SELL_PRICE - B.STOCK_PRICE as SELL_GAP, ";
            sSql += "           ROUND(CASE A.SELL_PRICE WHEN 0 THEN 0 ELSE (A.SELL_PRICE - B.STOCK_PRICE) / A.SELL_PRICE * 100 END, 2) as SELL_GAP_RATE, ";
            sSql += "           ROUND(CASE A.AVG_PRICE WHEN 0 THEN 0 ELSE (B.STOCK_PRICE - A.AVG_PRICE) / A.AVG_PRICE * 100 END,2) as AVG_GAP, ";
            sSql += "           (   SELECT   COUNT(*) REG_CNT ";
            sSql += "               FROM     USER_STOCK	C    ";
            sSql += "               WHERE    C.STOCK_CODE   = A.STOCK_CODE ) REG_CNT, ";
            sSql += "           (   SELECT   ISNULL(AVG(C.BUY_PRICE),0) BUY_AVG ";
            sSql += "               FROM     USER_STOCK	C    ";
            sSql += "               WHERE    C.STOCK_CODE   = A.STOCK_CODE  AND C.BUY_PRICE > 0 ) BUY_AVG, ";
            sSql += "           (   SELECT   ISNULL(AVG(C.SELL_PRICE),0) SELL_PRICE ";
            sSql += "               FROM     USER_STOCK	C    ";
            sSql += "               WHERE    C.STOCK_CODE   = A.STOCK_CODE  AND C.SELL_PRICE > 0 ) SELL_AVG, ";
            sSql += "           (   SELECT   ISNULL(AVG(C.AVG_PRICE),0) AVG_AVG ";
            sSql += "               FROM     USER_STOCK	C    ";
            sSql += "               WHERE    C.STOCK_CODE   = A.STOCK_CODE AND C.AVG_PRICE > 0) AVG_AVG ";

            sSql += "   FROM    USER_STOCK  A";
            sSql += "       ,   STOCK_INFO  B";
            sSql += "   WHERE   A.USER_ID    = " + User_ID;
            sSql += "   AND     B.STOCK_CODE = A.STOCK_CODE ";
            sSql += "   AND   ( B.STOCK_CODE LIKE '%" + Search_name + "%'" + " OR B.STOCK_NAME LIKE '%" + Search_name + "%')";
            sSql += "   AND   ( B.STOCK_CLASS1 LIKE '%" + Search_class + "%'" + " OR B.STOCK_CLASS2 LIKE '%" + Search_class + "%')";

            if (!string.IsNullOrEmpty(Search_buy_gap) && Search_buy_gap != "")
            {
                sSql += "   AND   (A.BUY_PRICE - B.STOCK_PRICE) / A.BUY_PRICE * 100  <= " + Search_buy_gap;
                sSql += "   AND   A.BUY_PRICE <> 0 ";
            }

            if (!string.IsNullOrEmpty(Search_sell_gap) && Search_sell_gap != "")
            {
                sSql += "   AND   (A.SELL_PRICE - B.STOCK_PRICE) / A.SELL_PRICE * 100  >= " + Search_sell_gap;
                sSql += "   AND   A.SELL_PRICE <> 0 ";
            }
            sSql += "   ORDER BY B.TOTAL_AMT DESC";


            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
        public static async Task SendLoginNotification(MSSQLDB db, IConfiguration configuration, Profile user)
        {
            var email = @"Hi there!

This is an automated email, since you have logged in to Journal Limpet at least once.

I'm sorry that I have to send you this email, but we need you to log in to Journal Limpet <https://journal-limpet.com> again.

.. at least if you want us to be able to continue:
- Storing your Elite: Dangerous journals
- Sync progress with other applications

And if you don't want us to sync your account any longer, we'll delete your account after 6 months from your last fetched journal.

This is the only email we will ever send you (every time that you need to login)

Regards,
NoLifeKing85
Journal Limpet";

            var htmlEmail = @"<html>
<head></head>
<body>
Hi there!<br />
<br />
This is an automated email, since you have logged in to <b>Journal Limpet</b> at least once.<br />
<br />
I'm sorry that I have to send you this email, but we need you to log in to <a href=""https://journal-limpet.com/Login"" target=""_blank"">Journal Limpet</a> again.<br />
<br />
.. at least if you want us to be able to continue:<br />
- Storing your Elite: Dangerous journals<br />
- Sync progress with other applications<br />
<br />
And if you don't want us to sync your account any longer, we'll delete your account after 6 months from your last fetched journal.<br />
<br />
This is the only email we will ever send you (every time that you need to login)<br />
<br />
Regards,<br />
NoLifeKing85<br />
<a href=""https://journal-limpet.com/"" target=""_blank"">Journal Limpet</a>
</body></html>";

            var sendgridClient = new SendGridClient(configuration["SendGrid:ApiKey"]);
            var mail           = MailHelper.CreateSingleEmail(
                new EmailAddress("*****@*****.**", "Journal Limpet"),
                new EmailAddress(user.NotificationEmail),
                "Login needed for further journal storage",
                email,
                htmlEmail
                );

            await sendgridClient.SendEmailAsync(mail);

            await db.ExecuteNonQueryAsync("UPDATE user_profile SET last_notification_mail = GETUTCDATE() WHERE user_identifier = @userIdentifier",
                                          new SqlParameter("@userIdentifier", user.UserIdentifier)
                                          );
        }
Exemplo n.º 11
0
        public static async Task <IndexStatsModel> GetIndexStatsAsync(MSSQLDB _db)
        {
            return(await _db.ExecuteSingleRowAsync <IndexStatsModel>(@"SELECT COUNT_BIG(DISTINCT up.user_identifier) user_count,
COUNT_BIG(journal_id) journal_count,
SUM(last_processed_line_number) total_number_of_lines
FROM user_profile up
LEFT JOIN user_journal uj ON up.user_identifier = uj.user_identifier AND uj.last_processed_line_number > 0
WHERE up.deleted = 0"));
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MSSQLDB mydb = new MSSQLDB(@"DESKTOP-UQ6D8UK\SQLEXPRESS", "PW", "admintest", "adminTest");

            if (mydb.Status)
            {
                mydb.ReadData("SELECT TOP 2 A_ID, A_DATE, A_NAME, A_DESCRIPTION, A_ANCHORLINK FROM PW_ARTICLE_TBL ORDER BY A_ID DESC");
                switch (mydb.DTTable.Rows.Count)
                {
                case 2:
                    des1.InnerHtml      = mydb.DTTable.Rows[0]["A_DESCRIPTION"].ToString() + "<span class =\"desID\">文章ID: " + mydb.DTTable.Rows[0]["A_ID"].ToString() + "</span>";
                    des2.InnerHtml      = mydb.DTTable.Rows[1]["A_DESCRIPTION"].ToString() + "<span  class =\"desID\">文章ID: " + mydb.DTTable.Rows[1]["A_ID"].ToString() + "</span>";
                    des1AnchorLink.HRef = mydb.DTTable.Rows[0]["A_ANCHORLINK"].ToString();
                    des2AnchorLink.HRef = mydb.DTTable.Rows[1]["A_ANCHORLINK"].ToString();
                    break;

                case 1:
                    des1.InnerHtml      = mydb.DTTable.Rows[0]["A_DESCRIPTION"].ToString() + "<span  class =\"desID\">文章ID: " + mydb.DTTable.Rows[0]["A_ID"].ToString() + "</span>";
                    des1AnchorLink.HRef = mydb.DTTable.Rows[0]["A_ANCHORLINK"].ToString();
                    des2.InnerHtml      = "暂时只有一篇文章";
                    break;

                default:
                    des1.InnerHtml = "暂时没有文章";
                    des2.InnerHtml = "暂时没有文章";
                    break;
                }
                mydb.ReadData("SELECT A_ABOUT FROM PW_ABOUT_TBL ORDER BY Count DESC");
                if (mydb.DTTable.Rows.Count > 0)
                {
                    for (int i = 0; i < mydb.DTTable.Rows.Count; i++)
                    {
                        if (i == 0)
                        {
                            about.InnerHtml += "<span class=\"badge\">" + mydb.DTTable.Rows[i]["A_ABOUT"].ToString() + "</span>\r\n";
                        }
                        else
                        {
                            about.InnerHtml += "        " + "<span class=\"badge\">" + mydb.DTTable.Rows[i]["A_ABOUT"].ToString() + "</span>\r\n";
                        }
                    }
                }
                else
                {
                    about.InnerText = "暂时没有相关标签";
                }
            }
            else
            {
                des1.InnerHtml = "数据库连接失败,无法读取";
                des2.InnerHtml = "数据库连接失败,无法读取";
            }
        }
Exemplo n.º 13
0
        public void Init()
        {
            conection             = new MSSQLDB(new DBConfiguration());
            _DREP                 = new DisciplineRepository(conection);
            _PREPProfessorContext = new Infra.ProfessorContext.ProfessorRepository(conection);
            _PREPCourseContext    = new Infra.CourseContext.ProfessorRepository(conection);
            _encryptor            = new Encryptor();
            handler               = new DisciplineCommandHandler(_DREP, _PREPCourseContext);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Entities.ProfessorContext.Entities.Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);

            _PREPProfessorContext.Create(professor);

            // Create Course
            course = new Course(Guid.NewGuid());
            var sql = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, 'LTP6')";

            db.Execute(sql, param: new { Id = course.Id });

            commandRegister = new DisciplineInputRegister()
            {
                Name           = "Filosofia",
                CourseId       = course.Id,
                ProfessorId    = professor.Id,
                WeeklyWorkload = 1,
                Period         = 1
            };
            discipline = new Discipline("Filosofia", course, new Professor(professor.Id), 1, 1, 0);

            _DREP.Create(discipline);

            commandUpdate = new DisciplineInputUpdate()
            {
                DisciplineId   = discipline.Id,
                Name           = "Matematica",
                CourseId       = course.Id,
                ProfessorId    = professor.Id,
                WeeklyWorkload = 2,
                Period         = 2
            };

            commandDelete = new DisciplineInputDelete()
            {
                DisciplineId = discipline.Id
            };
        }
Exemplo n.º 14
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _SREP      = new StudentRepository(conection);
            _encryptor = new Encryptor();
            handler    = new StudentCommandHandler(_SREP, _encryptor);

            var db = conection.GetCon();

            // Create Course
            course = new Course(Guid.NewGuid(), "LTP5");
            var sql = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, @Name)";

            db.Execute(sql, param: new { Id = course.CourseId, Name = course.Name });

            var    cpf      = "964.377.278-02";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            student = new Student(course, DateTime.Now, "Abmael", "Araujo", cpf, "*****@*****.**", "(86) 2802-4826", "M", "Brasil", "Araguaina", "Centro", password, salt);
            _SREP.Create(student);

            commandRegister = new StudentInputRegister()
            {
                CourseId  = course.CourseId,
                Birthdate = DateTime.Now,
                FirstName = "Ester",
                LastName  = "Emily Oliveira",
                CPF       = "494.035.320-68",
                Email     = "*****@*****.**",
                Phone     = "(45) 2509-8770",
                Gender    = "M",
                Country   = "Brasil",
                City      = "Araguaina",
                Address   = "Centro"
            };

            commandUpdate = new StudentInputUpdate()
            {
                CourseId  = course.CourseId,
                Birthdate = DateTime.Now,
                FirstName = "Iago",
                LastName  = "Bernardo Nunes",
                Email     = "*****@*****.**",
                Phone     = "(65) 3544-9294",
                Gender    = "M",
                Country   = "França",
                City      = "Budapeste",
                Address   = "Norte",
                StudentId = student.Id
            };
        }
Exemplo n.º 15
0
        private static async Task ExecuteBatchInsert(List <string> batchInserts, MSSQLDB db)
        {
            var batch = $@"BEGIN TRANSACTION;
INSERT INTO EliteSystem (SystemAddress, StarSystem, StarPos)
VALUES
{string.Join(",\n", batchInserts)}
COMMIT TRANSACTION";

            await db.ExecuteNonQueryAsync(batch);

            batchInserts.Clear();
        }
Exemplo n.º 16
0
        public static DataSet AvgKospi()
        {
            string YD_POINT;


            // 어제 날짜 지수 가져오기
            string sSql = @"";

            sSql += " SELECT MAX(INDEX_POINT) INDEX_POINT ";
            sSql += " FROM   INDEX_POINT A ";
            sSql += " WHERE  STOCK_MARKET	=	'KOSPI'";
            sSql += " AND    INDEX_DATE = ( ";
            sSql += "       SELECT MAX(INDEX_DATE) INDEX_DATE ";
            sSql += "       FROM   INDEX_POINT A ";
            sSql += "       WHERE  STOCK_MARKET	=	'KOSPI'";
            sSql += "       AND    INDEX_DATE <  ";
            sSql += "           (       SELECT  TOP 1	INDEX_DATE";
            sSql += "                   FROM	INDEX_POINT";
            sSql += "                   WHERE	STOCK_MARKET	=	'KOSPI'";
            sSql += "                   AND 	INDEX_DATE 	    >	GETDATE() - 10 ";
            sSql += "                   ORDER BY INDEX_DATE DESC ";
            sSql += "           ) ";
            sSql += "      ) ";
            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            YD_POINT = user.Tables[0].Rows[0][0].ToString();

            //평균 지수 가져오기
            sSql  = @"";
            sSql += " SELECT ROUND(AVG(INDEX_POINT),2) AVG_POINT, MIN(CONVERT(CHAR(10), INDEX_DATE, 111)) INDEX_DATE ";
            sSql += " FROM   ( ";
            sSql += "        SELECT  TOP 60	ISNULL(INDEX_POINT,0) INDEX_POINT, INDEX_DATE";
            sSql += "        FROM	INDEX_POINT";
            sSql += "        WHERE	STOCK_MARKET	=	'KOSPI'";
            sSql += "        AND 	INDEX_DATE 	    >	GETDATE() - 120 ";
            sSql += "        ORDER BY INDEX_DATE DESC ";
            sSql += "        ) A";
            sSql += " UNION ALL";
            sSql += " SELECT " + YD_POINT + " AVG_POINT, CONVERT(CHAR(10),GETDATE(),111) INDEX_DATE ";

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
Exemplo n.º 17
0
        protected override void OnStart(string[] args)
        {
            /*************
             * Carrega configurações
             */

            System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(this.GetType());
            basePath = Path.GetDirectoryName(asm.Location);

            localConfig = new LocalConfig();
            localConfig.LoadConfig();

            if ((localConfig.SqlServer == null) || (localConfig.SqlServer.Trim() == ""))
            {
                StopOnError("Parâmetro 'sqlserver' não localizado no arquivo de configuração 'server.conf'", null);
            }

            if ((localConfig.SqlDb == null) || (localConfig.SqlDb.Trim() == ""))
            {
                StopOnError("Parâmetro 'sqldb' não localizado no arquivo de configuração 'server.conf'", null);
            }

            if ((localConfig.SqlUsername == null) || (localConfig.SqlUsername.Trim() == ""))
            {
                StopOnError("Parâmetro 'sqlusername' não localizado no arquivo de configuração 'server.conf'", null);
            }

            if ((localConfig.SqlPassword == null) || (localConfig.SqlPassword.Trim() == ""))
            {
                StopOnError("Parâmetro 'sqlpassword' não localizado no arquivo de configuração 'server.conf'", null);
            }

            try
            {
                MSSQLDB db = new MSSQLDB(localConfig.SqlServer, localConfig.SqlDb, localConfig.SqlUsername, localConfig.SqlPassword);
                db.openDB();

                db.closeDB();
            }
            catch (Exception ex)
            {
                StopOnError("Falha ao acessar o banco de dados", ex);
            }


            /*************
             * Inicia timer que processa os arquivos
             */

            inboundTimer  = new Timer(new TimerCallback(InboundTimer), null, 1000, 900000);
            outboundTimer = new Timer(new TimerCallback(OutboundTimer), null, 1000, 900000);
        }
Exemplo n.º 18
0
        public static async Task SendStatsActivityAsync(MSSQLDB _db)
        {
            try
            {
                var stats = await SharedSettings.GetIndexStatsAsync(_db);

                await SharedSettings.RedisPubsubSubscriber.PublishAsync($"stats-activity", JsonSerializer.Serialize(stats), CommandFlags.FireAndForget);
            }
            catch
            {
                // It is better is we don't send stats, instead of possibly sending the wrong one
            }
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            A_DATE.Value = DateTime.Now.ToString();
            MSSQLDB mydb = new MSSQLDB(@"DESKTOP-UQ6D8UK\SQLEXPRESS", "PW", "admintest", "adminTest");

            if (mydb.Status)
            {
                mydb.ReadData("SELECT TOP 1 A_ID FROM PW_ARTICLE_TBL ORDER BY A_ID DESC;");
                string tempStr = GetRepeatNumberStr((Convert.ToInt32(mydb.DTTable.Rows[0]["A_ID"]) + 1), 0, 8);
                A_ID.Value = tempStr;
            }
            else
            {
            }
        }
Exemplo n.º 20
0
        static public void sendEmail(MSSQLDB db, String Subject, List <String> to, String replyTo, String body, Boolean isHTML, List <Attachment> atts)
        {
            using (ServerDBConfig conf = new ServerDBConfig(db.conn))
            {
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress(conf.GetItem("mailFrom"));
                foreach (String t in to)
                {
                    mail.To.Add(new MailAddress(t));
                }

                mail.Subject = Subject;

                mail.IsBodyHtml = isHTML;
                mail.Body       = body;

                if (replyTo != null)
                {
                    try
                    {
                        mail.ReplyTo = new MailAddress(replyTo);
                    }
                    catch { }
                }

                if ((atts != null) && (atts.Count > 0))
                {
                    foreach (Attachment a in atts)
                    {
                        mail.Attachments.Add(a);
                    }
                }

                SmtpClient client = new SmtpClient();
                client.Host        = conf.GetItem("smtpServer");
                client.Port        = 587;
                client.EnableSsl   = true;
                client.Credentials = new System.Net.NetworkCredential(conf.GetItem("username"),
                                                                      conf.GetItem("password"));

                System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertificateValidationCallback);

                client.Send(mail);

                client = null;
                mail   = null;
            }
        }
Exemplo n.º 21
0
        public static int SetUser(string UserCode, string PassWord, string UserAlias, string UserPhone, string UserEmail)
        {
            string sSql = @"";

            sSql += "   INSERT INTO USER_MST ( USER_CODE, PASSWORD, USER_ALIAS, USER_PHONE, USER_EMAIL, USER_STATUS )";
            sSql += "   VALUES  ( '" + UserCode + "', '" + PassWord + "', '" + UserAlias + "', '" + UserPhone + "', '" + UserEmail + "', 'Y')";

            int result;

            using (var db = new MSSQLDB())
            {
                result = db.Execute(sSql);
            }

            return(result);
        }
Exemplo n.º 22
0
        public static int SetStockDelete(string Stock_Code)
        {
            string sSql = @"";

            sSql += "   DELETE FROM STOCK_INFO ";
            sSql += "   WHERE STOCK_CODE = '" + Stock_Code + "'";

            int Result;

            using (var db = new MSSQLDB())
            {
                Result = db.Execute(sSql);
            }

            return(Result);
        }
Exemplo n.º 23
0
        public static DataSet GetUser(string UserCode)
        {
            string sSql = @"";

            sSql += "   SELECT  USER_ID, USER_ALIAS, USER_STATUS ";
            sSql += "   FROM    USER_MST";
            sSql += "   WHERE   USER_CODE = '" + UserCode + "'";

            DataSet ds;

            using (var db = new MSSQLDB())
            {
                ds = db.Query(sSql);
            }

            return(ds);
        }
Exemplo n.º 24
0
        public static int SetRemarkSave(string Stock_Code, string Stock_Remark)
        {
            string sSql = @"";

            sSql += "   UPDATE STOCK_CLASS ";
            sSql += "     SET  STOCK_REMARK = '" + Stock_Remark + "'";
            sSql += "   WHERE STOCK_CODE = '" + Stock_Code + "'";

            int Result;

            using (var db = new MSSQLDB())
            {
                Result = db.Execute(sSql);
            }

            return(Result);
        }
Exemplo n.º 25
0
        public static DataSet GetKospi()
        {
            string sSql = @"";

            sSql += "   SELECT  TOP 300	INDEX_DATE, ISNULL(INDEX_POINT,0) INDEX_POINT,	ISNULL(INDEX_START,0) INDEX_START,	ISNULL(INDEX_HIGH,0) INDEX_HIGH, ISNULL(INDEX_LOW,0) INDEX_LOW";
            sSql += "   FROM	INDEX_POINT";
            sSql += "   WHERE	STOCK_MARKET	=	'KOSPI'";
            sSql += "   AND 	INDEX_DATE 	    >	GETDATE() - 600 ";
            sSql += "   ORDER BY INDEX_DATE ";

            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
Exemplo n.º 26
0
        public static bool SetSavePrice(string Stock_Code, string User_ID, string Buy_Price, string Sell_Price, string Avg_Price)
        {
            string sSql = @"";

            sSql += "   UPDATE  USER_STOCK ";
            sSql += "   SET     BUY_PRICE = " + Buy_Price;
            sSql += "       ,   SELL_PRICE = " + Sell_Price;
            sSql += "       ,   AVG_PRICE = " + Avg_Price;
            sSql += "   WHERE   STOCK_CODE = '" + Stock_Code + "'";
            sSql += "   AND     USER_ID = " + User_ID;

            int Result;

            using (var db = new MSSQLDB())
            {
                Result = db.Execute(sSql);
            }

            return(true);
        }
Exemplo n.º 27
0
        public static DataSet GetAllData()
        {
            string sSql = @"";

            sSql += "   SELECT  STOCK_CODE, STOCK_NAME, STOCK_URL, TOTAL_AMT, SALES_AMT, BIZ_PROFIT, NET_PROFIT, PER, EST_PER, BIZ_PER, STOCK_PRICE, NAVER_PRICE, ";
            sSql += "           CAL_PSR, CAL_POR, CAL_PER, BIZ_RATE, NET_RATE, ";
            sSql += "           SA_Y3, SA_Y2, SA_Y1, SA_Y0, BP_Y3, BP_Y2, BP_Y1, BP_Y0, NP_Y3, NP_Y2, NP_Y1, NP_Y0, ";
            sSql += "           SA_RATE, BP_RATE, NP_RATE ";
            sSql += "   FROM    STOCK_INFO";
            sSql += "   ORDER BY TOTAL_AMT DESC";


            DataSet user;

            using (var db = new MSSQLDB())
            {
                user = db.Query(sSql);
            }

            return(user);
        }
Exemplo n.º 28
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _PREP      = new ProfessorRepository(conection);
            _encryptor = new Encryptor();
            handler    = new ProfessorQueryHandler(_PREP);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);
            _PREP.Create(professor);

            commandGet = new ProfessorInputGet()
            {
                ProfessorId = professor.Id
            };
        }
Exemplo n.º 29
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _PREP      = new ProfessorRepository(conection);
            _encryptor = new Encryptor();
            handler    = new ProfessorCommandHandler(_PREP, _encryptor);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);
            _PREP.Create(professor);

            commandRegister = new ProfessorInputRegister()
            {
                FirstName = "Lívia",
                LastName  = "Emanuelly Elisa",
                CPF       = cpf,
                Email     = "*****@*****.**",
                Phone     = "(21) 2682-8370",
                Degree    = EDegree.Master
            };

            commandUpdate = new ProfessorInputUpdate()
            {
                ProfessorId = professor.Id,
                FirstName   = "Lívia",
                LastName    = "Emanuelly Elisa",
                Email       = "*****@*****.**",
                Phone       = "(21) 2682-8370",
                Degree      = EDegree.Master
            };
        }
Exemplo n.º 30
0
        public static bool GetAliasCheck(string UserAlias)
        {
            string sSql = @"";

            sSql += "   SELECT  COUNT(*) ";
            sSql += "   FROM    USER_MST";
            sSql += "   WHERE   USER_ALIAS = '" + UserAlias + "'";

            DataSet ds;

            using (var db = new MSSQLDB())
            {
                ds = db.Query(sSql);
            }

            if (ds.Tables[0].Rows[0][0].ToString() == "1")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }