示例#1
0
        private void ApplyStyles(string screenName, ILayoutable scr, object cache)
        {
            string cssFile = null;
            var    sheet   = scr as ICustomStyleSheet;

            if (sheet != null)
            {
                if (!string.IsNullOrEmpty(sheet.StyleSheet))
                {
                    cssFile = sheet.StyleSheet;
                }
            }

            TimeStamp.Start("Init styles");

            IStyleSheet styleSheet = InitStyles(screenName, cssFile);

            styleSheet.SetCache((IDisposable)cache);

            TimeStamp.Log("Init styles");
            TimeStamp.Start("Assign styles");

            styleSheet.Assign(scr);

            TimeStamp.Log("Assign styles");
            TimeStamp.Start("Apply styles");

            scr.ApplyStyles(styleSheet, StyleSheetContext.Current.EmptyBound, StyleSheetContext.Current.EmptyBound);

            TimeStamp.Log("Apply styles");
        }
示例#2
0
        public T CreateController <T>(String moduleName, bool isGlobal = false, bool assignGlobal = false) where T : Controller, new()
        {
            TimeStamp.Start("CreateController");

            Controller controller = null;

            if (!controllers.TryGetValue(moduleName, out controller))
            {
                Stream scriptStream = null;
                ApplicationContext.Context.DAL.TryGetScriptByName(moduleName, out scriptStream);
                if (scriptStream != null && !isGlobal)
                {
                    scriptStream = ApplyMixins(moduleName, scriptStream);
                }

                //scriptStream CAN be null !!!
                ScriptEngine scriptEngine = ScriptEngine.LoadScript(scriptStream, moduleName, Debugger);

                //init script variables ant types here..
                scriptEngine.AddVariable("String", typeof(String));
                scriptEngine.AddVariable("DateTime", typeof(DateTime));
                scriptEngine.AddVariable("Workflow", new Workflow());
                scriptEngine.AddVariable("DB", new DB(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("GPS", new GPS(ApplicationContext.Context.LocationProvider));
                scriptEngine.AddVariable("GPSTracking", new GPSTracking(ApplicationContext.Context.LocationTracker));
                scriptEngine.AddVariable("Gallery", new Gallery(ApplicationContext.Context, scriptEngine));

                Variables v = new Variables(ApplicationContext.Context);
                scriptEngine.AddVariable("Variables", v);
                scriptEngine.AddVariable("$", v);

                scriptEngine.AddVariable("Dialog", new Dialog(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("Translate", new Translate(ApplicationContext.Context));
                scriptEngine.AddVariable("Converter", new Converter());
                scriptEngine.AddVariable("Phone", new Phone(ApplicationContext.Context));
                scriptEngine.AddVariable("FileSystem", new FileSystem(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("Camera", new Camera(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("Console", new BitMobile.ClientModel.Console(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("BarcodeScanner", new BarcodeScanner(scriptEngine, ApplicationContext.Context));
                scriptEngine.AddVariable("Application", new ClientModel.Application(ApplicationContext.Context));
                scriptEngine.AddVariable("Clipboard", new Clipboard(ApplicationContext.Context));

                if (!isGlobal || assignGlobal)
                {
                    AssignGlobalControllers(scriptEngine);
                }

                controller = new T();
                controller.Init(scriptEngine);//, isGlobal ? null : GlobalEventsController());
                controllers.Add(moduleName, controller);
            }

            AssignBreakPoints(controller, true);

            TimeStamp.Log("CreateController", moduleName);

            return((T)controller);
        }
示例#3
0
 public void ExecuteInto(String tableName)
 {
     try
     {
         TimeStamp.Start("ExecuteInto");
         ExecuteIntoInternal(tableName);
     }
     finally
     {
         TimeStamp.Log("ExecuteInto", text);
     }
 }
示例#4
0
 public DbRecordset Execute()
 {
     try
     {
         TimeStamp.Start("Execute");
         return(new DbRecordset(ExecuteInternal()));
     }
     finally
     {
         TimeStamp.Log("Execute", text);
     }
 }
示例#5
0
 public IDbRecordset Execute()
 {
     try
     {
         TimeStamp.Start("Execute");
         return(DbContext.Current.CreateDbRecordset(ExecuteInternal()));
     }
     finally
     {
         TimeStamp.Log("Execute", _text);
     }
 }
示例#6
0
        public object CreateScreen(string screenName, IValueStack stack, IScreenController controller, object styleCache)
        {
            controller.SetCurrentScreenController();

            string tsName = "CreateScreen: " + screenName;

            TimeStamp.Start(tsName);

            var screenStream = ApplicationContext.Current.Dal.GetScreenByName(screenName);

            if (screenStream == null)
            {
                throw new Exception(String.Format("Can't load screen {0}", screenName));
            }

            TimeStamp.Log(tsName, "Prepare");
            TimeStamp.Start(tsName);

            controller.OnLoading(screenName);

            TimeStamp.Log(tsName, "OnLoading invoke");
            TimeStamp.Start(tsName);

            var scr = (IControl <object>)ObjectFactory.CreateObject(stack, screenStream);

            TimeStamp.Log(tsName, "Parse screen");
            TimeStamp.Start(tsName);

//            GC.Collect();
//            TimeStamp.Log(tsName, "GC collect");
//            TimeStamp.Start(tsName);

            scr.CreateView(); // TODO: Replace to platform controllers

            TimeStamp.Log(tsName, "Create views");

            ApplyStyles(screenName, scr, styleCache);

            TimeStamp.Start(tsName);

            controller.OnLoad(screenName);

            TimeStamp.Log(tsName, "OnLoad invoke");

            ApplicationContext.Current.Dal.ClearStringCache();

            TimeStamp.WriteAll();
            TimeCollector.WriteAll();

            return(scr);
        }
示例#7
0
        public object CreateScreen <T>(String screenName, ValueStack.ValueStack stack, BitMobile.Controllers.ScreenController controller) where T : StyleSheet, new()
        {
            string TS_NAME = "CreateScreen: " + screenName;

            TimeStamp.Start("Total");
            TimeStamp.Start(TS_NAME);

            System.IO.Stream screenStream = ApplicationContext.Context.DAL.GetScreenByName(screenName);
            if (screenStream == null)
            {
                throw new Exception(String.Format("Can't load screen {0}", screenName));
            }

            TimeStamp.Log(TS_NAME, "Prepare");
            TimeStamp.Start(TS_NAME);

            controller.OnLoading();

            TimeStamp.Log(TS_NAME, "OnLoading invoke");
            TimeStamp.Start(TS_NAME);

            IControl <object> scr = (IControl <object>)objectFactory.CreateObject(stack, screenStream);

            TimeStamp.Log(TS_NAME, "CreateInstance objects");
            TimeStamp.Start(TS_NAME);

            scr.CreateView(); // TODO: Replace to platform controllers

            TimeStamp.Log(TS_NAME, "CreateInstance views");
            TimeStamp.Start(TS_NAME);

            ApplyStyles(screenName, scr as IStyledObject, new T());

            TimeStamp.Log(TS_NAME, "Apply styles");
            TimeStamp.Start(TS_NAME);

            controller.OnLoad();

            TimeStamp.Log(TS_NAME, "OnLoad invoke");

            TimeStamp.Log("Total");
            TimeStamp.WriteLog();
            TimeCollector.Write("CallFunction");
            TimeCollector.Stop("CallFunction");
            TimeCollector.Write("CallFunctionNoException");
            TimeCollector.Stop("CallFunctionNoException");

            return(scr);
        }
示例#8
0
        public object CallFunction(string functionName, object[] parameters)
        {
            try
            {
                TimeStamp.Start("CallFunction: " + functionName);
                TimeCollector.Start("CallFunction");

                return(ScriptEngine.CallFunction(functionName, parameters));
            }
            finally
            {
                TimeCollector.Pause("CallFunction");
                TimeStamp.Log("CallFunction: " + functionName);
            }
        }
示例#9
0
        public object ExecuteScalar()
        {
            try
            {
                TimeStamp.Start("ExecuteScalar");

                IDatabase db        = DbContext.Current.Database;
                var       arguments = Prepare();
                return(db.SelectScalar(_text, arguments));
            }
            finally
            {
                TimeStamp.Log("ExecuteScalar", _text);
            }
        }
示例#10
0
        public int ExecuteCount()
        {
            try
            {
                TimeStamp.Start("ExecuteCount");

                int rc = 0;
                using (IDbRecordset rs = Execute())
                    while (rs.Next())
                    {
                        rc++;
                    }

                return(rc);
            }
            finally
            {
                TimeStamp.Log("ExecuteCount", _text);
            }
        }
示例#11
0
        public object ExecuteScalar()
        {
            try
            {
                TimeStamp.Start("ExecuteScalar");

                BitMobile.DbEngine.Database db = BitMobile.DbEngine.Database.Current;

                List <object> arguments = new List <object>();
                foreach (var kvp in parameters)
                {
                    arguments.Add(kvp.Value);
                    text = text.Replace("@" + kvp.Key, "@p" + arguments.Count.ToString());
                }

                return(db.SelectScalar(text, arguments.ToArray <object>()));
            }
            finally
            {
                TimeStamp.Log("ExecuteScalar", text);
            }
        }