static void Main(string[] args)
        {
            bError = false;
            int   iCnt      = 0;
            short iSheetCnt = 0;

            Console.WriteLine("Installer Begins.");
            string sCmdLine = "";


            string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);



            try
            {
                string sQuote = "\"";

                sHost   = args[0];
                sUnid   = args[1];
                sUnid   = sUnid.Trim();
                sEmail  = args[2];
                sTarget = args[3];


                sTarget = sTarget.Replace(sQuote, "");

                sTarget = sTarget.Replace("$", "");

                if (sTarget.Trim().EndsWith(@"\"))
                {
                }
                else
                {
                    sTarget += @"\";
                }
            }

            catch (Exception ex)
            {
                sHost = @"http://ccisupportsite.com";
                //      sTarget = @"c:\As400da\";
                //       sUnid = "4621E8E7157912B185257829006ECFC0";
                //      sEmail = "*****@*****.**";
                Console.WriteLine("Error - Parameter Signature Invalid " + ex.Message);
                // throw ex;

                // fix the install directory
                if (!Directory.Exists(sTarget))
                {
                    iCnt = 0;
                    bool bValid = false;
                    while (iCnt <= 2 && !bValid)
                    {
                        Console.WriteLine("Problem with Target Location");
                        Console.WriteLine("The target {0} cannot be Validated Please Reenter:", sTarget);
                        sTarget = Console.ReadLine();
                        Console.WriteLine("");
                        sTarget = sTarget.Trim();
                        iCnt   += 1;

                        if (Directory.Exists(sTarget))
                        {
                            bValid = true;
                        }
                    }
                    if (iCnt > 2 && !bValid)
                    {
                        bError = true;
                    }
                }


                // fix the email address

                Console.WriteLine("Problem with Email Address");
                Console.WriteLine("The email address {0} cannot be Validated Please Reenter:", sEmail);
                sEmail = Console.ReadLine();
                Console.WriteLine("");
                sEmail = sEmail.Trim();
            }



setParms:



            iBatchCl = -999;
            // Lets Id the box
            PcId pc = new PcId(sUnid, sTarget, sEmail);

            pc.sEmail = sEmail;

            if (bError)
            {
                goto Done;
            }


            // 21 Jan 2011 - Added support for godaddy webservice and Id on box
            try
            {
                if (sEmail.Contains(@"cookconsulting.net"))
                {
                    goto Next;
                }

                //if (pc.ChkInstall(sUnid)  == "stop"  )
                //{
                //    Console.WriteLine("This install is terminated - This license code has been previously installed");
                //    bError = true;
                //    goto Done;
                //}


Next:


                pc.LogEvent();
                iBatchCl = pc.IBatchNo;
                bWebLog  = true;
                if (iBatchCl == -1)
                {
                    // logging is not available
                    bWebLog = false;
                    pc.CreateLogFile(sTarget);
                }
            }
            catch (Exception ex)
            {
                bWebLog = false;
                pc.CreateLogFile(sTarget);
            }

            //sUnid = sUnid.Trim();

            while (iCnt <= 2 && sUnid.Length != 32)
            {
                Console.Write("Problem with the Customer License Code Check your Cut and Past");
                Console.Write("The unid {0} cannot be Validated Please Reenter:", sUnid);
                sUnid = Console.ReadLine();
                Console.WriteLine("");
                sUnid = sUnid.Trim();
                iCnt += 1;
            }
            if (sUnid.Length != 32)
            {
                Console.WriteLine("The unid {0} cannot be Validated.", sUnid);
                bError = true;
                goto Done;
            }

            Console.WriteLine("Installer is running Batch ID -> {0} for UNID -> {1}.", iBatchCl, sUnid);


            ArrayList nProd = new ArrayList();

            //if (args.GetUpperBound(0) > 0)
            //    sUnid = args[0];

            // make sure our work directory exists

            FileInfo fi;

            try
            {
                if (!Directory.Exists(sTarget))
                {
                    Directory.CreateDirectory(sTarget);
                }
            }
            catch (Exception ex) { }



            try
            {
                fi            = new FileInfo(sTarget + @"Products.xml");
                fi.IsReadOnly = false;
                File.Delete(sTarget + @"Products.xml");
            }
            catch { }


            try
            {
                fi            = new FileInfo(sTarget + @"Cust.xml");
                fi.IsReadOnly = false;
                File.Delete(sTarget + @"Cust.xml");
            }
            catch { }



            try
            {
                string sFileName = "";
                sFileName = sHost + @"/Xml/Products.xml";


                DownLoadASheet(sFileName, sTarget + @"Products.Xml");



                if (bWebLog)
                {
                    pc.LogEvent(sUnid, "File Download Complete on "
                                + sTarget + @"Products.Xml", 0, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, "File Download Complete on "
                               + sTarget + @"Products.Xml", 0, pc.IBatchNo);
                }


                Partial.WSCustomer.GetCustomersPartialService gcp = new Partial.WSCustomer.GetCustomersPartialService();
                NetworkCredential cc = new NetworkCredential(@"mmoen", @"bobbob1", "");
                gcp.Credentials = cc;
                string sXmlOut = gcp.GETCUSTOMERSPARTIAL("changeor.nsf", "XMLOUTPUT", sUnid);



                try
                {
                    fi            = new FileInfo(sTarget + @"Cust.xml");
                    fi.IsReadOnly = false;
                    File.Delete(sTarget + @"Cust.xml");
                }
                catch { }

                StreamWriter swcust   = new StreamWriter(sTarget + @"Cust.Xml", false);
                string       sProcxml = pc.PackXml(sXmlOut, sUnid);
                swcust.Write(sProcxml);

                swcust.Close();
                swcust.Dispose();


                if (bWebLog)
                {
                    pc.LogEvent(sUnid, "File Download Complete on "
                                + sTarget + @"Cust.Xml", 0, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, "File Download Complete on "
                               + sTarget + @"Cust.Xml", 0, pc.IBatchNo);
                }
            }
            catch (Exception ex)
            {
                bError = bError || true;

                if (bWebLog)
                {
                    pc.LogEvent(sUnid, ex.Message + " - Program Abort", -1, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, ex.Message + " - Program Abort", -1, pc.IBatchNo);
                }

                if (bWebLog)
                {
                    pc.LogEvent(sUnid, ex.Message + "Program Abort", 11000, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, ex.Message + "Program Abort", 11000, pc.IBatchNo);
                }

                // test
                try
                {
                    pc.Close();
                }
                catch { }

                Console.WriteLine("Program Stopping - " + ex.Message);
                goto Done;
            }


            fi = new FileInfo(sTarget + @"\Products.Xml");
            if (File.Exists(sTarget + @"\Products.Xml") && fi.Length == 0)
            {
                if (bWebLog)
                {
                    pc.LogEvent(sUnid, "Products File did not Download", -1, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, "Products File did not Download", -1, pc.IBatchNo);
                }

                bError = bError || true;

                goto Done;
            }

            fi = new FileInfo(sTarget + @"\Cust.Xml");

            if (File.Exists(sTarget + @"\Cust.Xml") && fi.Length == 0)
            {
                if (bWebLog)
                {
                    pc.LogEvent(sUnid, "Customer File did not Download", -1, pc.IBatchNo);
                }
                else
                {
                    pc.FileLog(sUnid, "Customer File did not Download", -1, pc.IBatchNo);
                }
                bError = bError || true;

                goto Done;
            }

            if (bWebLog)
            {
                pc.LogEvent(sUnid, "File Download Complete ", 0, pc.IBatchNo);
            }
            else
            {
                pc.FileLog(sUnid, "File Download Complete ", 0, pc.IBatchNo);
            }
            // Process the xmlDoc

            XmlDocument xmldoc         = new XmlDocument();
            XmlDocument xmldocProducts = new XmlDocument();

            xmldocProducts.Load(sTarget + @"\Products.Xml");


            System.Text.UTF8Encoding str = new System.Text.UTF8Encoding();

            string       sContents;
            StreamReader sr = new StreamReader(sTarget + @"\Cust.Xml");

            sContents = sr.ReadToEnd();

            sr.Close();
            sr.Dispose();



            xmldoc.Load(sTarget + @"\Cust.Xml");

            NameValueCollection nMethods = new NameValueCollection();
            //       LoadMethods(ref nMethods, xmldocMethods);

            //  Call the Config Clas
            DocDetails dt = new DocDetails(xmldocProducts);

            dt.SetProducts(nProd);

            NameValueCollection nParms = new NameValueCollection();

            XmlNode root;

            root = xmldoc.DocumentElement;

            XmlNodeList nodes;


            //  nodes = root.SelectNodes("Customer/Parms[@Sheet='Y']");
            nodes = root.SelectNodes("Customer/Parms");
            // Build all the nodes, mark which are sheets, which are parms.
            // Match it by queryand and sheet to determine the parms.

            string sQryP = "", sQry = "";

            foreach (XmlNode n in nodes)
            {
                if (n.Name == "Parms")
                {
                }



                foreach (XmlAttribute att in n.Attributes)
                {
                    Debug.Print("att value={0} Attribute Name{1}", att.Value, att.Name);

                    if (att.Name == "Product" && att.Value == "Y")
                    {
                        iSheetCnt += 1;


                        try
                        {
                            if (sQry == "")
                            {
                                sQry = n.Attributes["queryend"].Value;
                            }
                        }
                        catch (Exception ex)
                        { }


                        Debug.Print("Got a Product{0}", n.Attributes["Value"].Value);

                        //     string sRemoteName = "http://localhost/sheets/" + n.Attributes["Value"].Value + ".xls";
                        //     string sLocalName = @"C:\cci\" + n.Attributes["Value"].Value + ".xls";
                        try
                        {
                            char[]   delimiterChars = { ',' };
                            string[] sqrysplit;
                            //try
                            //{
                            //     sQry = nParms.Get("queryend").ToString();
                            //    sqrysplit = sQry.Split(delimiterChars);
                            //    sQry = sqrysplit[0];

                            //   // try the queryend
                            //    try
                            //    {


                            //            sQry = n.Attributes["queryend"].Value;



                            //    }
                            //    catch (Exception ex)
                            //    { }


                            //}
                            //catch (Exception ex)
                            //{
                            //    sQry = @"070110";
                            //}
                            string sQueryEnd;
                            // logic is there is a node queryend attribute use it
                            // else use the file queryend

                            if (sQry == "")
                            {
                                sQueryEnd = sQryP;
                            }
                            else
                            {
                                sQueryEnd = sQry;
                            }



                            NameValueCollection tParms = FindParmSet(n.Attributes["Value"].Value, sQueryEnd, dt.cSheetColl, nParms);
                            string sFile       = FindLiveFile(n.Attributes["Value"].Value, sQueryEnd, dt.cSheetColl);
                            string sRemoteName = sHost + @"/sheets/version/" + sQry + @"/" + HttpUtility.UrlPathEncode(sFile);
                            string sLocalName  = sTarget + sFile;

                            if (bWebLog)
                            {
                                pc.LogEvent(sUnid, "Downloading Sheet " + sRemoteName, 0, pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(sUnid, "Downloading Sheet " + sRemoteName, 0, pc.IBatchNo);
                            }

                            sCurrentFile = sRemoteName;
                            iDotCount    = 0;

                            if (File.Exists(sLocalName))
                            {
                                FileInfo fi2 = new FileInfo(sLocalName);
                                fi2.IsReadOnly = false;
                                fi2.Delete();
                            }

                            DownLoadASheet(sRemoteName, sLocalName);

                            if (bWebLog)
                            {
                                pc.LogEvent(sUnid, "Download Complete Sheet " + sRemoteName, 0, pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(sUnid, "Download Complete Sheet " + sRemoteName, 0, pc.IBatchNo);
                            }

                            //    Call Configure on it!
                            //       ConfigureASheet(sLocalName, ref  dt.cSheetColl, n.Value, sQry, nParms, dt);


                            bool bProcess = false;

                            fi = new FileInfo(sLocalName);



                            if (File.Exists(sLocalName) && fi.Length > 0)
                            {
                                try
                                {
                                    // inc the logger
                                    iLogCount += 1;

                                    if (!pc.bCust)
                                    {
                                        pc.LogEvent(sUnid, "", 10000, pc.IBatchNo);
                                        pc.bCust = true;
                                    }
                                    if (bWebLog)
                                    {
                                        pc.LogEvent(sUnid, "Trying to configure " + sLocalName, 0, pc.IBatchNo);
                                    }
                                    else
                                    {
                                        pc.FileLog(sUnid, "Trying to configure " + sLocalName, 0, pc.IBatchNo);
                                    }


                                    ConfigureASheet(sLocalName, ref dt.cSheetColl, n.Attributes["Value"].Value, sQueryEnd, tParms, dt, ref pc);

                                    if (bWebLog)
                                    {
                                        pc.LogEvent(sUnid, "Configuring " + sLocalName, 0, pc.IBatchNo);
                                    }
                                    else
                                    {
                                        pc.FileLog(sUnid, "Configuring " + sLocalName, 0, pc.IBatchNo);
                                    }



                                    sQry = "";
                                }

                                catch (Exception ex)
                                {
                                    bError = bError || true;

                                    pc.LogEvent(sUnid, ex.Message + " - Configuring Sheet Fails", -1, pc.IBatchNo);
                                }
                            }
                            else
                            {
                                fi.Delete();
                            }
                            break;
                        }
                        catch (Exception ex)
                        {
                            bError = bError || true;

                            if (bWebLog)
                            {
                                pc.LogEvent(sUnid, ex.Message + " - Downloading Sheet", -1, pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(sUnid, ex.Message + " - Downloading Sheet", -1, pc.IBatchNo);
                            }

                            Console.WriteLine("Error - " + ex.Message);
                        }
                    }
                    else
                    { // it is not a sheet
                        try
                        {
                            if (nParms.Get(n.Attributes["LkeyName"].Value) != null)
                            {//skip it
                                string sKeyName = n.Attributes["LkeyName"].Value;
                                if (sKeyName == "queryend")
                                {
                                    sQryP = n.Attributes["Value"].Value;
                                }

                                string sKeyValue   = n.Attributes["Value"].Value;
                                string sCurrentVal = nParms.Get(n.Attributes["LkeyName"].Value);
                                Debug.Print("Atrib {0} ", n.Attributes["Value"].Value);
                                //       if (sKeyValue == sCurrentVal) goto Lp1;
                                switch (sKeyName)
                                {
                                //salariedcodes
                                //salariedwithsupp
                                //certifiedcodes
                                //princodes
                                //suppcodes


                                case "suppcodes":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "princodes":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "certifiedcodes":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "salariedwithsupp":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "salariedcodes":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "otherdepts":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "budgetind":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "specialind":
                                    nParms.Remove(n.Attributes["LkeyName"].Value);
                                    nParms.Add(n.Attributes["LkeyName"].Value
                                               , sCurrentVal
                                               + "," + sKeyValue);
                                    break;

                                case "username":
                                    pc.setUser(n.Attributes["Value"].Value);
                                    break;

                                case "customername":
                                    pc.setCust(n.Attributes["Value"].Value);
                                    break;

                                default:
                                    break;
                                }
                                goto Lp1;
                            }

                            else
                            {
                                nParms.Add(n.Attributes["LkeyName"].Value, n.Attributes["Value"].Value);
                            }
                        }
                        catch (ArgumentOutOfRangeException ex)
                        { // is missing
                        }
                        catch
                        { }
                    }

                    Lp1 :;
                }
                ;
            }

            // Calling Configuration Class
            //  dt = new DocDetails(xmldocProducts );
            //  dt.SetProducts(nProd);
            //   dt.CallBudgetMethod(new sTheProducts());
            if (bWebLog)
            {
                pc.LogEvent(sUnid, "Processing Completed", 0, pc.IBatchNo);
            }
            else
            {
                pc.FileLog(sUnid, "Processing Completed", 0, pc.IBatchNo);
            }
            pc.Close();

            FileInfo
                fi1 = new FileInfo(sTarget + "Cust.xml");

            fi1.Delete();
            fi1 = new FileInfo(sTarget + "Products.xml");
            fi1.Delete();


Done:
            if (iSheetCnt == 0)
            {
                bError = true;
                Console.WriteLine("No Sheets were retrieved from WebService - Check Domino Sheet Selections");
            }

            if (bError)
            {
                Console.WriteLine("An Install Error has Occurred! Please Contact Support desk @ 800 425 0720 or email [email protected]");
                Console.WriteLine("Please note the following information Batch ID -> {0} and UNID -> {1}.", iBatchCl, sUnid);
                Console.WriteLine("Press Enter key to continue.");
                Console.ReadLine();
            }

            if (!bError)
            {
                try
                {
                    Partial.WSPartials.RemovePartialFlagsService rp = new Partial.WSPartials.RemovePartialFlagsService();
                    NetworkCredential cc = new NetworkCredential(@"mmoen", @"bobbob1", "");
                    rp.Credentials = cc;
                    if (!sEmail.Contains(@"*****@*****.**"))
                    {
                        rp.REMOVEPARTIALFLAGS("Changeor.nsf", "XMLOUTPUT", sUnid);
                    }
                }
                catch { }
            }

            Console.WriteLine("Installer Processing Completed!");

            if (bWebLog)
            {
                pc.LogEvent(sUnid, " Installer Closing", 11000, pc.IBatchNo);
            }
            else
            {
                pc.FileLog(sUnid, " Installer Closing", 11000, pc.IBatchNo);
            }
            return;
        }
        private static void ConfigureASheet(
            string sLocalName
            , ref ArrayList allProducts
            , string sProductName
            , string sQueryEnd
            , NameValueCollection nParms
            , DocDetails dt
            , ref PcId pc
            )
        {
            /*
             * Sub to Call config on the Sheet with the Method
             *
             *
             */
            try
            {
                foreach (object o in allProducts)
                {
                    Products pd = (Products)o;
                    if (
                        //pd.sProduct == sProductName && pd.sQueryEnd == sQueryEnd
                        pd.sProduct.Trim() == sProductName.Trim() && pd.sQueryEnd.Trim() == sQueryEnd.Trim()

                        )
                    {  // Got It
                        // Marshall the Parms
                        try
                        {
                            pc.LogEvent(sUnid
                                        , "At dt.CallXlConfigure for " + sLocalName
                                        , 0
                                        , pc.IBatchNo);
                            dt.sTarget = sTarget;
                            dt.CallXlConfigure(pd, sLocalName, nParms, sQueryEnd);
                        }
                        catch (Exception ex)
                        {
                            if (bWebLog)
                            {
                                pc.LogEvent(sUnid
                                            , ex.Message + "Results from Configure on  " + sLocalName
                                            , -1
                                            , pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(sUnid
                                           , ex.Message + "Results from Configure on  " + sLocalName
                                           , -1
                                           , pc.IBatchNo);
                            }
                        }
                        finally
                        {
                            FileInfo fi = new FileInfo(sLocalName);

                            fi.IsReadOnly = false;

                            fi.Delete();

                            // 26 July 2011
                            // added for repeated installs
                            // MM

                            if (File.Exists(sLocalName))
                            {
                                throw new IOException();
                            }

                            if (bWebLog)
                            {
                                pc.LogEvent(sUnid
                                            , "Success Results w/Delete from Configure on  " + sLocalName
                                            , 0
                                            , pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(sUnid
                                           , "Success Results w/Delete from Configure on  " + sLocalName
                                           , 0
                                           , pc.IBatchNo);
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        private static void Main(string[] args)
        {
            DownloadInstall.bError = false;
            int   num1 = 0;
            short num2 = 0;

            Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            Console.WriteLine("Installer Begins. {0}", (object)Assembly.GetExecutingAssembly().GetName().Version);
            string fullName = Assembly.GetExecutingAssembly().FullName;

            try
            {
                string oldValue = "\"";
                DownloadInstall.sHost   = args[0];
                DownloadInstall.sUnid   = args[1];
                DownloadInstall.sUnid   = DownloadInstall.sUnid.Trim();
                DownloadInstall.sEmail  = args[2];
                DownloadInstall.sTarget = args[3];
                DownloadInstall.sTarget = DownloadInstall.sTarget.Replace(oldValue, "");
                DownloadInstall.sTarget = DownloadInstall.sTarget.Replace("$", "");
                if (!DownloadInstall.sTarget.Trim().EndsWith("\\"))
                {
                    DownloadInstall.sTarget += "\\";
                }
            }
            catch (Exception ex)
            {
                DownloadInstall.sHost = "http://ccisupportsite.com";
                Console.WriteLine("Error - Parameter Signature Invalid " + ex.Message);
                if (!Directory.Exists(DownloadInstall.sTarget))
                {
                    num1 = 0;
                    bool flag = false;
                    while (num1 <= 2 && !flag)
                    {
                        Console.WriteLine("Problem with Target Location");
                        Console.WriteLine("The target {0} cannot be Validated Please Reenter:", (object)DownloadInstall.sTarget);
                        DownloadInstall.sTarget = Console.ReadLine();
                        Console.WriteLine("");
                        DownloadInstall.sTarget = DownloadInstall.sTarget.Trim();
                        ++num1;
                        if (Directory.Exists(DownloadInstall.sTarget))
                        {
                            flag = true;
                        }
                    }
                    if (num1 > 2 && !flag)
                    {
                        DownloadInstall.bError = true;
                    }
                }
                Console.WriteLine("Problem with Email Address");
                Console.WriteLine("The email address {0} cannot be Validated Please Reenter:", (object)DownloadInstall.sEmail);
                DownloadInstall.sEmail = Console.ReadLine();
                Console.WriteLine("");
                DownloadInstall.sEmail = DownloadInstall.sEmail.Trim();
            }
            DownloadInstall.iBatchCl = -999;
            PcId pc = new PcId(DownloadInstall.sUnid, DownloadInstall.sTarget, DownloadInstall.sEmail);

            pc.sEmail = DownloadInstall.sEmail;
            if (!DownloadInstall.bError)
            {
                try
                {
                    DownloadInstall.sEmail.Contains("cookconsulting.net");
                    pc.LogEvent();
                    DownloadInstall.iBatchCl = pc.IBatchNo;
                    DownloadInstall.bWebLog  = true;
                    if (DownloadInstall.iBatchCl == -1)
                    {
                        DownloadInstall.bWebLog = false;
                        pc.CreateLogFile(DownloadInstall.sTarget);
                    }
                }
                catch (Exception ex)
                {
                    DownloadInstall.bWebLog = false;
                    pc.CreateLogFile(DownloadInstall.sTarget);
                }
                pc.LogEvent(DownloadInstall.sUnid, "Installer is running Batch ID -> " + pc.IBatchNo.ToString() + " for UNID -> " + DownloadInstall.sUnid, 0, pc.IBatchNo);
                pc.LogEvent(DownloadInstall.sUnid, "Assembly Name is " + fullName, 0, pc.IBatchNo);
                for (; num1 <= 2 && DownloadInstall.sUnid.Length != 32; ++num1)
                {
                    Console.Write("Problem with the Customer License Code Check your Cut and Past");
                    Console.Write("The unid {0} cannot be Validated Please Reenter:", (object)DownloadInstall.sUnid);
                    DownloadInstall.sUnid = Console.ReadLine();
                    Console.WriteLine("");
                    DownloadInstall.sUnid = DownloadInstall.sUnid.Trim();
                }
                if (DownloadInstall.sUnid.Length != 32)
                {
                    Console.WriteLine("The unid {0} cannot be Validated.", (object)DownloadInstall.sUnid);
                    DownloadInstall.bError = true;
                }
                else
                {
                    Console.WriteLine("Installer is running Batch ID -> {0} for UNID -> {1}.", (object)DownloadInstall.iBatchCl, (object)DownloadInstall.sUnid);
                    ArrayList inProds = new ArrayList();
                    try
                    {
                        if (!Directory.Exists(DownloadInstall.sTarget))
                        {
                            Directory.CreateDirectory(DownloadInstall.sTarget);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    try
                    {
                        new FileInfo(DownloadInstall.sTarget + "Products.xml").IsReadOnly = false;
                        System.IO.File.Delete(DownloadInstall.sTarget + "Products.xml");
                    }
                    catch
                    {
                    }
                    try
                    {
                        new FileInfo(DownloadInstall.sTarget + "Cust.xml").IsReadOnly = false;
                        System.IO.File.Delete(DownloadInstall.sTarget + "Cust.xml");
                    }
                    catch
                    {
                    }
                    try
                    {
                        DownloadInstall.DownLoadASheet(DownloadInstall.sHost + "/Xml/Products.xml", DownloadInstall.sTarget + "Products.Xml");
                        if (DownloadInstall.bWebLog)
                        {
                            pc.LogEvent(DownloadInstall.sUnid, "File Download Complete on " + DownloadInstall.sTarget + "Products.Xml", 0, pc.IBatchNo);
                        }
                        else
                        {
                            pc.FileLog(DownloadInstall.sUnid, "File Download Complete on " + DownloadInstall.sTarget + "Products.Xml", 0, pc.IBatchNo);
                        }
                        GetCustomersPartialService customersPartialService = new GetCustomersPartialService();
                        NetworkCredential          networkCredential       = new NetworkCredential("mmoen", "bobbob1", "");
                        customersPartialService.Credentials = (ICredentials)networkCredential;
                        string sXml = customersPartialService.GETCUSTOMERSPARTIAL("changeor.nsf", "XMLOUTPUT", DownloadInstall.sUnid);
                        try
                        {
                            new FileInfo(DownloadInstall.sTarget + "Cust.xml").IsReadOnly = false;
                            System.IO.File.Delete(DownloadInstall.sTarget + "Cust.xml");
                        }
                        catch
                        {
                        }
                        StreamWriter streamWriter = new StreamWriter(DownloadInstall.sTarget + "Cust.Xml", false);
                        string       str          = pc.PackXml(sXml, DownloadInstall.sUnid);
                        streamWriter.Write(str);
                        streamWriter.Close();
                        streamWriter.Dispose();
                        if (DownloadInstall.bWebLog)
                        {
                            pc.LogEvent(DownloadInstall.sUnid, "File Download Complete on " + DownloadInstall.sTarget + "Cust.Xml", 0, pc.IBatchNo);
                        }
                        else
                        {
                            pc.FileLog(DownloadInstall.sUnid, "File Download Complete on " + DownloadInstall.sTarget + "Cust.Xml", 0, pc.IBatchNo);
                        }
                    }
                    catch (Exception ex)
                    {
                        int num3 = DownloadInstall.bError ? 1 : 0;
                        DownloadInstall.bError = true;
                        if (DownloadInstall.bWebLog)
                        {
                            pc.LogEvent(DownloadInstall.sUnid, ex.Message + " - Program Abort", -1, pc.IBatchNo);
                        }
                        else
                        {
                            pc.FileLog(DownloadInstall.sUnid, ex.Message + " - Program Abort", -1, pc.IBatchNo);
                        }
                        if (DownloadInstall.bWebLog)
                        {
                            pc.LogEvent(DownloadInstall.sUnid, ex.Message + "Program Abort", 11000, pc.IBatchNo);
                        }
                        else
                        {
                            pc.FileLog(DownloadInstall.sUnid, ex.Message + "Program Abort", 11000, pc.IBatchNo);
                        }
                        try
                        {
                            pc.Close();
                        }
                        catch
                        {
                        }
                        Console.WriteLine("Program Stopping - " + ex.Message);
                        goto label_133;
                    }
                    FileInfo fileInfo1 = new FileInfo(DownloadInstall.sTarget + "\\Products.Xml");
                    if (System.IO.File.Exists(DownloadInstall.sTarget + "\\Products.Xml") && fileInfo1.Length == 0L)
                    {
                        if (DownloadInstall.bWebLog)
                        {
                            pc.LogEvent(DownloadInstall.sUnid, "Products File did not Download", -1, pc.IBatchNo);
                        }
                        else
                        {
                            pc.FileLog(DownloadInstall.sUnid, "Products File did not Download", -1, pc.IBatchNo);
                        }
                        int num3 = DownloadInstall.bError ? 1 : 0;
                        DownloadInstall.bError = true;
                    }
                    else
                    {
                        FileInfo fileInfo2 = new FileInfo(DownloadInstall.sTarget + "\\Cust.Xml");
                        if (System.IO.File.Exists(DownloadInstall.sTarget + "\\Cust.Xml") && fileInfo2.Length == 0L)
                        {
                            if (DownloadInstall.bWebLog)
                            {
                                pc.LogEvent(DownloadInstall.sUnid, "Customer File did not Download", -1, pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(DownloadInstall.sUnid, "Customer File did not Download", -1, pc.IBatchNo);
                            }
                            int num3 = DownloadInstall.bError ? 1 : 0;
                            DownloadInstall.bError = true;
                        }
                        else
                        {
                            if (DownloadInstall.bWebLog)
                            {
                                pc.LogEvent(DownloadInstall.sUnid, "File Download Complete ", 0, pc.IBatchNo);
                            }
                            else
                            {
                                pc.FileLog(DownloadInstall.sUnid, "File Download Complete ", 0, pc.IBatchNo);
                            }
                            XmlDocument xmlDocument = new XmlDocument();
                            XmlDocument xmlprod     = new XmlDocument();
                            xmlprod.Load(DownloadInstall.sTarget + "\\Products.Xml");
                            UTF8Encoding utF8Encoding = new UTF8Encoding();
                            StreamReader streamReader = new StreamReader(DownloadInstall.sTarget + "\\Cust.Xml");
                            streamReader.ReadToEnd();
                            streamReader.Close();
                            streamReader.Dispose();
                            xmlDocument.Load(DownloadInstall.sTarget + "\\Cust.Xml");
                            NameValueCollection nameValueCollection = new NameValueCollection();
                            DocDetails          dt = new DocDetails(xmlprod);
                            dt.SetProducts(inProds);
                            NameValueCollection nVals       = new NameValueCollection();
                            XmlNodeList         xmlNodeList = xmlDocument.DocumentElement.SelectNodes("Customer/Parms");
                            string str1 = "";
                            foreach (XmlNode xmlNode in xmlNodeList)
                            {
                                if (xmlNode.Name == "Parms")
                                {
                                    try
                                    {
                                        if (str1 == "")
                                        {
                                            str1 = xmlNode.Attributes["queryend"].Value;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                foreach (XmlAttribute attribute in (XmlNamedNodeMap)xmlNode.Attributes)
                                {
                                    if (attribute.Name == "Product")
                                    {
                                        if (attribute.Value == "Y")
                                        {
                                            ++num2;
                                            try
                                            {
                                                if (str1 == "")
                                                {
                                                    str1 = xmlNode.Attributes["queryend"].Value;
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                            try
                                            {
                                                string sQueryEnd            = str1;
                                                NameValueCollection parmSet = DownloadInstall.FindParmSet(xmlNode.Attributes["Value"].Value, sQueryEnd, dt.cSheetColl, nVals);
                                                string liveFile             = DownloadInstall.FindLiveFile(xmlNode.Attributes["Value"].Value, sQueryEnd, dt.cSheetColl);
                                                string sAddr = DownloadInstall.sHost + "/sheets/version/" + str1 + "/" + HttpUtility.UrlPathEncode(liveFile);
                                                string str2  = DownloadInstall.sTarget + liveFile;
                                                if (DownloadInstall.bWebLog)
                                                {
                                                    pc.LogEvent(DownloadInstall.sUnid, "Downloading Sheet " + sAddr, 0, pc.IBatchNo);
                                                }
                                                else
                                                {
                                                    pc.FileLog(DownloadInstall.sUnid, "Downloading Sheet " + sAddr, 0, pc.IBatchNo);
                                                }
                                                DownloadInstall.sCurrentFile = sAddr;
                                                DownloadInstall.iDotCount    = 0;
                                                if (System.IO.File.Exists(str2))
                                                {
                                                    new FileInfo(str2)
                                                    {
                                                        IsReadOnly = false
                                                    }
                                                }
                                                .Delete();
                                                DownloadInstall.DownLoadASheet(sAddr, str2);
                                                if (DownloadInstall.bWebLog)
                                                {
                                                    pc.LogEvent(DownloadInstall.sUnid, "Download Complete Sheet " + sAddr, 0, pc.IBatchNo);
                                                }
                                                else
                                                {
                                                    pc.FileLog(DownloadInstall.sUnid, "Download Complete Sheet " + sAddr, 0, pc.IBatchNo);
                                                }
                                                FileInfo fileInfo3 = new FileInfo(str2);
                                                if (System.IO.File.Exists(str2))
                                                {
                                                    if (fileInfo3.Length > 0L)
                                                    {
                                                        try
                                                        {
                                                            ++DownloadInstall.iLogCount;
                                                            if (!pc.bCust)
                                                            {
                                                                pc.LogEvent(DownloadInstall.sUnid, "", 10000, pc.IBatchNo);
                                                                pc.bCust = true;
                                                            }
                                                            if (DownloadInstall.bWebLog)
                                                            {
                                                                pc.LogEvent(DownloadInstall.sUnid, "Trying to configure " + str2, 0, pc.IBatchNo);
                                                            }
                                                            else
                                                            {
                                                                pc.FileLog(DownloadInstall.sUnid, "Trying to configure " + str2, 0, pc.IBatchNo);
                                                            }
                                                            DownloadInstall.ConfigureASheet(str2, ref dt.cSheetColl, xmlNode.Attributes["Value"].Value, sQueryEnd, parmSet, dt, ref pc);
                                                            if (DownloadInstall.bWebLog)
                                                            {
                                                                pc.LogEvent(DownloadInstall.sUnid, "Configuring " + str2, 0, pc.IBatchNo);
                                                            }
                                                            else
                                                            {
                                                                pc.FileLog(DownloadInstall.sUnid, "Configuring " + str2, 0, pc.IBatchNo);
                                                            }
                                                            str1 = "";
                                                            break;
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            int num3 = DownloadInstall.bError ? 1 : 0;
                                                            DownloadInstall.bError = true;
                                                            pc.LogEvent(DownloadInstall.sUnid, ex.Message + " - Configuring Sheet Fails", -1, pc.IBatchNo);
                                                            break;
                                                        }
                                                    }
                                                }
                                                int num4 = DownloadInstall.bError ? 1 : 0;
                                                DownloadInstall.bError = true;
                                                pc.LogEvent(DownloadInstall.sUnid, str2 + " Fails to Download", -1, pc.IBatchNo);
                                                Console.WriteLine("Error - " + str2 + " Fails to Download");
                                                fileInfo3.Delete();
                                                break;
                                            }