Exemple #1
0
        private void getfilesforop(storagenode node, bool binstall, ref Dictionary <string, actiondata> actionsmap)
        {
            AppendToLog(String.Format("getfilesforop({0},{1})", node.nodedata.name, binstall));

            if (node.children.Count > 0)
            {
                foreach (storagenode sn in node.children)
                {
                    foreach (var ca in (binstall ? sn.nodedata.inscustomactions : sn.nodedata.uinscustomactions))
                    {
                        if (!actionsmap.ContainsKey(ca.Key))
                        {
                            actiondata ad = new actiondata();
                            ad.action = ca.Value;
                            ad.nodes.Add(sn.nodedata);
                            actionsmap.Add(ca.Key, ad);
                        }
                        else
                        {
                            actionsmap[ca.Key].nodes.Add(sn.nodedata);
                        }
                    }
                    if (sn.children.Count > 0)
                    {
                        getfilesforop(sn, binstall, ref actionsmap);
                    }
                }
            }
        }
Exemple #2
0
 private void updatephysicalpath(storagenode node, string sourcepath)
 {
     AppendToLog(String.Format("updatephysicalpath({0},{1})", node.nodedata.name, sourcepath));
     try
     {
         if (node.children.Count > 0)
         {
             foreach (storagenode sn in node.children)
             {
                 string srcpath = sourcepath + sn.nodedata.name;
                 if (sn.children.Count == 0)
                 {
                     sn.nodedata.physicalpath = srcpath;
                 }
                 else
                 {
                     sn.nodedata.physicalpath = srcpath;
                     updatephysicalpath(sn, srcpath + "\\");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         AppendToLog("Exception:" + ex.Message);
         errormsg = ex.Message;
         throw;
     }
 }
Exemple #3
0
        private bool savedata(ref string filename, bool bfrmmsi)
        {
            try
            {
                if (!validate())
                {
                    return(false);
                }

                storagenode sn = new storagenode();
                sn.nodedata = (Nodedata)treeView1.Nodes[0].Tag;
                addchildnodes(treeView1.Nodes[0], ref sn);
                if (!bfrmmsi || filename == "" || bdirty)
                {
                    savefrm sf = new savefrm(sn, filename, bfrmmsi);
                    if (sf.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return(false);
                    }
                    filename = sf.filename;
                    loadlayoutfile();
                }
            }
            catch (Exception ex)
            {
                updatestatus(ex.Message);
                return(false);
            }

            return(true);
        }
Exemple #4
0
        private void writedata(storagenode node)
        {
            try
            {
                cn.propmapinfo["ProductName"] = txtname.Text;
                cn.preinstall        = txtpreinstall.Text;
                cn.preinstallargs    = txtpreinstallargs.Text;
                cn.postinstall       = txtpostinstall.Text;
                cn.postinstallargs   = txtpostinstallargs.Text;
                cn.preuninstall      = txtpreuninstall.Text;
                cn.preuninstallargs  = txtpreuninstallargs.Text;
                cn.postuninstall     = txtpostuninstall.Text;
                cn.postuninstallargs = txtpostuninstallargs.Text;
                cn.packageguid       = Guid.NewGuid().ToString("B");
                cn.bask = chkfolders.Checked;

                if (chkrelative.Checked)
                {
                    layout.mergepath(cn, Path.GetDirectoryName(filename), true);
                    layout.mergepath(node, Path.GetDirectoryName(filename), true);
                }
                layout.write(filename, cn, node);
            }
            catch (Exception ex)
            {
                MessageBox.Show("an exception occured in savefrm()\r\n" + ex.Message);
            }
        }
Exemple #5
0
        public savefrm(storagenode sn, string filename, bool bfrmmsi)
        {
            try
            {
                InitializeComponent();
                this.sn = sn;
                if (File.Exists(filename))
                {
                    cn = layout.getcontainer(filename);

                    txtname.Text                 = cn.propmapinfo["ProductName"];
                    txtloc.Text                  = filename;
                    txtpreinstall.Text           = cn.preinstall;
                    txtpreinstallargs.Text       = cn.preinstallargs;
                    txtpreinstallargs.Enabled    = (cn.preinstall != "");
                    txtpostinstall.Text          = cn.postinstall;
                    txtpostinstallargs.Text      = cn.postinstallargs;
                    txtpostinstallargs.Enabled   = (cn.postinstall != "");
                    txtpreuninstall.Text         = cn.preuninstall;
                    txtpreuninstallargs.Text     = cn.preuninstallargs;
                    txtpreuninstallargs.Enabled  = (cn.preuninstall != "");
                    txtpostuninstall.Text        = cn.postuninstall;
                    txtpostuninstallargs.Text    = cn.postuninstallargs;
                    txtpostuninstallargs.Enabled = (cn.postuninstall != "");
                    chkfolders.Checked           = cn.bask;
                }

                if (bfrmmsi)
                {
                    txtname.Text = "sample";
                    txtloc.Text  = filename;
                }
                else
                {
                    List <string> parlist = new List <string>();
                    getparameters(sn, ref parlist);
                    foreach (string s in parlist)
                    {
                        string temp;
                        if (!cn.dirmapinfo.TryGetValue(s, out temp))
                        {
                            string key = '%' + s + '%';
                            string val = Environment.ExpandEnvironmentVariables(key);
                            cn.dirmapinfo.Add(s, (val == key) ? "" : val);
                        }
                    }
                }

                groupBox1.Enabled = !bfrmmsi;
            }
            catch (Exception ex)
            {
                MessageBox.Show("an exception occured in savefrm()\r\n" + ex.Message);
            }
        }
Exemple #6
0
        private void loadlayoutfile()
        {
            try
            {
                storagenode node = layout.getstoragenode(filename);

                treeView1.Nodes.Clear();
                populatetree(node, treeView1.Nodes);
                bdirty = false;
            }
            catch (Exception ex)
            {
                updatestatus(ex.Message);
            }
        }
Exemple #7
0
        private void copyfiles(storagenode node, string sourcepath, string targetpath)
        {
            try
            {
                AppendToLog(String.Format("copyfiles({0},{1},{2})", node.nodedata.name, sourcepath, targetpath));
                if (node.children.Count > 0)
                {
                    foreach (storagenode sn in node.children)
                    {
                        if (targetpath == "" && sn.nodedata.name == "Setup")
                        {
                            continue;
                        }

                        string srcpath  = sourcepath + sn.nodedata.name;
                        string destpath = targetpath + Environment.ExpandEnvironmentVariables(sn.nodedata.name);

                        string dirs = destpath;
                        if (sn.children.Count == 0)
                        {
                            dirs = Path.GetDirectoryName(destpath);
                            Directory.CreateDirectory(dirs);
                            sn.nodedata.physicalpath = destpath;
                            AppendToLog(String.Format("copying {0} {1}", srcpath, destpath));
                            File.Copy(srcpath, destpath, true);
                        }
                        else
                        {
                            if (sn.nodedata.inscustomactions.ContainsKey(Customaction.CREATEFOLDER) && Directory.Exists(dirs))
                            {
                                AppendToLog(string.Format("deleting {0}", dirs));
                                Directory.Delete(dirs, true);
                            }
                            AppendToLog(string.Format("creating {0}", dirs));
                            Directory.CreateDirectory(dirs);
                            sn.nodedata.physicalpath = dirs;
                            copyfiles(sn, srcpath + "\\", destpath + "\\");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppendToLog("Exception:" + ex.Message);
                errormsg = ex.Message;
                throw;
            }
        }
Exemple #8
0
 private void populatetree(storagenode node, TreeNodeCollection nodes)
 {
     try
     {
         TreeNode tn = nodes.Add(node.nodedata.name);
         tn.Tag        = node.nodedata;
         tn.ImageIndex = node.children.Count == 0 ? 1 : 0;
         foreach (storagenode sn in node.children)
         {
             populatetree(sn, tn.Nodes);
         }
     }
     catch (Exception ex)
     {
         updatestatus(ex.Message);
     }
 }
Exemple #9
0
 private void addchildnodes(TreeNode tn, ref storagenode node)
 {
     try
     {
         foreach (TreeNode ctn in tn.Nodes)
         {
             storagenode sn = new storagenode();
             sn.nodedata = (Nodedata)ctn.Tag;
             node.children.Add(sn);
             addchildnodes(ctn, ref sn);
         }
     }
     catch (Exception ex)
     {
         updatestatus(ex.Message);
     }
 }
Exemple #10
0
        private void Copyfiles()
        {
            DirectoryInfo dir = new DirectoryInfo(stagefolder);

            if (dir.Exists)
            {
                dir.Delete(true);
            }
            dir.Create();

            storagenode node = layout.getstoragenode(layoutfile);

            copyfiles(node, dir.FullName);

            string setupdir = dir.FullName + "\\Root\\setup";

            Directory.CreateDirectory(setupdir);
            File.Copy(layoutfile, setupdir + "\\installfiles.layout", true);
            container co = layout.getcontainer(layoutfile);
            Dictionary <string, string> dirmap = co.dirmapinfo;

            for (int i = 0; i < 4; ++i)
            {
                string sifile  = (i % 2 == 0 ? co.preinstall : co.postinstall);
                string suifile = (i % 2 == 0 ? co.preuninstall : co.postuninstall);
                string sfile   = (i < 2) ? sifile : suifile;
                if (sfile == "")
                {
                    continue;
                }

                FileInfo fi = new FileInfo(sfile);
                if (!fi.Exists)
                {
                    Program.UpdateStatus(String.Format("File doesnot exist:{0}", fi.FullName));
                }
                else
                {
                    File.Copy(fi.FullName, setupdir + "\\" + fi.Name);
                }
            }
        }
Exemple #11
0
        private void copyfiles(storagenode node, string fullpath)
        {
            System.Windows.Forms.Application.DoEvents();
            string path = fullpath + "\\" + node.nodedata.name;

            if (node.children.Count > 0)
            {
                Program.UpdateStatus("creating dir:" + path);
                Directory.CreateDirectory(path);
                foreach (storagenode sn in node.children)
                {
                    copyfiles(sn, path);
                }
            }
            else
            {
                Program.UpdateStatus("copying file " + path);
                File.Copy(node.nodedata.physicalpath, path, true);
            }
        }
Exemple #12
0
        public void performfileops(bool binstall)
        {
            AppendToLog(string.Format("performfileops({0})", binstall));
            string layoutfile = Program.workfolder + "\\setup\\installfiles.layout";

            node = layout.getstoragenode(layoutfile);

            Dictionary <string, actiondata> actionsmap = new Dictionary <string, actiondata>();

            getfilesforop(node, binstall, ref actionsmap);
            for (int x = 0; x < 5; ++x)
            {
                foreach (var kv in actionsmap)
                {
                    if (kv.Value.action.priority == x)
                    {
                        performfileop(kv.Value, binstall);
                    }
                }
            }
        }
Exemple #13
0
 private void getparameters(storagenode node, ref List <string> parlist)
 {
     string[] oneparlist = node.nodedata.name.Split(new char[] { '%' });
     if (oneparlist.Length > 1)
     {
         foreach (string s in oneparlist)
         {
             if (s != "" && s.IndexOf('\\') == -1)
             {
                 parlist.Add(s);
             }
         }
     }
     if (node.children.Count > 0)
     {
         foreach (storagenode sn in node.children)
         {
             getparameters(sn, ref parlist);
         }
     }
 }
Exemple #14
0
 public void copyfiles()
 {
     try
     {
         AppendToLog("copyfiles()");
         string layoutfile = Program.workfolder + "\\setup\\installfiles.layout";
         node = layout.getstoragenode(layoutfile);
         copyfiles(node, Program.workfolder + "\\", "");
         foreach (storagenode sn in node.children)
         {
             if (sn.nodedata.name == "Setup")
             {
                 updatephysicalpath(sn, Program.workfolder + "\\Setup\\");
             }
         }
         layout.write(layoutfile, co, node);
     }
     catch (Exception ex)
     {
         AppendToLog("Exception:" + ex.Message);
         errormsg = ex.Message;
         throw;
     }
 }