Пример #1
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 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 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);
        }
Пример #4
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) {}
   }
 }
Пример #5
0
 /// <summary>
 /// Do the unistall procces. The unistall file info should be already loaded.
 /// </summary>
 public void UnInstall()
 {
   Util.KillAllMediaPortalProcesses();
   for (int i = UnInstallInfo.Items.Count - 1; i >= 0; i--)
   {
     UnInstallItem item = UnInstallInfo.Items[i];
     if (string.IsNullOrEmpty(item.ActionType))
     {
       MpeInstaller.InstallerTypeProviders[item.InstallType].Uninstall(this, item);
       if (FileUnInstalled != null)
         FileUnInstalled(this,
                         new UnInstallEventArgs("Removing file " + Path.GetFileName(item.OriginalFile),
                                                item));
     }
     else
     {
       MpeInstaller.ActionProviders[item.ActionType].UnInstall(this, item);
       if (FileUnInstalled != null)
         FileUnInstalled(this,
                         new UnInstallEventArgs("Removing action " + item.ActionType,
                                                item));
     }
   }
   UnInstallInfo.Items.Clear();
   DoAdditionalUnInstallTasks();
 }
Пример #6
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(fileItem);
                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) {}
        }
        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);
        }
        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);
            }
        }
Пример #9
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;
 }
Пример #10
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) {}
    }
Пример #11
0
        public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            try
            {
                AsmHelper script =
                    new AsmHelper(CSScript.LoadCode(item.ActionParam[Const_Un_script].Value,
                                                    Path.GetTempFileName(), true));

                script.Invoke("Script.Main", packageClass, item);
            }
            catch (Exception ex)
            {
                if (!packageClass.Silent)
                {
                    MessageBox.Show("Eror in script : " + ex.Message);
                }
            }
            return(SectionResponseEnum.Ok);
        }
 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);
 }
        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);
        }
Пример #14
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) {}
     }
 }
Пример #15
0
 public void Uninstall(PackageClass packageClass, UnInstallItem fileItem)
 {
     throw new NotImplementedException();
 }
 public UnInstallEventArgs(string message, UnInstallItem item)
 {
     Message       = message;
     UnInstallItem = item;
 }
 public UnInstallEventArgs()
 {
     Message       = string.Empty;
     UnInstallItem = new UnInstallItem();
 }
Пример #18
0
 public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
 {
   return SectionResponseEnum.Ok;
 }
Пример #19
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;
    }
Пример #20
0
    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;
    }
Пример #21
0
 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;
 }
Пример #22
0
 public UnInstallEventArgs()
 {
   Message = string.Empty;
   UnInstallItem = new UnInstallItem();
 }
Пример #23
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 void Uninstall(PackageClass packageClass, UnInstallItem fileItem)
 {
     // should not be called, since Install creates a UnInstallItem with type CopyFile
 }
Пример #25
0
 public UnInstallEventArgs(string message, UnInstallItem item)
 {
   Message = message;
   UnInstallItem = item;
 }
 public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
 {
     return(SectionResponseEnum.Ok);
 }
Пример #27
0
 public SectionResponseEnum UnInstall(PackageClass packageClass, UnInstallItem item)
 {
   Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
   try
   {
     AsmHelper script =
       new AsmHelper(CSScript.LoadCode(item.ActionParam[Const_Un_script].Value,
                                       Path.GetTempFileName(), true));
     script.Invoke("Script.Main", packageClass, item);
   }
   catch (Exception ex)
   {
     if (!packageClass.Silent)
       MessageBox.Show("Eror in script : " + ex.Message);
   }
   return SectionResponseEnum.Ok;
 }