Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     msqlConn  = FKWebTools.GetDBPool();
     mDeviceId = (string)Session["dev_id"];
     makeConfig();
     Session["run_time"] = DateTime.Now;
 }
Esempio n. 2
0
    protected void GetInfoBtn_Click(object sender, EventArgs e)
    {
        //    DisplayUserInfo();
        //     return;



        byte[] mByteParam = new byte[0];
        string mStrParam;

        try
        {
            Enables(false);
            JObject       vResultJson = new JObject();
            FKWebCmdTrans cmdTrans    = new FKWebCmdTrans();
            mUserId = UserList.SelectedItem.Value;

            vResultJson.Add("user_id", mUserId);
            mStrParam          = vResultJson.ToString(Formatting.None);
            UserPhoto.ImageUrl = null;
            cmdTrans.CreateBSCommBufferFromString(mStrParam, out mByteParam);
            mTransId             = FKWebTools.MakeCmd(msqlConn, "GET_USER_INFO", mDevId, mByteParam);
            mTransIdTxt.Text     = mTransId;
            Session["operation"] = GET_USER_INFO;

            Editable(false, "");
            UserPriv.SelectedItem.Value = "USER";
        }catch (Exception ex) {
            StatusTxt.Text = ex.ToString();
        }
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            mDevId     = (string)Session["dev_id"];
            DevID.Text = mDevId;

            //  msDbConn = ConfigurationManager.ConnectionStrings["SqlConnFkWeb"].ConnectionString.ToString();

            //  msqlConn = new SqlConnection(msDbConn);

            msqlConn = FKWebTools.GetDBPool();


            gvLog.AllowPaging = true;
            gvLog.PageSize    = 20;


            ViewState["SortExpression"] = "update_time ASC";



            BindGridView();
        }
        catch (Exception ex)
        {
            msqlConn.Close();
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        gvLog.AllowSorting = true;

        msqlConn = FKWebTools.GetDBPool();
        ViewState["SortExpression"] = "update_time ASC";
    }
Esempio n. 5
0
    private void select_device()
    {
        string sSql;
        string sJson;

        mDeviceId      = (string)Session["dev_id"];                                            //Device_List.SelectedItem.Value;
        LDev_Name.Text = Device_List.SelectedItem.Text + ":" + Device_List.SelectedItem.Value; // sqlReader.GetString(1);
        int mFlag = 0;

        sSql = "select * from tbl_fkdevice_status where device_id='" + mDeviceId + "'";
        SqlCommand    sqlCmd = new SqlCommand(sSql, msqlConn);
        SqlDataReader sqlReader = sqlCmd.ExecuteReader();
        DateTime      dtNow, dtDev;

        dtNow = DateTime.Now;
        long nTimeDiff = 0;

        try
        {
            if (sqlReader.HasRows)
            {
                if (sqlReader.Read())
                {
                    mFlag          = 1;
                    LDev_ID.Text   = mDeviceId;
                    LDev_Name.Text = sqlReader.GetString(1);
                    sJson          = sqlReader.GetString(5);
                    JObject jobjTest = JObject.Parse(sJson);
                    LDev_Firmware.Text = jobjTest["firmware"].ToString();
                    LDev_Support.Text  = jobjTest["supported_enroll_data"].ToString();//
                    dtDev              = sqlReader.GetDateTime(3);
                    nTimeDiff          = dtNow.Ticks - dtDev.Ticks;
                    UpdateTimeTxt.Text = Convert.ToString(dtDev);// +":" + Convert.ToString(dtNow) + "---->" + Convert.ToString(nTimeDiff);//
                    if (nTimeDiff > 1800000000)
                    {
                        sqlReader.Close();
                        sSql = "UPDATE tbl_fkdevice_status SET connected='0' where device_id='" + mDeviceId + "'";
                        FKWebTools.ExecuteSimpleCmd(msqlConn, sSql);
                        FKWebTools.CheckDeviceLives(msqlConn, StatusImg, UpdateTimeTxt, mDeviceId);
                        return;
                    }
                }
            }
            if (mFlag == 0)
            {
                LDev_ID.Text       = mDeviceId;
                LDev_Name.Text     = Device_List.SelectedItem.Text;
                LDev_Firmware.Text = "";
                LDev_Support.Text  = "";//
            }
            sqlReader.Close();
            FKWebTools.CheckDeviceLives(msqlConn, StatusImg, UpdateTimeTxt, mDeviceId);
        }
        catch (Exception ex)
        {
            //StatusTxt.Text = ex.ToString();
            sqlReader.Close();
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        msqlConn = FKWebTools.GetDBPool();

        mDevId = (string)Session["dev_id"];

        DevID.Text = mDevId;
    }
Esempio n. 7
0
    protected void ServerChangeBtn_Click(object sender, EventArgs e)
    {
        string mServerIpTxt = mServerIP.Text;
        string mPortTxt     = mServerPort.Text;
        int    mPort;

        if (mServerIpTxt.Length == 0)
        {
            StatusTxt.Text = ("Input the server ip address!");
            return;
        }
        try
        {
            IPAddress ipAddr = IPAddress.Parse(mServerIpTxt);
        }
        catch {
            StatusTxt.Text = ("Invaild Ip address! Please Input the server ip address!");
            mServerIP.Text = "";
            return;
        }
        if (mPortTxt.Length == 0)
        {
            StatusTxt.Text = ("Input the server Port address!");
            return;
        }

        try
        {
            mPort = Convert.ToInt32(mPortTxt);
        }
        catch
        {
            StatusTxt.Text   = ("Invaild port address! Please Input the server port address!");
            mServerPort.Text = "";
            return;
        }

        try
        {
            JObject       vResultJson = new JObject();
            FKWebCmdTrans cmdTrans    = new FKWebCmdTrans();
            vResultJson.Add("ip_address", mServerIpTxt);
            vResultJson.Add("port", mPortTxt);
            string sFinal   = vResultJson.ToString(Formatting.None);
            byte[] strParam = new byte[0];
            cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);
            mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "SET_WEB_SERVER_INFO", mDevId, strParam);
            StatusTxt.Text   = "Success : Device's server info has been changed!,so that device is no longer in this server!";
            Enables(false);
        }
        catch
        {
            StatusTxt.Text = "Error : Device's server info has not been changed!";
        }
    }
Esempio n. 8
0
 protected void ClearBtn_Click(object sender, EventArgs e)
 {
     try
     {
         Session["operation"] = ALL_DEL;
         mTransIdTxt.Text     = FKWebTools.MakeCmd(msqlConn, "CLEAR_ENROLL_DATA", mDevId, null);
     }
     catch (Exception ex)
     {
         StatusTxt.Text = ex.ToString();
     }
 }
Esempio n. 9
0
    protected void GetLogBtn_Click(object sender, EventArgs e)
    {
        string        sBeginDate = BeginDate.Text;
        string        sEndDate = EndDate.Text;
        JObject       vResultJson = new JObject();
        FKWebCmdTrans cmdTrans = new FKWebCmdTrans();
        DateTime      dtBegin, dtEnd;

        if (sBeginDate.Length > 0)
        {
            try
            {
                dtBegin    = Convert.ToDateTime(sBeginDate);
                sBeginDate = FKWebTools.GetFKTimeString14(dtBegin);
                vResultJson.Add("begin_time", sBeginDate);
            }
            catch
            {
                BeginDate.Text = "";
            }
        }

        if (sEndDate.Length > 0)
        {
            try
            {
                dtEnd    = Convert.ToDateTime(sEndDate);
                sEndDate = FKWebTools.GetFKTimeString14(dtEnd);
                vResultJson.Add("end_time", sEndDate);
            }
            catch
            {
                EndDate.Text = "";
            }
        }

        try
        {
            string sFinal   = vResultJson.ToString(Formatting.None);
            byte[] strParam = new byte[0];
            cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);
            mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "GET_LOG_DATA", mDevId, strParam);

            GetLogBtn.Enabled = false;
            ClearBtn.Enabled  = false;
            Timer.Enabled     = true;
        }
        catch (Exception ex)
        {
            StatusTxt.Text = "Fail! Get Log Data! " + ex.ToString();
        }
    }
Esempio n. 10
0
 protected void ClearLogBtn_Click(object sender, EventArgs e)
 {
     try
     {
         mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "CLEAR_LOG_DATA", mDevId, null);
         StatusTxt.Text   = "Success : All of log data has been deleted!";
         Enables(false);
     }
     catch (Exception ex)
     {
         StatusTxt.Text = "Error: All of log data delete operation failed!";
     }
 }
