public QueueCommand(PackageClass packageClass, CommandEnum oper)
 {
     Date          = DateTime.Now;
     CommandEnum   = oper;
     TargetId      = packageClass.GeneralInfo.Id;
     TargetVersion = packageClass.GeneralInfo.Version;
 }
 public void OnShowScreenShot(ExtensionControlExpanded control, PackageClass pak)
 {
     if (ShowScreenShot != null)
     {
         ShowScreenShot(control, pak);
     }
 }
 public void OnInstallExtension(ExtensionControlExpanded control, PackageClass pak)
 {
     if (InstallExtension != null)
     {
         InstallExtension(control, pak);
     }
 }
Esempio n. 4
0
    public PackageClass GetPackage(int id)
    {
        ConnectToDB("SimpleGame.db");

        PackageClass newPackage = new PackageClass();

        newPackage.id = id;

        dataReader =
            ExecuteQuery("SELECT Slot1, Slot2, Slot3, Slot4, Slot5, Slot6, Slot7, Slot8, Slot9, Slot10, " +
                         "Slot11, Slot12, Slot13, Slot14, Slot15, Slot16, Slot17, Slot18, Slot19, Slot20, " +
                         "Slot21, Slot22, Slot23, Slot24, Slot25, Slot26, Slot27, Slot28, Slot29, Slot30, " +
                         "Weapon, Armor, Halmet, Boot, Ring, Amulet FROM Package WHERE ID = " + id + ";");
        while (dataReader.HasRows)
        {
            if (dataReader.Read())
            {
                for (int i = 0; i < 30; i++)
                {
                    newPackage.slots.Add(dataReader.GetInt32(i));
                }
                newPackage.weapon = dataReader.GetInt32(30);
                newPackage.armor  = dataReader.GetInt32(31);
                newPackage.halmet = dataReader.GetInt32(32);
                newPackage.boot   = dataReader.GetInt32(33);
                newPackage.ring   = dataReader.GetInt32(34);
                newPackage.amulet = dataReader.GetInt32(35);
            }
        }

        CloseConnection();

        return(newPackage);
    }
Esempio n. 5
0
 public void Execute(PackageClass packageClass, bool silent)
 {
     if (!silent)
     {
         if (
             MessageBox.Show("Do you want to Uninstall extension " + packageClass.GeneralInfo.Name, "Uninstall extension",
                             MessageBoxButtons.YesNo) != DialogResult.Yes)
         {
             return;
         }
     }
     packageClass.UnInstallInfo = new UnInstallInfoCollection(packageClass);
     packageClass.UnInstallInfo = packageClass.UnInstallInfo.Load();
     packageClass.Silent        = silent;
     if (packageClass.UnInstallInfo == null)
     {
         if (!silent)
         {
             if (
                 MessageBox.Show("No uninstall information found. Do you want to remowe from list ? ", "Uninstall extension",
                                 MessageBoxButtons.YesNo) != DialogResult.Yes)
             {
                 return;
             }
         }
         packageClass.UnInstallInfo = new UnInstallInfoCollection(packageClass);
     }
     packageClass.FileUnInstalled += packageClass_FileUnInstalled;
     progressBar1.Maximum          = packageClass.UnInstallInfo.Items.Count + 1;
     Package = packageClass;
     ShowDialog();
 }
Esempio n. 6
0
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
   if (ItemProcessed != null)
     ItemProcessed(this, new InstallEventArgs("Message box"));
   MessageBox.Show(actionItem.Params[Const_MESSAGE].Value);
   return SectionResponseEnum.Ok;
 }
