Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void performfileop(actiondata ad, bool binstall)
        {
            try
            {
                AppendToLog(string.Format("performfileop({0})", ad.action.name));
                if (ad.action.name == Customaction.CREATEFOLDER)
                {
                    return;
                }

                if (ad.action.name == Customaction.REMOVEFOLDER)
                {
                    string dirpath = ad.nodes[0].physicalpath;
                    if (Directory.Exists(dirpath))
                    {
                        Directory.Delete(dirpath, true);
                        return;
                    }
                }

                Process p = new Process();
                p.StartInfo.FileName = getexeforaction(ad.action);
                AppendToLog(string.Format("{0}", p.StartInfo.FileName));

                if (ad.action.grpaction)
                {
                    string files = "";
                    foreach (var n in ad.nodes)
                    {
                        files = files + " " + '"' + n.physicalpath + '"';
                    }

                    if (Program.uilevel != 5 && ad.action.name == Customaction.CONFIG_EDIT)
                    {
                        ad.action.args = "-s " + ad.action.args;
                    }
                    p.StartInfo.Arguments = ad.action.args + "  " + files;
                    AppendToLog(string.Format("Args:{0}", p.StartInfo.Arguments));
                    if (ad.action.name != Customaction.CONFIG_EDIT)
                    {
                        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    }
                    p.Start();
                    if (ad.action.wfe)
                    {
                        p.WaitForExit();
                    }
                }
                else
                {
                    foreach (var n in ad.nodes)
                    {
                        foreach (var a in binstall ? n.inscustomactions : n.uinscustomactions)
                        {
                            if (a.Key != ad.action.name)
                            {
                                continue;
                            }
                            p.StartInfo.Arguments = a.Value.args + "  " + '"' + n.physicalpath + '"';
                            AppendToLog(string.Format("Args:{0}", p.StartInfo.Arguments));
                            if (ad.action.name != Customaction.CONFIG_EDIT)
                            {
                                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                            }
                            p.Start();
                            if (ad.action.wfe)
                            {
                                p.WaitForExit();
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppendToLog("Exception:" + ex.Message);
                errormsg = ex.Message;
                throw;
            }
        }