Beispiel #1
0
        public List <Sungero.Domain.Shared.IEntity> GetChangedBankAccountsFromSyncDateRemote(List <Guid> entityTypeGuids,
                                                                                             int processedEntitiesCount,
                                                                                             int entitiesCountForProcessing,
                                                                                             string extEntityType,
                                                                                             string systemId)
        {
            using (var session = new Domain.Session())
            {
                var entities = new List <Sungero.Domain.Shared.IEntity>().AsQueryable();

                foreach (var entityTypeGuid in entityTypeGuids)
                {
                    entities = entities.Union(this.GetChangedEntities(session, entityTypeGuid, extEntityType, systemId));
                }
                entities = entities.Where(x => Counterparties.Is(x) &&
                                          Counterparties.As(x).Status == Sungero.Parties.Counterparty.Status.Active &&
                                          Counterparties.As(x).Bank != null &&
                                          !string.IsNullOrEmpty(Counterparties.As(x).Account));

                var entitiesBatch = entities
                                    .Skip(processedEntitiesCount)
                                    .Take(entitiesCountForProcessing)
                                    .ToList();

                return(entitiesBatch);
            }
        }
        /// <summary>
        /// Create all your controls here for rendering.
        /// Try to avoid using the RenderWebPart() method.
        /// </summary>
        protected override void CreateChildControls()
        {
            if (!_error)
            {
                try
                {
                    base.CreateChildControls();

                    // Get the session token
                    ISessionService sessionService = new SessionService(Utilities.ApiProvider);
                    Domain.Session  session        = sessionService.GetToken("/");

                    string buttonUri = session.ReturnURL;

                    // Create the container control
                    HtmlGenericControl containerControl = new HtmlGenericControl("div");
                    this.Controls.Add(containerControl);

                    // Create the button control
                    HtmlGenericControl buttonControl = new HtmlGenericControl("input");
                    buttonControl.Attributes["type"]    = "button";
                    buttonControl.Attributes["onclick"] = "javascript:location.href='" + buttonUri + "';";
                    buttonControl.Attributes["value"]   = (!String.IsNullOrEmpty(_buttonValue) ? _buttonValue.Replace("\"", "&quot;") : "Launch");
                    containerControl.Controls.Add(buttonControl);
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Create all your controls here for rendering.
        /// Try to avoid using the RenderWebPart() method.
        /// </summary>
        protected override void CreateChildControls()
        {
            if (!_error)
            {
                try
                {
                    base.CreateChildControls();

                    // Parse any given 23_return_url path
                    NameValueCollection query = Page.Request.QueryString;

                    var returnUrl = "/";

                    if (!String.IsNullOrEmpty(query.Get("23_return_url")))
                    {
                        returnUrl = query.Get("23_return_url");
                    }

                    // Get the session token
                    ISessionService sessionService = new SessionService(Utilities.ApiProvider);
                    Domain.Session  session        = sessionService.GetToken(returnUrl, null, null);

                    string iframeUri = session.ReturnURL;

                    // Build the width and height
                    string width  = (String.IsNullOrEmpty(Width.ToString()) ? "100%" : Width.ToString());
                    string height = (String.IsNullOrEmpty(Height.ToString()) ? "100%" : Height.ToString());

                    // Create the container control
                    HtmlGenericControl ContainerControl = new HtmlGenericControl("div");
                    ContainerControl.Attributes["width"]  = width;
                    ContainerControl.Attributes["height"] = height;
                    this.Controls.Add(ContainerControl);

                    // Create the inline frame control
                    HtmlGenericControl InlineFrameControl = new HtmlGenericControl("iframe");
                    InlineFrameControl.Attributes["width"]       = width;
                    InlineFrameControl.Attributes["height"]      = height;
                    InlineFrameControl.Attributes["src"]         = iframeUri;
                    InlineFrameControl.Attributes["style"]       = _inlineStyle;
                    InlineFrameControl.Attributes["frameborder"] = "0";
                    ContainerControl.Controls.Add(InlineFrameControl);
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }
Beispiel #4
0
        public int GetChangedEntitiesFromSyncDateRemoteCount(List <Guid> entityTypeGuids,
                                                             string extEntityType,
                                                             string systemId)
        {
            using (var session = new Domain.Session())
            {
                var totalCount = 0;

                foreach (var entityTypeGuid in entityTypeGuids)
                {
                    totalCount += this.GetChangedEntities(session, entityTypeGuid, extEntityType, systemId).Count();
                }
                return(totalCount);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string debug = Context.Request.QueryString["debug"];

            if (WebPartManager.DisplayMode == WebPartManager.EditDisplayMode)
            {
                debug = "yes";
            }

            IApiProvider apiProvider = Utilities.ApiProvider;

            _session = null;
            string return_url = Context.Request.QueryString["return_url"];

            if (return_url == null)
            {
                return_url = "/";
                debug      = "yes"; // Do not instant redirect
            }

            if (apiProvider != null)
            {
                SPUser user     = SPContext.Current.Web.CurrentUser;
                string email    = null;
                string fullname = null;

                if (user != null)
                {
                    email    = _sendEmail ? user.Email : null;
                    fullname = _sendFullName ? user.Name : null;
                }

                ISessionService sessionService = new SessionService(apiProvider);
                _session = sessionService.GetToken(return_url, email, fullname);
            }

            // Do not redirect if debug is set
            if (debug == null)
            {
                if (_session != null)
                {
                    SPUtility.Redirect(_session.ReturnURL, SPRedirectFlags.Static, HttpContext.Current);
                }
            }
        }
Beispiel #6
0
        public int GetChangedBankAccountsFromSyncDateRemoteCount(List <Guid> entityTypeGuids,
                                                                 string extEntityType,
                                                                 string systemId)
        {
            using (var session = new Domain.Session())
            {
                var totalCount = 0;

                foreach (var entityTypeGuid in entityTypeGuids)
                {
                    var entities = this.GetChangedEntities(session, entityTypeGuid, extEntityType, systemId).ToList();
                    totalCount += entities.Where(x => Counterparties.Is(x) &&
                                                 Counterparties.As(x).Status == Sungero.Parties.Counterparty.Status.Active &&
                                                 Counterparties.As(x).Bank != null &&
                                                 !string.IsNullOrEmpty(Counterparties.As(x).Account))
                                  .Count();
                }
                return(totalCount);
            }
        }
Beispiel #7
0
        public List <Sungero.Domain.Shared.IEntity> GetChangedEntitiesFromSyncDateRemote(List <Guid> entityTypeGuids,
                                                                                         int processedEntitiesCount,
                                                                                         int entitiesCountForProcessing,
                                                                                         string extEntityType,
                                                                                         string systemId)
        {
            using (var session = new Domain.Session())
            {
                var entities = new List <Sungero.Domain.Shared.IEntity>().AsQueryable();

                foreach (var entityTypeGuid in entityTypeGuids)
                {
                    entities = entities.Union(this.GetChangedEntities(session, entityTypeGuid, extEntityType, systemId));
                }
                var entitiesBatch = entities
                                    .Skip(processedEntitiesCount)
                                    .Take(entitiesCountForProcessing)
                                    .ToList();

                return(entitiesBatch);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string debug = Context.Request.QueryString["debug"];

            if (WebPartManager.DisplayMode == WebPartManager.EditDisplayMode)
                debug = "yes";

            IApiProvider apiProvider = Utilities.ApiProvider;
            _session = null;
            string return_url = Context.Request.QueryString["return_url"];
            if (return_url == null)
            {
                return_url = "/";
                debug = "yes"; // Do not instant redirect
            }

            if (apiProvider != null)
            {
                SPUser user = SPContext.Current.Web.CurrentUser;
                string email = null;
                string fullname = null;

                if (user != null)
                {
                    email = _sendEmail ? user.Email : null;
                    fullname = _sendFullName ? user.Name : null;
                }

                ISessionService sessionService = new SessionService(apiProvider);
                _session = sessionService.GetToken(return_url, email, fullname);
            }

            // Do not redirect if debug is set
            if (debug == null)
            {
                if (_session != null)
                {
                    SPUtility.Redirect(_session.ReturnURL, SPRedirectFlags.Static, HttpContext.Current);
                }
            }
        }