Esempio n. 1
0
        // GET: api/TestTour/5
        public Tour Get(string ToursType, string Country = "TW", int?LineLevel = 0, string BuType = "T", int ShowType = 1, string LineID = "", string TravelID = "", string WebAreaID = "", int PageStart = 0, int PageCount = 0)
        {
            string strLine  = string.Empty;
            string strwhere = string.Empty;

            if (ToursType == TT.NEW.ToString())
            {
                strwhere = "and hspd10_line <> 9";
            }
            if (ToursType == TT.NEWDOM.ToString())
            {
                strwhere = "and hspd10_line=9";
            }


            DynamicParameters sqlParm = new DynamicParameters();

            sqlParm.Add("@Country", Country);
            sqlParm.Add("@BuType", BuType);
            string sqlQuery = @"select hspd10_line AS LineID,hspd10_line_nm AS LineName,hspd10_travel AS TravelID,hspd10_travel_nm AS TravelName,hspd10_webarea AS WebAreaID, hspd10_warea_nm AS WebAreaName  from [dbo].[hspdm10] where hspd10_bu=@BuType and hspd10_country=@Country {0} ";

            using (var conn = SQLFunc.OpenConnection(DBList.LionAction))
            {
                sqlQuery = string.Format(sqlQuery, strwhere);
                return(conn.Query <Tour>(sqlQuery, sqlParm).FirstOrDefault());
            }
        }
Esempio n. 2
0
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        //測試用
        //txt_Sentence.Text = "我相信已有不少台中市民反應過這個問題。";

        string sentence = txt_Sentence.Text;
        string DM_ID    = hid_DM_ID.Value;
        string now_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

        if (!string.IsNullOrEmpty(sentence))
        {
            dialogHelper.Get_Dialog_Detail(DM_ID, sentence, now_date);
        }

        JiebaExecute jiebaExecute = new JiebaExecute();

        jiebaExecute.Get_Dialog_Detail_to_Jieba(DM_ID);

        DataTable dt = SQLFunc.Get_DIALOG_MAIN(DM_ID);

        Page_Bind(dt);

        txt_Sentence.Text = "";
        lv_Dialog.DataBind();
    }
Esempio n. 3
0
        public IEnumerable <Product> GetAllProducts()
        {
            string         sqlExecute  = string.Empty;
            List <Product> ProductList = new List <Product>();

            try
            {
                #region SQL 語法

                sqlExecute = @"select * from Product ";

                #endregion SQL 語法

                #region SQL 執行
                using (var conn = SQLFunc.OpenConnection(DBList.Test))
                {
                    ProductList = conn.Query <Product>(sqlExecute).ToList();
                }
                var builder = new ODataConventionModelBuilder()
                {
                    Namespace = "Default"
                };
                builder.EntitySet <Product>("Products");
                var model = builder.GetEdmModel();
                return(ProductList.AsQueryable());

                #endregion
            }
            catch (Exception ex)
            {
            }
            return(ProductList.AsQueryable());
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //測試用
        //DIALOG_USER data_User = SQLFunc.Get_DIALOG_USER("1", "Athena", "192.168.7.127", "2017-03-23 14:29:15.647");
        //Session["DIALOG_USER"] = data_User;

        if (!IsPostBack)
        {
            txt_Sentence.Attributes.Add("onkeydown", "if(event.keyCode == 13) {document.getElementById('" + btn_Submit.ClientID + "').click(); return false;}");
        }

        if (Session["DIALOG_USER"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            MotionClass.DIALOG_USER DIALOG_USER = (MotionClass.DIALOG_USER)Session["DIALOG_USER"];
            if (Request["DM_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                string    DM_ID = Request["DM_ID"].ToString();
                DataTable dt    = SQLFunc.Get_DIALOG_MAIN(DM_ID);
                Page_Bind(dt);
                ll_Name.Text = DIALOG_USER.U_Name;
            }
        }
        //ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "scrollTo", "window.scrollTo(0,document.body.scrollHeight);alert('aa');", true);
    }
Esempio n. 5
0
    private void jieba_execute(string sentence, string DD_ID, string DM_ID)
    {
        var data_detail = Get_Motion_DialogDetail(sentence, DD_ID);

        var data_main = Get_Motion_DialogMain(DM_ID, data_detail);

        //更新對話內容
        SQLFunc.Upd_DIALOG_DETAIL(data_detail);
        SQLFunc.Upd_DIALOG_MAIN(data_main);
    }
Esempio n. 6
0
    public void Get_Dialog_Detail_to_Jieba(string DM_ID)
    {
        DataTable dt_DD = SQLFunc.Get_DIALOG_DETAIL_By_DD_Type("0");

        if (dt_DD.Rows.Count > 0)
        {
            for (int i = 0; i < dt_DD.Rows.Count; i++)
            {
                jieba_execute(dt_DD.Rows[i]["DD_Sentence"].ToString(), dt_DD.Rows[i]["DD_ID"].ToString(), DM_ID);
            }
        }
    }
        public DepositRateDecrease(SQLFunc sql, Hashtable TblData)
        {
            InitializeComponent();

            List <SQLFunc.SubResults> data = sql.GetData(TblData["pCur"].ToString(), "*");

            for (int i = 0; i < data.Count; i++)
            {
                currencyBox.Items.Add(data[i]._SubResults[0].ToString());
            }

            this.sql = sql;
            this.DecreaseRateTable = TblData["DepositRateDecrease"].ToString();
        }
Esempio n. 8
0
    protected void On_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
    {
        var    cmd      = e.CommandName;
        var    arg      = e.CommandArgument.ToString();
        string now_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        string DF_ID    = "";
        string DF_DDID  = cmd;
        string DF_Type  = arg;

        MotionClass.DIALOG_FEEDBACK data_DF = SQLFunc.Get_DIALOG_FEEDBACK(DF_ID, DF_DDID, DF_Type, now_date);

        SQLFunc.Add_DIALOG_FEEDBACK(data_DF);

        lv_Dialog.DataBind();
    }
Esempio n. 9
0
        private void validateBtn_Click(object sender, EventArgs e)
        {
            SQLFunc mySql = new SQLFunc(ServerAddress, Database);

            mySql.Err += MySql_Err;
            mySql.Connect();

            SQLFunc.SubResults myData = mySql.Get1Data("Login", "Password", "Login='******'");

            if (myData == null || myData._SubResults.Count == 0)
            {
                MessageBox.Show("Wrong Login");
                NbMissed++;
                if (NbMissed == 3)
                {
                    Random _check = new Random();
                    Result = Result = (int)Math.Round((double)_check.Next(1000), 0);
                    this.Hide();
                }
            }
            else
            {
                string pwd = (string)myData._SubResults[0];

                if (!pwd.Equals(passwordBox.Text))
                {
                    MessageBox.Show("Wrong Password");
                    NbMissed++;
                    if (NbMissed == 3)
                    {
                        Random _check = new Random();
                        Result = (int)Math.Round((double)_check.Next(1000), 0);
                        this.Hide();
                    }
                }
                else
                {
                    Result = Thread.CurrentThread.ManagedThreadId;
                    this.Hide();
                }
            }
        }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable    dt           = SQLFunc.Get_FB_Message_List("0");
        JiebaExecute jiebaExecute = new JiebaExecute();

        string DM_ID    = "1";
        string now_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string sentence = jiebaExecute.MakePlainText(dt.Rows[i]["Message"].ToString());
            string id       = dt.Rows[i]["id"].ToString();

            dialogHelper.Get_Dialog_Detail(DM_ID, sentence, now_date);

            jiebaExecute.Get_Dialog_Detail_to_Jieba(DM_ID);

            SQLFunc.Update_FB_Message_Dialog_Chk(id);
        }
    }
Esempio n. 11
0
        public ChangeDBParam(string TPTbl, SQLFunc sql, ParameterToChange param, string CountryTbl = "", string SectorTbl = "", string SubSectorTbl = "")
        {
            InitializeComponent();

            this.TPTbl = TPTbl;
            this.sql   = sql;

            this.sql.Err += Sql_Err;

            switch (param)
            {
            case ParameterToChange.ThirdParty:
                this.Text = "Change Third Party data";
                break;

            case ParameterToChange.Auditor:
                this.Text = "Change Auditor data";
                break;

            case ParameterToChange.CoinParams:
                this.Text = "Change Coin Params";
                dataGrid.AllowUserToAddRows    = false;
                dataGrid.AllowUserToDeleteRows = false;
                IsCoinParams = true;
                break;

            case ParameterToChange.RiskTests:
                this.Text = "Change Risk Tests";
                dataGrid.CellValueChanged += DataGrid_CellValueChanged;
                dataGrid.RowsAdded        += DataGrid_RowsAdded;
                IsRiskTests = true;
                break;
            }

            this.CountryTbl   = CountryTbl;
            this.SectorTbl    = SectorTbl;
            this.SubSectorTbl = SubSectorTbl;

            SetGrid();
            GetTblData();
        }
