Exemple #1
0
 void OnDestroy()
 {
     f1   = null;
     f2   = null;
     f3   = null;
     f4   = null;
     f5   = null;
     farr = null;
     flua = null;
     ie   = null;
     add  = null;
     luaenv.Dispose();
 }
        private void buttonPrepareExport_Click(object sender, EventArgs e)
        {
            if (cbProcNames.Items.Count > 0)
            {
                List <ReportParamV2> paramList = new List <ReportParamV2>();

                Dictionary <string, string> parameters =
                    ServicesProvider.GetInstance().GetAccountingServices().SelectExportAccountingProcParams("ExportAccounting_" + cbProcNames.Text);

                if (parameters != null && parameters.Count > 0)
                {
                    foreach (var parameter in parameters)
                    {
                        ReportParamV2 reportParam;
                        string        paramName = parameter.Key.TrimStart('@');
                        if (paramName.Equals("branch_id", StringComparison.CurrentCultureIgnoreCase))
                        {
                            reportParam = new BranchParam(string.Empty);
                        }
                        else
                        {
                            string paramType = parameter.Value;
                            switch (paramType)
                            {
                            case "bit":
                                reportParam = new BoolParam(false);
                                break;

                            case "datetime":
                                reportParam = new DateParam(DateTime.Today);
                                break;

                            case "char":
                                reportParam = new CharParam(' ');
                                break;

                            case "nvarchar":
                            case "varchar":
                            case "text":
                                reportParam = new StringParam(string.Empty);
                                break;

                            case "int":
                                reportParam = new IntParam(1);
                                break;

                            case "float":
                                reportParam = new DoubleParam(1d);
                                break;

                            case "money":
                                reportParam = new DecimalParam(1m);
                                break;

                            default:
                                throw new NotImplementedException(string.Format("Sql type:{0} is not handled.", paramName));
                            }
                        }

                        reportParam.Label = paramName;
                        reportParam.Name  = paramName;
                        paramList.Add(reportParam);
                    }
                    ReportParamsForm frm = new ReportParamsForm(paramList, cbProcNames.Text);
                    frm.ShowDialog();
                }

                _dataTable =
                    ServicesProvider.GetInstance().GetAccountingServices().FindElementaryMvtsToExport(
                        "ExportAccounting_"
                        + cbProcNames.Text, paramList, out _idTable);

                _total = _dataTable.Rows.Count;

                _bwSelect = new BackgroundWorker {
                    WorkerSupportsCancellation = true
                };
                _bwSelect.DoWork += BwSelect_DoWork;

                ExportBookings_Load(this, null);
            }
        }
Exemple #3
0
        // Use this for initialization
        void Start()
        {
            XLuaEnv.onDispose += () =>
            {
                f1   = null;
                f2   = null;
                f3   = null;
                f4   = null;
                f5   = null;
                farr = null;
                flua = null;
                ie   = null;
                add  = null;
            };
            XLuaEnv.DoString(@"
                function id(...)
                    return ...
                end

                function add(a, b) return a + b end
            
                function array_exchange(arr)
                    arr[0], arr[1] = arr[1], arr[0]
                end

                local v3 = CS.UnityEngine.Vector3(7, 8, 9)
                local vt = CS.IFramework.Hotfix.Lua.MyStruct(5, 6)

                function lua_access_csharp()
                    monoBehaviour:FloatParamMethod(123) --primitive
                    monoBehaviour:Vector3ParamMethod(v3) --vector3
                    local rnd = math.random(1, 100)
                    local r = monoBehaviour:Vector3ParamMethod({x = 1, y = 2, z = rnd}) --vector3
                    assert(r.x == 1 and r.y == 2 and r.z == rnd)
                    monoBehaviour:StructParamMethod(vt) --custom struct
                    r = monoBehaviour:StructParamMethod({a = 1, b = rnd, e = {c = rnd}})
                    assert(r.b == rnd and r.e.c == rnd)
                    monoBehaviour:EnumParamMethod(CS.IFramework.Hotfix.Lua.MyEnum.E2) --enum
                    monoBehaviour:DecimalParamMethod(monoBehaviour.a5[0])
                    monoBehaviour.a1[0], monoBehaviour.a1[1] = monoBehaviour.a1[1], monoBehaviour.a1[0] -- field
                end

                exchanger = {
                    exchange = function(self, arr)
                        array_exchange(arr)
                    end
                }

                A = { B = { C = 789}}
                GDATA = 1234;
            ");

            XLuaEnv.gtable.Set("monoBehaviour", this);

            XLuaEnv.gtable.Get("id", out f1);
            XLuaEnv.gtable.Get("id", out f2);
            XLuaEnv.gtable.Get("id", out f3);
            XLuaEnv.gtable.Get("id", out f4);
            XLuaEnv.gtable.Get("id", out f5);

            XLuaEnv.gtable.Get("array_exchange", out farr);
            XLuaEnv.gtable.Get("lua_access_csharp", out flua);
            XLuaEnv.gtable.Get("exchanger", out ie);
            XLuaEnv.gtable.Get("add", out add);

            XLuaEnv.gtable.Set("g_int", 123);
            XLuaEnv.gtable.Set(123, 456);
            int i;

            XLuaEnv.gtable.Get("g_int", out i);
            Debug.Log("g_int:" + i);
            XLuaEnv.gtable.Get(123, out i);
            Debug.Log("123:" + i);
        }