예제 #1
0
        public void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (LogoutCommand)Command;
            }
            try
            {
                //clear login settings
                Common.RemoveSettings(Me.SettingsToRemove);

                //app start screen
                App  app = Configuration.GetInstance().App;
                Page p   = MobilePage.GetPage(app.DefaultScreen).GetPage();

                Page.Navigation.PushModalAsync(p);
            }
            catch (Exception ex)
            {
                IPage.DisplayErrorAlert(ex.Message);
            }
        }
        public void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (NavigateToScreenCommand)Command;
            }

            //log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            try
            {
                Page p = MobilePage.GetPage(Me.NavigateScreen).GetPage();

                Page.Navigation.PushAsync(p);

                //if (Command != null)
                //{
                //    Me = (NavigateToUrlCommand)Command;
                //}

                //if (String.IsNullOrEmpty(Me.NavigateUrl))
                //{
                //    throw new ApplicationException("NavigateUrl is invalid");
                //}
                //string url = Common.CreateUrlWithQueryStringContext(Me.NavigateUrl, Me.Context);
                //url = String.Format(url, Page.Request.QueryString[Me.EntityID]);

                //log.DebugFormat("RedirectUrl:{0}", url);
                //Page.Response.Redirect(url,false);
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                //Page.DisplayErrorAlert(ex);

                //log.Error(ex);
            }
        }
        protected async void SaveEditForm()
        {
            DataCommandService dataCommandDB = DataCommandService.GetInstance();

            bool   SuccessIndicator = false;
            string retVal           = null;

            if (true)//Page.IsValid)
            {
                try
                {
                    object r = null;
                    List <ScreenDataCommandParameter> parameters = null;
                    switch (PageMode)
                    {
                    case FormViewMode.View:
                        CodeTorch.Core.Common.LogInfo("\r\n\r\nIn Insert Mode");

                        if (String.IsNullOrEmpty(Me.InsertCommand))
                        {
                            throw new Exception("InsertCommand is invalid");
                        }
                        CodeTorch.Core.Common.LogDebug(String.Format("InsertCommand:{0}", Me.InsertCommand));

                        parameters = Common.GetPopulatedCommandParameters(Me.InsertCommand, IPage);

                        DataCommand command = DataCommand.GetDataCommand(Me.InsertCommand);

                        switch (command.ReturnType)
                        {
                        case DataCommandReturnType.DataTable:
                            r = await dataCommandDB.GetDataForDataCommand(Me.InsertCommand, parameters);

                            break;

                        case DataCommandReturnType.Integer:
                            r = await dataCommandDB.ExecuteDataCommand(Me.InsertCommand, parameters);

                            break;

                        case DataCommandReturnType.Xml:
                            throw new NotImplementedException();
                            break;

                        case DataCommandReturnType.None:
                            break;
                        }


                        if (r != null)
                        {
                            if (!String.IsNullOrEmpty(Me.AfterInsertSettings))
                            {
                                if (r is DataTable)
                                {
                                    DataTable dt = r as DataTable;
                                    if (dt.Rows.Count > 0)
                                    {
                                        DataRow row = dt.Rows[0];
                                        Common.DataRowToSettings(row, Me.AfterInsertSettings);
                                    }
                                }
                            }
                            //if r is datatable - see if any of the values need to be stored in settings
                            //retVal = r.ToString();
                            //CodeTorch.Core.Common.LogDebug(String.Format("Output Parameter:{0}", retVal));
                        }

                        CodeTorch.Core.Common.LogDebug(String.Format("RedirectAfterInsert:{0}", Me.RedirectAfterInsert));
                        if (Me.RedirectAfterInsert)
                        {
                            if (!String.IsNullOrEmpty(Me.AfterInsertRedirectScreen))
                            {
                                Page p = MobilePage.GetPage(Me.AfterInsertRedirectScreen).GetPage();

                                Page.Navigation.PushAsync(p);
                            }
                            else
                            {
                                //TODO: do what -tell about config error
                            }

                            //string url = GetRedirectUrl(retVal);
                            //log.DebugFormat("RedirectUrl:{0}", url);
                            //Page.Response.Redirect(url,false);
                            //HttpContext.Current.ApplicationInstance.CompleteRequest();
                        }
                        else
                        {
                            Page.DisplayAlert("Alert", Me.AfterInsertConfirmationMessage, "OK");

                            //Page.DisplaySuccessAlert(String.Format(Me.AfterInsertConfirmationMessage, retVal));

                            //RefreshSections();
                        }
                        break;
                        //case FormViewMode.Edit:
                        //    log.Info("In Edit Mode");
                        //    if (String.IsNullOrEmpty(Me.UpdateCommand))
                        //    {
                        //        throw new ApplicationException("UpdateCommand is invalid");
                        //    }
                        //    log.DebugFormat("UpdateCommand:{0}", Me.UpdateCommand);

                        //    parameters = pageDB.GetPopulatedCommandParameters(Me.UpdateCommand, Page);
                        //    dataCommandDB.ExecuteDataCommand(Me.UpdateCommand, parameters);

                        //    log.DebugFormat("RedirectAfterUpdate:{0}", Me.RedirectAfterUpdate);
                        //    if (Me.RedirectAfterUpdate)
                        //    {
                        //        string url = GetRedirectUrl(Page.Request.QueryString[Me.EntityID]);
                        //        log.DebugFormat("RedirectUrl:{0}", url);
                        //        Page.Response.Redirect(url, false);
                        //        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        //    }
                        //    else
                        //    {
                        //        Page.DisplaySuccessAlert(String.Format(Me.AfterUpdateConfirmationMessage, retVal));

                        //        RefreshSections();
                        //    }
                        //    break;
                    }
                    SuccessIndicator = true;
                }
                catch (Exception ex)
                {
                    SuccessIndicator = false;

                    IPage.DisplayErrorAlert(ex.Message);



                    //log.Error(ex);
                }
            }

            //return SuccessIndicator;
        }
예제 #4
0
        public async void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (ValidateUserCommand)Command;
            }
            try
            {
                DataTable          dt            = null;
                DataCommandService dataCommandDB = DataCommandService.GetInstance();
                bool IsAuthenticated             = false;

                //call data command

                //if we get datatable and row=1 store

                List <ScreenDataCommandParameter> parameters = null;
                parameters = Common.GetPopulatedCommandParameters(Me.LoginCommand, IPage);

                DataCommand command = DataCommand.GetDataCommand(Me.LoginCommand);

                switch (command.ReturnType)
                {
                case DataCommandReturnType.DataTable:
                    dt = await dataCommandDB.GetDataForDataCommand(Me.LoginCommand, parameters);

                    break;

                case DataCommandReturnType.Integer:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.Xml:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.None:
                    throw new NotImplementedException();
                    break;
                }

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        DataRow row = dt.Rows[0];
                        Common.DataRowToSettings(row, Me.AfterLoginSettings);
                        IsAuthenticated = true;
                        if (!String.IsNullOrEmpty(Me.AfterLoginRedirectScreen))
                        {
                            Page p = MobilePage.GetPage(Me.AfterLoginRedirectScreen).GetPage();

                            Page.Navigation.PushAsync(p);
                        }
                    }
                }

                if (!IsAuthenticated)
                {
                    IPage.DisplayErrorAlert("You have entered an invalid username/password combination. Please try again.");
                }
            }
            catch (Exception ex)
            {
                IPage.DisplayErrorAlert(ex.Message);
            }
        }