Esempio n. 11
0
    protected void ResetBtn_Click(object sender, EventArgs e)
    {
        try
        {
            mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "RESET_FK", mDevId, null);

            Enables(false);
        }
        catch
        {
            StatusTxt.Text = "Error: Reboot device fail!";
        }
    }
Esempio n. 12
0
 protected void DevManBtn_Click(object sender, EventArgs e)
 {
     if (mDeviceId == null || mDeviceId == "" || mDeviceId.Length == 0)
     {
         StatusTxt.Text = ("You must select avaiable device!");
         return;
     }
     if (FKWebTools.CheckDeviceLives(msqlConn, StatusImg, UpdateTimeTxt, mDeviceId) == 0)
     {
         StatusTxt.Text = "Error: Device has been disconnected!";
         return;
     }
     Response.Redirect("DeviceManage.aspx");
 }
Esempio n. 13
0
 protected void SetTimeBtn_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime      now         = DateTime.Now;
         string        sNowTxt     = FKWebTools.GetFKTimeString14(now);
         JObject       vResultJson = new JObject();
         FKWebCmdTrans cmdTrans    = new FKWebCmdTrans();
         vResultJson.Add("time", sNowTxt);
         string sFinal   = vResultJson.ToString(Formatting.None);
         byte[] strParam = new byte[0];
         cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);
         mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "SET_TIME", mDevId, strParam);
         Enables(false);
     }catch {
         StatusTxt.Text = "Error: Set time fail!";
     }
 }
Esempio n. 14
0
 protected void  DeleteUserBtn_Click(object sender, EventArgs e)
 {
     try
     {
         Session["operation"] = DEL_USER_INFO;
         string        sUserId     = UserList.SelectedItem.Value;
         FKWebCmdTrans cmdTrans    = new FKWebCmdTrans();
         JObject       vResultJson = new JObject();
         vResultJson.Add("user_id", sUserId);
         string sFinal   = vResultJson.ToString(Formatting.None);
         byte[] strParam = new byte[0];
         cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);
         mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "DELETE_USER", mDevId, strParam);
         Enables(false);
     }
     catch (Exception ex)
     {
         StatusTxt.Text = ex.ToString();
     }
 }
Esempio n. 15
0
 protected void UpdateBtn_Click(object sender, EventArgs e)
 {
     try
     {
         string default_filename       = GetFirmwareFileName();
         string FirmwareBinDir         = Path.GetDirectoryName(ConfigurationManager.AppSettings["FirmwareBinDir"]);
         byte[] bytCmdParamFirmwareBin = new byte[0];
         byte[] bytCmdParam            = new byte[0];
         if (default_filename.Length == 0)
         {
             StatusTxt.Text = ("Couldn't get file name!");
             return;
         }
         Firmware.Text    = default_filename;
         mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "UPDATE_FIRMWARE", mDevId, null);
         StatusTxt.Text   = mTransIdTxt.Text;
         Enables(false);
     }
     catch (Exception ex) {
         StatusTxt.Text = ex.ToString();
     }
 }
Esempio n. 16
0
    protected void LogManBtn_Click(object sender, EventArgs e)
    {
        if (Device_List.SelectedItem == null)
        {
            StatusTxt.Text = ("You must select device!");
            return;
        }
        mDeviceId      = Device_List.SelectedItem.Value;
        StatusTxt.Text = "ID=" + mDeviceId;
        if (mDeviceId == null || mDeviceId == "" || mDeviceId.Length == 0)
        {
            StatusTxt.Text = ("You must select avaiable device!");
            return;
        }
        if (FKWebTools.CheckDeviceLives(msqlConn, StatusImg, UpdateTimeTxt, mDeviceId) == 0)
        {
            StatusTxt.Text = "Error: Device has been disconnected!";
            return;
        }

        emptyUserListTable();
        Response.Redirect("LogManager.aspx");
    }
