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()); } }
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()); } }
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(); }
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()); } }
public void goTimer <R>(object t, string method, int interval, Action <R, HttpHandlerException> timerProcess) { Timer timer = new Timer(delegate { R r; HttpHandlerException e = goSingle(t, out r, method); timerProcess(r, e); }, null, 0, interval); }
public void goSingleAsync <R>(object t, string method, Action <R, HttpHandlerException> callback) { Thread asyncThread = new Thread(new ThreadStart(delegate { R r; HttpHandlerException e = goSingle(t, out r, method); callback(r, e); })); asyncThread.Start(); }
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()); } }
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()); } }
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 = ""; } })); }
public void goCycle <R>(object t, string method, int cycleNum, Action <R, HttpHandlerException> cycleProcess) { Thread cycleThread = new Thread(new ThreadStart(delegate { while (cycleNum != 0) { R r; HttpHandlerException e = goSingle(t, out r, method); cycleProcess(r, e); --cycleNum; if (cycleNum < 0) { cycleNum = -1; } } })); cycleThread.Start(); }
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(); }