Esempio n. 12
0
        public MainWdw()
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en-US");
            InitializeComponent();

            /*Thread myThread = Thread.CurrentThread;
             *
             * LoginWdw login = new LoginWdw(ServerAddress, Database);
             * login.ShowDialog();
             *
             * if(login == null || login.Result != myThread.ManagedThreadId) { LoginFailed = true; }*/

            mySQL      = new SQLFunc(ServerAddress, Database);
            mySQL.Err += MySQL_Err;
            mySQL.Connect();

            SetTables();
            SetCoinParams();

            UpdateProjectInScope();
        }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txt_Name.Attributes.Add("onkeydown", "if(event.keyCode == 13) {document.getElementById('" + btn_Save.ClientID + "').click(); return false;}");
            string ip_string = GetClientIP();

            lb_IP.Text = ip_string;
            DataTable dt = SQLFunc.Get_DIALOG_USER(ip_string);
            if (dt.Rows.Count > 0)
            {
                txt_Name.Text  = dt.Rows[0]["U_Name"].ToString();
                hid_U_ID.Value = dt.Rows[0]["U_ID"].ToString();
                MotionClass.DIALOG_USER data = SQLFunc.Get_DIALOG_USER(dt.Rows[0]["U_ID"].ToString(), dt.Rows[0]["U_Name"].ToString(), dt.Rows[0]["U_IP"].ToString(), dt.Rows[0]["U_CreateTime"].ToString());
                Session["DIALOG_USER"] = data;
            }
            else
            {
                Session.Clear();
            }
        }
    }
Esempio n. 14
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        MotionClass.DIALOG_USER data = null;
        string now_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        string name     = txt_Name.Text;

        if (string.IsNullOrEmpty(name))
        {
            Alert_msg("交出名字,饒你一命");
        }
        else
        {
            if (name == "gis@5200")
            {
                data = SQLFunc.Get_DIALOG_USER("", "Manager", lb_IP.Text, now_date);
                Session["DIALOG_USER"] = data;

                Response.Redirect("~/Page/Summary.aspx");
            }
            else
            {
                if (Session["DIALOG_USER"] == null)
                {
                    data = SQLFunc.Get_DIALOG_USER("", name, lb_IP.Text, now_date);
                    string U_ID = SQLFunc.Add_DIALOG_USER(data);
                    data = SQLFunc.Get_DIALOG_USER(U_ID, name, lb_IP.Text, now_date);
                    Session["DIALOG_USER"] = data;
                }

                MotionClass.DIALOG_USER data_USER = (MotionClass.DIALOG_USER)Session["DIALOG_USER"];
                MotionClass.DIALOG_MAIN data_Main = SQLFunc.Get_DIALOG_MAIN(data_USER.U_ID, "0", now_date);
                string DM_ID = SQLFunc.Add_DIALOG_MAIN(data_Main);
                //string DM_ID = "1";
                Response.Redirect("Page/Dialog.aspx?DM_ID=" + DM_ID);
            }
        }
    }