Esempio n. 7
0
        private void PopulateInstallBtn()
        {
            ExtensionCollection collection = MpeCore.MpeInstaller.KnownExtensions.GetList(Package.GeneralInfo.Id);

            collection.Add(Package);
            foreach (PackageClass item in collection.GetList(Package.GeneralInfo.Id).Items)
            {
                ToolStripMenuItem testToolStripMenuItem = new ToolStripMenuItem();
                testToolStripMenuItem.Text = string.Format("Version - {0} [{1}]", item.GeneralInfo.Version,
                                                           item.GeneralInfo.DevelopmentStatus);
                PackageClass pak = MpeCore.MpeInstaller.InstalledExtensions.Get(Package.GeneralInfo.Id);
                if (pak != null && item.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) == 0)
                {
                    testToolStripMenuItem.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold,
                                                          GraphicsUnit.Point, ((byte)(0)));
                }
                if (!item.CheckDependency(true))
                {
                    testToolStripMenuItem.ForeColor = Color.Red;
                }
                if (item.GeneralInfo.VersionDescription != null)
                {
                    testToolStripMenuItem.ToolTipText = item.GeneralInfo.VersionDescription.Length > 1024
                                                ? item.GeneralInfo.VersionDescription.Substring(0, 1024) + "..."
                                                : item.GeneralInfo.VersionDescription;
                }
                testToolStripMenuItem.Tag    = item;
                testToolStripMenuItem.Click += testToolStripMenuItem_Click;
                btn_install.DropDownItems.Add(testToolStripMenuItem);
            }
        }
        public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
        {
            Process myProcess = new Process();

            try
            {
                myProcess.StartInfo.UseShellExecute = false;

                myProcess.StartInfo.FileName  = MpeInstaller.TransformInRealPath(item.ActionParam[Const_Un_APP].Value);
                myProcess.StartInfo.Arguments = MpeInstaller.TransformInRealPath(item.ActionParam[Const_Un_Params].Value);
                if (packageClass.Silent)
                {
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.StartInfo.WindowStyle    = ProcessWindowStyle.Minimized;
                }
                myProcess.Start();
                if (item.ActionParam[Const_Un_Wait].GetValueAsBool())
                {
                    myProcess.WaitForExit();
                }
            }
            catch (Exception)
            {
                if (ItemProcessed != null)
                {
                    ItemProcessed(this, new InstallEventArgs("Error to start application"));
                }
                return(SectionResponseEnum.Ok);
            }
            if (ItemProcessed != null)
            {
                ItemProcessed(this, new InstallEventArgs("Application start done"));
            }
            return(SectionResponseEnum.Ok);
        }
 public void parseJSONPurchasePackage(String jsonPackage)
 {
     try
     {
         var packageJSONObj = JsonConvert.DeserializeObject <PackageClass>(jsonPackage);
         if (packageJSONObj.success == true)
         {
             packageClass         = new PackageClass();
             this.success         = true;
             packageClass.success = packageJSONObj.success;
             packageClass.content = packageJSONObj.content;
             packageClass.reason  = packageJSONObj.reason;
             packageClass.type    = packageJSONObj.type;
         }
         else
         {
             MessageBox.Show(packageJSONObj.type + "----" + packageJSONObj.reason);
         }
         disabelProgressBar();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
        public void Initialize(bool isInstalled, bool meetsAllDependencies, PackageClass package, PackageClass updatePackage)
        {
            Package       = package;
            UpdatePackage = updatePackage;

            lbl_name.Text    = package.GeneralInfo.Name;
            lblAuthors.Text  = string.Format("[{0}]", package.GeneralInfo.Author);
            lbl_version.Text = package.GeneralInfo.Version.ToString();
            img_dep.Visible  = meetsAllDependencies;
            if (meetsAllDependencies)
            {
                (Parent.Parent.Parent as ExtensionListControl).toolTip1.SetToolTip(img_dep,
                                                                                   "Some dependencies are not met.\r\nThe extension may not work properly.\r\nClick here for more information.");
            }
            lbl_description.Text   = package.GeneralInfo.ExtensionDescription;
            btn_screenshot.Visible = !string.IsNullOrEmpty(package.GeneralInfo.Params[ParamNamesConst.ONLINE_SCREENSHOT].Value);
            btn_conf.Visible       = isInstalled && !string.IsNullOrEmpty(Package.GeneralInfo.Params[ParamNamesConst.CONFIG].GetValueAsPath());
            btn_uninstall.Visible  = isInstalled;
            if (string.IsNullOrEmpty(Package.GeneralInfo.HomePage))
            {
                btn_home.Visible = false;
            }
            else
            {
                btn_home.Visible = true;
                (Parent.Parent.Parent as ExtensionListControl).toolTip1.SetToolTip(btn_home, "Extension web page");
            }
            if (string.IsNullOrEmpty(Package.GeneralInfo.ForumPage))
            {
                btn_forum.Visible = false;
            }
            else
            {
                btn_forum.Visible = true;
                (Parent.Parent.Parent as ExtensionListControl).toolTip1.SetToolTip(btn_forum, "Extension forum page");
            }
            PopulateInstallBtn();

            if (isInstalled && updatePackage != null)
            {
                btn_update.Visible = true;
                img_update.Visible = true;
                (Parent.Parent.Parent as ExtensionListControl).toolTip1.SetToolTip(img_update,
                                                                                   string.Format("New update available. Version: {0}", updatePackage.GeneralInfo.Version.ToString()));
            }
            else
            {
                btn_update.Visible = false;
                img_update.Visible = false;
            }

            if (Package.Parent != null)
            {
                chk_ignore.Checked = Package.Parent.IgnoredUpdates.Contains(Package.GeneralInfo.Id);
            }

            GetThumbnail();

            IsInitialized = true;
        }
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
     Section       = sectionItem;
     _packageClass = packageClass;
     SetValues(sectionItem);
     ShowDialog();
 }
Esempio n. 12
0
    public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
    {
      if (ItemProcessed != null)
        ItemProcessed(this, new InstallEventArgs("Create ShortCut"));

      try
      {
        UnInstallItem unInstallItem =
          packageClass.UnInstallInfo.BackUpFile(actionItem.Params[Const_Loc].GetValueAsPath(), "CopyFile");

        WshShellClass wshShell = new WshShellClass();
        // Create the shortcut

        IWshShortcut myShortcut = (IWshShortcut)wshShell.CreateShortcut(actionItem.Params[Const_Loc].GetValueAsPath());
        myShortcut.TargetPath = Path.GetFullPath(actionItem.Params[Const_Target].GetValueAsPath());
        myShortcut.WorkingDirectory = Path.GetDirectoryName(myShortcut.TargetPath);
        myShortcut.Description = actionItem.Params[Const_Description].Value;

        if (!string.IsNullOrEmpty(actionItem.Params[Const_Icon].Value))
          myShortcut.IconLocation = actionItem.Params[Const_Icon].GetValueAsPath();
        else
          myShortcut.IconLocation = actionItem.Params[Const_Target].GetValueAsPath();

        myShortcut.Save();

        FileInfo info = new FileInfo(actionItem.Params[Const_Loc].GetValueAsPath());
        unInstallItem.FileDate = info.CreationTimeUtc;
        unInstallItem.FileSize = info.Length;
        packageClass.UnInstallInfo.Items.Add(unInstallItem);
      }
      catch (Exception) {}

      return SectionResponseEnum.Ok;
    }
Esempio n. 13
0
        private void DoUpdateAll()
        {
            this.Hide();
            var updatelist = new Dictionary <PackageClass, PackageClass>();

            foreach (PackageClass packageClass in MpeCore.MpeInstaller.InstalledExtensions.Items)
            {
                PackageClass update = MpeCore.MpeInstaller.KnownExtensions.GetUpdate(packageClass);
                if (update == null)
                {
                    continue;
                }
                updatelist.Add(packageClass, update);
            }
            foreach (KeyValuePair <PackageClass, PackageClass> valuePair in updatelist)
            {
                if (valuePair.Value == null)
                {
                    continue;
                }
                DoUpdate(valuePair.Key, valuePair.Value, true);
            }
            RefreshLists();
            this.Show();
        }
Esempio n. 14
0
        private void extensionListControl_UnInstallExtension(object sender, PackageClass packageClass)
        {
            UnInstall dlg = new UnInstall();

            dlg.Execute(packageClass, false);
            RefreshLists();
        }
Esempio n. 15
0
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
   packageClass.FileInstalled += packageClass_FileInstalled;
   packageClass.Install();
   packageClass.FileInstalled -= packageClass_FileInstalled;
   return SectionResponseEnum.Ok;
 }
 public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
 {
     if (!item.ActionParam[Const_Remove].GetValueAsBool())
     {
         return(SectionResponseEnum.Ok);
     }
     if (!string.IsNullOrEmpty(item.ActionParam[Const_Question].Value))
     {
         if (!packageClass.Silent &&
             MessageBox.Show(item.ActionParam[Const_Question].Value, "Question ", MessageBoxButtons.YesNo) ==
             DialogResult.Yes)
         {
             try
             {
                 Directory.Delete(item.ActionParam[Const_Loc].Value, true);
             }
             catch (Exception) {}
         }
     }
     else
     {
         try
         {
             Directory.Delete(item.ActionParam[Const_Loc].Value, true);
         }
         catch (Exception) {}
     }
     return(SectionResponseEnum.Ok);
 }
        public bool Save(PackageClass pak, string filename)
        {
            pak.GeneralInfo.OnlineLocation = pak.ReplaceInfo(pak.GeneralInfo.OnlineLocation);

            string temfile = Path.GetTempFileName();

            pak.Save(temfile);
            if (!Directory.Exists(Path.GetDirectoryName(filename)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filename));
            }
            using (ZipFile zip = new ZipFile())
            {
                zip.AddFile(temfile).FileName = "MediaPortalExtension.xml";

                foreach (FileItem fileItem in pak.UniqueFileList.Items)
                {
                    zip.AddFile(fileItem.LocalFileName).FileName = fileItem.ZipFileName;
                }

                zip.Save(filename);
            }
            File.Delete(temfile);
            return(true);
        }
 public AddFolder2Group(PackageClass packageClass, GroupItem groupItem, string folder)
 {
     Init();
     _groupItem      = groupItem;
     txt_folder.Text = folder;
     Package         = packageClass;
 }