Esempio n. 17
0
    protected void DevNameChangeBtn_Click(object sender, EventArgs e)
    {
        string mDevNameTxt = mDeviceName.Text;

        if (mDevNameTxt.Length == 0)
        {
            StatusTxt.Text = ("Input the device name!");
            return;
        }
        try{
            JObject       vResultJson = new JObject();
            FKWebCmdTrans cmdTrans    = new FKWebCmdTrans();
            vResultJson.Add("fk_name", mDevNameTxt);
            string sFinal   = vResultJson.ToString(Formatting.None);
            byte[] strParam = new byte[0];
            cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);
            mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "SET_FK_NAME", mDevId, strParam);
            StatusTxt.Text   = "Success : Device name has been changed!";
            Enables(false);
        }
        catch {
            StatusTxt.Text = "Error : Device name has not been changed!";
        }
    }
Esempio n. 18
0
 protected void ConnectStatusTimer_Watch(object sender, EventArgs e)
 {
     FKWebTools.CheckDeviceLives(msqlConn, StatusImg, UpdateTimeTxt, mDevId);
 }
Esempio n. 19
0
    private void DisplayUserInfo()
    {
        string        sTransId = mTransIdTxt.Text;
        FKWebCmdTrans cmdTrans = new FKWebCmdTrans();
        JObject       vResultJson;// = new JObject();

        mUserId = UserList.SelectedItem.Value;

        string sCmdCode = "";

        if (sTransId.Length == 0)
        {
            return;
        }
        string        sSql      = "select trans_id, cmd_code from tbl_fkcmd_trans where trans_id='" + sTransId + "' AND status='RESULT'";
        SqlCommand    sqlCmd    = new SqlCommand(sSql, msqlConn);
        SqlDataReader sqlReader = sqlCmd.ExecuteReader();

        sTransId = "";
        if (sqlReader.HasRows)
        {
            if (sqlReader.Read())
            {
                sTransId = sqlReader.GetString(0);
                sCmdCode = sqlReader.GetString(1);
            }
        }
        sqlReader.Close();

        if (sTransId.Length == 0)
        {
            return;
        }

        sSql   = "select @cmd_result=cmd_result from tbl_fkcmd_trans_cmd_result where trans_id='" + sTransId + "'";
        sqlCmd = new SqlCommand(sSql, msqlConn);
        SqlParameter sqlParamCmdParamBin = new SqlParameter("@cmd_result", SqlDbType.VarBinary);

        sqlParamCmdParamBin.Direction = ParameterDirection.Output;
        sqlParamCmdParamBin.Size      = -1;
        sqlCmd.Parameters.Add(sqlParamCmdParamBin);

        sqlCmd.ExecuteNonQuery();

        byte[] bytCmdResult = (byte[])sqlParamCmdParamBin.Value;

        byte[] bytResultBin = new byte[0];
        string sResultText;


        cmdTrans.GetStringAndBinaryFromBSCommBuffer(bytCmdResult, out sResultText, out bytResultBin);
        vResultJson = JObject.Parse(sResultText);
        //a cmdTrans.PrintDebugMsg("", "");
        UserID.Text   = vResultJson["user_id"].ToString();
        UserName.Text = vResultJson["user_name"].ToString();

        string sUserpriv = vResultJson["user_privilege"].ToString();

        UserPriv.SelectedIndex = UserPriv.Items.IndexOf(UserPriv.Items.FindByText(sUserpriv));

        int vnBinIndex = 0;
        int vnBinCount = FKWebTools.BACKUP_MAX + 1;

        int[] vnBackupNumbers = new int[vnBinCount];

        for (int i = 0; i < vnBinCount; i++)
        {
            vnBackupNumbers[i] = -1;
            if (i <= FKWebTools.BACKUP_FP_9)
            {
                FKWebTools.mFinger[i] = new byte[0];
            }
        }
        FKWebTools.mFace  = new byte[0];
        FKWebTools.mPhoto = new byte[0];
        try
        {
            string vStrUserPhotoBinIndex = vResultJson["user_photo"].ToString(); //aCmdParamJson.get("user_photo", "").asString();
            if (vStrUserPhotoBinIndex.Length != 0)
            {
                vnBinIndex = FKWebTools.GetBinIndex(vStrUserPhotoBinIndex) - 1;
                vnBackupNumbers[vnBinIndex] = FKWebTools.BACKUP_USER_PHOTO;
            }
        }
        catch (Exception e)
        {
        }



        string tmp = "";

        JArray vEnrollDataArrayJson = JArray.Parse(vResultJson["enroll_data_array"].ToString());

        foreach (JObject content in vEnrollDataArrayJson.Children <JObject>())
        {
            int vnBackupNumber = Convert.ToInt32(content["backup_number"].ToString());

            string vStrBinIndex = content["enroll_data"].ToString();
            vnBinIndex = FKWebTools.GetBinIndex(vStrBinIndex) - 1;
            vnBackupNumbers[vnBinIndex] = vnBackupNumber;
            tmp = tmp + ":" + Convert.ToInt32(vnBinIndex) + "-" + Convert.ToInt32(vnBackupNumber);
        }
        Fp.Checked     = false;
        Face.Checked   = false;
        StatusTxt.Text = tmp;
        for (int i = 0; i < vnBinCount; i++)
        {
            if (vnBackupNumbers[i] == -1)
            {
                continue;
            }

            if (vnBackupNumbers[i] == FKWebTools.BACKUP_USER_PHOTO)
            {
                byte[] bytResultBinParam = new byte[0];
                int    vnBinLen          = FKWebTools.GetBinarySize(bytResultBin, out bytResultBin);
                string AbsImgUri         = Server.MapPath(".") + "\\photo\\" + mDevId + "_" + mUserId + ".jpg";
                string relativeImgUrl    = ".\\photo\\" + mDevId + "_" + mUserId + ".jpg";
                FKWebTools.GetBinaryData(bytResultBin, vnBinLen, out bytResultBinParam, out bytResultBin);
                FKWebTools.mPhoto = new byte[vnBinLen];

                Array.Copy(bytResultBinParam, FKWebTools.mPhoto, vnBinLen);
                try
                {
                    FileStream fs = new FileStream(AbsImgUri, FileMode.Create, FileAccess.Write);
                    fs.Write(bytResultBinParam, 0, bytResultBinParam.Length);
                    fs.Close();
                }
                catch
                { }
                UserPhoto.ImageUrl = relativeImgUrl;
            }
            if (vnBackupNumbers[i] == FKWebTools.BACKUP_PSW)
            {
                byte[] bytResultBinParam = new byte[0];
                Password.Text = cmdTrans.GetStringFromBSCommBuffer(bytResultBin);
                int vnBinLen = FKWebTools.GetBinarySize(bytResultBin, out bytResultBin);
                FKWebTools.GetBinaryData(bytResultBin, vnBinLen, out bytResultBinParam, out bytResultBin);
            }
            if (vnBackupNumbers[i] == FKWebTools.BACKUP_CARD)
            {
                byte[] bytResultBinParam = new byte[0];
                CardNum.Text = cmdTrans.GetStringFromBSCommBuffer(bytResultBin);
                int vnBinLen = FKWebTools.GetBinarySize(bytResultBin, out bytResultBin);
                FKWebTools.GetBinaryData(bytResultBin, vnBinLen, out bytResultBinParam, out bytResultBin);
            }

            if (vnBackupNumbers[i] == FKWebTools.BACKUP_FACE)
            {
                byte[] bytResultBinParam = new byte[0];
                int    vnBinLen          = FKWebTools.GetBinarySize(bytResultBin, out bytResultBin);
                FKWebTools.GetBinaryData(bytResultBin, vnBinLen, out bytResultBinParam, out bytResultBin);
                Face.Checked     = true;
                FKWebTools.mFace = new byte[vnBinLen];
                Array.Copy(bytResultBinParam, FKWebTools.mFace, vnBinLen);
            }
            if (vnBackupNumbers[i] >= FKWebTools.BACKUP_FP_0 && vnBackupNumbers[i] <= FKWebTools.BACKUP_FP_9)
            {
                byte[] bytResultBinParam = new byte[0];
                int    vnBinLen          = FKWebTools.GetBinarySize(bytResultBin, out bytResultBin);
                FKWebTools.GetBinaryData(bytResultBin, vnBinLen, out bytResultBinParam, out bytResultBin);
                Fp.Checked = true;
                FKWebTools.mFinger[vnBackupNumbers[i]] = new byte[vnBinLen];
                Array.Copy(bytResultBinParam, FKWebTools.mFinger[vnBackupNumbers[i]], vnBinLen);
            }
        }
    }
