예제 #1
0
            public AccountType(string name, string psw, string lvl)
            {
                mName = name;
                mPsw  = psw;
                mLvl  = lvl;
                //add to database
                HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
                ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

                up.mCode   = "11N1";
                up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
                up.mParamU = "RPAT&" + mName + "&" + mPsw + "&" + mLvl;
                ConsoleCodeDownTransmissionType newDown = new ConsoleCodeDownTransmissionType();
                HttpHandlerException            newE    = handler.goSingle(up, out newDown, "POST");

                if (newE.IsOK())
                {
                    mId     = Convert.ToInt32(newDown.mServiceAnwser);
                    mInited = true;
                }
                else
                {
                    throw new Exception(newE.getMessage());
                }
            }
예제 #2
0
            public FlowerInfoType(string name, string description, string info)
            {
                mName        = name;
                mDescription = description;
                mInfo        = info;
                //add to database
                HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
                ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

                up.mCode   = "11N1";
                up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
                up.mParamU = "RPFI&" + mName + "&" + mDescription + "&" + mInfo;
                ConsoleCodeDownTransmissionType newDown = new ConsoleCodeDownTransmissionType();
                HttpHandlerException            newE    = handler.goSingle(up, out newDown, "POST");

                if (newE.IsOK())
                {
                    mId     = Convert.ToInt32(newDown.mServiceAnwser);
                    mInited = true;
                }
                else
                {
                    throw new Exception(newE.getMessage());
                }
            }
예제 #3
0
            public AccountType(int id)
            {
                mId = id;
                //read from database
                HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
                ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

                up.mCode   = "11R1";
                up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
                up.mParamU = "RPAT&" + id;
                ConsoleCodeDownTransmissionType readDown = new ConsoleCodeDownTransmissionType();
                HttpHandlerException            readE    = handler.goSingle(up, out readDown, "POST");

                if (readE.IsOK())
                {
                    string[] dataGrp = readDown.mServiceAnwser.Split('&');
                    mName   = dataGrp[0];
                    mPsw    = dataGrp[1];
                    mLvl    = dataGrp[2];
                    mInited = true;
                }
                else
                {
                    throw new Exception(readE.getMessage());
                }
            }
예제 #4
0
        public FlowerPicCtrl(string name, string description, byte[] buf, string type, Action onDelete)
        {
            mName        = name;
            mDescription = description;
            mPicBuf      = buf;
            mType        = type;
            mOnDelete    = onDelete;
            //add to database
            HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
            ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

            up.mCode   = "11N1";
            up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
            up.mParamU = "RPFP&" + mName + "&" + mDescription + "&" + mType + "&" + Convert.ToBase64String(mPicBuf);
            ConsoleCodeDownTransmissionType newDown = new ConsoleCodeDownTransmissionType();
            HttpHandlerException            newE    = handler.goSingle(up, out newDown, "POST");

            if (newE.IsOK())
            {
                mId     = Convert.ToInt32(newDown.mServiceAnwser);
                mInited = true;
            }
            else
            {
                throw new Exception(newE.getMessage());
            }

            InitializeComponent();
        }
예제 #5
0
            public void remove()
            {
                HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
                ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

                up.mCode   = "11D0";
                up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
                up.mParamU = "RPAT&" + mId;
                ConsoleCodeDownTransmissionType deleteDown = new ConsoleCodeDownTransmissionType();
                HttpHandlerException            removeE    = handler.goSingle(up, out deleteDown, "POST");

                if (!removeE.IsOK())
                {
                    throw new Exception(removeE.getMessage());
                }
            }
예제 #6
0
            private void sync()
            {
                HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
                ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

                up.mCode   = "11U0";
                up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
                up.mParamU = "RPAT&" + mId + "&" + mName + "&" + mPsw + "&" + mLvl;
                ConsoleCodeDownTransmissionType upDateDown = new ConsoleCodeDownTransmissionType();
                HttpHandlerException            syncE      = handler.goSingle(up, out upDateDown, "POST");

                if (!syncE.IsOK())
                {
                    throw new Exception(syncE.getMessage());
                }
            }
예제 #7
0
 private void handleHttpResponse(ConsoleCodeDownTransmissionType response, HttpHandlerException e)
 {
     this.Dispatcher.Invoke(new Action(delegate
     {
         if (e.IsOK())
         {
             mHttpResponseBox.Text         = response.mServiceAnwser;
             mHttpResponseStateBox.Content = "";
         }
         else
         {
             mHttpResponseStateBox.Content = e.getMessage();
             mHttpResponseBox.Text         = "";
         }
     }));
 }
예제 #8
0
        public FlowerPicCtrl(int id, Action onDelete)
        {
            mId       = id;
            mOnDelete = onDelete;
            //read from database
            HttpHandler handler = new HttpHandler(DAO.sConsoleUrl);
            ConsoleCodeUpTransmissionType up = new ConsoleCodeUpTransmissionType();

            up.mCode   = "11R1";
            up.mParamL = StdMd5Maker.toMd5String(DAO.sUserName + DAO.sPassword);
            up.mParamU = "RPFP&" + id;
            ConsoleCodeDownTransmissionType readDown = new ConsoleCodeDownTransmissionType();
            HttpHandlerException            readE    = handler.goSingle(up, out readDown, "POST");

            if (readE.IsOK())
            {
                string[] dataGrp = readDown.mServiceAnwser.Split('&');
                mName        = dataGrp[0];
                mDescription = dataGrp[1];
                mType        = dataGrp[2];
                StringBuilder picData = new StringBuilder();
                picData.Append(dataGrp[3]);
                if (dataGrp.Length > 4)
                {
                    //recover data
                    for (int index = 4; index < dataGrp.Length; ++index)
                    {
                        picData.Append("&").Append(dataGrp[index]);
                    }
                }
                mPicBuf = Convert.FromBase64String(picData.ToString());

                mInited = true;
            }
            else
            {
                throw new Exception(readE.getMessage());
            }

            InitializeComponent();
        }