/// <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));
        }
Exemple #2
0
 /// <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>());
     }
 }
Exemple #3
0
        /// <summary>
        /// Switches the company context for the requestor.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult Instance(string id)
        {
            try
            {
                if (!IsLoggedIn)
                {
                    throw Framework.DataContracts.LoginRequiredException.Create(Framework.DataContracts.LoginRequiredReason.Credentials);
                }

                var client = SvcBldr.Hosting();
                Astria.Framework.DataContracts.ExceptionsML bizEx = null;
                var token = client.SwitchContext(id, out bizEx);
                if (bizEx == null)
                {
                    var authCookie = AstriaCookie.SetToken(token, Functions.GetProxyCookieDomain());
                    Response.Cookies.Add(authCookie);
                }
                return(Result(null, bizEx, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex) { return(Result(null, Astria.Framework.DataContracts.ExceptionsML.GetExceptionML(ex), JsonRequestBehavior.AllowGet)); }
        }
Exemple #4
0
        public JsonResult ReIndexInstance(string instanceId)
        {
            ExceptionsML bizEx;
            var          companyClient = SvcBldr.Company();
            var          hostingClient = SvcBldr.Hosting();

            var token = hostingClient.SwitchContext(instanceId, out bizEx);

            if (bizEx != null)
            {
                return(Result(null, bizEx, JsonRequestBehavior.AllowGet));
            }

            var authCookie = AstriaCookie.SetToken(token, Functions.GetProxyCookieDomain());

            Response.Cookies.Add(authCookie);

            SvcBldr.Token = token;
            var idxClient = SvcBldr.SearchV2();
            var sr        = idxClient.DeleteReIndex();

            return(Result(sr.Result, sr.Error, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        private string GetRedirectURL(out Astria.Framework.DataContracts.ExceptionsML bizEx)
        {
            bizEx = null;
            var redirectUrl = "";

            if (!String.IsNullOrEmpty(Request.QueryString[Constants.INSTANCEID]))
            {
                var hostingClient = SvcBldr.Hosting();
                var token         = hostingClient.SwitchContext(Request.QueryString[Constants.INSTANCEID], out bizEx);
                if (bizEx == null)
                {
                    redirectUrl = Url.Content("~/");
                    var authCookie = AstriaCookie.SetToken(token, Functions.GetProxyCookieDomain());
                    Response.Cookies.Add(authCookie);
                    SvcBldr.Token = token;
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString[Constants.TYPE]) && bizEx == null)
            {
                if (String.IsNullOrEmpty(redirectUrl))
                {
                    redirectUrl = Url.Content("~/");
                }

                var    type       = (DC.EntityType)Enum.Parse(typeof(DC.EntityType), Request.QueryString[Constants.TYPE], true);
                string typeString = type.ToString();
                switch (type)
                {
                case DC.EntityType.DocumentVersion:
                    typeString = "ver";     // this abbreviation used for DocumentVersion, the most common cache entity
                    goto case Astria.Framework.DataContracts.EntityType.Document;

                case DC.EntityType.Document:
                    var searchClient = SvcBldr.SearchV2();
                    var data         = new Dictionary <Guid, string>();
                    data.Add(new Guid(Request.QueryString[Constants.ENTITYID]), typeString);
                    if (Request.QueryString[Constants.WF_LINK_ACTION] == Constants.WF_UPDATE_DUEDATE)
                    {
                        var      dueDate = Request.QueryString[Constants.DUEDATE];
                        DateTime tempDate;
                        if (!DateTime.TryParse(dueDate, out tempDate))
                        {
                            throw new Exception(Constants.i18n("invalidDueDate"));
                        }
                        UpdateDueDate(new Guid(Request.QueryString[Constants.ENTITYID]), Convert.ToDateTime(dueDate));
                    }
                    var sr = searchClient.SetCachedViewData(data);
                    if (sr.Error == null)
                    {
                        if (!String.IsNullOrEmpty(Request.QueryString[Constants.WF_LINK_ACTION]))
                        {
                            redirectUrl += String.Format("#Retrieve/view/{0}/index/1/page/1/query?{1}={2}", sr.Result, Constants.WF_LINK_ACTION, Request.QueryString[Constants.WF_LINK_ACTION]);
                        }
                        else
                        {
                            redirectUrl += String.Format("#Retrieve/view/{0}/index/1/page/1", sr.Result);
                        }
                    }
                    break;

                case DC.EntityType.Workflow:
                    redirectUrl = String.Format("#Workflow/queues/1/25/DFWfId/asc/wfItems/{0}/{1}", Request.QueryString[Constants.ENTITYID], Request.QueryString[Constants.USERID]);
                    break;

                // direct links to other entities are not currently supported
                default:
                    break;
                }
            }

            return(redirectUrl);
        }