Exemplo n.º 1
0
 private void PackageAndSendButton_Click(object sender, RoutedEventArgs e)
 {
     using(Packager onePackager = new Packager())
     {
         string desktopSamplePackage = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "Sample Package");
         onePackager.SendToFile(SessionCriteria.AllSessions, true, desktopSamplePackage);
     }
 }
Exemplo n.º 2
0
    public void OnGUI()
    {
        //GUI.DrawTexture(this.mWelcomeScreenImageRect, this.mWelcomeScreenImage);
        GUI.Label(this.mWelcomeIntroRect, "欢迎使用SimpleFramework,它是个基于uLua/CSTOLUA,\n将C#类注册进Lua,并且附带了AssetBundle管理的演示框架。入门步骤如下:");
        GUI.DrawTexture(this.mSamplesImageRect, this.mSamplesImage);
        GUI.Label(this.mSamplesHeaderRect, "新手入门 - 生成Wrap文件(必须)");
        GUI.Label(this.mSamplesDescriptionRect, "单击Lua菜单里面Gen Lua Wrap File子菜单.");
        GUI.DrawTexture(this.mDocImageRect, this.mDocImage);
        GUI.Label(this.mDocHeaderRect, "新手入门 - 根据不同平台生成AssetBundle资源(必须)");
        GUI.Label(this.mDocDescriptionRect, "单击Game菜单里面Build XXX Resources子菜单.");
        GUI.DrawTexture(this.mVideoImageRect, this.mVideoImage);
        GUI.Label(this.mVideoHeaderRect, "新手入门 - 改完注册到Lua的C#类,需清除文件缓存,重新生成");
        GUI.Label(this.mVideoDescriptionRect, "单击Lua菜单里面Clear LuaBinder File + Wrap Files子菜单.");
        GUI.DrawTexture(this.mForumImageRect, this.mForumImage);
        GUI.Label(this.mForumHeaderRect, "新手入门 - Lua需要统一的UTF-8文件编码");
        GUI.Label(this.mForumDescriptionRect, "单击Lua菜单里面Encode LuaFile with UTF-8子菜单.");
        GUI.DrawTexture(this.mContactImageRect, this.mContactImage);
        GUI.Label(this.mContactHeaderRect, " 加入技术支持社群");
        GUI.Label(this.mContactDescriptionRect, "QQ群:469941220 或者 QQ群:62978170");
        GUI.Label(this.mVersionRect, version);

        flag = GUI.Toggle(this.mToggleButtonRect, flag, "开始时候显示对话框");
        if (flag)
        {
            PlayerPrefs.SetInt("ShowWelcomeScreen", 1);
        }
        else
        {
            PlayerPrefs.SetInt("ShowWelcomeScreen", 0);
        }
        EditorGUIUtility.AddCursorRect(this.mSamplesImageRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mSamplesHeaderRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mSamplesDescriptionRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mDocImageRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mDocHeaderRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mDocDescriptionRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mVideoImageRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mVideoHeaderRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mVideoDescriptionRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mForumImageRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mForumHeaderRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mForumDescriptionRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mContactImageRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mContactHeaderRect, MouseCursor.Link);
        EditorGUIUtility.AddCursorRect(this.mContactDescriptionRect, MouseCursor.Link);
        if (Event.current.type == EventType.MouseUp)
        {
            Vector2 mousePosition = Event.current.mousePosition;
            if ((this.mSamplesImageRect.Contains(mousePosition) || this.mSamplesHeaderRect.Contains(mousePosition)) || this.mSamplesDescriptionRect.Contains(mousePosition))
            {
                LuaBinding.Binding();
            }
            else if ((this.mDocImageRect.Contains(mousePosition) || this.mDocHeaderRect.Contains(mousePosition)) || this.mDocDescriptionRect.Contains(mousePosition))
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    Packager.BuildWindowsResource();
                }
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    Packager.BuildiPhoneResource();
                }
            }
            else if ((this.mVideoImageRect.Contains(mousePosition) || this.mVideoHeaderRect.Contains(mousePosition)) || this.mVideoDescriptionRect.Contains(mousePosition))
            {
                LuaBinding.ClearLuaBinder();
            }
            else if ((this.mForumImageRect.Contains(mousePosition) || this.mForumHeaderRect.Contains(mousePosition)) || this.mForumDescriptionRect.Contains(mousePosition))
            {
                LuaBinding.EncodeLuaFile();
            }
            else if ((this.mContactImageRect.Contains(mousePosition) || this.mContactHeaderRect.Contains(mousePosition)) || this.mContactDescriptionRect.Contains(mousePosition))
            {
                Application.OpenURL("http://shang.qq.com/wpa/qunwpa?idkey=20a9db3bac183720c13a13420c7c805ff4a2810c532db916e6f5e08ea6bc3a8f");
            }
        }
    }
Exemplo n.º 3
0
        public void SetElement(VisualElement element)
        {
            TElement oldElement = Element;

            Element = (TElement)element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged      -= OnElementPropertyChanged;
                oldElement.FocusChangeRequested -= OnElementFocusChangeRequested;
            }

            if (element != null)
            {
                Element.PropertyChanged      += OnElementPropertyChanged;
                Element.FocusChangeRequested += OnElementFocusChangeRequested;

                if (AutoPackage && Packager == null)
                {
                    Packager = new VisualElementPackager(this);
                }

                if (AutoTrack && Tracker == null)
                {
                    Tracker = new VisualElementTracker <TElement, TNativeElement>();
                }

                // Disabled until reason for crashes with unhandled exceptions is discovered
                // Without this some layouts may end up with improper sizes, however their children
                // will position correctly
                // Consider using Loading vs Loaded if this is added back, calling in Loaded appears to be to late in the layout cycle
                // and may cause issues
                //Loaded += (sender, args) =>
                //{
                if (Packager != null)
                {
                    Packager.Load();
                }
                //};
            }

            OnElementChanged(new ElementChangedEventArgs <TElement>(oldElement, Element));

            if (_control != null && this is IDontGetFocus)
            {
                _control.GotFocus     += OnGotFocus;
                _control.GettingFocus += OnGettingFocus;
            }

            var controller = (IElementController)oldElement;

            if (controller != null && (Panel)controller.EffectControlProvider == this)
            {
                controller.EffectControlProvider = null;
            }

            controller = element;
            if (controller != null)
            {
                controller.EffectControlProvider = this;
            }
        }
Exemplo n.º 4
0
 private static void ReleaseDirectoryRemove(int Id, ref Packager.Database.PackagerDatabase database)
 {
     var result = from sp in database.ReleaseDirectories
                           where sp.Id == Id
                           select sp;
     if (result != null) {
         database.ReleaseDirectories.Remove (result.First ());
     }
 }
