Example #1
0
        /// <summary>
        /// ServerURI and other non-confidential info.  This info is available to unauthenticated clients!
        /// There is a similar method like this in the Eclipse Proxy.
        /// </summary>
        public System.Web.Mvc.ActionResult GetWebServerData()
        {
            var data = new WebServerData {
                Proxy = false, MoveInProgress = false, UpdatedToken = null
            };

            try
            {
                var proxyUrl = Functions.GetAuthenticationProxyUrl();
                if (!String.IsNullOrWhiteSpace(proxyUrl) && !String.IsNullOrWhiteSpace(BaseToken))
                {
                    return(Redirect(Functions.CombineUri(proxyUrl, "BasicInfo/GetWebServerData")));
                }
                else
                {
                    data.ZoneUrl   = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
                    data.ServerUrl = GetServerURI();
                }
            }
            catch (Exception ex)
            {
                data.Exception = ExceptionsML.GetExceptionML(ex);
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public System.Web.Mvc.ActionResult Kiosk()
        {
            try
            {
                var kioskId    = Request.QueryString["Id"];
                var instanceId = Request.QueryString["IId"];
                var machineId  = Request.QueryString["MId"];

                if (String.IsNullOrWhiteSpace(kioskId) || String.IsNullOrWhiteSpace(instanceId) || String.IsNullOrWhiteSpace(machineId))
                {
                    throw new Exception(Constants.i18n("invalidRequest"));
                }

                SvcBldr.Source = "GuestRequest";
                var userSvc = SvcBldr.UserV2();
                var sr      = userSvc.LogInKiosk(new KioskLoginArgs {
                    Id = kioskId, InstanceId = new Guid(instanceId)
                });
                ExceptionsML.Check(sr.Error);
                SignIn(sr.Result.Token, sr.Result.CurrentUser, false);

                var url = String.Format("{0}://{1}/{2}#Capture/{3}", Request.Url.Scheme, Request.Url.Host, Request.ApplicationPath, machineId);
                return(Redirect(url));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
Example #3
0
        public System.Web.Mvc.ActionResult SetLicenseFromFile(FormCollection form)
        {
            var          model = new LicenseModel();
            ExceptionsML bizEx = null;

            try
            {
                SR <License[]> result = null;
                if (Context.Request.Files != null && Context.Request.Files.Count == 1)
                {
                    HttpPostedFileBase file  = Context.Request.Files[0];
                    byte[]             bytes = new byte[file.ContentLength];
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    string responseFile = Context.Request.ContentEncoding.GetString(bytes);
                    var    client       = SvcBldr.LicenseV2();
                    result = client.SetLicenses(responseFile);

                    if (bizEx == null)
                    {
                        model.Message = String.Format(Constants.i18n("licensesUpdated"), result.Result.SafeLength());
                    }
                    else
                    {
                        model.Error = bizEx;
                    }
                }
            }
            catch (Exception ex)
            {
                model.Error = ExceptionsML.GetExceptionML(ex);
            }

            return(View("LicensingFrame", model));
        }
Example #4
0
        public System.Web.Mvc.ActionResult AddAttachment(FormCollection form)
        {
            try
            {
                var f = SvcBldr.FileTransferV2();
                foreach (string item in Context.Request.Files)
                {
                    var file = Context.Request.Files.Get(item);
                    if (String.IsNullOrEmpty(file.FileName))
                    {
                        continue;
                    }

                    f.UploadFile(String.Format(@"{0}\{1}", AstriaCookie.GetUserId(), Path.GetFileName(file.FileName)), file.InputStream);
                }

                var sr = f.GetFileInSubDirectory(AstriaCookie.GetUserId().ToString());
                ExceptionsML.Check(sr.Error);
                return(View(sr.Result));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
 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)));
     }
 }
Example #6
0
 public JsonResult GetAxdId()
 {
     try
     {
         return(Result(Session.SessionID, null));
     }
     catch (Exception ex) { return(Result(null, ExceptionsML.GetExceptionML(ex))); }
 }
Example #7
0
        public JsonResult GetFolderChildren(String ParentId = "", Int32 Depth = 1, bool includeParent = false)
        {
            ////If we are requesting the root node then return an empty list. This should only happen on systems with 0 folders.
            if (ParentId == ROOTNODE)
            {
                return(Result(new List <JSTreeData>(), null, JsonRequestBehavior.AllowGet));
            }
            Guid?rootNodeId        = String.IsNullOrWhiteSpace(ParentId) ? null : new Guid?(new Guid(ParentId));
            var  clientV2          = SvcBldr.FolderV2();
            var  foldRecursionArgs = new FolderRecursionArgs
            {
                ParentId = rootNodeId,
                Depth    = Depth
            };
            var srChildren = clientV2.GetChildren(foldRecursionArgs);

            if (srChildren.Error != null)
            {
                return(Result(null, srChildren.Error));
            }
            var children = srChildren.Result;
            var subNodes = JSTreeFormat.ConvertToJSTreeFormat(children);

            if (rootNodeId == null) // Is the Root Folder
            {
                var rootNode = new JSTreeData("Folders");
                rootNode.children = subNodes;
                return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (includeParent)
                {
                    var srRoot = clientV2.Get(rootNodeId.Value);
                    if (srRoot.Error != null)
                    {
                        return(Result(null, srRoot.Error, JsonRequestBehavior.AllowGet));
                    }
                    if (srRoot.Result != null)
                    {
                        var rootNode = new JSTreeData(srRoot.Result.Title);
                        rootNode.children = subNodes;
                        rootNode.attr.Id  = rootNodeId.ToString();
                        return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Result(null, ExceptionsML.GetExceptionML(new Exception(Constants.i18n("parentFolderNotFound"))), JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Result(subNodes, srChildren.Error, JsonRequestBehavior.AllowGet));
                }
            }
        }
        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));
        }
 public JsonResult SetApprovalsCache(Approval[] approvals)
 {
     try
     {
         ApprovalsCache = approvals == null ? null : approvals.ToDictionary(a => a.Id);
         return(Result(null, null));
     }
     catch (Exception ex)
     {
         return(Result(null, ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #10
0
        public mvc.ActionResult Index()
        {
            try
            {
                var reqId      = Guid.Empty;
                var instanceId = Guid.Empty;
                if (!Guid.TryParse(Request.QueryString[Constants.REQUESTID], out reqId) ||
                    !Guid.TryParse(Request.QueryString[Constants.INSTANCEID], out instanceId))
                {
                    throw new Exception(Constants.i18n("incompleteProxyAuthRequestURL"));
                }

                var gsc = GuestSessionCookie.Get(Request, reqId);
                if (gsc != null)
                {
                    var ar = RedirectToLastSession(gsc);
                    if (ar != null)
                    {
                        return(ar);
                    }
                }

                var cm = GuestChallengeModel.GetOrValidate(reqId, instanceId, Request, SvcBldr);
                if (cm.ShowPassword || cm.ShowRecaptcha)
                {
                    return(View("Challenge", cm));
                }

                switch (cm.ProxyRequest.RequestType)
                {
                case ProxyAuthRequestType.DownloadFiles:
                    return(View("DocumentDownload"));    //TODO: Fix, this cannot get the Request

                case ProxyAuthRequestType.AccessViewer:
                    var baseUri = Functions.CombineUri(CurrentDomain, HttpContext.Request.ApplicationPath);
                    var model   = new GuestViewerModel(SvcBldr);
                    model.Load(baseUri, cm.ProxyRequest);
                    SignIn(model.EncryptedToken, model.User, false);
                    return(View("GuestViewer", model));

                case ProxyAuthRequestType.CreateForm:
                    return(CreateForm(cm.ProxyRequest, instanceId));

                default:
                    throw new NotImplementedException(cm.ProxyRequest.RequestType.ToString());
                }
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
Example #11
0
 public System.Web.Mvc.ActionResult RemoveAttachment(string file)
 {
     try
     {
         var f = SvcBldr.FileTransferV2();
         f.DeleteTempFile(String.Format(@"{0}\{1}", AstriaCookie.GetUserId(), file));
         return(Result(null, null));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #12
0
 public System.Web.Mvc.ActionResult GetResourceInfo()
 {
     try
     {
         ExceptionsML        bizEx   = null;
         List <ResourceInfo> results = GetResourceInfo(ref bizEx);
         return(Result(results, bizEx, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #13
0
 public System.Web.Mvc.ActionResult AddAttachment()
 {
     try
     {
         var f  = SvcBldr.FileTransferV2();
         var sr = f.GetFileInSubDirectory(AstriaCookie.GetUserId().ToString());
         ExceptionsML.Check(sr.Error);
         return(View(sr.Result));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #14
0
        public mvc.ActionResult ProcessDownloadRequestResult()
        {
            Guid id         = new Guid(Request.QueryString["id"]);
            Guid instanceId = new Guid(Request.QueryString["instanceId"]);
            var  password   = Request.QueryString["password"];
            var  fileId     = Request.QueryString["fileId"];
            SR <ProxyAuthRequestResult> sr = null;

            try
            {
                var client = SvcBldr.SecurityV2();
                sr = client.GetProxyRequest(new GetProxyRequestArgs {
                    Id = id, InstanceId = instanceId, Password = password
                });
                ExceptionsML.Check(sr.Error);

                BaseToken = sr.Result.Token;

                var ip       = GetIP();
                var server   = GetServerURI();
                var sb       = new ServiceBuilder(server, BaseToken, ip);
                var fileName = Path.GetFileName(fileId);
                var mimeType = fileId.GetMIMEType();
                var ftSvc    = sb.FileTransferV2();
                var bytes    = RemoteFileHandler.DownloadFile(fileId, ftSvc);
                return(File(bytes, mimeType, fileName));
            }
            catch (LoginRequiredException lex)
            {
                if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress)
                {
                    var proxyUrl = Functions.GetAuthenticationProxyUrl();
                    var domain   = Functions.GetProxyCookieDomain();
                    var url      = Functions.CombineUri(proxyUrl, "Guest");
                    url += String.Format("?RequestId={0}&InstanceId={1}&auto={2}", id, instanceId, String.IsNullOrEmpty(password));
                    return(View("../Home/Oops", new ExceptionsML {
                        Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString()
                    }));
                }
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex)));
            }
            catch (RecordNotFoundException rex)
            {
                return(View("../Home/Oops", new ExceptionsML {
                    Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString()
                }));
            }
            catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); }
        }
Example #15
0
 public System.Web.Mvc.ActionResult GetAnnotationPng(string jsAnnotation, int?dpi)
 {
     byte[] png = null;
     try
     {
         Mark mark = Mark.JsonDeserialize(jsAnnotation);
         png = AnnoEngine.MarkToPng(mark, this, dpi);
     }
     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"));
 }
Example #16
0
        public System.Web.Mvc.ActionResult GetBuzzSpaceEditor(Guid?selectedId, ExceptionsML ex)
        {
            var model = new BuzzEditorModel();

            try
            {
                var dc = SvcBldr.AdministrationV2();
                model.Exception  = ex;
                model.BuzzSpaces = new List <BuzzSpace>();
                model.BuzzSpaces.Add(new BuzzSpace()
                {
                    Title = Constants.i18n("newTitle"), Content = "", Id = Guid.Empty
                });
                var b = dc.GetAllBuzzSpace();
                if (b.Error != null)
                {
                    return(Result(null, b.Error, JsonRequestBehavior.AllowGet));
                }
                model.BuzzSpaces.AddRange(b.Result);
                if (selectedId.HasValue)
                {
                    var selected = model.BuzzSpaces.FirstOrDefault(r => r.Id == selectedId.Value);
                    if (selected != null)
                    {
                        model.SelectedBuzz = selected;
                    }
                }
                else
                {
                    var userBS = dc.GetCurrentBuzzSpace(false);
                    if (userBS != null && userBS.Result != null)
                    {
                        model.SelectedBuzz = model.BuzzSpaces.FirstOrDefault(r => r.Id == userBS.Result.Id);
                    }

                    if (model.SelectedBuzz == null)
                    {
                        model.SelectedBuzz = model.BuzzSpaces.First();
                    }
                }
            }
            catch (Exception err)
            {
                model.Exception = ExceptionsML.GetExceptionML(err);
            }
            return(View(model));
        }
Example #17
0
        public JsonResult GetMarkFromMarkXML(string markXML)
        {
            var          decodedXML = Uri.UnescapeDataString(markXML);
            ExceptionsML bizEx      = null;
            Mark         mark       = null;

            if (!string.IsNullOrEmpty(markXML))
            {
                try
                {
                    mark = XmlSerializerExtension.XmlDeserialize <Mark>(decodedXML);
                }
                catch (Exception ex)
                {
                    bizEx = ExceptionsML.GetExceptionML(ex);
                }
            }
            return(Result(mark, bizEx));
        }
Example #18
0
        public System.Web.Mvc.ActionResult GetSystemNotificationsEditor(Guid?selectedId, ExceptionsML ex)
        {
            var model = new SystemNotificationEditorModel();

            try
            {
                var dc = SvcBldr.CompanyV2();
                model.Exception     = ex;
                model.Notifications = new List <SystemNotification>();
                model.Notifications.Add(new SystemNotification()
                {
                    Title = Constants.i18n("newTitle"), Content = "", Id = Guid.Empty, StartDate = DateTime.Now, EndDate = DateTime.Now
                });
                var b = dc.GetAllSystemNotification();
                if (b.Error != null)
                {
                    return(Result(null, b.Error, JsonRequestBehavior.AllowGet));
                }
                model.Notifications.AddRange(b.Result);
                if (selectedId.HasValue)
                {
                    var selected = model.Notifications.FirstOrDefault(r => r.Id == selectedId.Value);
                    if (selected != null)
                    {
                        model.SelectedNotification = selected;
                    }
                }
                else
                {
                    model.SelectedNotification = new SystemNotification()
                    {
                        Title = Constants.i18n("newTitle"), Content = "", Id = Guid.Empty, StartDate = DateTime.Now, EndDate = DateTime.Now
                    };
                }
            }
            catch (Exception err)
            {
                model.Exception = ExceptionsML.GetExceptionML(err);
            }
            return(View(model));
        }
Example #19
0
        /// <summary>
        /// Returns RedactionsXML string and object collection for redactions.
        /// Somewhere herein, real values are rounded to integers as necessary.
        /// </summary>
        /// <param name="jsRedactions">stringified redaction objects</param>
        private object SetRedactions(string jsRedactions, ref ExceptionsML bizEx)
        {
            string           redactionsXML = null;
            List <Redaction> redactions    = new List <Redaction>();

            if (!string.IsNullOrEmpty(jsRedactions))
            {
                try
                {
                    redactions    = Redaction.JsonDeserializeList(jsRedactions);
                    redactionsXML = XmlSerializerExtension.XmlSerialize <List <Redaction> >(redactions);
                }
                catch (Exception ex)
                {
                    bizEx = ExceptionsML.GetExceptionML(ex);
                }
            }
            var result = new { redactionsXML, redactions };

            return(result);
        }
Example #20
0
        /// <summary>
        /// Returns AnnotationsXML string and object collection for annotations.
        /// Somewhere herein, real values are rounded to integers as necessary.
        /// </summary>
        /// <param name="jsAnnotations">stringified annotation (mark) objects</param>
        /// <param name="bizEx"></param>
        private object SetMarks(string jsAnnotations, ref ExceptionsML bizEx)
        {
            string      marksXML = null;
            List <Mark> marks    = new List <Mark>();

            if (!string.IsNullOrEmpty(jsAnnotations))
            {
                try
                {
                    marks    = Mark.JsonDeserializeList(jsAnnotations);
                    marksXML = XmlSerializerExtension.XmlSerialize <List <Mark> >(marks);
                }
                catch (Exception ex)
                {
                    bizEx = ExceptionsML.GetExceptionML(ex);
                }
            }
            var result = new { marksXML, marks };

            return(result);
        }
Example #21
0
        public System.Web.Mvc.ActionResult SendIdeaMessage(string message, string url)
        {
            try
            {
                var adminClient = SvcBldr.AdministrationV2();

                StringBuilder bodyBuilder = new StringBuilder();
                bodyBuilder.AppendLine("<html>");
                bodyBuilder.Append(System.IO.File.ReadAllText(Server.MapPath(Url.Content("~/Content/templates/IdeaEmailTemplate.htm"))));
                bodyBuilder.AppendLine("</html>");

                var sr = adminClient.IdeaMessage(new IdeaMessagePackage {
                    BodyTemplate = bodyBuilder.ToString(), ContextURI = url, Message = message
                });
                return(Result(sr.Result, sr.Error));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
Example #22
0
 public ViewResult MonitorHub()
 {
     try
     {
         var client = SvcBldr.UserV2();
         var sr     = client.GetCurrent();
         ExceptionsML.Check(sr.Error);
         if (!sr.Result.Flags.HasFlag(UserFlags.SuperAdmin))
         {
             throw new Exception("Super Admin Permissions Required");
         }
         var model = new ServerUriModel {
             ServerUri = GetServerURI()
         };
         return(View(model));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #23
0
        public mvc.ActionResult ProcessDownloadRequest()
        {
            Guid id           = new Guid(Request.QueryString["id"]);
            Guid instanceId   = new Guid(Request.QueryString["instanceId"]);
            var  password     = Request.QueryString["password"];
            var  connectionId = Request.QueryString["connectionId"];
            SR <ProxyAuthRequestResult> sr = null;

            try
            {
                var client = SvcBldr.SecurityV2();
                sr = client.GetProxyRequest(new GetProxyRequestArgs {
                    Id = id, InstanceId = instanceId, Password = password
                });
                ExceptionsML.Check(sr.Error);
                return(DownloadFiles(sr.Result, connectionId));
            }
            catch (LoginRequiredException lex)
            {
                if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress)
                {
                    var proxyUrl = Functions.GetAuthenticationProxyUrl();
                    var domain   = Functions.GetProxyCookieDomain();
                    var url      = Functions.CombineUri(proxyUrl, "Guest");
                    url += String.Format("?{0}={1}&{2}={3}&{4}={5}", Constants.REQUESTID, id, Constants.INSTANCEID, instanceId, Constants.AUTO, String.IsNullOrEmpty(password));
                    return(View("../Home/Oops", new ExceptionsML {
                        Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString()
                    }));
                }
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex)));
            }
            catch (RecordNotFoundException rex)
            {
                return(View("../Home/Oops", new ExceptionsML {
                    Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString()
                }));
            }
            catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); }
        }
Example #24
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"));
        }
Example #25
0
 public System.Web.Mvc.ActionResult LiveChat()
 {
     try
     {
         var companyClient = SvcBldr.CompanyV2();
         var cd            = companyClient.GetChatData();
         if (String.IsNullOrEmpty(cd.Result.Channel))
         {
             cd.Result.Channel = @Functions.GetSetting("ChatChannelId", "716209851");
         }
         if (cd.Result.IsGuest)
         {
             cd.Result.UserName = "******" + cd.Result.UserName;
         }
         ExceptionsML.Check(cd.Error);
         return(View(cd.Result));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
Example #26
0
        /// <summary>
        /// error handler for validation messages
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="businessException"></param>
        /// <returns></returns>
        public bool ErrorHandler(Exception ex = null, ExceptionsML businessException = null)
        {
            var noError = true;

            if (businessException != null)
            {
                if (businessException.Type == typeof(LoginRequiredException).ToString())
                {
                    throw LoginRequiredException.Create((LoginRequiredReason)Enum.Parse(typeof(LoginRequiredReason), businessException.Data));
                }
                else
                {
                    if (ValidationMessages.ContainsKey("Exception"))
                    {
                        ValidationMessages["Exception"] = businessException;
                    }
                    else
                    {
                        ValidationMessages.Add("Exception", businessException);
                    }
                }
                noError = false;
            }
            if (ex != null)
            {
                if (ValidationMessages.ContainsKey("Exception"))
                {
                    ValidationMessages["Exception"] = ExceptionsML.GetExceptionML(ex);
                }
                else
                {
                    ValidationMessages.Add("Exception", ExceptionsML.GetExceptionML(ex));
                }

                noError = false;
            }

            return(noError);
        }
Example #27
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)));
            }
        }
Example #28
0
        private mvc.ActionResult DownloadFiles(ProxyAuthRequestResult request, string connectionId)
        {
            try
            {
                BaseToken = request.Token;

                var ip     = GetIP();
                var server = GetServerURI();
                var sb     = new ServiceBuilder(server, request.Token, ip);
                sb.Options = ServiceRequestOptions.OverrideErrors;
                var         docClient   = sb.DocumentV2();
                var         documentIds = new List <Guid>();
                SendOptions sendOptions = new SendOptions
                {
                    ActionType         = ActionType.Downloaded,
                    ExportType         = ExportDocumentType.Native,
                    IncludeAnnotations = true,
                    IncludeRedactions  = true,
                    PageSelection      = null,
                    Password           = null
                };
                var parameters = new ProxySendOptions {
                    DocumentIds = null, SendOptions = null
                };
                if (request.Arguments.StartsWith("{"))
                {
                    parameters = JsonConvert.DeserializeObject <ProxySendOptions>(request.Arguments);
                }
                else if (request.Arguments.StartsWith("<?xml version=\"1.0\" encoding=\"utf-16\"?><ProxySendOptions"))
                {
                    parameters = (ProxySendOptions)parameters.DeserializeObject(request.Arguments);
                }
                else
                {
                    documentIds = (List <Guid>)documentIds.DeserializeObject(request.Arguments);
                }
                documentIds = parameters.DocumentIds ?? documentIds;
                sendOptions = parameters.SendOptions ?? sendOptions;
                sendOptions.ConnectionId = connectionId;
                sendOptions.ActionType   = ActionType.Downloaded; //Downloading here so the action type is always download.

                var sr = docClient.PrepForSend(new Framework.DataContracts.V2.PrepForSendPackage {
                    DocumentIds = documentIds.ToArray(), SendOptions = sendOptions
                });
                if (sr.Error != null)
                {
                    return(View("../Home/Oops", sr.Error));
                }

                if (sr.Result == Constants.GONE_OOP)
                {
                    return(new mvc.EmptyResult());
                }
                else
                {
                    var fileName = Path.GetFileName(sr.Result);
                    var mimeType = sr.Result.GetMIMEType();
                    var ftSvc    = sb.FileTransferV2();
                    var bytes    = RemoteFileHandler.DownloadFile(sr.Result, ftSvc);
                    return(File(bytes, mimeType, fileName));
                }
            }
            catch (Exception ex)
            {
                return(Result(null, ExceptionsML.GetExceptionML(ex), mvc.JsonRequestBehavior.AllowGet));
            }
        }
Example #29
0
        public System.Web.Mvc.ActionResult SendHelpMessage(string message, string clientData, string contextURI)
        {
            try
            {
                var adminClient = SvcBldr.AdministrationV2();
                if (!String.IsNullOrEmpty(clientData))
                {
                    var cd = JsonConvert.DeserializeObject(clientData);
                    clientData = JsonConvert.SerializeObject(cd, Formatting.Indented);
                }

                var requestData = new
                {
                    Request.AcceptTypes,
                    Request.ApplicationPath,
                    Browser = new
                    {
                        Request.Browser.Capabilities,
                        Request.Browser.Cookies,
                        Request.Browser.Crawler,
                        Request.Browser.Id,
                        Request.Browser.IsColor,
                        Request.Browser.IsMobileDevice,
                        Request.Browser.JavaApplets,
                        Request.Browser.JScriptVersion,
                        Request.Browser.MaximumHrefLength,
                        Request.Browser.MaximumRenderedPageSize,
                        Request.Browser.MaximumSoftkeyLabelLength,
                        Request.Browser.MobileDeviceManufacturer,
                        Request.Browser.MobileDeviceModel,
                        Request.Browser.Platform,
                        Request.Browser.SupportsXmlHttp,
                        Request.Browser.Version,
                        Request.Browser.W3CDomVersion,
                        Request.Browser.Win32
                    },
                    Request.ContentEncoding,
                    Request.Cookies,
                    Request.HttpMethod,
                    Request.IsAuthenticated,
                    Request.IsLocal,
                    Request.IsSecureConnection,
                    Request.Path,
                    Request.PathInfo,
                    Request.RawUrl,
                    Request.UrlReferrer,
                    Request.UserAgent,
                    Request.UserHostAddress,
                    Request.UserHostName,
                    Request.UserLanguages
                };
                var requestStr = JsonConvert.SerializeObject(requestData, Formatting.Indented);

                var bodyBuilder = new StringBuilder();
                bodyBuilder.AppendLine("<html>");
                bodyBuilder.Append(System.IO.File.ReadAllText(Server.MapPath(Url.Content("~/Content/templates/HelpEmailTemplate.htm"))));
                bodyBuilder.AppendLine("</html>");
                var sr = adminClient.HelpMessage(new HelpMessagePackage {
                    BodyTemplate = bodyBuilder.ToString(), ClientData = clientData, ContextURI = contextURI, Message = message, RequestData = requestStr, WebResourceInfo = GetWebResources()
                });
                return(Result(sr.Result, sr.Error));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }