Пример #1
0
    private void sendToCity(cityDisplayData cityData)
    {
        udpSender sender = new udpSender("127.0.0.1", 2233);
        string    msg    = JsonConvert.SerializeObject(cityData);

        sender.send(msg);
    }
Пример #2
0
    public void getCityDisplay(ref List <cityDisplayData> cityDataList, int store)
    {
        using (SqlCommand cmd = new SqlCommand("getCityDisplay", _sqlConn))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@store", SqlDbType.TinyInt).Value = store;
            try
            {
                _sqlConn.Open();
                using (var data = cmd.ExecuteReader())
                {
                    cityDataList.Clear();
                    if (data.HasRows)
                    {
                        while (data.Read())
                        {
                            if (data[0].Equals(DBNull.Value))
                            {
                                break;
                            }

                            cityDisplayData c = new cityDisplayData();
                            c.nickName = data["nick"].ToString();
                            c.nickName = c.nickName.Replace(" ", string.Empty);
                            c.rank     = Convert.ToInt32(data["rank"]);
                            c.gender   = Convert.ToInt32(data["gender"]);
                            c.group    = Convert.ToInt32(data["cGroup"]);
                            c.score    = Convert.ToInt32(data["score"]);
                            cityDataList.Add(c);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex.GetBaseException();
            }
            finally
            {
                _sqlConn.Close();
                cmd.Dispose();
            }
        }
    }
Пример #3
0
 public void getNewCityUser(ref cityDisplayData cityData, int store)
 {
     using (SqlCommand cmd = new SqlCommand("getNewCityUser", _sqlConn))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@store", SqlDbType.TinyInt).Value = store;
         try
         {
             _sqlConn.Open();
             using (var data = cmd.ExecuteReader())
             {
                 if (data.HasRows)
                 {
                     data.Read();
                     cityData.nickName = data["nick"].ToString();
                     cityData.nickName = cityData.nickName.Replace(" ", string.Empty);
                     cityData.rank     = Convert.ToInt32(data["rank"]);
                     cityData.gender   = Convert.ToInt32(data["gender"]);
                     cityData.group    = Convert.ToInt32(data["cGroup"]);
                     cityData.score    = Convert.ToInt32(data["score"]);
                 }
                 else
                 {
                     cityData = null;
                 }
             }
         }
         catch (Exception ex)
         {
             throw ex.GetBaseException();
         }
         finally
         {
             _sqlConn.Close();
             cmd.Dispose();
         }
     }
 }
Пример #4
0
    public cityDisplayData addCityData(string guid, string nick, int rank, int store)
    {
        cityDisplayData c = new cityDisplayData();

        using (SqlCommand cmd = new SqlCommand("addCityData", _sqlConn))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@uKey", SqlDbType.NChar).Value    = guid;
            cmd.Parameters.Add("@nick", SqlDbType.NChar).Value    = nick;
            cmd.Parameters.Add("@rank", SqlDbType.Int).Value      = rank;
            cmd.Parameters.Add("@store", SqlDbType.TinyInt).Value = store;
            try
            {
                _sqlConn.Open();
                using (var data = cmd.ExecuteReader())
                {
                    data.Read();

                    c.nickName = nick;
                    c.rank     = Convert.ToInt32(data["r"]);
                    c.gender   = Convert.ToInt32(data["gender"]);
                    c.group    = Convert.ToInt32(data["cGroup"]);
                }
            }
            catch (Exception ex)
            {
                c = null;
                //throw ex.GetBaseException();
            }
            finally
            {
                _sqlConn.Close();
                cmd.Dispose();
            }
            return(c);
        }
    }
