コード例 #1
0
 public JsonResult SetTextStamp(AnnoStamp stamp, string jsAnnotation)
 {
     try
     {
         var client = SvcBldr.StampsV2();
         if (jsAnnotation != null)
         {
             Mark mark = Mark.JsonDeserialize(jsAnnotation);
             stamp.MarkXML = XmlSerializerExtension.XmlSerialize <Mark>(mark);
         }
         if (stamp.Id == Guid.Empty)
         {
             var r = client.CreateTextStamp(stamp);
             return(Result(r.Result, r.Error));
         }
         else
         {
             var r = client.UpdateTextStamp(stamp);
             return(Result(stamp, r.Error));
         }
     }
     catch (Exception ex)
     {
         return(Result(stamp, ExceptionsML.GetExceptionML(ex)));
     }
 }
コード例 #2
0
        /// <summary>
        /// Gets text and/or image stamps from admin or for current user
        /// </summary>
        /// <param name="forUser">if true, gets stamps visible to current user; otherwise gets stamps for admin</param>
        /// <param name="includeOther">if forUser is true, gets Admin (public) stamps too; if forUser is false, gets stamps for admin and ALL users</param>
        /// <param name="includeText">include text stamps</param>
        /// <param name="includeImage">include image stamps</param>
        /// <param name="bizEx"></param>
        /// <returns></returns>
        private StampsCollection GetStamps(bool forUser, bool includeOther, bool includeText, bool includeImage, out ExceptionsML bizEx)
        {
            var client = SvcBldr.StampsV2();

            bizEx = null;
            StampsCollection stamps = null;
            var pkg = new AnnoStampGetPackage {
                IncludeImage = includeImage, IncludeAdmin = includeOther
            };

            if (forUser)
            {
                var sr = client.GetAllForUser(pkg);
                bizEx  = sr.Error;
                stamps = sr.Result;
            }
            else
            {
                var sr = client.GetAll(pkg);
                bizEx  = sr.Error;
                stamps = sr.Result;
            }
            if (stamps == null)
            {
                stamps = new StampsCollection {
                    ImageStamps = new AnnoImageStamp[0], TextStamps = new AnnoStamp[0]
                }
            }
            ;                                                                                                         // to avoid need for null check in caller
            return(stamps);
        }
コード例 #3
0
        public AnnoImageStamp Get(Guid id, System.Data.SqlClient.SqlTransaction trans = null)
        {
            var client = SvcBldr.StampsV2();
            var r      = client.GetImageStamp(id);

            if (r.Error != null)
            {
                throw new Exception(r.Error.Message);
            }

            return(r.Result);
        }
コード例 #4
0
        public JsonResult SetImageStamp(AnnoImageStamp stamp)
        {
            var client = SvcBldr.StampsV2();

            if (stamp.Id == Guid.Empty)
            {
                return(Result(null, ExceptionsML.GetExceptionML(new InvalidOperationException("Set Image Stamp not supported. Use UploadImageStamp"))));
            }
            var r = client.UpdateImageStamp(stamp);

            return(Result(stamp, r.Error));
        }
コード例 #5
0
        public IEnumerable <AnnoImageStamp> GetAll(System.Data.SqlClient.SqlTransaction trans = null)
        {
            var client = SvcBldr.StampsV2();
            var r      = client.GetAll(new AnnoStampGetPackage {
                IncludeAdmin = true, IncludeDeleted = true, IncludeImage = true
            });

            if (r.Error != null)
            {
                throw new Exception(r.Error.Message);
            }

            return(r.Result.ImageStamps);
        }
コード例 #6
0
        public System.Web.Mvc.ActionResult GetStampsSprite(bool imageStamps)
        {
            var client = SvcBldr.StampsV2();

            byte[] png = null;
            try
            {
                var sr = client.GetAllForUser(new AnnoStampGetPackage {
                    IncludeAdmin = true, IncludeImage = imageStamps, IncludeDeleted = false
                });
                ExceptionsML.Check(sr.Error);
                var iStamps = imageStamps ? sr.Result.ImageStamps.Cast <IStamp>() : sr.Result.TextStamps.Cast <IStamp>();
                png = AnnoEngine.GetSpriteSheet(iStamps.ToList());
            }
            catch (Exception ex)
            {
                string key = string.Concat(AstriaCookie.GetToken(), "AnnoEngine");
                _cache.Remove(key);
                png = StandardResult.CreateBitmapImage(ExceptionsML.GetExceptionML(ex).Message);
            }
            return(File(png, "image/png"));
        }
コード例 #7
0
        public System.Web.Mvc.ActionResult UploadImageStamp(FormCollection form)
        {
            try
            {
                ExceptionsML bizEx = null;
                if (Context.Request.Files != null && Context.Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Context.Request.Files[0];
                    var stamp = new AnnoImageStamp();
                    stamp.Image = new Byte[file.ContentLength];
                    file.InputStream.Read(stamp.Image, 0, file.ContentLength);
                    stamp.Name = form["Name"];
                    Guid id = Guid.Empty;
                    if (Guid.TryParse(form["Id"], out id))
                    {
                        stamp.Id = id;
                    }
                    int seq = 0;
                    if (int.TryParse(form["Sequence"], out seq))
                    {
                        stamp.Sequence = seq;
                    }
                    if (form["Admin"] != "true")
                    {
                        stamp.Owner = AstriaCookie.GetUserId();
                    }

                    var client = SvcBldr.StampsV2();
                    var result = client.CreateImageStamp(stamp);
                    bizEx = result.Error;
                }
                return(View("ImageStampFrame", bizEx));
            }
            catch (Exception ex)
            {
                return(View("ImageStampFrame", ExceptionsML.GetExceptionML(ex)));
            }
        }