Esempio n. 20
0
 public void emptyUserListTable()
 {
     mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "GET_USER_ID_LIST", mDevId, null);
 }
Esempio n. 21
0
    protected void  SetInfoBtn_Click(object sender, EventArgs e)
    {
        try
        {
            Session["operation"] = SET_USER_INFO;
            JObject       vResultJson          = new JObject();
            JArray        vEnrollDataArrayJson = new JArray();
            FKWebCmdTrans cmdTrans             = new FKWebCmdTrans();
            string        sUserPwd             = Password.Text;
            string        sUserCard            = CardNum.Text;
            int           index     = 1;
            string        sUserId   = UserID.Text;
            string        sUserName = UserName.Text;
            string        sUserPriv = UserPriv.SelectedItem.Text;

            UserPhoto.ImageUrl = ".\\photo\\" + mDevId + "_" + sUserId + ".jpg";

            vResultJson.Add("user_id", sUserId);
            vResultJson.Add("user_name", sUserName);
            vResultJson.Add("user_privilege", sUserPriv);
            if (FKWebTools.mPhoto.Length > 0)
            {
                vResultJson.Add("user_photo", FKWebTools.GetBinIndexString(index++));
            }

            for (int nIndex = 0; nIndex <= FKWebTools.BACKUP_FP_9; nIndex++)
            {
                if (FKWebTools.mFinger[nIndex].Length > 0)
                {
                    JObject vEnrollDataJson = new JObject();
                    vEnrollDataJson.Add("backup_number", nIndex);
                    vEnrollDataJson.Add("enroll_data", FKWebTools.GetBinIndexString(index++));
                    vEnrollDataArrayJson.Add(vEnrollDataJson);
                }
            }
            if (sUserPwd.Length > 0)
            {
                JObject vEnrollDataJson = new JObject();
                vEnrollDataJson.Add("backup_number", FKWebTools.BACKUP_PSW);
                vEnrollDataJson.Add("enroll_data", FKWebTools.GetBinIndexString(index++));
                vEnrollDataArrayJson.Add(vEnrollDataJson);
            }

            if (sUserCard.Length > 0)
            {
                JObject vEnrollDataJson = new JObject();
                vEnrollDataJson.Add("backup_number", FKWebTools.BACKUP_CARD);
                vEnrollDataJson.Add("enroll_data", FKWebTools.GetBinIndexString(index++));
                vEnrollDataArrayJson.Add(vEnrollDataJson);
            }
            if (FKWebTools.mFace.Length > 0)
            {
                JObject vEnrollDataJson = new JObject();
                vEnrollDataJson.Add("backup_number", FKWebTools.BACKUP_FACE);
                vEnrollDataJson.Add("enroll_data", FKWebTools.GetBinIndexString(index++));
                vEnrollDataArrayJson.Add(vEnrollDataJson);
            }
            vResultJson.Add("enroll_data_array", vEnrollDataArrayJson);
            string sFinal = vResultJson.ToString(Formatting.None);

            byte[] binData  = new byte[0];
            byte[] strParam = new byte[0];

            if (FKWebTools.mPhoto.Length > 0)
            {
                FKWebTools.AppendBinaryData(ref binData, FKWebTools.mPhoto);
            }

            for (int nIndex = 0; nIndex <= FKWebTools.BACKUP_FP_9; nIndex++)
            {
                if (FKWebTools.mFinger[nIndex].Length > 0)
                {
                    FKWebTools.AppendBinaryData(ref binData, FKWebTools.mFinger[nIndex]);
                }
            }
            if (sUserPwd.Length > 0)
            {
                byte[] mPwdBin = new byte[0];
                cmdTrans.CreateBSCommBufferFromString(sUserPwd, out mPwdBin);
                FKWebTools.ConcateByteArray(ref binData, mPwdBin);
            }
            if (sUserCard.Length > 0)
            {
                byte[] mCardBin = new byte[0];
                cmdTrans.CreateBSCommBufferFromString(sUserCard, out mCardBin);
                FKWebTools.ConcateByteArray(ref binData, mCardBin);
            }
            if (FKWebTools.mFace.Length > 0)
            {
                FKWebTools.AppendBinaryData(ref binData, FKWebTools.mFace);
            }

            cmdTrans.CreateBSCommBufferFromString(sFinal, out strParam);

            FKWebTools.ConcateByteArray(ref strParam, binData);

            mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "SET_USER_INFO", mDevId, strParam);
            Enables(false);
        }
        catch (Exception ex)
        {
            StatusTxt.Text = ex.ToString();
        }
    }
