protected void ReplyISms(HeContext heContext, string message)
        {
            SmsEncoder enc = new SmsEncoder(MTMsg.Encoding);
            int        len = enc.GetCorrectMessageSize(message, _smsmaxlength);

            if (len != message.Length)
            {
                message = message.Remove(len, message.Length - len);
            }
            if (len > 160)
            {
                MTMsg.Pid = -1;
            }
            MTMsg.MaximumParts = 1;
            MTMsg.Message      = message;
            AppUtils.DoOnMobileTerminatedMessage(heContext, ref MTMsg);
            SMSInterface.QueueOutboundSMS(MTMsg);
        }
        protected void Application_Start(Object sender, EventArgs e)
        {
            try {
                Application["ApplicationStartError"] = null;
                Application["EspaceName"]            = "Address_CS";

                // Workaround: Force first access to HeContext to correctly save CurrentCulture
                var firstAccess = HeContext.UnknownEntryPoint;

                // Set default date/time format
                FormatInfo.SetDefaultDateAndDateTimeFormatString("yyyy-M-d", "yyyy-MM-dd");
                // Set decimal and group separator
                FormatInfo.SetInputDecimalSeparator(".");
                FormatInfo.SetInputGroupSeparator("");

                SMSInterface.Init();
                ESpaceInfoForAppStart eSpaceInfo = new ESpaceInfoForAppStart();

                // Check the eSpaceName from the begining of the path
                eSpaceInfo.ESpaceName          = "Address_CS";
                eSpaceInfo.ESpaceId            = eSpaceId;
                eSpaceInfo.ESpaceVersionId     = int.Parse(ConfigurationManager.AppSettings["OutSystems.HubEdition.EspaceVersionID"]);
                eSpaceInfo.ESpaceJQueryVersion = JQueryVersion.JQuery183;

                AppInfo App = new AppInfo(eSpaceInfo);
                if (!forTestAction)
                {
                    App.SetupInvalidateCallbackCache();
                    App.InjectionCache.RunCallbacks(App, null, OutSystems.HubEdition.RuntimePlatform.Callbacks.CallbackEvent.ApplicationStart);
                }
                OutSystems.HubEdition.WebWidgets.OSPage.ValidationMessagesInstance        = new ValidationMessages();
                OutSystems.HubEdition.WebWidgets.OSUserControl.ValidationMessagesInstance = new ValidationMessages();
                System.Net.ServicePointManager.Expect100Continue = Settings.GetBool(Settings.Configs.Runtime_Expect100Continue);

                LifecyleListenerManager.RegisterListener("OutSystems.RESTService.ServiceConfiguration", new System.Reflection.AssemblyName("OutSystems.RESTService.Runtime"));

                LifecyleListenerManager.OnApplicationStart();
            } catch (Exception excep) {
                Application["ApplicationStartError"] = excep;
                AppInfo.SetAppInfo(HttpContext.Current, null);
                ErrorLog.LogApplicationError(excep, /*context*/ null, "Global");
            }
        }
        protected void SendSms(HeContext heContext, string message, string largeAccount, string msisdn, int count)
        {
            SmsEncoder enc = new SmsEncoder(MTMsg.Encoding);
            int        len = enc.GetCorrectMessageSize(message, _smsmaxlength);

            if (len != message.Length)
            {
                message = message.Remove(len, message.Length - len);
            }
            if (len > 160)
            {
                MTMsg.Pid = -1;
            }
            MTMsg.LargeAccount = largeAccount;
            MTMsg.MaximumParts = count;
            MTMsg.Message      = message;
            MTMsg.MSISDN       = msisdn;
            AppUtils.DoOnMobileTerminatedMessage(heContext, ref MTMsg);
            SMSInterface.QueueOutboundSMS(MTMsg);
        }