Exemplo n.º 5
0
        private static RelaseDirectoy ReleaseDirectoryExist(int Id, ref Packager.Database.PackagerDatabase database)
        {
            var result = from sp in database.ReleaseDirectories
                                  where sp.Id == Id
                                  select sp;
            if (result.Count () <= 0) {
                return null;
            }

            return result.First ();
        }
Exemplo n.º 6
0
        private static RelaseDirectoy ReleaseDirectoryExist(string fullName, ref Packager.Database.PackagerDatabase database)
        {
            var result = from sp in database.ReleaseDirectories
                                  where sp.ReleaseDirectoryLocation == fullName
                                  select sp;
            if (result.Count () <= 0) {
                return null;
            }

            return result.First ();
        }
Exemplo n.º 7
0
 private static void ExcludeFileRemove(string file, ref Packager.Database.PackagerDatabase database)
 {
     var result = from sp in database.ExcludedFiles
                           where sp.Filename == file
                           select sp;
     if (result.Count () <= 0) {
         return;
     }
     database.ExcludedFiles.Remove (result.First ());
 }
 public static void buildAndRun()
 {
     PlayerPrefs.SetInt("autobuild", 2);
     Packager.BuildResource();
 }
Exemplo n.º 9
0
 public static void createWindow()
 {
     EditorWindow.GetWindow <BuildWindow>();
     Packager.Init();
     Packager.bLoadAB = !AssetBundleManager.SimulateAssetBundleInEditor;
 }
Exemplo n.º 10
0
 void OnEnable()
 {
     myVersion = VersionEditorManager.Instance().curVersion;
     Packager.Init();
 }
Exemplo n.º 11
0
 static public string getPlatformManifest()
 {
     return(getPlatformDir(Packager.getBuildTarget()) + ".manifest");
 }