Esempio n. 15
0
    private MotionClass.DIALOG_DETAIL.REPLY Get_Motion_DialogDetail(string sentence, string DD_ID)
    {
        //正面辭典
        Dictionary <string, int> HappyDic = new Dictionary <string, int>();
        //負面辭典
        Dictionary <string, int> SadDict = new Dictionary <string, int>();
        //正面分數
        int GoodVal = 0;
        //負面分數
        int BadVal = 0;

        List <MotionClass.MotionWords> GoodList = new List <MotionClass.MotionWords>();
        List <MotionClass.MotionWords> BadList  = new List <MotionClass.MotionWords>();

        MotionClass.MotionResult results = new MotionClass.MotionResult();

        var segmenter    = new JiebaSegmenter();
        var userDictPath = ConfigurationManager.AppSettings["UserDictFile"];

        segmenter.LoadUserDict(userDictPath);
        //segmenter.LoadUserDict(@"D:\\Practise\\Study\\Jieba.dict\\new_dict.txt");

        // ============== 正面用語 =================
        DataTable feelGood = SQLFunc.Get_Sort_Good(); //Get_Excel("Sort_Good");

        for (int i = 0; i < feelGood.Rows.Count; i++)
        {
            HappyDic.Add(feelGood.Rows[i]["S_Word"].ToString(), int.Parse(feelGood.Rows[i]["S_Score"].ToString()));
        }

        // ============== 負面用語 =================
        DataTable feelBad = SQLFunc.Get_Sort_Bad(); //Get_Excel("Sort_Bad");

        for (int i = 0; i < feelBad.Rows.Count; i++)
        {
            SadDict.Add(feelBad.Rows[i]["S_Word"].ToString(), int.Parse(feelBad.Rows[i]["S_Score"].ToString()));
        }

        var tokens = segmenter.Cut(sentence);

        foreach (var token in tokens)
        {
            if (HappyDic.ContainsKey(token))
            {
                int ss = HappyDic[token];
                MotionClass.MotionWords wg = new MotionClass.MotionWords();
                wg.Terms  = token;
                wg.Scores = ss;
                GoodList.Add(wg);

                GoodVal += ss;
            }

            if (SadDict.ContainsKey(token))
            {
                int ss = SadDict[token];
                MotionClass.MotionWords wg = new MotionClass.MotionWords();
                wg.Terms  = token;
                wg.Scores = ss;
                BadList.Add(wg);

                BadVal += ss;
            }
        }

        if (GoodVal > BadVal)
        {
            results.Judgment = "正面";
        }
        else if (BadVal > GoodVal)
        {
            results.Judgment = "負面";
        }
        else
        {
            results.Judgment = "中立";
        }

        results.Good      = GoodVal;
        results.Bad       = BadVal;
        results.Good_Term = GoodList;
        results.Bad_Term  = BadList;

        string jsonData = JsonParse.Json(results);
        string now_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        float  score    = GoodVal - BadVal;

        MotionClass.DIALOG_DETAIL.REPLY data = new MotionClass.DIALOG_DETAIL.REPLY();
        data.DD_ID         = DD_ID;
        data.DD_Type       = "3";
        data.DD_Motion     = (score).ToString();
        data.DD_Reply      = jsonData;
        data.DD_Bad        = results.Bad.ToString();
        data.DD_Bad_Term   = JsonParse.Json_word(results.Bad_Term);
        data.DD_Good       = results.Good.ToString();
        data.DD_Good_Term  = JsonParse.Json_word(results.Good_Term);
        data.DD_Judgment   = results.Judgment;
        data.DD_UpdateTime = now_date;

        return(data);
    }
Esempio n. 16
0
 public void Get_Dialog_Detail(string DM_ID, string sentence, string now_date)
 {
     MotionClass.DIALOG_DETAIL.ASK data_ask = SQLFunc.Get_DIALOG_DETAIL(DM_ID, "0", sentence, now_date, now_date);
     SQLFunc.Add_DIALOG_DETAIL(data_ask);
 }
Esempio n. 17
0
        //用int 參數 串入 where in(SqlCommand 方式用)
        public string GetCommand(int d)
        {
            CommittableTransaction ct = new CommittableTransaction();
            string outString          = string.Empty;

            try
            {
                SqlCommand cmd = new SqlCommand();
                //加入 System.Transactions.dll, v4.0.0.0 參考

                string strQuery = string.Empty;
                string strIn    = string.Empty;



                #region SQL 執行
                using (var con = SQLFunc.OpenConnection(DBList.LionExAPIDB))
                {
                    string dd = "1,2,3";


                    con.EnlistTransaction(ct);
                    cmd.Connection = con;
                    List <string> list = new List <string>();
                    int           intN = 0;

                    foreach (string item in dd.Split(','))
                    {
                        //SqlParameter parameter = new SqlParameter("@dd" + intN, SqlDbType.Int, 50, item);
                        //parameter.IsNullable = true;
                        //parameter.Direction = ParameterDirection.Output;



                        //cmd.Parameters.Add("@dd" + intN, System.Data.DbType.Int32).Value = item;

                        strIn += "@dd" + intN;
                        cmd.Parameters.Add(strIn, SqlDbType.Int).Value = item;
                        list.Add(item);

                        intN++;
                    }
                    strQuery        = string.Format("select createname from [dbo].[Application] where id in ({0});", string.Join(",", list.ToArray()));
                    cmd.CommandText = strQuery;
                    var Data = cmd.ExecuteReader();

                    while ((Data.Read()))
                    {
                        //5.判斷資料列是否為空
                        if (!Data[0].Equals(DBNull.Value))
                        {
                            outString = Data[0].ToString();
                        }
                    }
                }
                #endregion



                ct.Commit();
            }
            catch (Exception e)
            { ct.Rollback(); }
            return(outString);
        }