public JsonResult GetCompanyInstances() { ExceptionsML bizEx = null; var result = base.GetCompanyInstances(out bizEx); return(Result(result, bizEx, JsonRequestBehavior.AllowGet)); }
public JsonResult Companies() { ExceptionsML bizEx = null; var companyClient = SvcBldr.Company(); var companyClientV2 = SvcBldr.CompanyV2(); var company = new Company() { Id = Guid.Empty, Name = Constants.i18n("newTitle"), Prefix = "AAAA" }; var companiesSR = companyClientV2.GetCompanies(); if (companiesSR.Error != null) { bizEx = companiesSR.Error; } var companies = companiesSR.Result != null?companiesSR.Result.ToList() : null; if (companies != null) { companies.Insert(0, company); } return(Result(companies, bizEx, JsonRequestBehavior.AllowGet)); }
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))); } }
/// <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)); }
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)); }
/// <summary> /// /// </summary> /// <param name="setting"></param> /// <returns></returns> public JsonResult SetSystemPreferences(CompanySetting setting) { var client2 = SvcBldr.CompanyV2(); ExceptionsML bizEx = null; SR <CompanySetting> existingSetting = null; if (setting.Id != Guid.Empty) { existingSetting = client2.Get(setting.Id); } if (existingSetting != null && existingSetting.Error != null) { return(Result(null, bizEx)); } if (existingSetting == null) { setting.Id = Functions.NewSeq(); existingSetting = client2.Create(setting); } else { existingSetting = client2.Update(setting); } return(Result(existingSetting.Result, existingSetting.Error)); }
internal void Load(string baseUri, ProxyAuthRequestResult par) { _svcBldr.Token = par.Token; EncryptedToken = par.Token; Options = par.Arguments; var svc = _svcBldr.BulkDataV2(); var sr = svc.GetBulkGuestData(); ExceptionsML.Check(sr.Error); var result = sr.Result; BulkData = JsonConvert.SerializeObject(sr); if (result.LicenseTokens != null) { Licenses = new List <TokenKey>((result.LicenseTokens)); } User = result.CurrentUser; CurrentUser = JsonConvert.SerializeObject(new { Name = result.CurrentUser.Username, Id = result.CurrentUser.Id }); CompanyName = result.CompanyName; HttpRuntimeSection httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; MaxRequestLength = httpRuntimeSection.MaxRequestLength; IsReadOnlyUser = result.CurrentUser.ReadOnlyUser; Version = Functions.GetVersion(); SystemPreferences = JsonConvert.SerializeObject(result.CompanySettings); var views = GetCachedViews(baseUri); CommonTemplates = JsonConvert.SerializeObject(views); }
private mvc.ActionResult CreateDocumentAndRedirect(ProxyAuthRequestResult req, JObject jArgs, Guid instanceId) { var fSvc = SvcBldr.FormsV2(); var cdsr = fSvc.CreateDocument(new FormDocumentCreateArgs { IsTemporary = true, FormTemplateId = new Guid(jArgs["FormTemplateId"].Value <string>()) //Convert failure when .Value<Guid> is used. }); ExceptionsML.Check(cdsr.Error); var vrId = Functions.NewSeq(); jArgs["DocumentVersionId"] = cdsr.Result.Version.Id; jArgs["FormRequestId"] = req.Id; jArgs["ViewRequestId"] = vrId; jArgs["UseRecaptcha"] = false; ExceptionsML.Check(cdsr.Error); var secSvc = SvcBldr.SecurityV2(); var viewerCPR = new ProxyAuthRequest { Id = vrId, ExpirationType = ExpirationMode.CustomCount, ExpirationValue = "1", //Expires as soon as the form is submitted. RequestType = ProxyAuthRequestType.AccessViewer, Token = req.Token, Parameters = JsonConvert.SerializeObject(jArgs) }; var cprSR = secSvc.CreateProxyRequest(viewerCPR); ExceptionsML.Check(cprSR.Error); var fsc = GuestSessionCookie.Create(Response, cprSR.Result, instanceId, req.Id); return(RedirectToAction("Index", fsc)); }
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))); } }
public JsonResult Company(CompanyDTO company) { ExceptionsML bizEx = null; var companyClient = SvcBldr.Company(); CompanyDTO updateCompany = null; if (company.Id != Guid.Empty) { updateCompany = companyClient.GetCompany(company.Id.ToString(), out bizEx); if (bizEx != null) { return(Result(null, bizEx)); } updateCompany.Name = company.Name; } else { updateCompany = company; } var result = companyClient.UpdateCompany(updateCompany, out bizEx); UpdateProxy(); return(Result(result, bizEx)); }
public JsonResult GetDefaultCompanyInstance() { ExceptionsML bizEx = null; var hosting = SvcBldr.CompanyV2();//Hosting(); var instance = hosting.GetDefaultCompanyInstance(); return(Result(instance, bizEx)); }
public JsonResult GetAxdId() { try { return(Result(Session.SessionID, null)); } catch (Exception ex) { return(Result(null, ExceptionsML.GetExceptionML(ex))); } }
public System.Web.Mvc.ActionResult Index() { var companySvc = SvcBldr.Company(); ExceptionsML bizEx = null; var companies = companySvc.GetCompanies(out bizEx); return(View(companies)); }
private ReportPackage GetReportPackage() { var reportSvc = _sb.ReportingV2(); var rptSR = reportSvc.Get(_reportId); ExceptionsML.Check(rptSR.Error); return(rptSR.Result); }
/// <summary> /// Sets an instance as the current users default. /// If the user is not a member of the target instance the user is added. /// </summary> /// <param name="instanceId"></param> /// <returns></returns> public JsonResult SetDefaultInstance(string instanceId) { ExceptionsML bizEx = null; var hosting = SvcBldr.Hosting(); hosting.SetDefaultContext(instanceId, out bizEx); return(Result(null, bizEx)); }
public JsonResult Company(string id) { var companyClient = SvcBldr.Company(); ExceptionsML bizEx = null; var company = companyClient.GetCompany(id, out bizEx); return(Result(company, bizEx, JsonRequestBehavior.AllowGet)); }
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)); } } }
private static void ValidatePasswordFillModelProxyRequest(ProxyAuthRequestResult par, GuestChallengeModel model, HttpRequestBase request, ServiceBuilder svcBldr) { var pass = request.Form["password"]; var svc = svcBldr.SecurityV2(); if (par.HasPassword && !String.IsNullOrWhiteSpace(pass)) //Has a password and one has been provided by the user { var pwSR = svc.GetProxyRequest(new GetProxyRequestArgs { Id = par.Id, InstanceId = par.InstanceId, Password = pass }); if (pwSR.Error != null) { model.ErrorMessages.Add(pwSR.Error.Message); model.ShowPassword = true; } else { model.ProxyRequest = pwSR.Result; } } else if (!par.HasPassword && !model.ShowRecaptcha) //Does not have a password and is not showing the recaptcha, get the full ProxyAuthRequest (decrements counts, returns a restricted token). { var prSR = svc.GetProxyRequest(new GetProxyRequestArgs { Id = par.Id, InstanceId = par.InstanceId, Password = pass }); if (prSR.Error != null) { if (prSR.Error.Type == typeof(ProxyAuthRequestExpiredException).ToString()) { switch (par.RequestType) { case ProxyAuthRequestType.DownloadFiles: throw new Exception(Constants.i18n("downloadFilesProxyRequestExpired")); case ProxyAuthRequestType.AccessViewer: throw new Exception(Constants.i18n("accessViewerProxyRequestExpired")); case ProxyAuthRequestType.CreateForm: throw new Exception(Constants.i18n("createFormProxyRequestExpired")); default: ExceptionsML.Check(prSR.Error); break; } } ExceptionsML.Check(prSR.Error); } model.ProxyRequest = prSR.Result; } else //Has a password and it has not been filled out yet or is showing recaptcha { model.ProxyRequest = par; model.ShowPassword = par.HasPassword; } }
public JsonResult GetNewRedaction(Rectangle Rectangle = null) { ExceptionsML bizEx = null; var redaction = new Redaction(); if (Rectangle != null) { redaction = new Redaction(Rectangle); } return(Result(redaction, bizEx, JsonRequestBehavior.AllowGet)); }
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))); } }
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 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))); } }
public System.Web.Mvc.ActionResult GetSystemNotificationsEditor(SystemNotification notification) { var client = SvcBldr.CompanyV2(); string site = string.Empty; var model = new SystemNotificationEditorModel(); if (notification.Title == null) { return(GetSystemNotificationsEditor(Guid.Empty, new ExceptionsML { Message = Constants.i18n("titleEmptyWarning") })); } else { notification.Title.Trim(); } if (Context.Request.Form["Site"] != null) { site = Context.Request.Form["Site"]; } if (site.IndexOf("All") >= 0) { site = "All"; } else { notification.SiteID = site.Split(',').Select(s => Guid.Parse(s)).ToArray(); } if (Context.Request.Form["StartDate"] != null) { notification.StartDate = Convert.ToDateTime(Context.Request.Form["StartDate"]); } if (Context.Request.Form["EndDate"] != null) { notification.EndDate = Convert.ToDateTime(Context.Request.Form["EndDate"]); } if (notification.Id == Guid.Empty) { notification.Id = Guid.NewGuid(); client.CreateSystemNotification(notification); } else { client.UpdateSystemNotification(notification); } ExceptionsML ex = new ExceptionsML(); return(GetSystemNotificationsEditor(notification.Id, ex)); }
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))); } }
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))); } }
private XElement GetReportDefinition() { var reportSvc = _sb.ReportingV2(); var rSR = reportSvc.GetRdlc(_reportId); ExceptionsML.Check(rSR.Error); var reportStream = new MemoryStream(rSR.Result); ReportViewer1.LocalReport.LoadReportDefinition(reportStream); ReportViewer1.LocalReport.DataSources.Clear(); reportStream.Seek(0, SeekOrigin.Begin); return(XElement.Load(reportStream)); }
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))); } }
/// <summary> /// fetch the company instance /// </summary> /// <returns></returns> public List <CompanyInstanceDTO> GetCompanyInstances(out ExceptionsML bizEx) { bizEx = null; if (IsLoggedIn) { var client = SvcBldr.Hosting(); var result = client.GetCompaniesForUser(AstriaCookie.GetUserId().ToString(), out bizEx).ToList(); return(result); } else { return(new List <CompanyInstanceDTO>()); } }
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))); } }