Exemplo n.º 12
0
    void OnGUI()
    {
        GUILayout.Label(" 指定当前版本号, 与服务器保持一致", EditorStyles.boldLabel);
        myVersion = GUILayout.TextField(myVersion);
        GUILayout.Space(20);

        // =========================== 3. 标记AB资源   ===========================
        if (GUILayout.Button("刷新版本", GUILayout.Height(30)))
        {
            string[] szAssetBundleNames = AssetDatabase.GetAllAssetBundleNames();
            for (int i = 0; i < szAssetBundleNames.Length; i++)
            {
                AssetDatabase.RemoveAssetBundleName(szAssetBundleNames[i], true);
            }

            VersionEditorManager.Instance().curVersion = myVersion;
            PlayerSettings.Android.bundleVersionCode = VersionEditorManager.Instance().getVersionNum();
            PlayerSettings.bundleVersion             = myVersion;
        }

        GUILayout.Space(30);

        //=========================== 1.选择平台 ================================
        GUILayout.Label(" 选择发布平台  ", EditorStyles.boldLabel);
        GUILayout.Space(20);

        TargetPlatform select = (TargetPlatform)EditorGUILayout.EnumPopup(Packager.curTarget);

        if (select != Packager.curTarget)
        {
            // 重新判断当前版本设定
            Packager.curTarget = select;
        }

        GUILayout.Space(20);

        // =========================== 3. 标记AB资源   ===========================
        if (GUILayout.Button("标记AB", GUILayout.Height(30)))
        {
            Packager.BuildAssetMarks();
            Packager.WritePreloadFile();
            BuildUtil.createVersion();
        }

        GUILayout.Space(20);

        if (GUILayout.Button("生成AB", GUILayout.Height(30)))
        {
            Packager.ClearABFolder();
            Packager.GenerateAB();
        }

        // =========================== 4. 是否读取AB包  ===========================
        bool cur = GUILayout.Toggle(Packager.bLoadAB, "读取AB包");

        if (Packager.bLoadAB != cur)
        {
            Packager.bLoadAB = cur;
            AssetBundleManager.SimulateAssetBundleInEditor = !Packager.bLoadAB;
        }

        GUILayout.Space(20);
        GUIContent content = new GUIContent(" 请确认完成了 AB包 的制做过程 !!!");
        GUIStyle   style   = new GUIStyle();

        style.fontStyle = FontStyle.Normal;
        style.fontSize  = 13;

        GUILayout.Label(content);
        GUILayout.Space(20);
        GUILayout.Label(" 选择发布版本类型:");
        GUILayout.Space(20);
        BuildTargetGroup curGroup  = transPlatform(Packager.curTarget);
        string           curSymbol = null;

        if (curSelect == -1)
        {
            curSymbol = PlayerSettings.GetScriptingDefineSymbolsForGroup(curGroup);
            if (curSymbol.IndexOf("RELEASE_VER", 0, curSymbol.Length) == -1)
            {
                curSelect = 0;
            }
            else
            {
                if (curSymbol.IndexOf("STORE_VERSION", 0, curSymbol.Length) == -1)
                {
                    curSelect = 1;
                }
                else
                {
                    curSelect = 2;
                }
            }
        }

        int newSelect = GUILayout.SelectionGrid(curSelect, verList, 6);

        //处理不同版本的一些 PlayerSetting 设置
        if (newSelect != curSelect)
        {
            curSelect = newSelect;
            curSymbol = PlayerSettings.GetScriptingDefineSymbolsForGroup(curGroup);
            switch (curSelect)
            {
            case 0:
            {
                curSymbol = curSymbol.Replace("RELEASE_VER", "DEVELOP_VERSION");
                curSymbol = curSymbol.Replace("STORE_VERSION", "DEVELOP_VERSION");
                if (curSymbol.IndexOf("DEVELOP_VERSION", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "DEVELOP_VERSION";
                }
            }
            break;

            case 1:
            {
                curSymbol = curSymbol.Replace("DEVELOP_VERSION", "RELEASE_VER");
                curSymbol = curSymbol.Replace("STORE_VERSION", "RELEASE_VER");
                if (curSymbol.IndexOf("RELEASE_VER", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "RELEASE_VER";
                }
            }
            break;

            case 2:
            {
                curSymbol = curSymbol.Replace("DEVELOP_VERSION", "STORE_VERSION");
                curSymbol = curSymbol.Replace("RELEASE_VER", "STORE_VERSION");
                if (curSymbol.IndexOf("STORE_VERSION", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "STORE_VERSION";
                }
            }
            break;
            }

            PlayerSettings.SetScriptingDefineSymbolsForGroup(curGroup, curSymbol);
            Debug.Log(curSymbol);
        }
        GUILayout.Space(20);
        // =========================== 4. 拷贝资源    ===========================
        if (GUILayout.Button("拷贝资源 ", GUILayout.Height(30)))
        {
            switch (Packager.curTarget)
            {
            case TargetPlatform.IOS:
                BuildUtil.copyPlatformRes(BuildTarget.iOS);
                break;

            case TargetPlatform.Windows:
                BuildUtil.copyPlatformRes(BuildTarget.StandaloneWindows);
                break;

            case TargetPlatform.Android:
                BuildUtil.copyPlatformRes(BuildTarget.Android);
                break;

            case TargetPlatform.WebGL:
                BuildUtil.copyPlatformRes(BuildTarget.WebGL);
                break;
            }
            AssetDatabase.Refresh();
        }
        GUILayout.Space(20);
        // =========================== 5. 生成安装包    ===========================
        if (GUILayout.Button("生成安装包 ", GUILayout.Height(30)))
        {
            if (myVersion.Length == 0 || myVersion.Equals("0.0.0"))
            {
                EditorUtility.DisplayDialog(" Error !!", " 请修改版本为有效数字", "确定");
            }
            else
            {
                switch (Packager.curTarget)
                {
                case TargetPlatform.IOS:
                    BuildUtil.buildIOS();
                    break;

                case TargetPlatform.Windows:
                    BuildUtil.buildWindows();
                    break;

                case TargetPlatform.Android:
                    BuildUtil.buildAndroid();
                    break;

                case TargetPlatform.WebGL:
                    BuildUtil.buildWebGL();
                    break;
                }
            }
        }
        ;
        GUILayout.Space(20);

        if (Packager.curTarget == TargetPlatform.IOS)
        {
            if (GUILayout.Button("生成IPA", GUILayout.Height(30)))
            {
                IPABuilder.buildIPA();
            }
            GUILayout.Space(20);
        }

        if (GUILayout.Button("生成版本更新包 ", GUILayout.Height(30)))
        {
            BuildUtil.PatchAll();
        }
    }
Exemplo n.º 13
0
 public static string GetABPath()
 {
     return(Application.dataPath + "/../AssetBundles/" + Packager.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
 }
Exemplo n.º 14
0
    private List<SamplePackageResult> GetSamplePackages(Control row, out int count)
    {
        GridView grid = (GridView) row.FindControl("SamplePackages");

        PackagingRule rule = new PackagingRule();
        rule.BoxHeight = decimal.Parse(((TextBox)row.FindControl("HeightField")).Text);
        rule.BoxLength = decimal.Parse(((TextBox)row.FindControl("LengthField")).Text);
        rule.BoxWidth = decimal.Parse(((TextBox)row.FindControl("WidthField")).Text);
        rule.Limits.AddRange(
            ((BVModules_Shipping_Package_Rules_PackageMatchEditor) row.FindControl("PackageMatchEditor")).GetMatches());
        rule.Name = ((TextBox)row.FindControl("NameField")).Text.Trim();
        rule.TareWeight = decimal.Parse(((TextBox)row.FindControl("TareWeightField")).Text);
        Packager packager = new Packager(rule);

        count = 0;

        // Scan all placed orders
        List<SamplePackageResult> results = new List<SamplePackageResult>();
        int rowCount = 0;
        foreach (Order order in Order.FindByCriteria(new OrderSearchCriteria(), -1, grid.PageSize * 5, ref rowCount))
        {
            Order heavyOrder = Order.FindByBvin(order.Bvin);

            // "Unship" all of the items so that the samples look like they
            // were just placed. Skip any orders with deleted items.
            bool skipOrder = false;
            foreach (LineItem lineitem in heavyOrder.Items)
            {
                if (lineitem.AssociatedProduct == null || lineitem.AssociatedProduct.ShippingMode == ShippingMode.None)
                    skipOrder = true;
                else
                    lineitem.QuantityShipped = 0;
            }
            if (skipOrder) break;

            ExtendedShippingGroupList groups = new ExtendedShippingGroupList();
            foreach (ShippingGroup group in heavyOrder.GetShippingGroups())
            {
                groups.Add(new ExtendedShippingGroup(0, group, group.Items));
            }

            foreach (ExtendedShippingGroup group in groups)
            {
                ExtendedShippingGroupList splitGroups = packager.Split(group);
                List<String> remainingItems = new List<string>();
                SamplePackageResult result;

                Boolean matchingPackage = false;

                foreach (ExtendedShippingGroup splitGroup in splitGroups)
                {
                    if (splitGroup.Name.Equals(rule.Name))
                    {
                        matchingPackage = true;
                        count += 1;

                        result = new SamplePackageResult();
                        result.OrderNumber = order.OrderNumber;
                        result.OrderDisplay = string.Format("<a href=\"{0}\" target=\"order\">{1}</a>",
                                                            Page.ResolveUrl(
                                                                string.Format("~/BVAdmin/Orders/ViewOrder.aspx?id={0}",
                                                                              order.Bvin)),
                                                            order.OrderNumber);
                        List<string> matchValues = new List<string>();
                        List<string> limitValues = new List<string>();
                        for (int index = 0; index < rule.Limits.Count; index++)
                        {
                            PackageMatch match = rule.Limits[index];
                            string matchValue =
                                PackagePropertiesHelper.GetPackagePropertyValue(splitGroup, match.PackageProperty, match.ItemProperty,
                                                             match.CustomProperty, "1").ToString();
                            if (string.IsNullOrEmpty(matchValue)) matchValue = "(empty)";
                            matchValues.Add(matchValue);
                            string limitValue =
                                PackagePropertiesHelper.GetPackagePropertyValue(splitGroup, match.LimitPackageProperty, match.LimitItemProperty,
                                    match.LimitCustomProperty, match.Limit).ToString();
                            if (string.IsNullOrEmpty(limitValue)) limitValue = "(empty)";
                            limitValues.Add(limitValue);
                        }
                        result.MatchValues = string.Join(", ", matchValues.ToArray());
                        result.LimitValues = string.Join(", ", limitValues.ToArray());
                        result.Volume = splitGroup.GetShippingVolume().ToString("0.000");
                        result.Weight = splitGroup.GetShippingWeight().ToString("0.000");
                        if (splitGroup.HasBoxDimensions)
                        {
                            decimal boxVolume = splitGroup.BoxHeight * splitGroup.BoxLength * splitGroup.BoxWidth;
                            result.FillFactor = string.Format("{0:0.000}%", splitGroup.GetShippingVolume() * 100M / boxVolume);
                        }
                        else
                        {
                            result.FillFactor = "n/a";
                        }
                        List<string> lineitems = new List<string>();
                        foreach (LineItem lineitem in splitGroup.Items)
                        {
                            lineitems.Add(string.Format("{0:0} &times; {1}", lineitem.Quantity, lineitem.ProductSku));
                        }
                        result.Items = string.Join(", ", lineitems.ToArray());
                        results.Add(result);
                    }
                    else
                    {
                        foreach (LineItem lineitem in splitGroup.Items)
                        {
                            remainingItems.Add(string.Format("{0:0} &times; {1}", lineitem.Quantity, lineitem.ProductSku));
                        }
                    }

                    if (count > grid.PageSize * 5) break;
                }

                // If there was at least one matching package, then list the unmatched items
                if (matchingPackage && (remainingItems.Count > 0))
                {
                    result = new SamplePackageResult();
                    result.OrderNumber = order.OrderNumber;
                    result.OrderDisplay = string.Format("<a href=\"{0}\" target=\"order\">{1}</a>",
                                                        Page.ResolveUrl(
                                                            string.Format("~/BVAdmin/Orders/ViewOrder.aspx?id={0}",
                                                                          order.Bvin)),
                                                        order.OrderNumber);
                    result.MatchValues = "unpackaged items";
                    result.Items = string.Join(", ", remainingItems.ToArray());
                    results.Add(result);
                }
            }
            if (count > grid.PageSize*5) break;
        }
        results.Sort();
        return results;
    }
Exemplo n.º 15
0
        public void TestPacketSending()
        {
            var done = new ManualResetEvent(false);

            var packer = new Packager(new Type[] {
                typeof(CustomDataSending)
            });

            var arrPayload = new object[] {
                9,
                "SyncIOTest",
                "Example",
                666.333f
            };

            var cPayload = new CustomDataSending()
            {
                Num = 5555,
                str = "SyncIOTest",
                fl  = 6666.4444f
            };

            var server = new SyncIOServer(TransportProtocal.IPv4, packer);

            Guid cID = Guid.NewGuid();

            server.OnClientConnect += (s, c) => {
                Console.WriteLine("Connected.");
                cID             = c.ID;
                c.OnDisconnect += (rtcl, err) => {
                    throw new AssertFailedException(err.Message, err);
                };
            };

            server.SetHandler((SyncIOConnectedClient s, object[] dat) => {
                CollectionAssert.AreEqual(arrPayload, dat);
                s.Send(cPayload);
            });

            var listenSock = server.ListenTCP(9000);

            Assert.IsNotNull(listenSock);

            var client = new SyncIOClient(TransportProtocal.IPv4, packer);

            client.OnDisconnect += (sCl, err) => {
                throw new AssertFailedException(err.Message, err);
            };

            client.SetHandler <CustomDataSending>((s, d) => {
                Assert.AreEqual(cPayload.fl, d.fl);
                Assert.AreEqual(cPayload.Num, d.Num);
                Assert.AreEqual(cPayload.str, d.str);
                done.Set();
            });

            client.OnHandshake += (s, id, succ) => {
                Assert.IsTrue(succ);
                Thread.Sleep(100); //Wait for server callback to finish
                Assert.AreEqual(cID, id);
                s.Send(arrPayload);
            };

            Assert.IsTrue(client.Connect("127.0.0.1", 9000));


            Assert.IsTrue(done.WaitOne(10 * 1000));

            listenSock.Dispose();
        }
Exemplo n.º 16
0
    public void buildPatch()
    {
        //1. 创建当前版本目录
        string folderName = VersionEditorManager.Instance().curVersion.Replace(".", "_");

        folderName = targetPath + folderName;
        if (Directory.Exists(folderName))
        {
            return;
        }

        PatchInfo patchInfo = new PatchInfo(VersionEditorManager.Instance().curVersion);

        Directory.CreateDirectory(folderName);

        //2. 统计当前版本所有文件信息,保存至文本文件
        List <string> fileSystemEntries = new List <string>();

        fileSystemEntries.AddRange(Directory.GetFiles(sourcePath, "*", SearchOption.AllDirectories));

        FileStream   fs = new FileStream(folderName + "/files.txt", FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        for (int i = 0; i < fileSystemEntries.Count; i++)
        {
            string file = fileSystemEntries[i];
            file = file.Replace("\\", "/");

            if (file.EndsWith(".meta") || file.Contains(".DS_Store") || (file.Contains(".manifest") && !(file.Contains(BuildUtil.getPlatformManifest()))))
            {
                continue;
            }

            FileStream fileStream = new FileStream(file, FileMode.Open);

            int size = (int)fileStream.Length;

            string md5     = FileUtil.FSToMD5(fileStream);
            string value   = file.Replace(sourcePath, string.Empty).Substring(1);
            string content = value + "|" + md5 + "|" + size;
            patchInfo.addFileInfo(content);
            sw.WriteLine(content);
            fileStream.Close();
            Packager.UpdateProgress(i, fileSystemEntries.Count, "Generating file list..");
        }
        sw.Close(); fs.Close();

        //3.与历史版本对比压缩所有差异文件
        foreach (PatchInfo pInfo in patchList)
        {
            ArrayList diffFiles = pInfo.getDiffFiles(patchInfo);
            if (diffFiles.Count == 0)
            {
                continue;
            }

            FileStream      commonStream = new FileStream(pInfo.getPatchPath() + "/VersionContent.zip", FileMode.Create);
            ZipOutputStream commonZipper = new ZipOutputStream(commonStream);
            commonZipper.SetLevel(5);

            FileStream      iosStream = new FileStream(pInfo.getPatchPath() + "/iOS.zip", FileMode.Create);
            ZipOutputStream iosZipper = new ZipOutputStream(iosStream);
            iosZipper.SetLevel(5);

            ZipOutputStream androidZipper = new ZipOutputStream(new FileStream(pInfo.getPatchPath() + "/Android.zip", FileMode.Create));
            androidZipper.SetLevel(5);
            ZipOutputStream winZipper = new ZipOutputStream(new FileStream(pInfo.getPatchPath() + "/Windows.zip", FileMode.Create));
            winZipper.SetLevel(5);

            string versionNum = pInfo.ver.proCurVersion;
            for (int i = 0; i < diffFiles.Count; i++)
            {
                string          fileName   = diffFiles[i] as string;
                ZipOutputStream compressor = commonZipper;
                if (fileName.Contains("AssetBundles/iOS/") || fileName.Contains("Audio/GeneratedSoundBanks/iOS/"))
                {
                    compressor = iosZipper;
                }
                else if (fileName.Contains("AssetBundles/Windows/") || fileName.Contains("Audio/GeneratedSoundBanks/Windows/"))
                {
                    compressor = winZipper;
                }
                else if (fileName.Contains("AssetBundles/Android/") || fileName.Contains("Audio/GeneratedSoundBanks/Android/"))
                {
                    compressor = androidZipper;
                }
                compressor.PutNextEntry(new ZipEntry(fileName));
                string fullPath = sourcePath + "/" + fileName;
                Packager.UpdateProgress(i, diffFiles.Count, " Compress version: " + versionNum + " on file: " + fileName);
                byte[] data = new byte[2048];
                using (FileStream input = File.OpenRead(fullPath))
                {
                    int bytesRead;
                    while ((bytesRead = input.Read(data, 0, data.Length)) > 0)
                    {
                        compressor.Write(data, 0, bytesRead);
                    }
                }
            }
            commonZipper.Finish();
            iosZipper.Finish();
            androidZipper.Finish();
            winZipper.Finish();
        }

        //4. 记录当前版本号
        VersionEditorManager.Instance().saveVersion(targetPath + "version.txt");


        fs = new FileStream(folderName + "/mark.txt", FileMode.CreateNew);
        fs.Close();
        EditorUtility.ClearProgressBar();
    }
Exemplo n.º 17
0
 public RemoteCallServerManager(Packager _packer)
 {
     BindableTypes = _packer.GetTypeDictionary();
 }
Exemplo n.º 18
0
 private static ExcludedFiles ExcludeFileExist(string file, ref Packager.Database.PackagerDatabase database)
 {
     var result = from sp in database.ExcludedFiles
                           where sp.Filename == file
                           select sp;
     if (result.Count () <= 0) {
         return null;
     } else {
         return result.First ();
     }
 }
Exemplo n.º 19
0
        private void createPackageBtn_Click(object sender, EventArgs e)
        {
            createPackageBtn.Enabled = false;
            _displayTimer            = null;

            try
            {
                var options = new PackageCreationOptions();
                switch (packageVersion.SelectedIndex)
                {
                case 0:
                case 1:
                {
                    options.Version = PackageVersion.V13;
                    break;
                }

                case 2:
                {
                    options.Version = PackageVersion.V10;
                    break;
                }

                case 3:
                {
                    options.Version = PackageVersion.V9;
                    break;
                }

                case 4:
                {
                    options.Version = PackageVersion.V7;
                    break;
                }
                }

                switch (compressionMethod.SelectedIndex)
                {
                case 1:
                {
                    options.Compression = CompressionMethod.Zlib;
                    break;
                }

                case 2:
                {
                    options.Compression     = CompressionMethod.Zlib;
                    options.FastCompression = false;
                    break;
                }

                case 3:
                {
                    options.Compression = CompressionMethod.LZ4;
                    break;
                }

                case 4:
                {
                    options.Compression     = CompressionMethod.LZ4;
                    options.FastCompression = false;
                    break;
                }
                }

                // Fallback to Zlib, if the package version doesn't support LZ4
                if (options.Compression == CompressionMethod.LZ4 && options.Version <= PackageVersion.V9)
                {
                    options.Compression = CompressionMethod.Zlib;
                }

                if (solid.Checked)
                {
                    options.Flags |= PackageFlags.Solid;
                }

                if (allowMemoryMapping.Checked)
                {
                    options.Flags |= PackageFlags.AllowMemoryMapping;
                }

                if (preloadIntoCache.Checked)
                {
                    options.Flags |= PackageFlags.Preload;
                }

                options.Priority = (byte)packagePriority.Value;

                var packager = new Packager();
                packager.ProgressUpdate += PackageProgressUpdate;
                packager.CreatePackage(createPackagePath.Text, createSrcPath.Text, options);

                MessageBox.Show("Package created successfully.");
            }
            catch (Exception exc)
            {
                MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                packageProgressLabel.Text = "";
                packageProgress.Value     = 0;
                createPackageBtn.Enabled  = true;
            }
        }
Exemplo n.º 20
0
 private static IEnumerable<CommandRun> GetCommandRunById(int commandrunId, ref Packager.Database.PackagerDatabase database)
 {
     var result = from sp in database.ReleaseDirectories
                           where sp.CommandRunId == commandrunId
                           select sp;
     if (result.Count () <= 0) {
         return null;
     }
     var result2 = from sp in database.CommandsRun
                            where sp.Id == result.First ().CommandRunId
                            select sp;
     if (result2.Count () <= 0) {
         return null;
     }
     return result2;
 }
Exemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        RankData = new int[5];
        RankName = new string[5];

        aList = new ArrayList();
        bList = new ArrayList();
          //  wiipay.init();    MM支付初始化
        Moudle_main.EvtGameStart += Handle_GameStart;
           // GameServer.SocketConnect();
        go_Experience = Instantiate(Prefab_Experience) as GameObject;
        go_Experience.SetActive(false);

        go_text = Instantiate(Prefab_Text) as GameObject;
        go_text.SetActive(false);

        go_TimeTen = Instantiate(Prefab_TimeTen) as GameObject;
        go_TimeTen.SetActive(false);

        go_TimeGe = Instantiate(Prefab_TimeGe) as GameObject;
        go_TimeGe.SetActive(false);

        go_ServerHour = Instantiate(Prefab_ServerHour) as GameObject;
        go_ServerHour.SetActive(false);

        go_ServerMin = Instantiate(Prefab_ServerMin) as GameObject;
        go_ServerMin.SetActive(false);

        go_Lingqu = Instantiate(Prefab_Lingqu) as GameObject;
        go_Lingqu.SetActive(false);

        GameMain.EvtFishKilled += Handle_FishKill;
           // MobileInterface.EvtBulletHitFish += Hit;
        MobileInterface.EvtHitFishResult += Hit_Result;

        go_Score = Instantiate(Prefab_Score) as GameObject;
        go_Score.SetActive(false);
          //  Moudle_main.EvtLevelUP += Handle_LevelUP;
        mC = new WazClient();
        mP = new Packager(mC);

        mP.EvtRecevicePack += Handle_ReceivePack;
        mC.EvtSessionAccept += SendData;

        //session = mC.Connect(IP_ADDRESS, 9873);
        //StartCoroutine(ConnectToInternet());  //更新分数跟别的数据
    }
Exemplo n.º 22
0
 /// <summary>
 /// Adds the command run.
 /// </summary>
 /// <param name="releasedirectory">Releasedirectory.</param>
 /// <param name="database">Database.</param>
 /// <param name="commandparams">Commandparams.</param>
 public static void AddCommandRun(RelaseDirectoy releasedirectory, ref Packager.Database.PackagerDatabase database, params CommandRun[] commandparams)
 {
     foreach (var item in commandparams) {
         database.CommandsRun.Add (new CommandRun (item.Command, item.ExecuteEvent, releasedirectory.CommandRunId));
     }
 }
Exemplo n.º 23
0
        public void PackagerCalculatesModuleId()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\App\App.js", new MockFileData("export default ()=>'Hello';") },
                { @"c:\App\Module1\index.js", new MockFileData("export default ()=>'Hello';") },
                { @"c:\App\Module1\dir\index.js", new MockFileData("export default ()=>'Hello';") },
                { @"c:\App\Module1\dir\module.js", new MockFileData("export default ()=>'Hello';") }
            });

            var packager = new Packager(
                fileSystem: fileSystem,
                transformers: new IModuleTransformer[]
            {
                new BabelModuleTransformer(fileSystem)
            });
            Package package = packager.Package(new SourceConfig
            {
                RootPath    = @"c:\App",
                EntryPoints = new[] { "./App" },
                Globals     = new GlobalsConfig
                {
                    ["react"]     = "React",
                    ["react-dom"] = "ReactDOM"
                },
            });

            Assert.AreEqual(3, package.Modules.Count);
            Assert.AreEqual("react", package.Modules[0].ModuleId);
            Assert.AreEqual("react-dom", package.Modules[1].ModuleId);
            Assert.AreEqual("App", package.Modules[2].ModuleId);

            package = packager.Package(new SourceConfig
            {
                RootPath    = @"c:\App",
                EntryPoints = new[] { "./Module1" },
                Globals     = new GlobalsConfig
                {
                    ["react"]     = "React",
                    ["react-dom"] = "ReactDOM"
                }
            });
            Assert.AreEqual(3, package.Modules.Count);
            Assert.AreEqual("react", package.Modules[0].ModuleId);
            Assert.AreEqual("react-dom", package.Modules[1].ModuleId);
            Assert.AreEqual("Module1/", package.Modules[2].ModuleId);

            package = packager.Package(new SourceConfig
            {
                RootPath    = @"c:\App",
                EntryPoints = new[] { "./Module1/dir" },
                Globals     = new GlobalsConfig
                {
                    ["react"]     = "React",
                    ["react-dom"] = "ReactDOM"
                }
            });
            Assert.AreEqual(3, package.Modules.Count);
            Assert.AreEqual("react", package.Modules[0].ModuleId);
            Assert.AreEqual("react-dom", package.Modules[1].ModuleId);
            Assert.AreEqual("Module1/dir/", package.Modules[2].ModuleId);

            package = packager.Package(new SourceConfig
            {
                RootPath    = @"c:\App",
                EntryPoints = new[] { "./Module1/dir/module" },
                Globals     = new GlobalsConfig
                {
                    ["react"]     = "React",
                    ["react-dom"] = "ReactDOM"
                }
            });
            Assert.AreEqual(3, package.Modules.Count);
            Assert.AreEqual("react", package.Modules[0].ModuleId);
            Assert.AreEqual("react-dom", package.Modules[1].ModuleId);
            Assert.AreEqual("Module1/dir/module", package.Modules[2].ModuleId);
        }
Exemplo n.º 24
0
 private static void ReleaseDirectoryRemove(string fullName, ref Packager.Database.PackagerDatabase database)
 {
     var result = from sp in database.ReleaseDirectories
                           where sp.ReleaseDirectoryLocation == fullName
                           select sp;
     if (result != null) {
         database.ReleaseDirectories.Remove (result.First ());
     }
 }
Exemplo n.º 25
0
 public GameClient(Packager packager, Serializer serializable)
 {
     _packager     = packager;
     _serializable = serializable;
 }
Exemplo n.º 26
0
        /// <summary>
        /// Argumnentses the ahead.
        /// </summary>
        /// <param name="args">Arguments.</param>
        /// <param name="database">Database.</param>
        public static void ArgumnentsAhead(string[] args,ref Packager.Database.PackagerDatabase database, ref PackagerWorker worker)
        {
            Console.WriteLine (database.DatabasePath);
            // LogAttrbute.log.Info("There are top level argument has been caught to read it");
            switch (args [0].ToLower ()) {
            case "-h":
                    // LogAttrbute.log.Info("top level argument for help, showing help");
                HelpCommand.ShowHelp ();
                break;

            case "-v":
                    // LogAttrbute.log.Info("Top level argument for getting version, getting version");

                break;

            case "-l":
                    // LogAttrbute.log.Info("Top level argument for getting license of the project");
                if (args.Length < 2) {
                    // LogAttrbute.log.Info("License getting from LICENSE file");
                    FileInfo lic = new FileInfo ("LICENSE");
                    // LogAttrbute.log.Info("Checking if the license file is available or not");
                    if (!lic.Exists) {
                        // LogAttrbute.log.Info("License file not found, showing warning message");
                        Console.WriteLine ("Warning :License not found, you can view it at http://www.gnu.org/licenses/gpl-3.0.en.html");
                        // LogAttrbute.log.Info("Exit application with file not found existing for LICENSE file");
                        return;
                    }
                    // LogAttrbute.log.Info("File founded and now using read only stream file");
                    StreamReader strmreader = new StreamReader (lic.OpenRead ());
                    // LogAttrbute.log.Info("Writing a little bit big output for LICENSE file");
                    Console.WriteLine (strmreader.ReadToEnd ());
                    // LogAttrbute.log.Info("Writing output completed");
                    // LogAttrbute.log.Info("Exit application");

                    return;
                }

                    // LogAttrbute.log.Info("Second level argument for checking argument");
                switch (args [1].ToLower ()) {
                        case "--g":
                            // LogAttrbute.log.Info("Argument is getting gui window for showing license");

                            var s = new Packager.UI.License();
                            // LogAttrbute.log.Info("Showing license window..");
                            s.ShowDialog();
                            // LogAttrbute.log.Info("The user closed the window");
                            break;
                default:
                            // LogAttrbute.log.Info("The input arg is invalid , showing Error message");
                    Console.Error.WriteLine ("Argument unknown, please type -h for argument list");
                    break;
                }
                break;
            #if WIN
                case "-c":
                    // LogAttrbute.log.Info("Top level arg for checking for update on the GitHub repo");
                    // LogAttrbute.log.Info("Calling managed code...");
                    if (!CheckNet())
                    {
                        // LogAttrbute.log.Info("No connection to the Internet, or Internet is unavailable, because CheckNet() call  InternetGetConnectedState(out desc, 0); for if there is Internet and returned that there are no Internet access");
                        Console.Error.WriteLine("Please check your Internet connection in order to check the update. Or Go to https://github.com/AlkindiX/packager/releases");

                        return;
                    }
                    // LogAttrbute.log.Info("There are an Internet connection, processing to the update checker...");
                    // LogAttrbute.log.Info("Preparing GitHubClient from OctaKit using GitHub API");
                    GitHubClient clinet = new GitHubClient(new ProductHeaderValue("packager"));
                    // LogAttrbute.log.Info("Preparing to invoke for all releases from GitHub release from project packager repo by the creator of the progrma AlkindiX ");
                    var release = clinet.Release.GetAll("AlkindiX", "packager");
                    Release re = null;
                    // LogAttrbute.log.Info("The release checking is invoked, now waiting for result form GitHub...");
                    Console.WriteLine("Checking for update...");
                    release.Wait();
                    // LogAttrbute.log.Info("Result getting successfully");
                    foreach (var item in release.Result)
                    {
                        // LogAttrbute.log.Info("Getting the latest release at the top of the list and break the loop");
                        re = item;
                        break;
                    }
                    Console.WriteLine("The current release of packager is {0} released at {1}, you can download it at \n{2}", re.TagName, re.PublishedAt.ToString(), re.HtmlUrl);
                    Console.WriteLine("Change log:- \n{0}", re.Body);
                    // LogAttrbute.log.Info("Invoking GetAllRelease for getting files inside the release");
                    var ass = clinet.Release.GetAllAssets("AlkindiX", "packager", re.Id);
                    Console.WriteLine("Reading files on the current update...");
                    ass.Wait();
                    // LogAttrbute.log.Info("Checking if dir updates is exist");
                    DirectoryInfo updatedir = new DirectoryInfo("updates");
                    if (!updatedir.Exists)
                    {
                        // LogAttrbute.log.Info("Creating update dir");
                        updatedir.Create();
                    }
                    // LogAttrbute.log.Info("Create version file");
                    DirectoryInfo tagdir = new DirectoryInfo(Path.Combine(updatedir.FullName, re.TagName));
                    if (!tagdir.Exists)
                    {
                        tagdir.Create();
                    }
                    // LogAttrbute.log.Info("Begin perform download operation");
                    int x = 0;
                    foreach (var item in ass.Result)
                    {
                        x++;
                        Console.WriteLine("{0} {1}", x.ToString(), item.Name);
                        Console.WriteLine("Downloading {0}", item.Name);
                        WebClient clin = new WebClient();
                        var file_full_path = Path.Combine(tagdir.FullName, item.Name);
                        if (File.Exists(file_full_path))
                        {
                            Console.WriteLine("Warning: The release is already exist {0}", file_full_path);
                            File.Delete(file_full_path);
                        }
                        clin.DownloadFile(item.BrowserDownloadUrl, file_full_path);
                        Console.WriteLine("Downloading complete at {0}", file_full_path);
                    }
                    // LogAttrbute.log.Info("End download operation");

                    break;
            #endif
            case "-s":
                if (args.Length < 2) {
                    Console.Error.WriteLine ("Arguments are missing, type -h for argument list");

                    return;
                }
                switch (args [1].ToLower ()) {
                case "--c":
                    if (args.Length < 2) {
                        Console.Error.WriteLine ("Missing argument for command line configuration. Type -h for information");
                        return;
                    }
                    switch (args [2].ToLower ()) {
                    case "---add":
                        if (args.Length < 6) {
                            Console.WriteLine ("arguments are missing. please type -h for information");
                            return;
                        }
                        var releasedir = args [3];
                        var commandrun = args [4];
                        var commandevent = args [5];
                        var releasedirfromdatabase = ReleaseDirectoryExist (releasedir, ref database);
                        if (releasedirfromdatabase == null) {
                            Console.Error.WriteLine ("The release directory you have entered it is not exist in the application database");
                            return;
                        }
                        commandrun = commandrun.Replace ("\\n", "\n");
                        var commandeventargumented = Database.ExecuteEvent.BeforePackaging;
                        switch (commandevent.ToLower ()) {
                        case "before":
                            commandeventargumented = Database.ExecuteEvent.BeforePackaging;
                            break;

                        case "after":
                            commandeventargumented = Database.ExecuteEvent.AfterPackaging;
                            break;

                        case "pre":
                            commandeventargumented = Database.ExecuteEvent.PrePackaging;
                            break;

                        default:
                            Console.Error.WriteLine ("the command line event argument is unknown. Please put on of [before|after|pre]");
                            return;
                        }
                        CommandRun cmd = new CommandRun (commandrun, commandeventargumented, releasedirfromdatabase.CommandRunId);
                        AddCommandRun (releasedirfromdatabase,ref database, cmd);
                        Console.WriteLine ("Command line successful added to the database as :{0}, with unique id: ", commandeventargumented.ToString (), releasedirfromdatabase.CommandRunId);
                        break;

                    case "---remove":
                        break;

                    case "---show":
                        Console.WriteLine ("[{0}\t][{1}\t][{2}\t]- \"{3}\"", "Id", "release dir Id", "When", "Command line");

                        foreach (var item in database.CommandsRun) {
                            var crp = "[{0}\t][{1}\t][{2}\t]- \"{3}\"";
                            Console.WriteLine (crp, item.Id, item.uniqueId, item.ExecuteEvent, item.Command);
                        }
                        break;

                    case "---clear":
                        break;

                    default:
                        Console.WriteLine ("unknown argument, please enter -h for argument list");
                        break;
                    }
                    break;

            #if WIN
                        case "--log":
                            // LogAttrbute.log.Info("Second level for setting the logging value");
                            if (args.Length < 3)
                            {
                                // LogAttrbute.log.LogFast(Common.Logging.Logging.LogFastInfo.Error, "Missing argument for logging value");
                                Console.Error.WriteLine("Missing argument for enable logging");
                                return;
                            }
                            try
                            {
                                switch (bool.Parse(args[2].ToLower()))
                                {
                                    case true:
                                        // LogAttrbute.log.Info("Logging is enabled");
                                        Settings.Default.EnableLog = true;
                                        Console.WriteLine("Logging is enabled");
                                        break;

                                    case false:
                                        // LogAttrbute.log.Info("Logging is disabled");
                                        Settings.Default.EnableLog = false;
                                        Console.WriteLine("Logging is disabled");
                                        break;
                                }
                            }
                            catch (FormatException)
                            {
                                // LogAttrbute.log.LogFast(Common.Logging.Logging.LogFastInfo.Exception, fx.ToString());
                                Console.Error.WriteLine("The format given is invalid");
                            }
                            break;
            #endif
                case "--clear":
                    Console.WriteLine ("Reseting data...");
            #if WIN
                            Settings.Default.Reset();
            #endif
                    database.ReleaseDirectories.Clear ();
                    database.ExcludedFiles.Clear ();
                    database.SaveChanges ();
                    Console.WriteLine ("All data cleared");
                    return;

                        case "--g":
                            System.Windows.Forms.Application.EnableVisualStyles();
                            FormConfiguration config = new FormConfiguration(ref database);
                            config.ShowDialog();
                            break;
                case "--r":
                    if (args.Length < 3) {
                        Console.WriteLine ("Missing arguments, please type -h for more information");

                        return;
                    }
                    switch (args [2].ToLower ()) {
                    case "---add":
                        if (args.Length < 5) {
                            Console.Error.WriteLine ("Missing argument, please enter the directory name and release.zip name to be added");
                            return;
                        }
                                    // TODO : Make this function easier to use by allowing addaing more than one directory in one command line only This make this program much useful for this situatons
                        try {
                            var dir = args [3];
                            var zipname = args [4];
                            Console.WriteLine (zipname);
                            DirectoryInfo info;
                            if (Path.IsPathRooted (dir)) {
                                info = new DirectoryInfo (dir);
                            } else {
                                info = new DirectoryInfo (Path.Combine (Environment.CurrentDirectory, dir));
                            }
                            if (!info.Exists) {
                                Console.Error.WriteLine ("The directory is not exist");

                                return;
                            }
                            if (ReleaseDirectoryExist (info.FullName, ref database) != null) {
                                Console.Error.WriteLine ("The directory is already added to the release location list");
                                return;
                            }
                            if (Path.GetExtension (zipname).Contains ("zip") == false) {
                                zipname = Path.ChangeExtension (zipname, "zip");
                            }
                            var res = from sp in database.ReleaseDirectories
                                                  orderby sp.CommandRunId descending
                                                                       select sp;
                            var uniqid = 1;
                            if (res.Count () <= 0) {
                                uniqid = 1;
                            } else {
                                uniqid = res.First ().CommandRunId + 1;
                            }
                            database.ReleaseDirectories.Add (new RelaseDirectoy (info.FullName, uniqid, zipname));

                            Console.WriteLine ("The directory name \"{0}\" has been added to the release location list as command line id unique: {1} and zip name \"{2}\"", info.FullName, uniqid, zipname);
                        } catch (Exception ex) {
                            Console.Error.WriteLine (ex.ToString ());
                        }

                        break;

                    case "---remove":
                        if (args.Length < 4) {
                            Console.Error.WriteLine ("Missing argument, please enter the directory name or directorty Id");
                            return;
                        }
                        int releaseId;
                        if (int.TryParse ((string)args [3], out releaseId)) {
                            var release_data = ReleaseDirectoryExist (releaseId, ref database);
                            if (release_data == null) {
                                Console.Error.WriteLine ("The directory Id you have entered is not on the release directory database");
                                return;
                            }
                            ReleaseDirectoryRemove (releaseId, ref database);
                            Console.WriteLine ("The directory name \"" + release_data.ReleaseDirectoryLocation + "\" has been removed from the release location list");
                        } else {
                            try {
                                DirectoryInfo info = new DirectoryInfo (args [3]);
                                if (ReleaseDirectoryExist (info.FullName, ref database) == null) {
                                    Console.Error.WriteLine ("The directory you have entered is not on the release directory database");
                                    return;
                                }
                                ReleaseDirectoryRemove (info.FullName, ref database);
                                Console.WriteLine ("The directory name \"" + info.FullName + "\" has been removed from the release location list");
                            } catch (Exception ex) {
                                Console.Error.WriteLine (ex.Message);
                            }
                        }
                        break;

                    case "---show":
                        var rs = "[{0}\t][{1}\t] - \"{2}\"";
                        foreach (var item in database.ReleaseDirectories) {
                            Console.WriteLine (string.Format (rs, item.Id, item.ReleaseDirectoryLocation, item.ReleaseName));
                        }
                        break;

                    case "---clear":
                        database.ReleaseDirectories.Clear ();
                        Console.WriteLine ("Release directories are cleared");
                        break;

                    default:
                        Console.WriteLine ("argument is understandable, please enter -h for argument list");
                        break;
                    }
                    break;

                case "--e":
                    if (args.Length < 3) {
                        Console.WriteLine ("Missing arguments, type -h for argument list");

                        return;
                    }
                    switch (args [2].ToLower ()) {
                    case "---add":
                        if (args.Length < 4) {
                            Console.WriteLine ("You didn't write the file to be exclude");
                        } else {
                            if (ExcludeFileExist (args [3], ref database) == null) {
                                database.ExcludedFiles.Add (new ExcludedFiles (args [3]));
                                Console.WriteLine ("The filename: \"" + args [3] + "\" Added to the exclude list");
                            }
                            if (ExcludeFileExist (args [3], ref database) == null) {
                                Console.WriteLine ("The filename: \"" + args [3] + "\" is already included in the exclude list");
                            }
                        }
                        break;

                    case "---remove":
                        if (args.Length < 4) {
                            Console.WriteLine ("You didn't write the file to be include");
                        } else {
                            if (ExcludeFileExist (args [3], ref database) == null) {
                                Console.Error.WriteLine ("File is not found in the list");
                            } else {
                                ExcludeFileRemove (args [3], ref database);
                                Console.WriteLine ("The filename: \"" + args [3] + "\" removed from the exclude list");
                            }
                        }
                        break;

                    case "---show":
                        if (database.ExcludedFiles.Count == 0) {
                            Console.WriteLine ("The list is empty");
                        }
                        foreach (var item in database.ExcludedFiles) {
                            Console.WriteLine ("[{0}\t] - \"{1}\"", item.Id, item.Filename);
                        }
                        break;

                    case "---clear":

                        if (database.ExcludedFiles.Count == 0) {
                            Console.WriteLine ("The list is empty and nothing to be cleared");
                        }
                        database.ExcludedFiles.Clear ();
                        Console.WriteLine ("Excluded Files are cleared");
                        break;

                    default:
                        Console.Error.WriteLine ("Unknown arguments, -h for argument list");
                        break;
                    }
                    break;

                default:
                    Console.WriteLine ("Unknown argument, type -h for argument list");
                    break;
                }
                break;

            default:
                Console.Error.WriteLine ("Argument is invalid, type -h for more informations");
                break;
            }
            database.SaveChanges ();
            worker.CreateDatabaseBackup();
        }
Exemplo n.º 27
0
 public static void PackAllType()
 {
     Packager.BuildWindowsResource();
 }