Esempio n. 19
0
        public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            try
            {
                AsmHelper script =
                    new AsmHelper(CSScript.LoadCode(actionItem.Params[Const_script].Value,
                                                    Path.GetTempFileName(), true));
                script.Invoke("Script.Main", packageClass, actionItem);
            }
            catch (Exception ex)
            {
                if (!packageClass.Silent)
                {
                    MessageBox.Show("Eror in script : " + ex.Message);
                }
            }
            if (ItemProcessed != null)
            {
                ItemProcessed(this, new InstallEventArgs("Script executed " + actionItem.Name));
            }

            UnInstallItem unInstallItem = new UnInstallItem();

            unInstallItem.ActionType  = DisplayName;
            unInstallItem.ActionParam = new SectionParamCollection(actionItem.Params);
            unInstallItem.ActionParam[Const_script].Value    = ""; //actionItem.Params[Const_APP].GetValueAsPath();
            unInstallItem.ActionParam[Const_Un_script].Value = actionItem.Params[Const_Un_script].Value;
            packageClass.UnInstallInfo.Items.Add(unInstallItem);

            return(SectionResponseEnum.Ok);
        }
        public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
        {
            Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.BeforPanelShow);
            Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelShow);
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            bool state = false;

            try
            {
                AsmHelper script =
                    new AsmHelper(CSScript.LoadCode(sectionItem.Params[Const_script].Value,
                                                    Path.GetTempFileName(), true));
                state = (bool)script.Invoke("Script.GetState", packageClass, sectionItem);
            }
            catch (Exception ex)
            {
                if (!packageClass.Silent)
                {
                    MessageBox.Show("Eror in script : " + ex.Message);
                }
                state = false;
            }

            foreach (string includedGroup in sectionItem.IncludedGroups)
            {
                packageClass.Groups[includedGroup].Checked = state;
            }
            Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelHide);
            return(SectionResponseEnum.Ok);
        }
Esempio n. 21
0
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   Section = sectionItem;
   _packageClass = packageClass;
   SetValues();
   ShowDialog();
 }
