Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        public static void Register()
        {
            var container = new Container();

            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            DefaultPackage.RegisterServices(container);
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            container.Verify();

            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
        }
Ejemplo n.º 2
0
    void Package()
    {
        var temp = EditorUserBuildSettings.activeBuildTarget;

        EditorUserBuildSettings.SwitchActiveBuildTarget(PackagePlatform.GetBuildTarget());

        //切换贴图格式
        SwitchTextureFormat();

        //打包其他文件
        DefaultPackage.BuildDefaultSpecify(PackagePlatform.platformCurrent);


        //打包Assetbundle
        AssetBundlePackage.BuildAssetbundlesSpecify(PackagePlatform.platformCurrent);

        //打包场景
        if (needPackageScene)
        {
            PackagePlatform.sceneDirectoryPath = rawScenePath;
            SceneBundlePackage.BuildSceneSpecify(PackagePlatform.platformCurrent);
        }

        //生成版本号
        var minor = int.Parse(minorVersion);

        minor++;
        minorVersion = minor.ToString();
        PackageUtil.GeneratorVersion(mainVersion, minorVersion);

        //生成文件表
        PackageUtil.GeneratorChecklist();

        EditorUserBuildSettings.SwitchActiveBuildTarget(temp);
        SavePackageConfig();
    }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            _Application app   = new Application();
            Workbook     book  = null;
            Worksheet    sheet = null;
            Range        range = null;

            try
            {
                app.Visible        = false;
                app.ScreenUpdating = false;
                app.DisplayAlerts  = false;

                string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"MasterSheet.xlsx");

                book = app.Workbooks.Open(filePath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                sheet = (Worksheet)book.Worksheets[1];

                // get a range to work with
                range = sheet.get_Range("A2", Missing.Value);
                // get the end of values to the right (will stop at the first empty cell)
                range = range.get_End(XlDirection.xlToRight);
                // get the end of values toward the bottom, looking in the last column (will stop at first empty cell)
                range = range.get_End(XlDirection.xlDown);

                // get the address of the bottom, right cell
                string downAddress = range.get_Address(
                    false, false, XlReferenceStyle.xlA1,
                    Type.Missing, Type.Missing);

                // Get the range, then values from a1
                range            = sheet.get_Range("A2", downAddress);
                object[,] values = (object[, ])range.Value2;

                // Value2 is a two dimenial array dime one = row, dime two = column.
                Console.WriteLine("Col Count: " + values.GetLength(1).ToString());
                Console.WriteLine("Row Count: " + values.GetLength(0).ToString());

                using (DanceClassDbContext db = new DanceClassDbContext())
                {
                    var users       = new List <ApplicationUser>();
                    var memberships = new List <Membership>();
                    var packages    = new List <Package>();

                    var defaultPackages = db.DefaultPackages.ToList();

                    for (int i = 1; i <= values.GetLength(0); i++)
                    {
                        string fullName = values[i, 1].ToString().Trim();
                        if (!values[i, 2].ToString().Equals("0"))
                        {
                            fullName = values[i, 2].ToString().Trim() + " " + fullName;
                        }

                        DateTime?dob         = !values[i, 3].Equals("undefined") ? (DateTime?)DateTime.FromOADate((double)values[i, 3]) : null;
                        string   phoneNumber = "0" + values[i, 4].ToString().Trim();

                        int      numberOfSessions = int.Parse(values[i, 5].ToString());
                        int      months           = int.Parse(values[i, 6].ToString());
                        DateTime createdDate      = DateTime.FromOADate((double)values[i, 7]);
                        Console.WriteLine(createdDate);
                        DateTime expiryDate        = DateTime.FromOADate((double)values[i, 8]);
                        int      remainingSessions = int.Parse(values[i, 10].ToString());
                        double   price             = (double)values[i, 11];

                        ApplicationUser user = new ApplicationUser
                        {
                            FullName    = fullName,
                            UserName    = GenerateUserName(users, fullName),
                            PhoneNumber = phoneNumber,
                            Birthdate   = dob,
                            CreatedBy   = "Imported",
                            UpdatedBy   = "Imported",
                            CreatedDate = createdDate,
                            UpdatedDate = createdDate
                        };

                        Membership membership = new Membership
                        {
                            User = user,
                            RemainingSessions = remainingSessions,
                            ExpiryDate        = expiryDate,
                            CreatedBy         = "Imported",
                            UpdatedBy         = "Imported",
                            CreatedDate       = createdDate,
                            UpdatedDate       = createdDate
                        };

                        DefaultPackage defaultPackage = defaultPackages.FirstOrDefault(p => p.NumberOfSessions == numberOfSessions);
                        Package        package        = new Package
                        {
                            NumberOfSessions  = numberOfSessions,
                            RemainingSessions = remainingSessions,
                            Months            = months,
                            Price             = price,
                            DefaultPackageId  = defaultPackage != null ? (int?)defaultPackage.Id : null,
                            User        = user,
                            CreatedBy   = "Imported",
                            UpdatedBy   = "Imported",
                            CreatedDate = createdDate,
                            UpdatedDate = createdDate,
                            ExpiryDate  = expiryDate
                        };

                        users.Add(user);
                        memberships.Add(membership);
                        packages.Add(package);
                    }

                    ApplicationUserManager userManager = new ApplicationUserManager(new ApplicationUserStore(db));
                    using (DbContextTransaction transaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            Console.WriteLine("--------------------------------------");
                            Console.WriteLine("- ADDING USERS -------------------------");
                            Console.WriteLine("--------------------------------------");
                            foreach (var u in users)
                            {
                                Console.WriteLine("Adding user: "******"Mistake1234").GetAwaiter().GetResult();
                                if (result.Succeeded)
                                {
                                    result = userManager.AddToRoleAsync(u.Id, "Member").GetAwaiter().GetResult();
                                }

                                if (!result.Succeeded)
                                {
                                    throw new Exception(string.Join(". ", result.Errors));
                                }
                            }

                            Console.WriteLine("--------------------------------------");
                            Console.WriteLine("- ADDING MEMBERSHIPS -------------------------");
                            Console.WriteLine("--------------------------------------");
                            db.Memberships.AddRange(memberships);

                            Console.WriteLine("--------------------------------------");
                            Console.WriteLine("- ADDING PACKAGES -------------------------");
                            Console.WriteLine("--------------------------------------");
                            db.Packages.AddRange(packages);

                            Console.WriteLine("--------------------------------------");
                            Console.WriteLine("- SAVING CHANGES -------------------------");
                            Console.WriteLine("--------------------------------------");
                            db.SaveChanges();
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            Console.WriteLine(ex);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                range = null;
                sheet = null;
                if (book != null)
                {
                    try
                    {
                        book.Close(false, Missing.Value, Missing.Value);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                book = null;
                if (app != null)
                {
                    try
                    {
                        app.Quit();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

                app = null;
                Console.ReadKey();
            }
        }