Beispiel #1
0
        /// <include file='doc\MyWeb.uex' path='docs/doc[@for="MyWebManifest.Install1"]/*' />
        /// <devdoc>
        ///    <para>Marked internal for Beta 1 per ErikOls.</para>
        /// </devdoc>
        public MyWebApplication Install(String strLocation)
        {
            if (Installed)
            {
                return(null);
            }

            if (!MyWeb.IsAdminApp())
            {
                return(null);
            }

            if (strLocation != null)
            {
                _Properties[_InstalledLocation] = strLocation;
            }

            StringBuilder strError = new StringBuilder(1024);

            if (NativeMethods.MyWebInstallApp(CabFile,
                                              ApplicationUrl,
                                              InstalledLocation,
                                              ManifestFile,
                                              strError,
                                              1024) != 0)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Literal, strError.ToString()));
                //return null;
            }
            else
            {
                _Installed = true;
                return(new MyWebApplication(this));
            }
        }
Beispiel #2
0
        /// <include file='doc\MyWeb.uex' path='docs/doc[@for="MyWebApplication.Update"]/*' />
        /// <devdoc>
        ///    <para>Marked internal for Beta 1 per ErikOls.</para>
        /// </devdoc>
        public int Update()
        {
            if (!MyWeb.IsAdminApp())
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Operation_requires_url_to_be_myweb_home));
            }

            MyWebManifest manifest = MyWeb.GetManifest(Manifest.ApplicationUrl);

            if (manifest == null)
            {
                return(0);
            }

            StringBuilder strError = new StringBuilder(1024);
            int           iReturn  = 0;

            iReturn = NativeMethods.MyWebReInstallApp(manifest.CabFile,
                                                      manifest.ApplicationUrl,
                                                      manifest.InstalledLocation,
                                                      manifest.ManifestFile,
                                                      strError,
                                                      1024);

            if (iReturn != 0 && iReturn != 1)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Literal, strError.ToString()));
            }

            _Manifest = manifest;
            return(iReturn);
        }
Beispiel #3
0
        //////////////////////////////////////////////////////////////////////
        // Remove an app
        /// <include file='doc\MyWeb.uex' path='docs/doc[@for="MyWebManifest.Remove"]/*' />
        /// <devdoc>
        ///    <para>Marked internal for Beta 1 per ErikOls.</para>
        /// </devdoc>
        public int Remove()
        {
            int iReturn = 0;

            if (MyWeb.IsAdminApp())
            {
                iReturn    = NativeMethods.MyWebRemoveApp(ApplicationUrl);
                _Installed = false;
            }
            return(iReturn);
        }
Beispiel #4
0
        //////////////////////////////////////////////////////////////////////
        // Move an app
        /// <include file='doc\MyWeb.uex' path='docs/doc[@for="MyWebManifest.Move"]/*' />
        /// <devdoc>
        ///    <para>Marked internal for Beta 1 per ErikOls.</para>
        /// </devdoc>
        public int Move(String strNewLocation)
        {
            if (!MyWeb.IsAdminApp())
            {
                return(0);
            }

            int           iReturn  = 0;
            StringBuilder strError = new StringBuilder(1024);

            iReturn = NativeMethods.MyWebMoveApp(ApplicationUrl,
                                                 strNewLocation,
                                                 strError,
                                                 1024);
            if (iReturn != 0 && iReturn != 1)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Literal, strError.ToString()));
            }

            _Properties[_InstalledLocation] = strNewLocation;
            return(iReturn);
        }
Beispiel #5
0
        ////////////////////////////////////////////////////////////////////////
        // CTor: Create from an installed app
        internal MyWebApplication(int iIndex)
        {
            if (!MyWeb.IsAdminApp())
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Operation_requires_url_to_be_myweb_home));
            }

            StringBuilder strBFile = new StringBuilder(300);
            StringBuilder strBUrl  = new StringBuilder(1024);

            long [] pLongs = new long[3];

            if (NativeMethods.MyWebGetApplicationDetails(iIndex, strBFile, 300, strBUrl, 1024, pLongs) != 0)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Unable_to_create_app_object));
            }

            _Manifest         = MyWebManifest.CreateFromFile(strBFile.ToString() + "\\myweb.osd", strBUrl.ToString(), true, true);
            _InstalledDate    = DateTime.FromFileTime(pLongs[0]);
            _LastAccessDate   = DateTime.FromFileTime(pLongs[1]);
            _LocalApplication = (pLongs[2] != 0);
        }