Esempio n. 22
0
    // Start is called before the first frame update
    void Start()
    {
        canvas = transform.parent.gameObject;
        mm     = canvas.transform.GetComponent <MainManager>();

        DBManager dbm = new DBManager();

        equipList  = dbm.GetAllEquipment();
        theHero    = dbm.GetHero(1);
        thePackage = dbm.GetPackage(1);

        Init_SlotList();

        foreach (EquipmentClass i in equipList)
        {
            i.price = i.price * 2;
        }

        for (int i = 0; i < 6; i++)
        {
            EquipmentClass thisEquip = equipList[Random.Range(0, equipList.Count)];
            PutItemToSlot(thisEquip, slotList[i]);
            equipList.Remove(thisEquip);
        }

        Refresh();
    }
Esempio n. 23
0
        public void Initialize(PackageClass package, bool isInstalled)
        {
            this.Package              = package;
            this.isInstalled          = isInstalled;
            this.meetsAllDependencies = !package.CheckDependency(true);

            if (isInstalled)
            {
                UpdatePackage = MpeCore.MpeInstaller.KnownExtensions.GetUpdate(package);
            }

            extensionControlCollapsed.Initialize(
                package.GeneralInfo.Name,
                package.GeneralInfo.Author,
                package.GeneralInfo.Version.ToString(),
                meetsAllDependencies,
                UpdatePackage != null ? UpdatePackage.GeneralInfo.Version.ToString() : null,
                CollapsedItemClicked);
            Height = extensionControlCollapsed.PreferredSize.Height + Margin.Top + Margin.Bottom;

            if (ApplicationSettings.Instance.ExpandTile)
            {
                Expand();
            }
        }
        /// <summary>
        /// Gets the hightes version number package with specified id.
        /// </summary>
        /// <param name="id">The package GUID.</param>
        /// <returns>If found a package with specified GUID return the package else NULL</returns>
        public PackageClass Get(string id)
        {
            PackageClass ret = null;

            foreach (PackageClass item in Items)
            {
                if (item.IsHiden)
                {
                    continue;
                }
                if (item.GeneralInfo.Id == id)
                {
                    if (ret == null)
                    {
                        ret = item;
                    }
                    else
                    {
                        if (item.GeneralInfo.Version.CompareTo(ret.GeneralInfo.Version) > 0)
                        {
                            ret = item;
                        }
                    }
                }
            }
            return(ret);
        }
Esempio n. 25
0
 public QueueCommand(PackageClass packageClass, CommandEnum oper)
 {
   Date = DateTime.Now;
   CommandEnum = oper;
   TargetId = packageClass.GeneralInfo.Id;
   TargetVersion = packageClass.GeneralInfo.Version;
 }
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
     if (ItemProcessed != null)
     {
         ItemProcessed(this, new InstallEventArgs("Clear skin cache"));
     }
     try
     {
         Directory.Delete(MpeInstaller.TransformInRealPath("%Cache%"), true);
         Directory.CreateDirectory(MpeInstaller.TransformInRealPath("%Cache%"));
     }
     catch (Exception)
     {
         if (ItemProcessed != null)
         {
             ItemProcessed(this, new InstallEventArgs("Error clearing skin cache"));
         }
         return(SectionResponseEnum.Ok);
     }
     if (ItemProcessed != null)
     {
         ItemProcessed(this, new InstallEventArgs("Clear skin cache done"));
     }
     return(SectionResponseEnum.Ok);
 }
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
     packageClass.FileInstalled += packageClass_FileInstalled;
     packageClass.Install();
     packageClass.FileInstalled -= packageClass_FileInstalled;
     return(SectionResponseEnum.Ok);
 }
Esempio n. 28
0
        void Bind()
        {
            List <T_PRODUCE_PACKAGECALLBACK> list = new List <T_PRODUCE_PACKAGECALLBACK>();

            list = PackageClass.GetPackInfoByRegion(CmbRegion.SelectedItem.ToString());
            dataGridView1.DataSource = list;
        }
Esempio n. 29
0
 public void Uninstall(PackageClass packageClass, UnInstallItem fileItem)
 {
   if (fileItem.OriginalFile.EndsWith("\\"))
   {
     try
     {
       DirectoryInfo di = new DirectoryInfo(fileItem.OriginalFile);
       FileInfo[] fileList = di.GetFiles("*.*", SearchOption.AllDirectories);
       if (fileList.Length == 0)
       {
         Directory.Delete(fileItem.OriginalFile, true);
       }
     }
     catch (Exception) {}
   }
   else
   {
     if (!File.Exists(fileItem.OriginalFile))
       return;
     FileInfo fi = new FileInfo(fileItem.OriginalFile);
     if (fileItem.FileDate != fi.CreationTimeUtc || fileItem.FileSize != fi.Length)
       return;
     try
     {
       File.Delete(fileItem.OriginalFile);
       if (File.Exists(fileItem.BackUpFile))
         File.Move(fileItem.BackUpFile, fileItem.OriginalFile);
     }
     catch (Exception) {}
   }
 }
Esempio n. 30
0
        public static PackageClass Get(PackageClass packageClass)
        {
            var screen = new WizardSkinSelect();

            screen.Execute(packageClass);
            return(packageClass);
        }
Esempio n. 31
0
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
     Section       = sectionItem;
     _packageClass = packageClass;
     Mode          = ShowModeEnum.Preview;
     SetValues();
     ShowDialog();
 }
Esempio n. 32
0
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Preview;
   Package = packageClass;
   Section = sectionItem;
   SetValues();
   ShowDialog();
 }
Esempio n. 33
0
 private void extensionListControl_ShowScreenShot(object sender, PackageClass packageClass)
 {
     _screenShotNavigator.Set(packageClass);
     if (!_screenShotNavigator.Visible)
     {
         _screenShotNavigator.Show();
     }
 }
Esempio n. 34
0
 private void extensionListControl_UpdateExtension(object sender, PackageClass packageClass,
                                                   PackageClass newpackageClass)
 {
     this.Hide();
     DoUpdate(packageClass, newpackageClass, false);
     RefreshLists();
     this.Show();
 }
        public static void UpdateFiles(PackageClass packageClass, FolderGroup folderGroup)
        {
            if (string.IsNullOrEmpty(folderGroup.Folder))
            {
                return;
            }
            folderGroup.Folder = Path.GetFullPath(folderGroup.Folder);
            GroupItem     _groupItem = packageClass.Groups[folderGroup.Group];
            DirectoryInfo di         = new DirectoryInfo(Path.GetFullPath(folderGroup.Folder));

            FileInfo[] fileList;
            fileList = folderGroup.Recursive
                   ? di.GetFiles("*.*", SearchOption.AllDirectories)
                   : di.GetFiles("*.*", SearchOption.TopDirectoryOnly);
            string dir   = Path.GetFullPath(folderGroup.Folder);
            string templ = folderGroup.DestinationFilename;

            if (!dir.EndsWith("\\"))
            {
                dir += "\\";
            }
            if (!templ.EndsWith("\\"))
            {
                templ += "\\";
            }

            foreach (FileInfo f in fileList)
            {
                if (!f.DirectoryName.Contains(".svn"))
                {
                    FileItem fileItem = new FileItem(f.FullName, false);
                    fileItem.UpdateOption        = folderGroup.UpdateOption;
                    fileItem.Param1              = folderGroup.Param1;
                    fileItem.InstallType         = folderGroup.InstallType;
                    fileItem.Modified            = false;
                    fileItem.DestinationFilename = f.FullName.Replace(dir, templ);
                    if (_groupItem.Files.Get(f.FullName, fileItem.DestinationFilename) != null)
                    {
                        continue;
                    }
                    _groupItem.Files.Add(fileItem);
                }
            }
            List <FileItem> misingFiles = new List <FileItem>();

            foreach (FileItem item in _groupItem.Files.Items)
            {
                if (!File.Exists(item.LocalFileName) && !item.Modified)
                {
                    misingFiles.Add(item);
                }
            }

            foreach (FileItem item in misingFiles)
            {
                _groupItem.Files.Items.Remove(item);
            }
        }
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
     if (ItemProcessed != null)
     {
         ItemProcessed(this, new InstallEventArgs("Message box"));
     }
     MessageBox.Show(actionItem.Params[Const_MESSAGE].Value);
     return(SectionResponseEnum.Ok);
 }
Esempio n. 37
0
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Preview;
   Section = sectionItem;
   Package = packageClass;
   SetValues();
   timer1.Enabled = true;
   ShowDialog();
 }
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         DialogResult = DialogResult.OK;
         Result       = listView1.SelectedItems[0].Tag as PackageClass;
         Close();
     }
 }
Esempio n. 39
0
 public ValidationResponse Validate(PackageClass packageClass, ActionItem actionItem)
 {
   if (!string.IsNullOrEmpty(actionItem.ConditionGroup) && packageClass.Groups[actionItem.ConditionGroup] == null)
     return new ValidationResponse
              {
                Message = actionItem.Name + " condition group not found " + actionItem.ConditionGroup,
                Valid = false
              };
   return new ValidationResponse();
 }
Esempio n. 40
0
 public new void Install(PackageClass packageClass, FileItem fileItem)
 {
   base.Install(packageClass, fileItem);
   string fontFilePath = fileItem.ExpandedDestinationFilename;
   if (AddFontResource(fontFilePath) != 0)
   {
     SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
     WriteProfileString("fonts", Path.GetFileNameWithoutExtension(fontFilePath) + " (TrueType)",
                        Path.GetFileName(fontFilePath));
   }
 }
Esempio n. 41
0
    public static void UpdateFiles(PackageClass packageClass, FolderGroup folderGroup)
    {
      if (string.IsNullOrEmpty(folderGroup.Folder))
        return;
      folderGroup.Folder = Path.GetFullPath(folderGroup.Folder);
      GroupItem _groupItem = packageClass.Groups[folderGroup.Group];
      DirectoryInfo di = new DirectoryInfo(Path.GetFullPath(folderGroup.Folder));
      FileInfo[] fileList = new FileInfo[0];
      // only if the directory does not exists check files, otherwise exception would occur
      if (di.Exists) 
      {
        fileList = folderGroup.Recursive
                     ? di.GetFiles("*.*", SearchOption.AllDirectories)
                     : di.GetFiles("*.*", SearchOption.TopDirectoryOnly);
      }
      string dir = Path.GetFullPath(folderGroup.Folder);
      string templ = folderGroup.DestinationFilename;
      if (!dir.EndsWith("\\"))
      {
        dir += "\\";
      }
      if (!templ.EndsWith("\\"))
      {
        templ += "\\";
      }

      foreach (FileInfo f in fileList)
      {
        if (!f.DirectoryName.Contains(".svn"))
        {
          FileItem fileItem = new FileItem(f.FullName, false);
          fileItem.UpdateOption = folderGroup.UpdateOption;
          fileItem.Param1 = folderGroup.Param1;
          fileItem.InstallType = folderGroup.InstallType;
          fileItem.Modified = false;
          fileItem.DestinationFilename = f.FullName.Replace(dir, templ);
          if (_groupItem.Files.Get(f.FullName, fileItem.DestinationFilename) != null)
            continue;
          _groupItem.Files.Add(fileItem);
        }
      }
      List<FileItem> misingFiles = new List<FileItem>();
      foreach (FileItem item in _groupItem.Files.Items)
      {
        if (!File.Exists(item.LocalFileName) && !item.Modified)
          misingFiles.Add(item);
      }

      foreach (FileItem item in misingFiles)
      {
        _groupItem.Files.Items.Remove(item);
      }
    }
Esempio n. 42
0
 public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Real;
   Package = packageClass;
   Section = sectionItem;
   base.DisableX_Click();
   SetValues();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.BeforPanelShow);
   ShowDialog();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelHide);
   return base.Resp;
 }
Esempio n. 43
0
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
   if (ItemProcessed != null)
     ItemProcessed(this, new InstallEventArgs("Kill Task"));
   Process[] prs = Process.GetProcesses();
   foreach (Process pr in prs)
   {
     if (pr.ProcessName.Equals(actionItem.Params[Const_MESSAGE].Value, StringComparison.InvariantCultureIgnoreCase))
       pr.Kill();
   }
   return SectionResponseEnum.Ok;
 }
Esempio n. 44
0
 public ValidationResponse Validate(PackageClass packageClass, ActionItem actionItem)
 {
   if (!string.IsNullOrEmpty(actionItem.ConditionGroup) && packageClass.Groups[actionItem.ConditionGroup] == null)
     return new ValidationResponse()
              {
                Message = actionItem.Name + " condition group not found " + actionItem.ConditionGroup,
                Valid = false
              };
   if (string.IsNullOrEmpty(actionItem.Params[Const_Loc].Value))
     return new ValidationResponse()
              {Message = "[CreateFolder] no destnation folder specified !", Valid = false};
   return new ValidationResponse();
 }
Esempio n. 45
0
 public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
 {
   Section = sectionItem;
   _packageClass = packageClass;
   SetValues();
   Base.ActionExecute(_packageClass, Section, ActionExecuteLocationEnum.BeforPanelShow);
   Base.ActionExecute(_packageClass, Section, ActionExecuteLocationEnum.AfterPanelShow);
   Mode = ShowModeEnum.Real;
   if (!packageClass.Silent)
     ShowDialog();
   else
     resp = SectionResponseEnum.Next;
   Base.ActionExecute(_packageClass, Section, ActionExecuteLocationEnum.AfterPanelHide);
   return resp;
 }
Esempio n. 46
0
 public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
 {
   Package = packageClass;
   Params = sectionItem.Params;
   Section = sectionItem;
   SetValues();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.BeforPanelShow);
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelShow);
   if (!packageClass.Silent)
     ShowDialog();
   else
     base.Resp = SectionResponseEnum.Next;
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelHide);
   return base.Resp;
 }
Esempio n. 47
0
    public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
    {
      SectionResponseEnum _resp;
      _resp = ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.BeforPanelShow);
      if (_resp != SectionResponseEnum.Ok)
        return _resp;
      _resp = ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelShow);
      if (_resp != SectionResponseEnum.Ok)
        return _resp;

      foreach (string includedGroup in sectionItem.IncludedGroups)
      {
        packageClass.Groups[includedGroup].Checked = sectionItem.Params[Const_state].GetValueAsBool();
      }
      _resp = ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelHide);
      return _resp;
    }
Esempio n. 48
0
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
   try
   {
     if (ItemProcessed != null)
       ItemProcessed(this, new InstallEventArgs("Create Folder"));
     if (!Directory.Exists(actionItem.Params[Const_Loc].GetValueAsPath()))
       Directory.CreateDirectory(actionItem.Params[Const_Loc].GetValueAsPath());
     UnInstallItem unInstallItem = new UnInstallItem();
     unInstallItem.ActionType = DisplayName;
     unInstallItem.ActionParam = new SectionParamCollection(actionItem.Params);
     unInstallItem.ActionParam[Const_Loc].Value = actionItem.Params[Const_Loc].GetValueAsPath();
     packageClass.UnInstallInfo.Items.Add(unInstallItem);
   }
   catch {}
   return SectionResponseEnum.Ok;
 }
Esempio n. 49
0
 public static SectionResponseEnum ActionExecute(PackageClass packageClass, SectionItem sectionItem,
                                                 ActionExecuteLocationEnum locationEnum)
 {
   SectionResponseEnum responseEnum = SectionResponseEnum.Ok;
   foreach (ActionItem list in sectionItem.Actions.Items)
   {
     if (list.ExecuteLocation != locationEnum)
       continue;
     if (!string.IsNullOrEmpty(list.ConditionGroup) && !packageClass.Groups[list.ConditionGroup].Checked)
       continue;
     responseEnum = MpeInstaller.ActionProviders[list.ActionType].Execute(packageClass, list);
     if (responseEnum != SectionResponseEnum.Ok)
     {
       break;
     }
   }
   return responseEnum;
 }
Esempio n. 50
0
 /// <summary>
 /// Previews the section form, but no change made.
 /// </summary>
 /// <param name="packageClass">The package class.</param>
 /// <param name="sectionItem">The param collection.</param>
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   MessageBox.Show("This is a non visual Section. Nothing to show");
   bool state = false;
   try
   {
     Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
     AsmHelper script =
       new AsmHelper(CSScript.LoadCode(sectionItem.Params[Const_script].Value,
                                       Path.GetTempFileName(), true));
     state = (bool)script.Invoke("Script.GetState", packageClass, sectionItem);
     MessageBox.Show("Result of script : " + state.ToString());
   }
   catch (Exception ex)
   {
     MessageBox.Show("Eror in script : " + ex.Message);
   }
 }