Esempio n. 22
0
 protected void UpdateUserListBtn_Click(object sender, EventArgs e)
 {
     Enables(false);
     mTransIdTxt.Text = FKWebTools.MakeCmd(msqlConn, "GET_USER_ID_LIST", mDevId, null);
     Editable(false, "");
 }
Esempio n. 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        const string csFuncName = "Page_Load";
        string       sDevId;
        string       sTransId;
        string       sRequestCode;
        int          lenContent;

        byte[] bytRequestBin;
        byte[] bytRequestTotal;
        byte[] bytEmpty = new byte[0];

        FKWebCmdTrans cmdTrans = new FKWebCmdTrans();

        //Debug.WriteLine("Loading the page");
        //cmdTrans.PrintDebugMsg(csFuncName, "1");

        //{ #### 이 부분은 자체검사를 위한 부분이다. 최종판본에서는 삭제해야 한다.
        //cmdTrans.PrintDebugMsg(csFuncName, "2 - HOST:" + Request.Headers["HOST"]);
        //cmdTrans.PrintDebugMsg(csFuncName, "2 - trans_id:" + Request.Headers["trans_id"]);
        //cmdTrans.PrintDebugMsg(csFuncName, "2 - dev_id:" + Request.Headers["dev_id"]);
        //cmdTrans.PrintDebugMsg(csFuncName, "2 - blk_id:" + Request.Headers["blk_id"]);

        //cmdTrans.Test();
        //cmdTrans.TestStoredProcedureBinData();
        //byte [] bytTest;
        //cmdTrans.CreateBSCommBufferFromString("aaa", out bytTest);
        //cmdTrans.TestNewtonsoftJsonLib();
        //cmdTrans.MakeSetTimeCmdParamBin("SET_TIME", ref bytTest);
        //} ####

        // HTTP헤더에서 request_code 필드의 값을 얻는다.
        // 이 코드에는 현재의 요구가 무엇을 하려는것인가를 나타낸다.
        sRequestCode = Request.Headers["request_code"];

        if (!FKWebTools.IsValidEngDigitString(sRequestCode, 32))
        {
            cmdTrans.PrintDebugMsg(csFuncName, "error - Invalid request_code : " + sRequestCode);
            Response.Close();
            return;
        }
        // 일부 HTTP요구들에는 헤더에 trans_id필드가 존재하지 않을수도 있다.
        // 그러므로 그러한 경우에 대처하기 위하여 try/catch블로크를 사용한다.
        try
        {
            sTransId = Request.Headers["trans_id"];
            if (sTransId.Length > 0)
            {
                cmdTrans.PrintDebugMsg(csFuncName, "**************** sRequestCode = " + sRequestCode + " dev_id=" + Request.Headers["dev_id"] + " trans_id=" + sTransId + " content_length=" + Request.Headers["Content-Length"]);
            }
        }
        catch (Exception)
        {
            sTransId = "";
        }
        cmdTrans.PrintDebugMsg(csFuncName, "1 - request_code : " + sRequestCode + " ,trans_id : " + sTransId);

        // HTTP헤더에서 dev_id 필드의 값을 얻는다.
        // dev_id 필드의 값은 영수문자로서 최대 18문자이여야 한다.
        // 만일 이 필드가 빈 문자렬이면 허튼 요구라고 보고 응답하지 않는다.
        sDevId = Request.Headers["dev_id"];
        if (!FKWebTools.IsValidEngDigitString(sDevId, 18))
        {
            cmdTrans.PrintDebugMsg(csFuncName, "error - Invalid dev_id : " + sDevId);
            Response.Close();
            return;
        }

        //cmdTrans.PrintDebugMsg(csFuncName, "2 - " + sDevId);
        //cmdTrans.PrintDebugMsg(csFuncName, "2 - " + sDevId+);

        // HTTP POST요구와 함께 올라오는 바이너리 자료를 수신한다.
        lenContent = GetRequestStreamBytes(out bytRequestBin);
        if (lenContent < 0)
        {
            cmdTrans.PrintDebugMsg1(csFuncName, "2.1" + lenContent);

            // 만일 HTTP 헤더의 Content-Length만한 바이트를 다 접수하지 못한 경우는 접속을 차단한다.
            Response.Close();
            return;
        }

        // 기대는 HTTP요구에 덧붙여 보낼 자료가 클 때에는(5KB 이상)
        //  전체 자료를 블로크로 나누고 해당 request_code를 가진 요구를 여러번에 걸쳐 보낼수 있다.
        // 이때 첫시작블로크의 번호는 1, 마지막블로크의 번호는 0이다.
        // 서버측에서는 블로크번호가 1이상인 블로크가 올라오면 그 자료를 바퍼에 축적해나가다가
        //  블로크번호 0인 블로크가 접수되면 축적된 자료를 가지고 실제의 처리를 진행한다.
        // 블로크는 이전 블로크번호의 다음번호를 가지고 올라온다.
        int nBlkNo  = Convert.ToInt32(Request.Headers["blk_no"]);
        int nBlkLen = Convert.ToInt32(Request.Headers["blk_len"]);
        int vRet;

        if (nBlkNo > 0)
        {
            cmdTrans.PrintDebugMsg1(csFuncName, "3.0 - blk_no=" + Convert.ToString(nBlkNo) + ", blk_len=" + Convert.ToString(nBlkLen));

            // 블로크번호가 1 이상인 경우는 해당 블로크에 대한 자료를
            //  Web App범위에서 관리되는 기대에 대한 메모리스트림에 추가한다.
            vRet = AddBlockData(sDevId, nBlkNo, bytRequestBin);
            if (vRet != 0)
            {
                cmdTrans.PrintDebugMsg1(csFuncName, "3.0 - error - AddBlockData:" + Convert.ToString(vRet));
                SendResponseToClient("ERROR_ADD_BLOCK_DATA", sTransId, "", bytEmpty);
                return;
            }

            cmdTrans.PrintDebugMsg1(csFuncName, "3.1");

            SendResponseToClient("OK", sTransId, "", bytEmpty);
            return;
        }
        else if (nBlkNo < 0)
        {
            cmdTrans.PrintDebugMsg(csFuncName, "3.3 - blk_no=" + Convert.ToString(nBlkNo) + ", blk_len=" + Convert.ToString(nBlkLen));

            // 비정상적인 HTTP요구(블로크번호가 무효한 값)가 올라온 경우이다.
            SendResponseToClient("ERROR_INVLAID_BLOCK_NO", sTransId, "", bytEmpty);
            return;
        }
        else
        {
            cmdTrans.PrintDebugMsg(csFuncName, "3.4 - blk_no=" + Convert.ToString(nBlkNo) + ", blk_len=" + Convert.ToString(nBlkLen));

            // 기대측에서 결과자료를 보낼때 마지막 블로크를 보냈다면
            //  메모리스트림에 루적하였던 자료를 얻어내여 그 뒤에 최종으로 받은 블로크를 덧붙인다.
            GetBlockDataAndRemove(sDevId, out bytRequestTotal);
            FKWebTools.ConcateByteArray(ref bytRequestTotal, bytRequestBin);
        }

        if (sRequestCode == REQ_CODE_RECV_CMD)
        {
            // 블로크자료를 접수하기 위하여 창조하였던 스트림오브젝트가 지내 이전에 만들어진것이면
            //  그것을 삭제한다. 이러한 상황은 기대가 블로크자료를 올려보내던 도중 정전과 같은 이상현상으로 죽어버린 이후로부터
            //  현재까지 아무런 요구도 보내지 않으면 발생한다.
            RemoveOldBlockStream();

            OnReceiveCmd(cmdTrans, sDevId, sTransId, bytRequestTotal);
        }
        else if (sRequestCode == REQ_CODE_SEND_CMD_RESULT)
        {
            OnSendCmdResult(cmdTrans, sDevId, sTransId, bytRequestTotal);
        }
        else if (sRequestCode == REQ_CODE_REALTIME_GLOG)
        {
            OnRealtimeGLog(cmdTrans, sDevId, bytRequestTotal);
        }
        else if (sRequestCode == REQ_CODE_REALTIME_ENROLL)
        {
            OnRealtimeEnrollData(cmdTrans, sDevId, bytRequestTotal);
        }
        else
        {
            SendResponseToClient("ERROR_INVLAID_REQUEST_CODE", sTransId, "", bytEmpty);
            return;
        }
    }
Esempio n. 24
0
 public void emptyUserListTable()
 {
     Session["trans_id"] = FKWebTools.MakeCmd(msqlConn, "GET_USER_ID_LIST", mDeviceId, null);
 }