public override bool ProcessAnswer(IGAnswer answer) { string sLogin = answer.GetAttributeValue(IGREQUEST_USERLOGIN); string sFrameId = answer.GetParameterValue(IGREQUEST_FRAMEID); string sImageOutputPath = answer.GetParameterValue(IGREQUEST_PATH); sImageOutputPath = sImageOutputPath.Substring(0, sImageOutputPath.LastIndexOf('\\') + 1) + HC.PATH_LASTSAVEDPICTURE; if (!File.Exists(sImageOutputPath)) return false; string sImagePath = GetParameterValue(IGREQUEST_PATH); string sImagePathJPEG = sImagePath.Remove(sImagePath.Length - Path.GetExtension(sImagePath).Length) + "$" + GetAttributeValue(IGREQUEST_GUID) + ".JPG"; string sAccountMiniImagePath = HC.PATH_USERACCOUNT + sLogin + HC.PATH_USERMINI + HC.PATH_PREFIXMINI + sImagePath; Image imgInput = Image.FromFile(sImageOutputPath); float fRate = HC.MINIPICTURE_MAXSIZE / (float)Math.Max(imgInput.Size.Width, imgInput.Size.Height); Image imgMini = new Bitmap(imgInput, new Size((int)((float)imgInput.Size.Width * fRate), (int)((float)imgInput.Size.Height * fRate))); imgMini.Save(sAccountMiniImagePath, ImageFormat.Jpeg); imgMini.Save(HC.PATH_OUTPUT + sLogin + HC.PATH_OUTPUTMINI + HC.PATH_PREFIXMINI + sImagePathJPEG, ImageFormat.Jpeg); answer.SetParameter(IGREQUEST_SIZE, imgMini.Width.ToString() + "," + imgMini.Height.ToString()); return true; }
public override void GetParams(IGAnswer answer, HttpSessionState session) { if ((string)session[IGAnswer.IGANSWER_IMAGELIBRARY] == null) session[IGAnswer.IGANSWER_IMAGELIBRARY] = ""; string sLogin = answer.GetAttributeValue(IGREQUEST_USERLOGIN); string sServerIP = answer.GetParameterValue(IGAnswer.IGANSWER_SERVERIP); string sImagePath = GetParameterValue(IGREQUEST_PATH); string sImagePathExt = Path.GetExtension(sImagePath); string sImagePathPrefix = sImagePath.Remove(sImagePath.Length - Path.GetExtension(sImagePath).Length) + "$"; sImagePath = sImagePathPrefix + GetAttributeValue(IGREQUEST_GUID) + sImagePathExt; string sMiniOutputImagePath = HC.PATH_OUTPUTVIRTUAL + sServerIP + "/" + sLogin + HC.PATH_OUTPUTMINI + HC.PATH_PREFIXMINI + sImagePath; string sImageLibrary = (string)(string)session[IGAnswer.IGANSWER_IMAGELIBRARY]; sImageLibrary = sImageLibrary.ToUpper(); SetParameter(IGREQUEST_SIZE, answer.GetParameterValue(IGREQUEST_SIZE)); List<string> lsListSize = new List<string>(); splitParamToList(lsListSize, IGREQUEST_SIZE); m_pairSize = new KeyValuePair<string, string>(lsListSize[1], lsListSize[2]); if (sImageLibrary.Contains(sImagePathPrefix.ToUpper())) { int nIdxImPath = sImageLibrary.IndexOf(sImagePathPrefix.ToUpper()); int nIdxNextDot = sImageLibrary.IndexOf(',', nIdxImPath); if (nIdxNextDot < nIdxImPath) nIdxNextDot = sImageLibrary.Length; string sOldImagePath = HC.PATH_OUTPUTVIRTUAL + sServerIP + "/" + sLogin + HC.PATH_OUTPUTMINI + HC.PATH_PREFIXMINI + sImageLibrary.Substring(nIdxImPath, nIdxNextDot - nIdxImPath); sOldImagePath = sOldImagePath.ToUpper(); SetParameter(IGAnswer.IGANSWER_IMAGELIBRARY, sImageLibrary); List<string> lsOutputPath = new List<string>(); splitParamToList(lsOutputPath, IGAnswer.IGANSWER_IMAGELIBRARY); lsOutputPath[lsOutputPath.IndexOf(sOldImagePath)] = sMiniOutputImagePath; lsOutputPath.RemoveAt(0); session[IGAnswer.IGANSWER_IMAGELIBRARY] = createParamFromList(lsOutputPath); } else { if ((string)session[IGAnswer.IGANSWER_IMAGELIBRARY] != "") session[IGAnswer.IGANSWER_IMAGELIBRARY] += ","; session[IGAnswer.IGANSWER_IMAGELIBRARY] += sMiniOutputImagePath; session[IGAnswer.IGANSWER_IMAGELIBRARY] += "," + lsListSize[1]; // width session[IGAnswer.IGANSWER_IMAGELIBRARY] += "," + lsListSize[2]; // height } SetParameter(IGREQUEST_USERLOGIN, sLogin); SetParameter(IGAnswer.IGANSWER_SERVERIP, sServerIP); SetParameter(IGREQUEST_PATH, sMiniOutputImagePath); }