Esempio n. 51
0
    public void Install(PackageClass packageClass, FileItem fileItem)
    {
      try
      {
        string destination = fileItem.ExpandedDestinationFilename;

        FileItem item = packageClass.UniqueFileList.GetByLocalFileName(fileItem);
        if (item == null)
          return;

        if (File.Exists(destination))
        {
          switch (fileItem.UpdateOption)
          {
            case UpdateOptionEnum.NeverOverwrite:
              return;
            case UpdateOptionEnum.AlwaysOverwrite:
              break;
            case UpdateOptionEnum.OverwriteIfOlder:
              if (File.GetLastWriteTime(destination) > packageClass.ZipProvider.FileDate(item))
                return;
              break;
          }
        }
        if (!Directory.Exists(Path.GetDirectoryName(destination)))
        {
          string dirname = Path.GetDirectoryName(destination);
          Directory.CreateDirectory(dirname);
          if (!dirname.EndsWith("\\"))
            dirname += "\\";
          UnInstallItem unI = new UnInstallItem();
          unI.OriginalFile = dirname;
          unI.InstallType = "CopyFile";
          packageClass.UnInstallInfo.Items.Add(unI);
        }
        UnInstallItem unInstallItem = packageClass.UnInstallInfo.BackUpFile(item);
        packageClass.ZipProvider.Extract(item, destination);
        FileInfo info = new FileInfo(destination);
        unInstallItem.FileDate = info.CreationTimeUtc;
        unInstallItem.FileSize = info.Length;
        packageClass.UnInstallInfo.Items.Add(unInstallItem);
      }
      catch (Exception) {}
    }
Esempio n. 52
0
 public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
 {
   if (ItemProcessed != null)
     ItemProcessed(this, new InstallEventArgs("Clear skin cache"));
   try
   {
     Directory.Delete(MpeInstaller.TransformInRealPath("%Cache%"), true);
     Directory.CreateDirectory(MpeInstaller.TransformInRealPath("%Cache%"));
   }
   catch (Exception)
   {
     if (ItemProcessed != null)
       ItemProcessed(this, new InstallEventArgs("Error clearing skin cache"));
     return SectionResponseEnum.Ok;
   }
   if (ItemProcessed != null)
     ItemProcessed(this, new InstallEventArgs("Clear skin cache done"));
   return SectionResponseEnum.Ok;
 }
Esempio n. 53
0
    public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
    {
      if (actionItem.Params[Const_APP].GetValueAsBool() && packageClass.Silent)
        return SectionResponseEnum.Ok;

      Process myProcess = new Process();

      try
      {
        myProcess.StartInfo.UseShellExecute = false;
        myProcess.StartInfo.FileName = MpeInstaller.TransformInRealPath(actionItem.Params[Const_APP].Value);
        myProcess.StartInfo.Arguments = MpeInstaller.TransformInRealPath(actionItem.Params[Const_Params].Value);
        myProcess.StartInfo.CreateNoWindow = true;

        if (packageClass.Silent)
        {
          myProcess.StartInfo.CreateNoWindow = true;
          myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
        }
        myProcess.Start();
        if (actionItem.Params[Const_Wait].GetValueAsBool())
        {
          myProcess.WaitForExit();
          if (myProcess.ExitCode != 0)
            return SectionResponseEnum.Error;
        }
      }
      catch
      {
        if (ItemProcessed != null)
          ItemProcessed(this, new InstallEventArgs("Error to start application"));
        return SectionResponseEnum.Error;
      }
      UnInstallItem unInstallItem = new UnInstallItem();
      unInstallItem.ActionType = DisplayName;
      unInstallItem.ActionParam = new SectionParamCollection(actionItem.Params);
      unInstallItem.ActionParam[Const_APP].Value = actionItem.Params[Const_APP].GetValueAsPath();
      unInstallItem.ActionParam[Const_Un_APP].Value = actionItem.Params[Const_Un_APP].GetValueAsPath();
      packageClass.UnInstallInfo.Items.Add(unInstallItem);
      return SectionResponseEnum.Ok;
    }
Esempio n. 54
0
    public void Install(PackageClass packageClass, FileItem file)
    {
      List<string> skinList = GetInstalledSkins(file.Param1.Split(ParamNamesConst.SEPARATORS));
      foreach (string list in skinList)
      {
        FileItem fileItem = new FileItem(file);
        string destination = fileItem.ExpandedDestinationFilename.Replace("[DEFAULT]", list);

        FileItem item = packageClass.UniqueFileList.GetByLocalFileName(fileItem);
        if (item == null)
          return;

        item.InstallType = "CopyFile";

        if (File.Exists(destination))
        {
          switch (fileItem.UpdateOption)
          {
            case UpdateOptionEnum.NeverOverwrite:
              continue;
            case UpdateOptionEnum.AlwaysOverwrite:
              break;
            case UpdateOptionEnum.OverwriteIfOlder:
              if (File.GetLastWriteTime(destination) > packageClass.ZipProvider.FileDate(item))
                continue;
              break;
          }
        }
        if (!Directory.Exists(Path.GetDirectoryName(destination)))
          Directory.CreateDirectory(Path.GetDirectoryName(destination));
        UnInstallItem unInstallItem = packageClass.UnInstallInfo.BackUpFile(destination, item.InstallType);
        packageClass.ZipProvider.Extract(item, destination);
        FileInfo info = new FileInfo(destination);
        unInstallItem.FileDate = info.CreationTimeUtc;
        unInstallItem.FileSize = info.Length;
        packageClass.UnInstallInfo.Items.Add(unInstallItem);
      }
    }
