public IHttpActionResult ImagesShow() { QpiroJSON resp = new QpiroJSON(); string img_path = ""; string valImg = HttpContext.Current.Request["name"]; string valTyp = HttpContext.Current.Request["type"]; try { if (valImg == null || valTyp == null) throw new Exception("Parametreler geçersiz."); UserProperty.ImgType itype = new UserProperty.ImgType(); try { itype = (UserProperty.ImgType)ImageProperty.StringToEnum(typeof(UserProperty.ImgType), valTyp); } catch { throw new Exception("Tip doğrulanamadı."); } HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); if (itype == UserProperty.ImgType.Resources) img_path = UserProperty.ResourcePhotos_Path; else if (itype == UserProperty.ImgType.Saved) img_path = UserProperty.SavedPhotos_Path; else if (itype == UserProperty.ImgType.Mini) img_path = Path.Combine(UserProperty.Data_Path, PixFormat._94x94.ToString()); if (!Directory.Exists(img_path)) throw new Exception("Mini dosya yolu doğrulanamadı."); img_path = Path.Combine(img_path, valImg + ImageProperty.JPG); if (!File.Exists(img_path)) throw new Exception("Mini dosya bulunamadı."); Bitmap btm = new Bitmap(img_path); string val = ImageProperty.ImageToBase64(btm, System.Drawing.Imaging.ImageFormat.Jpeg); resp.Data.Add(val); btm.Dispose(); val = null; } catch (Exception e) { resp.Message = e.Message; } return this.Json<QpiroJSON>(resp); }
public IHttpActionResult ImageGenerate() { QpiroJSON resp = new QpiroJSON(); UserProperty.ImgType itype = new UserProperty.ImgType(); PixFormat PixelFormat = new PixFormat(); string imgName = ""; try { /////////////////////////////////////////////// int bsy = UserProperty.XmlGetValue("Busy"); if (bsy == 1) throw new Exception("Bir işlem halen devam etmekte bitmesini bekleyiniz.") { Source = "Busy" }; /////////////////////////////////////////////////// int tck = UserProperty.XmlGetValue("Ticket"); if (tck == -3) { throw new Exception("Kullanıcı bilgileri bulunamadı.") { Source = "Ticket1" }; } else { if (!UserProperty.EmailVerified) throw new Exception("Eposta adresinizi onaylamanız gerekmektedir") { Source = "EVerified" }; if (-1 >= tck - 1) { throw new Exception("Biletiniz bitmiş işlem yapamıyoruz.") { Source = "Ticket2" }; } else { UserProperty.XmlUpdate("Ticket", -1, true); UserProperty.XmlUpdate("Busy", 1, false); } } //////////////////////////////////////////////////// imgName = Convert.ToString(HttpContext.Current.Request["imagename"]); itype = UserProperty.ImgType.Resources; string typ = HttpContext.Current.Request["pixtype"]; if (typ == null) throw new Exception("Lütfen format seçiniz") { Source = "" }; PixelFormat = (PixFormat)ImageProperty.StringToEnum(typeof(PixFormat), Convert.ToString(typ)); } catch (Exception e) { if (e.Source == "Ticket1" || e.Source == "Ticket2" || e.Source == "Ticket3" || e.Source == "Ticket4" || e.Source == "Busy" || e.Source == "EVerified") { } else { UserProperty.XmlUpdate("Ticket", 1, true); UserProperty.XmlUpdate("Busy", 0, false); } resp.Message = e.Message; return this.Json<QpiroJSON>(resp); } try { string imgPath = ""; switch (itype) { case UserProperty.ImgType.Resources: imgPath = Path.Combine(UserProperty.ResourcePhotos_Path, imgName + ImageProperty.JPG); break; default: throw new Exception("Tanımlanamayan imagename formatı") { Source = "" }; break; } if (File.Exists(imgPath)) { DateTime start = DateTime.Now; System.GC.Collect(); List<PartOfImage> imgsInf = ImageProperty.PartOfImage(imgPath, imgName, (int)PixelFormat); ServerAsyncCallBack servers = new ServerAsyncCallBack(); servers.Execute(_QPR.Type.AsyncCallType.ImageGenerate, imgsInf, (int)PixelFormat); imgsInf.Clear(); if (UserProperty.ComputerNumber == 1) { do { Thread.Sleep(999); } while (servers._respLocalTest.Status == TaskStatus.WaitingForActivation); } else { do { Thread.Sleep(999); } while ( servers._resp1.Status == TaskStatus.WaitingForActivation || servers._resp2.Status == TaskStatus.WaitingForActivation || servers._resp3.Status == TaskStatus.WaitingForActivation || servers._resp4.Status == TaskStatus.WaitingForActivation || servers._resp5.Status == TaskStatus.WaitingForActivation || servers._resp6.Status == TaskStatus.WaitingForActivation || servers._resp7.Status == TaskStatus.WaitingForActivation || servers._resp8.Status == TaskStatus.WaitingForActivation ); } DateTime end = DateTime.Now; string time = TimeSpan.FromTicks(end.Ticks - start.Ticks).ToString(); resp.Time = (time.Split(':')[time.Split(':').Length - 2] + ":" + time.Split(':')[time.Split(':').Length - 1]); /////////////////////////////////////// if (UserProperty.ComputerNumber == 1)//local test { byte[] bitmp0 = servers._respLocalTest.Result.Body.ImageGenerateResult.newImage; Rectangle br0 = ImageProperty.stringToRectangle(servers._respLocalTest.Result.Body.ImageGenerateResult.ImagePartInfo); MagickImage img0 = new MagickImage(bitmp0); Bitmap newImg0 = new Bitmap(img0.Width, img0.Height); Graphics grr0 = Graphics.FromImage(newImg0); grr0.DrawImage(img0.ToBitmap(), br0.X, br0.Y); grr0.Dispose(); (resp.Data as List<object>).Add(ImageProperty.ImageToBase64(newImg0, System.Drawing.Imaging.ImageFormat.Jpeg)); } else { byte[] bitmp1 = servers._resp1.Result.Body.ImageGenerateResult.newImage; Rectangle br1 = ImageProperty.stringToRectangle(servers._resp1.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp2 = servers._resp2.Result.Body.ImageGenerateResult.newImage; Rectangle br2 = ImageProperty.stringToRectangle(servers._resp2.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp3 = servers._resp3.Result.Body.ImageGenerateResult.newImage; Rectangle br3 = ImageProperty.stringToRectangle(servers._resp3.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp4 = servers._resp4.Result.Body.ImageGenerateResult.newImage; Rectangle br4 = ImageProperty.stringToRectangle(servers._resp4.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp5 = servers._resp5.Result.Body.ImageGenerateResult.newImage; Rectangle br5 = ImageProperty.stringToRectangle(servers._resp5.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp6 = servers._resp6.Result.Body.ImageGenerateResult.newImage; Rectangle br6 = ImageProperty.stringToRectangle(servers._resp6.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp7 = servers._resp7.Result.Body.ImageGenerateResult.newImage; Rectangle br7 = ImageProperty.stringToRectangle(servers._resp7.Result.Body.ImageGenerateResult.ImagePartInfo); byte[] bitmp8 = servers._resp8.Result.Body.ImageGenerateResult.newImage; Rectangle br8 = ImageProperty.stringToRectangle(servers._resp8.Result.Body.ImageGenerateResult.ImagePartInfo); servers = null; int newW = 0, newH = 0; if (br1.Width < br1.Height) { newW = br1.Width * UserProperty.ComputerNumber; newH = br1.Height; } else { newW = br1.Width; newH = br1.Height * UserProperty.ComputerNumber; } //MagickImage img0 = new MagickImage(bitmp0); MagickImage img1 = new MagickImage(bitmp1); MagickImage img2 = new MagickImage(bitmp2); MagickImage img3 = new MagickImage(bitmp3); MagickImage img4 = new MagickImage(bitmp4); MagickImage img5 = new MagickImage(bitmp5); MagickImage img6 = new MagickImage(bitmp6); MagickImage img7 = new MagickImage(bitmp7); MagickImage img8 = new MagickImage(bitmp8); Bitmap newImg = new Bitmap(newW, newH); Graphics grr = Graphics.FromImage(newImg); //grr.DrawImage(img0.ToBitmap(), br0.X, br0.Y); grr.DrawImage(img1.ToBitmap(), br1.X, br1.Y); grr.DrawImage(img2.ToBitmap(), br2.X, br2.Y); grr.DrawImage(img3.ToBitmap(), br3.X, br3.Y); grr.DrawImage(img4.ToBitmap(), br4.X, br4.Y); grr.DrawImage(img5.ToBitmap(), br5.X, br5.Y); grr.DrawImage(img6.ToBitmap(), br6.X, br6.Y); grr.DrawImage(img7.ToBitmap(), br7.X, br7.Y); grr.DrawImage(img8.ToBitmap(), br8.X, br8.Y); grr.Dispose(); (resp.Data as List<object>).Add(ImageProperty.ImageToBase64(newImg, System.Drawing.Imaging.ImageFormat.Jpeg)); } /////////////////////////////////////// UserProperty.XmlUpdate("Busy", 0, false); time = ""; } else { throw new Exception("Belirtilen resim bulunamadı") { Source = "" }; } } catch (Exception e) { UserProperty.XmlUpdate("Busy", 0, false); UserProperty.XmlUpdate("Ticket", 1, true); resp.Message = e.Message; } return this.Json<QpiroJSON>(resp); }