Пример #5
0
    private void handleActive()
    {
        var      active = Request["active"];
        var      store  = Int32.Parse(Request["store"]);
        response rep    = new response();

        rep.active = active;
        rep.store  = store;
        switch (active)
        {
        //admin
        case "getShareMsg":
        {
            var config = _dbMgr.getConfigData(configData.ConfigMap["MobileMsg"], store);

            if (config != null)
            {
                rep.result = true;
                rep.data   = config.value_3;
            }
            else
            {
                rep.result = false;
                rep.msg    = "Can't found config data";
            }
            break;
        }

        case "getLabRunStartTime":
        {
            var config = _dbMgr.getConfigData(configData.ConfigMap["RunStartT"], store);
            if (config != null)
            {
                rep.result = true;
                rep.data   = config.value_1;
            }
            else
            {
                rep.result = false;
                rep.msg    = "Can't found config data";
            }
            break;
        }

        case "getLabRunRestTime":
        {
            var config = _dbMgr.getConfigData(configData.ConfigMap["RunResetT"], store);
            if (config != null)
            {
                rep.result = true;
                rep.data   = config.value_1;
            }
            else
            {
                rep.result = false;
                rep.msg    = "Can't found config data";
            }
            break;
        }

        case "getBoxType":
        {
            var config = _dbMgr.getConfigData(configData.ConfigMap["RunBoxType"], store);
            if (config != null)
            {
                rep.result = true;
                rep.data   = config.value_1;
            }
            else
            {
                rep.result = false;
                rep.msg    = "Can't found config data";
            }
            break;
        }

        //Lab Run
        case "getRunRank":
        {
            getRunRank(ref rep, store);

            break;
        }

        case "updateRunData":
        {
            if (Request["runData"] == null)
            {
                break;
            }
            var runData = JsonConvert.DeserializeObject <runData>(Request["runData"]);
            _dbMgr.updateRunData(Request["guid"], runData);
            rep.result = true;
            break;
        }

        case "createRunData":
        {
            string guid = getShortGUID();
            _dbMgr.addRunData(guid, store);
            rep.result = true;
            rep.data   = guid;
            break;
        }

        case "getUserRank":
        {
            int rank  = -1;
            int score = 0;
            _dbMgr.getUserRank(Request["guid"], ref rank, ref score, store);

            if (rank != -1)
            {
                rep.result = true;
                rep.data   = rank;
            }
            break;
        }

        case "getRunSetting":
        {
            configData runResetT = _dbMgr.getConfigData(configData.ConfigMap["RunResetT"], store);
            configData boxType   = _dbMgr.getConfigData(configData.ConfigMap["RunBoxType"], store);
            configData runStartT = _dbMgr.getConfigData(configData.ConfigMap["RunStartT"], store);
            runSetting setting   = new runSetting();
            setting.resetSecond = runResetT.value_1;
            setting.boxType     = boxType.value_1;
            setting.startSecond = runStartT.value_1;
            rep.result          = true;
            rep.data            = setting;
            break;
        }

        //LabCity
        case "getCityData":
        {
            getCityData(ref rep, store);
            break;
        }

        case "getNewCityUser":
        {
            cityDisplayData cityData = new cityDisplayData();
            try
            {
                _dbMgr.getNewCityUser(ref cityData, store);
                rep.result = true;
                rep.data   = cityData;
            }
            catch (Exception ex)
            {
                rep.result = false;
                rep.msg    = "DB Error";
                throw ex.GetBaseException();
            }
            break;
        }

        //Mobile
        case "addMobileData":
        {
            var ukey = Request["guid"];
            if (ukey == null)
            {
                rep.result = false;
            }
            else
            {
                if (_dbMgr.addMobileData(ukey))
                {
                    rep.result = true;
                }
                else
                {
                    rep.msg    = "Wrong guid";
                    rep.result = false;
                }
            }
            break;
        }

        case "addCityData":
        {
            var ukey     = Request["guid"];
            var nickName = Request["nick"];


            if (ukey == null || nickName == null)
            {
                rep.result = false;
            }
            else
            {
                int rank  = -1;
                int score = 0;
                _dbMgr.getUserRank(Request["guid"], ref rank, ref score, store);

                cityDisplayData cityData = _dbMgr.addCityData(ukey, nickName, rank, store);
                if (cityData == null)
                {
                    rep.result = false;
                    rep.msg    = "GUID Dupicate";
                }
                else
                {
                    rep.data   = cityData;
                    rep.result = true;
                }
            }
            break;
        }

        case "updateMobileData":
        {
            if (Request["mobileData"] == null || Request["guid"] == null)
            {
                break;
            }
            var mobileData = JsonConvert.DeserializeObject <mobileData>(Request["mobileData"]);
            var guid       = Request["guid"];
            _dbMgr.updateMobileData(guid, mobileData);
            rep.result = true;
            break;
        }

        case "getShareUrl":
        {
            var ukey    = Request["guid"];
            var imgData = Request["img"];
            var shareTo = Request["share"];
            if (!checkShare(ukey, ref imgData, store))
            {
                rep.result = false;
                rep.msg    = "DB error";
            }
            else
            {
                rep.result = true;
                if (shareTo == "line")
                {
                    _dbMgr.updateShare(ukey, 0, 1);
                }
                else
                {
                    _dbMgr.updateShare(ukey, 1, 0);
                }
                rep.data = parameter._serverUrl + "s/share/" + ukey + ".html";
            }
            break;
        }

        //DEGUB
        case "listShare":
        {
            List <string> shareList = new List <string>();
            listShare(ref shareList);
            rep.data   = shareList;
            rep.result = true;
            break;
        }

        case "fixShare":
        {
            List <string> shareList = new List <string>();
            listShare(ref shareList);

            foreach (var name in shareList)
            {
                _dbMgr.updateShare(name, 1, 0);
            }
            rep.data   = shareList;
            rep.result = true;
            break;
        }

        default:
        {
            rep.result = false;
            rep.msg    = "Unknow active";
            break;
        }
        }
        var repJson = JsonConvert.SerializeObject(rep);

        Response.Write(repJson);
    }