Esempio n. 55
0
 /// <summary>
 /// Loads the specified zipfile.
 /// 
 /// </summary>
 /// <param name="zipfile">The zipfile.</param>
 /// <returns>if something wrong, return null else the loaded package</returns>
 public PackageClass Load(string zipfile)
 {
   try
   {
     PackageClass pak = new PackageClass();
     _zipPackageFile = ZipFile.Read(zipfile);
     string tempPackageFile = Path.GetTempFileName();
     var fs = new FileStream(tempPackageFile, FileMode.Create);
     _zipPackageFile["MediaPortalExtension.xml"].Extract(fs);
     fs.Close();
     pak.Load(tempPackageFile);
     _tempFileList.Add(tempPackageFile);
     foreach (FileItem fileItem in pak.UniqueFileList.Items)
     {
       if (fileItem.SystemFile)
       {
         string tempfil = Path.GetTempFileName();
         tempfil = Path.Combine(Path.GetDirectoryName(tempfil), Path.GetFileNameWithoutExtension(tempfil) +
                   Path.GetExtension(fileItem.LocalFileName));
         Extract(fileItem, tempfil);
         fileItem.TempFileLocation = tempfil;
         //fileItem.LocalFileName = tempfil;
         _tempFileList.Add(tempfil);
       }
     }
     pak.ZipProvider = this;
     pak.GetFilePaths();
     pak.GeneralInfo.Location = zipfile;
     return pak;
   }
   catch (Exception)
   {
     if (_zipPackageFile != null)
       _zipPackageFile.Dispose();
     return null;
   }
 }
    public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
    {
      if (packageClass.Silent)
        return SectionResponseEnum.Ok;
      try
      {
        if (!packageClass.Silent && File.Exists(MpeInstaller.TransformInRealPath(actionItem.Params[Const_APP].Value)))
        {
          string assemblyFileName = MpeInstaller.TransformInRealPath(actionItem.Params[Const_APP].Value);
          AppDomainSetup setup = new AppDomainSetup();
          setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
          setup.PrivateBinPath = Path.GetDirectoryName(assemblyFileName);
          setup.ApplicationName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
          setup.ShadowCopyFiles = "true";
          setup.ShadowCopyDirectories = Path.GetDirectoryName(assemblyFileName);
          AppDomain appDomain = AppDomain.CreateDomain("pluginDomain", null, setup);

          PluginLoader remoteExecutor =
            (PluginLoader)
            appDomain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location,
                                                  typeof (PluginLoader).ToString());
          remoteExecutor.Load(assemblyFileName);
          remoteExecutor.Dispose();

          AppDomain.Unload(appDomain);
        }
      }
      catch (Exception)
      {
        if (ItemProcessed != null)
          ItemProcessed(this, new InstallEventArgs("Error to configure plugin"));
        return SectionResponseEnum.Ok;
      }
      if (ItemProcessed != null)
        ItemProcessed(this, new InstallEventArgs("Plugin configuration donne"));
      return SectionResponseEnum.Ok;
    }
Esempio n. 57
0
 /// <summary>
 /// Adds the specified package class. But without copy all the structure the GeneralInfo and the group Names
 /// If the package with same version number already exist, will be replaced
 /// </summary>
 /// <param name="packageClass">The package class.</param>
 public void Add(PackageClass packageClass)
 {
   PackageClass oldpak = Get(packageClass);
   if (oldpak != null)
     Items.Remove(oldpak);
   PackageClass pak = new PackageClass();
   pak.GeneralInfo = packageClass.GeneralInfo;
   foreach (GroupItem groupItem in packageClass.Groups.Items)
   {
     pak.Groups.Items.Add(new GroupItem(groupItem.Name, groupItem.Checked));
   }
   pak.Dependencies = packageClass.Dependencies;
   pak.PluginDependencies = packageClass.PluginDependencies;
   pak.IsSkin = packageClass.IsSkin;
   pak.Version = packageClass.Version;
   pak.Parent = this;
   Items.Add(pak);
 }
Esempio n. 58
0
 /// <summary>
 /// Removes the specified package class fromr the list.
 /// </summary>
 /// <param name="packageClass">The package class.</param>
 public void Remove(PackageClass packageClass)
 {
   PackageClass pak = Get(packageClass);
   if (pak == null)
     return;
   Items.Remove(pak);
 }
Esempio n. 59
0
 public PackageClass Get(PackageClass pak)
 {
   return Get(pak.GeneralInfo.Id, pak.GeneralInfo.Version.ToString());
 }
Esempio n. 60
0
 /// <summary>
 /// Gets the latest version of a package. If not found or no new version return Null
 /// </summary>
 /// <param name="pak">The package</param>
 /// <returns></returns>
 public PackageClass GetUpdate(PackageClass pak)
 {
   if (IgnoredUpdates.Contains(pak.GeneralInfo.Id))
     return null;
   PackageClass ret = Get(pak.GeneralInfo.Id);
   if (ret == null)
     return null;
   if (ret.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) > 0)
     return ret;
   return null;
 }