Beispiel #6
0
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        // Private stuff

        //////////////////////////////////////////////////////////////////////
        // Create a manifest from a manifest file
        static internal MyWebManifest CreateFromFile(
            String strFile,
            String strUrl,
            bool installed,
            bool donotfail)
        {
            String []         strProperties = null;
            ConfigXmlDocument xmlDoc        = null;
            ConfigXmlCursor   cursor        = null;
            int           iter        = 0;
            int           iRet        = 0;
            StringBuilder strBuf      = new StringBuilder(1024);
            bool          fFound      = false;
            ArrayList     customUrls  = new ArrayList();
            ArrayList     customUrlDs = new ArrayList();
            String        strRandom   = System.Web.SessionState.SessionId.Create();

            ////////////////////////////////////////////////////////////
            // Step 1: Parse the file and get the other properties
            try {
                xmlDoc = new ConfigXmlDocument();
                xmlDoc.Load(strFile);
                cursor = xmlDoc.GetCursor();
                cursor.MoveToFirstChild();
            }
            catch (Exception e) {
                if (!donotfail)
                {
                    throw e;
                }
                cursor = null;
            }

            if (cursor != null)
            {
                do
                {
                    if (cursor.Type == ConfigXmlElement.Element && cursor.Name.ToLower(CultureInfo.InvariantCulture).Equals("softpkg"))
                    {
                        fFound = true;
                        break;
                    }
                }while (cursor.MoveNext());
            }

            if (!fFound && !donotfail)
            {
                return(null);
            }

            ////////////////////////////////////////////////////////////
            // Step 2: Get the non-manifest file properties
            strProperties = new String[NUM_PROPERTIES];
            for (iter = 0; iter < NUM_PROPERTIES; iter++)
            {
                strProperties[iter] = String.Empty;
            }

            strProperties[_ApplicationUrl] = strUrl.Replace('\\', '/');
            strProperties[_ManifestFile]   = strFile;

            if (!installed)
            {
                iRet = NativeMethods.MyWebGetInstallLocationForUrl(MyWeb.GetDefaultInstallLocation(),
                                                                   strUrl, strRandom, strBuf, 1024);

                if (iRet < 0)
                {
                    iRet   = -iRet + 100;
                    strBuf = new StringBuilder(iRet);
                    iRet   = NativeMethods.MyWebGetInstallLocationForUrl(MyWeb.GetDefaultInstallLocation(),
                                                                         strUrl, strRandom, strBuf, iRet);
                }
                if (iRet <= 0)
                {
                    throw new HttpException(HttpRuntime.FormatResourceString(SR.Unable_to_get_app_location));
                }

                strProperties[_InstalledLocation] = strBuf.ToString();
            }
            else
            {
                strProperties[_InstalledLocation] = strFile.Substring(0, strFile.LastIndexOf('\\'));
            }


            if (cursor == null && donotfail)
            {
                return(new MyWebManifest(strProperties, installed, new String[0], new String[0]));
            }

            strProperties[_Name]    = cursor.AttributeText("name");
            strProperties[_Version] = cursor.AttributeText("version");
            cursor.MoveToFirstChild();
            do
            {
                if (cursor.Type == ConfigXmlElement.Element)
                {
                    String strName = cursor.Name.ToLower(CultureInfo.InvariantCulture);

                    if (strName.Equals("implementation"))
                    {
                        strProperties[_CabFile] = GetCabFileNameFromCursor(cursor);
                    }
                    else if (strName.Equals("license"))
                    {
                        strProperties[_License] = cursor.AttributeText("href");
                    }
                    else if (strName.Equals("customurl"))
                    {
                        String strC = cursor.AttributeText("href");
                        String strD = cursor.AttributeText("description");
                        customUrls.Add(strC);
                        customUrlDs.Add(strD);
                    }
                    else
                    {
                        for (iter = 0; iter < _OtherProperties.Length; iter++)
                        {
                            if (strName.Equals(_OtherProperties[iter]))
                            {
                                strProperties[OTHER_PROP_START + iter] = GetCursorText(cursor);
                                break;
                            }
                        }
                    }
                }
            }while (cursor.MoveNext());

            return(new MyWebManifest(strProperties, installed, customUrls.ToArray(), customUrlDs.ToArray()));
        }