Example #1
0
 public ModuleInfo Parse(string script)
 {
     var alreadyModuleDef = Regex.Match(script, "^require.define\\(", RegexOptions.Singleline);
     var directiveHeader = Regex.Match(script, "^[\"'](.*)[\"'];\r?\n", RegexOptions.Singleline);
     if (alreadyModuleDef.Success || !directiveHeader.Success) return new ModuleInfo() { Content = script, Dependencies = new List<string>(), Packaged = true };
     var directives = directiveHeader.Groups[1].Value.Split(';');
     var moduleInfo = new ModuleInfo();
     foreach (var directive in directives)
     {
         var parts = directive.Split(':');
         var name = parts[0].Trim();
         var value = parts[1].Trim();
         if (name == "depends")
         {
             if (value.Length > 0)
                 moduleInfo.Dependencies.AddRange(value.Split(new char[] { ',' }).Select(v => v.Trim()));
         }
         if (name == "provides")
         {
             moduleInfo.Name = value;
         }
     }
     moduleInfo.Content = script.Substring(directiveHeader.Index + directiveHeader.Value.Length, script.Length - directiveHeader.Value.Length);
     return moduleInfo;
 }
Example #2
0
        public bool Add(ModuleInfo entity)
        {
            T_PF_MODULEINFO model = entity.CloneObject<T_PF_MODULEINFO>(new T_PF_MODULEINFO());
            model = Utility.CreateCommonProperty().CloneObject<T_PF_MODULEINFO>(model);

            return _commonDAL.Add(model);
        }
Example #3
0
 public static void ExtractAll(string path, string projectName)
 {
     if (!Directory.Exists(Path.Combine(path, "Projects")))
         Directory.CreateDirectory(Path.Combine(path, "Projects"));
     var module = new ModuleInfo { Name = projectName };
     module.Save(Path.Combine(path, "Module.xml"));
 }
Example #4
0
        /// <summary>
        /// Starts retrieving the <paramref name="moduleInfo"/> and calls the <paramref name="callback"/> when it is done.
        /// </summary>
        /// <param name="moduleInfo">Module that should have it's type loaded.</param>
        /// <param name="callback">Delegate to be called when typeloading process completes or fails.</param>
        public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
        {
            Uri uriRef = new Uri(moduleInfo.Ref, UriKind.RelativeOrAbsolute);
            lock (this.typeLoadingCallbacks)
            {
                ModuleTypeLoaderCallbackMetadata callbackMetadata = new ModuleTypeLoaderCallbackMetadata { Callback = callback, ModuleInfo = moduleInfo };

                List<ModuleTypeLoaderCallbackMetadata> callbacks;
                if (this.typeLoadingCallbacks.TryGetValue(uriRef, out callbacks))
                {
                    callbacks.Add(callbackMetadata);
                    return;
                }

                this.typeLoadingCallbacks[uriRef] = new List<ModuleTypeLoaderCallbackMetadata> { callbackMetadata };
            }

            IFileDownloader downloader = this.CreateDownloader();
            downloader.DownloadCompleted += this.OnDownloadCompleted;

            try
            {
                downloader.DownloadAsync(uriRef, uriRef);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Module download from failed : {0}", uriRef), ex);
            }
        }
Example #5
0
 public static void Open(ModuleInfo root, object obj, Action update)
 {
     var definitionInfo = obj as DefinitionInfo;
     var moduleInfo = obj as ModuleInfo;
     if (definitionInfo != null)
     {
         // Open XML in editor.
         Process.Start("monodevelop", definitionInfo.DefinitionPath);
     }
     if (moduleInfo != null)
     {
         // Start the module's Protobuild unless it's also our
         // module (for the root node).
         if (moduleInfo.Path != root.Path)
         {
             var info = new ProcessStartInfo
             {
                 FileName = System.IO.Path.Combine(moduleInfo.Path, "Protobuild.exe"),
                 WorkingDirectory = moduleInfo.Path
             };
             var p = Process.Start(info);
             p.EnableRaisingEvents = true;
             p.Exited += (object sender, EventArgs e) => update();
         }
     }
 }
Example #6
0
    //helper for simple devices
    public DeviceInfo(
		int id,		
		string deviceName,
		string spriteName,
		string promoterName,
		float productionMax,
		float terminatorFactor,
		string formula,
		string product,
		float rbs)
    {
        ModuleInfo moduleInfo = new ModuleInfo(
            "pLac",
            10.0f,
            1.0f,
            "![0.8,2]LacI",
            "GFP",
            1.0f
            );
        List<ModuleInfo> modules = new List<ModuleInfo>();
        modules.Add(moduleInfo);

        _id = id;
        _name = deviceName;
        _spriteName = spriteName;
        _modules = modules;
    }
Example #7
0
        public void update_list_closes_the_cycle_with_additional_module()
        {
            /*
             * Local:
             * A(v1) v1-> B(v1) v1 -> C(v1)
             *
             * Remote:
             * C(v2) v2-> D(v2) v0-> A(v1) from local
             *
             * Result: failure
             */

            ModuleInfo c1;
            ModuleInfo a1;
            ModuleInfo b1;

            PrepareChainWithVersion(_v1, out a1, out b1, out c1);

            ModuleInfo c2 = SetUpModuleInfoWithVersion("C", _v2,
                                                       new KeyValuePair<string, Version>("D", _v2));
            ModuleInfo d2 = SetUpModuleInfoWithVersion("D", _v2,
                                                       new KeyValuePair<string, Version>("A", _v0));

            Modules = new[] {a1, b1, c1};
            _updateModules = new[] {c2, d2};

            // FIXME:  should it be empty list ? or we should put what ?
            ExpectedModules = new ModuleInfo[] {};

            PerformTest();

            Assert.IsFalse(_resultBool);
            Assert.AreEqual(ExpectedModules, _resultNonValidModules);
        }
        public void load_modules_only_loads_modules_that_pass_filter()
        {
            var a = new ModuleInfo("a", _moduleManifestMock.Object);
            var b = new ModuleInfo("b", _moduleManifestMock.Object);

            var expectedModuleInfos = new[]
                                          {
                                              a, b
                                          };

            var discoveryMock = new Mock<IModuleDiscovery>(MockBehavior.Loose);
            discoveryMock.Setup(discovery => discovery.GetModules())
                .Returns(expectedModuleInfos);

            var filterMock = new Mock<IModuleFilter>(MockBehavior.Loose);
            filterMock.Setup(filter => filter.Matches(a))
                .Returns(true);
            filterMock.Setup(filter => filter.Matches(b))
                .Returns(false);

            var loaderMock = new Mock<IModuleLoader>(MockBehavior.Strict);
            loaderMock.Setup(x => x.GetLoadedModules()).Returns(new List<ModuleInfo>());
            loaderMock.Setup(loader => loader.LoadModule(a));

            var moduleManager = new ModuleManager(loaderMock.Object, filterMock.Object,
                                                  _dependencyMock.Object);

            moduleManager.LoadModules(discoveryMock.Object);

            loaderMock.Verify(x => x.LoadModule(a));
            loaderMock.Verify(x => x.LoadModule(It.IsAny<ModuleInfo>()), Times.Exactly(1));
        }
 private static void AddContent(XmlNode nodeModule, ModuleInfo objModule)
 {
     XmlAttribute xmlattr;
     if (!String.IsNullOrEmpty(objModule.DesktopModule.BusinessControllerClass) && objModule.DesktopModule.IsPortable)
     {
         try
         {
             object objObject = Framework.Reflection.CreateObject(objModule.DesktopModule.BusinessControllerClass, objModule.DesktopModule.BusinessControllerClass);
             if (objObject is IPortable)
             {
                 string Content = Convert.ToString(((IPortable)objObject).ExportModule(objModule.ModuleID));
                 if (!String.IsNullOrEmpty(Content))
                 {
                     XmlNode newnode = nodeModule.OwnerDocument.CreateElement("content");
                     xmlattr = nodeModule.OwnerDocument.CreateAttribute("type");
                     xmlattr.Value = Globals.CleanName(objModule.DesktopModule.ModuleName);
                     newnode.Attributes.Append(xmlattr);
                     xmlattr = nodeModule.OwnerDocument.CreateAttribute("version");
                     xmlattr.Value = objModule.DesktopModule.Version;
                     newnode.Attributes.Append(xmlattr);
                     Content = HttpContext.Current.Server.HtmlEncode(Content);
                     newnode.InnerXml = XmlUtils.XMLEncode(Content);
                     nodeModule.AppendChild(newnode);
                 }
             }
         }
         catch
         {
         }
     }
 }
 private static bool CanAddContentToPage(ModuleInfo objModule)
 {
     bool canManage = Null.NullBoolean;
     TabInfo objTab = new TabController().GetTab(objModule.TabID, objModule.PortalID, false);
     canManage = TabPermissionController.CanAddContentToPage(objTab);
     return canManage;
 }
Example #11
0
 /// <summary>Inherited</summary>
 public void LoadModule(ModuleInfo moduleInfo)
 {
     var assembly = LoadAssembly(moduleInfo);
     var bootstraper = CreateBootstraper(assembly);
     ExecuteOnLoad(bootstraper);
     RegisterModule(moduleInfo, bootstraper);
 }
Example #12
0
        /// <summary>
        /// Starts retrieving the <paramref name="moduleInfo"/> and calls the <paramref name="callback"/> when it is done.
        /// </summary>
        /// <param name="moduleInfo">Module that should have it's type loaded.</param>
        /// <param name="callback">Delegate to be called when typeloading process completes or fails.</param>
        public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
        {
            Uri uriRef = new Uri(moduleInfo.Ref, UriKind.RelativeOrAbsolute);
            lock (this.typeLoadingCallbacks)
            {
                ModuleTypeLoaderCallbackMetadata callbackMetadata = new ModuleTypeLoaderCallbackMetadata()
                                                                 {
                                                                     Callback = callback,
                                                                     ModuleInfo = moduleInfo
                                                                 };

                List<ModuleTypeLoaderCallbackMetadata> callbacks;
                if (this.typeLoadingCallbacks.TryGetValue(uriRef, out callbacks))
                {
                    callbacks.Add(callbackMetadata);
                    return;
                }

                this.typeLoadingCallbacks[uriRef] = new List<ModuleTypeLoaderCallbackMetadata> { callbackMetadata };
            }

            IFileDownloader downloader = this.CreateDownloader();
            downloader.DownloadCompleted += this.OnDownloadCompleted;

            downloader.DownloadAsync(uriRef, uriRef);
        }
 public ContextSecurity(ModuleInfo objModule)
 {
     UserId = UserController.Instance.GetCurrentUserInfo().UserID;
     CanView = ModulePermissionController.CanViewModule(objModule);
     CanEdit = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "EDIT");
     IsAdmin = PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName);
 }
Example #14
0
 /// <summary>
 /// Inherited.
 /// </summary>
 public ModuleManifest GetManifest(ModuleInfo moduleInfo)
 {
     var manifestPath = string.Format("{0}{1}", moduleInfo.AssemblyPath,
                                      ModuleManifest.ManifestFileNameSuffix);
     var manifest = File.ReadAllBytes(manifestPath);
     return
         XmlSerializerHelper.Deserialize<ModuleManifest>(manifest);
 }
Example #15
0
 public NativeModule(NativeRuntime runtime, ModuleInfo module)
 {
     _runtime = runtime;
     _name = string.IsNullOrEmpty(module.FileName) ? "" : Path.GetFileNameWithoutExtension(module.FileName);
     _filename = module.FileName;
     _imageBase = module.ImageBase;
     _size = module.FileSize;
 }
Example #16
0
 public RhModule(RhRuntime runtime, ModuleInfo module)
 {
     m_runtime = runtime;
     m_name = string.IsNullOrEmpty(module.FileName) ? "" : Path.GetFileNameWithoutExtension(module.FileName);
     m_filename = module.FileName;
     m_imageBase = module.ImageBase;
     m_size = module.FileSize;
 }
Example #17
0
 public string GetCommonJsModule(ModuleInfo moduleInfo)
 {
     return ModuleFormat
         .Replace("<name>", moduleInfo.Name)
         .Replace("<content>", moduleInfo.Content.Replace("\n", "\t\t\n"))
         .Replace("<dependencies>", moduleInfo.Dependencies.Count==0 ? "[]" :  string.Format("['{0}']", String.Join("','", moduleInfo.Dependencies)))
         .Replace("\t", indent);
 }
Example #18
0
 internal ProjectEntry(PythonAnalyzer state, string moduleName, string filePath, IAnalysisCookie cookie) {
     _projectState = state;
     _moduleName = moduleName ?? "";
     _filePath = filePath;
     _cookie = cookie;
     _myScope = new ModuleInfo(_moduleName, this, state.Interpreter.CreateModuleContext());
     _unit = new AnalysisUnit(_tree, _myScope.Scope);
     AnalysisLog.NewUnit(_unit);
 }
Example #19
0
        public new void ReadModuleInfo( BinaryReader BinaryStream, uint Count )
        {
            ModuleInfo = new ModuleInfo[Count];

            for( uint ModuleIndex = 0; ModuleIndex < Count; ModuleIndex++ )
            {
                ModuleInfo[ModuleIndex] = new ModuleInfo( BinaryStream );
            }
        }
Example #20
0
		public PEFilesSaver(SimpleProcessReader simpleProcessReader, Tuple<DnModule, string>[] files) {
			this.simpleProcessReader = simpleProcessReader;
			infos = new ModuleInfo[files.Length];
			for (int i = 0; i < files.Length; i++) {
				var module = files[i].Item1;
				infos[i] = new ModuleInfo(module.Process.CorProcess.Handle, module.Address, module.Size, files[i].Item2, !module.IsInMemory);
				maxProgress += 2;
			}
		}
Example #21
0
 public AppDataMap(bool languageCaseSensitive, AstNode programRoot = null) {
   LanguageCaseSensitive = languageCaseSensitive;
   ProgramRoot = programRoot?? new AstNode(); 
   var mainScopeInfo = new ScopeInfo(ProgramRoot, LanguageCaseSensitive); 
   StaticScopeInfos.Add(mainScopeInfo);
   mainScopeInfo.StaticIndex = 0;
   MainModule = new ModuleInfo("main", "main", mainScopeInfo);
   Modules.Add(MainModule);
 }
Example #22
0
 public BindingRequest(ScriptThread thread, AstNode fromNode, string symbol, BindingRequestFlags flags) {
   Thread = thread;
   FromNode = fromNode;
   FromModule = thread.App.DataMap.GetModule(fromNode.ModuleNode);
   Symbol = symbol;
   Flags = flags;
   FromScopeInfo = thread.CurrentScope.Info;
   IgnoreCase = !thread.Runtime.Language.Grammar.CaseSensitive;
 }
        /// <summary>
        /// Connects to database and adds modules details.
        /// </summary>
        /// <param name="objList">Object of ModuleInfo.</param>
        /// <param name="isAdmin">Set true if the module is admin.</param>
        /// <param name="PackageID">Package ID.</param>
        /// <param name="IsActive">Set true if the module is active.</param>
        /// <param name="AddedOn">Module added date.</param>
        /// <param name="PortalID">Portal ID.</param>
        /// <param name="AddedBy">Module added user's name.</param>
        /// <returns>Returns array of int containing 1: ModuleID and 2: ModuleDefID.</returns>
        public int[] AddModules(ModuleInfo objList, bool isAdmin, int PackageID, bool IsActive, DateTime AddedOn, int PortalID, string AddedBy)
        {
            string sp = "[dbo].[sp_ModulesAdd]";
            //SQLHandler sagesql = new SQLHandler();
            try
            {
                List<KeyValuePair<string, object>> ParamCollInput = new List<KeyValuePair<string, object>>();
                ParamCollInput.Add(new KeyValuePair<string, object>("@ModuleName", objList.ModuleName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Name", objList.Name));
                ParamCollInput.Add(new KeyValuePair<string, object>("@FriendlyName", objList.FriendlyName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Description", objList.Description));
                ParamCollInput.Add(new KeyValuePair<string, object>("@FolderName", objList.FolderName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Version", objList.Version));

                ParamCollInput.Add(new KeyValuePair<string, object>("@isPremium", objList.isPremium));
                ParamCollInput.Add(new KeyValuePair<string, object>("@isAdmin", isAdmin));


                ParamCollInput.Add(new KeyValuePair<string, object>("@Owner", objList.Owner));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Organization", objList.Organization));
                ParamCollInput.Add(new KeyValuePair<string, object>("@URL", objList.URL));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Email", objList.Email));
                ParamCollInput.Add(new KeyValuePair<string, object>("@ReleaseNotes", objList.ReleaseNotes));
                ParamCollInput.Add(new KeyValuePair<string, object>("@License", objList.License));
                ParamCollInput.Add(new KeyValuePair<string, object>("@PackageType", objList.PackageType));
                ParamCollInput.Add(new KeyValuePair<string, object>("@supportedFeatures", objList.supportedFeatures));
                ParamCollInput.Add(new KeyValuePair<string, object>("@BusinessControllerClass", objList.BusinessControllerClass));
                ParamCollInput.Add(new KeyValuePair<string, object>("@CompatibleVersions", objList.CompatibleVersions));
                ParamCollInput.Add(new KeyValuePair<string, object>("@dependencies", objList.dependencies));
                ParamCollInput.Add(new KeyValuePair<string, object>("@permissions", objList.permissions));

                ParamCollInput.Add(new KeyValuePair<string, object>("@PackageID", PackageID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@IsActive", IsActive));
                ParamCollInput.Add(new KeyValuePair<string, object>("@AddedOn", AddedOn));
                ParamCollInput.Add(new KeyValuePair<string, object>("@PortalID", PortalID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@AddedBy", AddedBy));

                List<KeyValuePair<string, object>> ParamCollOutput = new List<KeyValuePair<string, object>>();
                ParamCollOutput.Add(new KeyValuePair<string, object>("@ModuleID", objList.ModuleID));
                ParamCollOutput.Add(new KeyValuePair<string, object>("@ModuleDefID", objList.ModuleDefID));

                SageFrameSQLHelper sagesql = new SageFrameSQLHelper();

                List<KeyValuePair<int, string>> OutputValColl = new List<KeyValuePair<int, string>>();
                OutputValColl = sagesql.ExecuteNonQueryWithMultipleOutput(sp, ParamCollInput, ParamCollOutput);
                int[] arrOutPutValue = new int[2];
                arrOutPutValue[0] = int.Parse(OutputValColl[0].Value);
                arrOutPutValue[1] = int.Parse(OutputValColl[1].Value);

                return arrOutPutValue;

            }
            catch (Exception)
            {
                throw;
            }
        }
 public ModulePermissionCollection(ModuleInfo objModule)
 {
     foreach (ModulePermissionInfo permission in objModule.ModulePermissions)
     {
         if (permission.ModuleID == objModule.ModuleID)
         {
             Add(permission);
         }
     }
 }
Example #25
0
 private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
 {
     moduleInfo = (sender as HyperlinkButton).DataContext as ModuleInfo;
     if (moduleInfo == null)
     {
         return;
     }
     loadbar.Start();
     ayTools.BeginRun();            
 }
Example #26
0
        /// <summary>
        /// Evaluates the <see cref="ModuleInfo.Ref"/> property to see if the current typeloader will be able to retrieve the <paramref name="moduleInfo"/>.
        /// </summary>
        /// <param name="moduleInfo">Module that should have it's type loaded.</param>
        /// <returns><see langword="true"/> if the current typeloader is able to retrieve the module, otherwise <see langword="false"/>.</returns>
        public bool CanLoadModuleType(ModuleInfo moduleInfo)
        {
            if (!string.IsNullOrEmpty(moduleInfo.Ref))
            {
                Uri uriRef;
                return Uri.TryCreate(moduleInfo.Ref, UriKind.RelativeOrAbsolute, out uriRef);
            }

            return false;
        }
Example #27
0
 public void SaveModule(IModuleInfo moduleInfo)
 {
     // make the new id for newly saved thing
     var info = new ModuleInfo()
                           {
                               Id = GetNewId(),
                               Manifest = moduleInfo.Manifest,
                               ModuleData = moduleInfo.ModuleData,
                           };
     _moduleInfos.Add(info);
 }
Example #28
0
        /// <summary>
        /// 验证当前需要加载的 <paramref name="moduleInfo"/>包含的地址是否可以下载。
        /// </summary>
        /// <param name="moduleInfo">
        /// 需要进行判断验证的子系统信息。
        /// </param>
        /// <returns>
        /// 若当前子系统的引用地址可以访问则返回<see langword="true"/>,否则返回 <see langword="false"/>。
        /// </returns>
        public bool CanLoadModuleType(ModuleInfo moduleInfo)
        {
            //if (moduleInfo == null) throw new ArgumentNullException("moduleInfo");
            //if (!string.IsNullOrEmpty(moduleInfo.Ref))
            //{
            //    Uri uri;
            //    return Uri.TryCreate(moduleInfo.Ref, UriKind.RelativeOrAbsolute, out uri);
            //}

            return true;
        }
Example #29
0
        public TextIndexer(ModuleInfo module)
        {
            this.module = module;

            var names = module.Name.Split('_');
            var path = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, TextIndexCfg.DataPath), names[0], names[1]);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
Example #30
0
        public void publishes_avaliable_modules_message_when_everything_is_ok()
        {
            const string assembly = "test_assembly.dll";
            var moduleInfo = new ModuleInfo(assembly);

            var moduleManifest = new ModuleManifest
                                 	{
                                 		ModuleName = assembly,
                                 		ModuleVersion = new Version("0.0.0.0")
                                 	};

            var updateManifest = new ModuleManifest
                                 	{
                                 		ModuleName = assembly,
                                 		ModuleVersion = new Version("0.0.0.1")
                                 	};

            ModuleDiscovery.Setup(x => x.GetModules()).Returns(new List<ModuleInfo>
                                                               	{
                                                               		moduleInfo
                                                               	});

            // FIXME: this should use internal manifest factory
            ModuleManifestFactory.Setup(x => x.GetManifest(It.Is<ModuleInfo>(y => y == moduleInfo)))
                .Returns(moduleManifest);

            EventAggregator.Setup(x => x.Publish(It.IsAny<NomadAvailableUpdatesMessage>()))
                .Callback<NomadAvailableUpdatesMessage>(msg =>
                                                            {
                                                                Assert.AreEqual(1,
                                                                                msg.AvailableUpdates.
                                                                                    Count);
                                                                Assert.AreEqual(updateManifest,
                                                                                msg.AvailableUpdates.
                                                                                    First());
                                                            })
                .Returns(null)
                .Verifiable("Message was not published");

            ModulesRepository
                .Setup(x => x.GetAvailableModules())
                .Returns(new AvailableModules
                         	{
                         		Manifests = new List<ModuleManifest> {updateManifest}
                         	})
                .Verifiable("Get Avaliable modules has not been called");

            NomadUpdater.CheckUpdates();

            ModulesRepository.Verify();
            EventAggregator.Verify();
        }
 ///-----------------------------------------------------------------------------
 /// <summary>
 /// Determines if user has the necessary permissions to access an item with the
 /// designated AccessLevel.
 /// </summary>
 /// <param name="accessLevel">The SecurityAccessLevel required to access a portal module or module action.</param>
 /// <param name="permissionKey">If Security Access is Edit the permissionKey is the actual "edit" permisison required.</param>
 /// <param name="moduleConfiguration">The ModuleInfo object for the associated module.</param>
 /// <returns>A boolean value indicating if the user has the necessary permissions</returns>
 /// <remarks>Every module control and module action has an associated permission level.  This
 /// function determines whether the user represented by UserName has sufficient permissions, as
 /// determined by the PortalSettings and ModuleSettings, to access a resource with the
 /// designated AccessLevel.</remarks>
 ///-----------------------------------------------------------------------------
 public static bool HasModuleAccess(SecurityAccessLevel accessLevel, string permissionKey, ModuleInfo moduleConfiguration)
 {
     return(_provider.HasModuleAccess(accessLevel, permissionKey, moduleConfiguration));
 }
 /// <inheritdoc/>
 public override Control CreateModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration)
 {
     return(this.CreateControl(containerControl, string.Empty, moduleConfiguration.ModuleControl.ControlSrc));
 }
Example #33
0
        private readonly ModuleInfo _module; // active module (not datasource module)

        public RenderEngine(ModuleInfo module)
        {
            _module   = module;
            _settings = module.OpenContentSettings();
        }
Example #34
0
        private ModulesItemViewModel CreateModuleItemViewModel(SoftwareInfo software, string name, ModuleInfo module)
        {
            var displayName = GetModuleTitle(software, name);

            if (string.IsNullOrEmpty(displayName))
            {
                return(null);
            }

            return(new ModulesItemViewModel
            {
                Name = name,
                Info = module,
                DisplayName = displayName,
                ToolTip = $"{name}\n{module.Changeset}\n{module.Created}"
            });
        }
Example #35
0
 public static string GetModuleName(ModuleInfo module)
 {
     return(Regex.Replace(module.ModuleDefinition.DefinitionName, @"^R7_University_", string.Empty));
 }
Example #36
0
        private void UninstallModule(ModuleInfo moduleInfo, bool deleteModuleFolder)
        {
            Installers installerClass = new Installers();
            string     path           = HttpContext.Current.Server.MapPath("~/");

            //checked if directory exist for current module foldername
            string moduleFolderPath = path + "modules\\" + moduleInfo.FolderName;

            if (!string.IsNullOrEmpty(moduleFolderPath))
            {
                if (Directory.Exists(moduleFolderPath))
                {
                    //check for valid .sfe file exist or not
                    string fileName = installerClass.checkFormanifestFile(moduleFolderPath, moduleInfo);
                    if (fileName != "")
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(moduleFolderPath + '\\' + fileName);
                        XmlElement root = doc.DocumentElement;
                        if (installerClass.checkValidManifestFile(root, moduleInfo))
                        {
                            XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder");
                            foreach (XmlNode xn in xnList)
                            {
                                moduleInfo.ModuleName = xn["modulename"].InnerXml.ToString();
                                moduleInfo.FolderName = xn["foldername"].InnerXml.ToString();
                            }
                            try
                            {
                                if (moduleInfo.ModuleID > 0)
                                {
                                    //Run script
                                    ReadUninstallScriptAndDLLFiles(doc, moduleFolderPath, installerClass);

                                    if (deleteModuleFolder == true)
                                    {
                                        //Delete Module's Folder
                                        //installerClass.DeleteTempDirectory(moduleInfo.InstalledFolderPath);
                                        Directory.Delete(moduleFolderPath, true);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Exceptions = ex.Message;
                            }

                            if (Exceptions != string.Empty)
                            {
                                ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ModuleExtensionIsUninstallError"), "", SageMessageType.Alert);
                            }
                            else
                            {
                                string ExtensionMessage = GetSageMessage("Extensions", "ModuleExtensionIsUninstalledSuccessfully");
                                //UninstallProcessCancelRequestBase(Request.RawUrl, true, ExtensionMessage);
                            }
                        }
                        else
                        {
                            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageIsNotValid"), "", SageMessageType.Alert);
                            if (Directory.Exists(moduleFolderPath))
                            {
                                Directory.Delete(moduleFolderPath, true);
                            }
                        }
                    }
                    else
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ThisPackageDoesNotAppearToBeValid"), "", SageMessageType.Alert);
                        if (Directory.Exists(moduleFolderPath))
                        {
                            Directory.Delete(moduleFolderPath, true);
                        }
                    }
                }
                else
                {
                    if (Directory.Exists(moduleFolderPath))
                    {
                        Directory.Delete(moduleFolderPath, true);
                    }
                    ShowMessage(SageMessageTitle.Exception.ToString(), GetSageMessage("Extensions", "ModuleFolderDoesnotExist"), "", SageMessageType.Error);
                }
            }
        }
 public abstract int AddModule(ModuleInfo module);
 /// <summary>
 /// Returns a flag indicating whether the current user can import a module
 /// </summary>
 /// <param name="module">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public static bool CanImportModule(ModuleInfo module)
 {
     return(_provider.CanImportModule(module));
 }
Example #39
0
        private TabInfo CreateSubTab(string tabName, int departmentId, string settingsName = "department", int?parentTabID = null)
        {
            //Create Tab
            TabController tabController = new TabController();

            TabInfo tab = new TabInfo();

            tab.PortalID = PortalId;
            tab.TabName  = tabName;
            tab.Title    = tabName;

            //works for include in menu option. if true, will be shown in menus, else will not be shown, we have to redirect internally
            tab.IsVisible   = true;
            tab.DisableLink = false;

            //if this tab has any parents provide parent tab id, so that it will be shown in parent tab menus sub menu list, else is NULL
            //and will be in main menu list
            if (parentTabID == null)
            {
                tab.ParentId = TabId;
            }
            else
            {
                tab.ParentId = parentTabID.Value;
            }
            tab.IsDeleted    = false;
            tab.Url          = "";
            tab.IsSuperTab   = false;                            //if true, it has no parents, else false
            tab.SkinSrc      = "[G]Skins/Artfolio001/page.ascx"; //provide skin src, else will take default skin
            tab.ContainerSrc = "[G]Containers/Artfolio001/Block.ascx";
            int tabId = tabController.AddTab(tab, true);         //true to load defalut modules

            //Set Tab Permission
            TabPermissionController objTPC = new TabPermissionController();

            TabPermissionInfo tpi = new TabPermissionInfo();

            tpi.TabID          = tabId;
            tpi.PermissionID   = 3; //for view
            tpi.PermissionKey  = "VIEW";
            tpi.PermissionName = "View Tab";
            tpi.AllowAccess    = true;
            tpi.RoleID         = 0; //Role ID of administrator
            objTPC.AddTabPermission(tpi);

            TabPermissionInfo tpi1 = new TabPermissionInfo();

            tpi1.TabID          = tabId;
            tpi1.PermissionID   = 4; //for edit
            tpi1.PermissionKey  = "EDIT";
            tpi1.PermissionName = "Edit Tab";
            tpi1.AllowAccess    = true;
            tpi1.RoleID         = 0; //Role ID of administrator
            objTPC.AddTabPermission(tpi1);

            TabPermissionInfo tpi4 = new TabPermissionInfo();

            tpi4.TabID          = tabId;
            tpi4.PermissionID   = 3;
            tpi4.PermissionKey  = "VIEW";
            tpi4.PermissionName = "View Tab";
            tpi4.AllowAccess    = true;
            tpi4.RoleID         = -1; //All users
            objTPC.AddTabPermission(tpi4);

            //Add Module
            DesktopModuleController objDMC            = new DesktopModuleController();
            DesktopModuleInfo       desktopModuleInfo = objDMC.GetDesktopModuleByName("Clothes");

            ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
            ModuleInfo           moduleInfo           = new ModuleInfo();

            moduleInfo.PortalID                     = PortalId;
            moduleInfo.TabID                        = tabId;
            moduleInfo.ModuleOrder                  = 1;
            moduleInfo.ModuleTitle                  = "Clothes";
            moduleInfo.PaneName                     = "Clothes";
            moduleInfo.ModuleDefID                  = 160;
            moduleInfo.CacheTime                    = moduleDefinitionInfo.DefaultCacheTime; //Default Cache Time is 0
            moduleInfo.InheritViewPermissions       = true;                                  //Inherit View Permissions from Tab
            moduleInfo.AllTabs                      = false;
            moduleInfo.ModuleSettings[settingsName] = departmentId;

            ModuleController moduleController = new ModuleController();
            int moduleId = moduleController.AddModule(moduleInfo);

            //Set Module Permission
            ModulePermissionController objMPC = new ModulePermissionController();

            ModulePermissionInfo mpi1 = new ModulePermissionInfo();

            mpi1.ModuleID     = moduleId;
            mpi1.PermissionID = 1; //View Permission
            mpi1.AllowAccess  = true;
            mpi1.RoleID       = 0; //Role ID of Administrator
            objMPC.AddModulePermission(mpi1);

            ModulePermissionInfo mpi2 = new ModulePermissionInfo();

            mpi2.ModuleID     = moduleId;
            mpi2.PermissionID = 2; //Edit Permission
            mpi2.AllowAccess  = true;
            mpi2.RoleID       = 0; //Role ID of Administrator
            objMPC.AddModulePermission(mpi2);

            ModulePermissionInfo mpi5 = new ModulePermissionInfo();

            mpi5.ModuleID     = moduleId;
            mpi5.PermissionID = 1; //View Permission
            mpi5.AllowAccess  = true;
            mpi5.RoleID       = 1; //Role ID of Registered User
            objMPC.AddModulePermission(mpi5);
            return(tab);
        }
 /// <summary>
 /// Returns a flag indicating whether the current user can edit module content
 /// </summary>
 /// <param name="module">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public static bool CanEditModuleContent(ModuleInfo module)
 {
     return(_provider.CanEditModuleContent(module));
 }
        private void Create()
        {
            //Create new Folder
            string folderMapPath = Server.MapPath(string.Format("~/DesktopModules/RazorModules/{0}", txtFolder.Text));

            if (Directory.Exists(folderMapPath))
            {
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FolderExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return;
            }
            else
            {
                //Create folder
                Directory.CreateDirectory(folderMapPath);
            }

            //Create new Module Control
            string moduleControlMapPath = folderMapPath + "/" + ModuleControl;

            try
            {
                using (var moduleControlWriter = new StreamWriter(moduleControlMapPath))
                {
                    moduleControlWriter.Write(Localization.GetString("ModuleControlText.Text", LocalResourceFile));
                    moduleControlWriter.Flush();
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ModuleControlCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return;
            }

            //Copy Script to new Folder
            string scriptSourceFile = Server.MapPath(string.Format(razorScriptFileFormatString, scriptList.SelectedValue));
            string scriptTargetFile = folderMapPath + "/" + scriptList.SelectedValue;

            try
            {
                File.Copy(scriptSourceFile, scriptTargetFile);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ScriptCopyError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return;
            }

            //Create new Manifest in target folder
            string manifestMapPath = folderMapPath + "/" + ModuleControl.Replace(".ascx", ".dnn");

            try
            {
                using (var manifestWriter = new StreamWriter(manifestMapPath))
                {
                    string manifestTemplate = Localization.GetString("ManifestText.Text", LocalResourceFile);
                    string manifest         = string.Format(manifestTemplate, txtName.Text, txtDescription.Text, txtFolder.Text, ModuleControl, scriptList.SelectedValue);
                    manifestWriter.Write(manifest);
                    manifestWriter.Flush();
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ManifestCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return;
            }

            //Register Module
            ModuleDefinitionInfo moduleDefinition = ImportManifest(manifestMapPath);

            //remove the manifest file
            try
            {
                FileWrapper.Instance.Delete(manifestMapPath);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }


            //Optionally goto new Page
            if (chkAddPage.Checked)
            {
                string tabName = "Test " + txtName.Text + " Page";
                string tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName);
                int    tabID   = TabController.GetTabByTabPath(ModuleContext.PortalId, tabPath, ModuleContext.PortalSettings.CultureCode);

                if (tabID == Null.NullInteger)
                {
                    //Create a new page
                    var newTab = new TabInfo();
                    newTab.TabName   = "Test " + txtName.Text + " Page";
                    newTab.ParentId  = Null.NullInteger;
                    newTab.PortalID  = ModuleContext.PortalId;
                    newTab.IsVisible = true;
                    newTab.TabID     = TabController.Instance.AddTabBefore(newTab, ModuleContext.PortalSettings.AdminTabId);

                    var objModule = new ModuleInfo();
                    objModule.Initialize(ModuleContext.PortalId);

                    objModule.PortalID               = ModuleContext.PortalId;
                    objModule.TabID                  = newTab.TabID;
                    objModule.ModuleOrder            = Null.NullInteger;
                    objModule.ModuleTitle            = moduleDefinition.FriendlyName;
                    objModule.PaneName               = Globals.glbDefaultPane;
                    objModule.ModuleDefID            = moduleDefinition.ModuleDefID;
                    objModule.InheritViewPermissions = true;
                    objModule.AllTabs                = false;
                    ModuleController.Instance.AddModule(objModule);

                    Response.Redirect(Globals.NavigateURL(newTab.TabID), true);
                }
                else
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                //Redirect to main extensions page
                Response.Redirect(Globals.NavigateURL(), true);
            }
        }
Example #42
0
 public static extern bool GetModuleInformation(IntPtr hProcess, IntPtr hModule, out ModuleInfo lpmodinfo, uint cb);
Example #43
0
 public Control CreateModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration)
 {
     return(CreateControl(containerControl, String.Empty, moduleConfiguration.ModuleControl.ControlSrc));
 }
Example #44
0
        public HttpResponseMessage Get(string entity, int pageIndex, int pageSize, string filter = null, string sort = null)
        {
            try
            {
                var        collection = entity;
                RestSelect restSelect = new RestSelect()
                {
                    PageIndex = pageIndex,
                    PageSize  = pageSize
                };
                if (!string.IsNullOrEmpty(filter))
                {
                    restSelect.Query = JsonConvert.DeserializeObject <RestGroup>(filter);
                }
                if (!string.IsNullOrEmpty(sort))
                {
                    restSelect.Sort = JsonConvert.DeserializeObject <List <RestSort> >(sort);
                }

                ModuleInfo activeModule = ActiveModule;

                OpenContentSettings   settings = activeModule.OpenContentSettings();
                OpenContentModuleInfo module   = new OpenContentModuleInfo(ActiveModule);
                JObject reqOptions             = null;

                if (module.IsListMode())
                {
                    var          indexConfig  = OpenContentUtils.GetIndexConfig(settings.TemplateDir, collection);
                    QueryBuilder queryBuilder = new QueryBuilder(indexConfig);
                    bool         isEditable   = ActiveModule.CheckIfEditable(PortalSettings);
                    queryBuilder.Build(settings.Query, !isEditable, UserInfo.UserID, DnnLanguageUtils.GetCurrentCultureCode(), UserInfo.Social.Roles);

                    RestQueryBuilder.MergeQuery(indexConfig, queryBuilder.Select, restSelect, DnnLanguageUtils.GetCurrentCultureCode());
                    IDataItems dsItems;
                    if (queryBuilder.DefaultNoResults && queryBuilder.Select.IsQueryEmpty)
                    {
                        dsItems = new DefaultDataItems()
                        {
                            Items = new List <DefaultDataItem>(),
                            Total = 0
                        };
                    }
                    else
                    {
                        IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                        var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID, false, reqOptions);
                        dsContext.Collection = collection;
                        dsItems = ds.GetAll(dsContext, queryBuilder.Select);
                    }
                    var mf = new ModelFactoryMultiple(dsItems.Items, module, PortalSettings, collection);
                    mf.Options = reqOptions;
                    var model = mf.GetModelAsJson(false);
                    var res   = new JObject();
                    res["meta"] = new JObject();
                    if (LogContext.IsLogActive)
                    {
                        var logKey = "Query";
                        LogContext.Log(activeModule.ModuleID, logKey, "select", queryBuilder.Select);
                        LogContext.Log(activeModule.ModuleID, logKey, "debuginfo", dsItems.DebugInfo);
                        LogContext.Log(activeModule.ModuleID, logKey, "model", model);
                        res["meta"]["logs"] = JToken.FromObject(LogContext.Current.ModuleLogs(activeModule.ModuleID));

                        if (restSelect != null)
                        {
                            //res["meta"]["select"] = JObject.FromObject(restSelect);
                        }
                    }
                    foreach (var item in model["Items"] as JArray)
                    {
                        item["id"] = item["Context"]["Id"];
                        JsonUtils.IdJson(item);
                    }
                    res[entity]          = model[collection];
                    res["meta"]["total"] = dsItems.Total;
                    return(Request.CreateResponse(HttpStatusCode.OK, res));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "not supported because not in multi items template "));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Example #45
0
        private UrlRule GetCategoryLinkRule(DNNArticleInfo article, CategoryInfo category, ModuleInfo module, List <UrlRule> rules)
        {
            object selectedArticleList = ModuleSetting(MySettings.SelectedArticleList, module, -1); //List module to use to show the results

            if (selectedArticleList.ToString() == "-1")
            {
                return(null);
            }
            object selectedModule = ModuleSetting(MySettings.SelectedModule, module, -1); //base DNNArticle module
            string param          = string.Format("cid={0}&smid={1}&tmid={2}", category.ItemID, selectedArticleList, selectedModule);
            bool   duplicate      = rules.Any(urlRule => (urlRule.Parameters.StartsWith(param)) && urlRule.TabId == module.TabID);

            UrlRule rule = null;

            if (!duplicate)
            {
                rule = new UrlRule
                {
                    CultureCode = module.CultureCode,
                    TabId       = module.TabID,
                    RuleType    = UrlRuleType.Module,
                    Parameters  = param,
                    Action      = UrlRuleAction.Rewrite,
                    Url         = CleanupUrl(category.Title),
                    RemoveTab   = !_includePageName
                };
                rule.Url = FullCategoryTitleAsPath(category, module.ModuleID);
            }

            return(rule);
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// SaveModulePermissions updates a Module's permissions
 /// </summary>
 /// <param name="module">The Module to update</param>
 /// -----------------------------------------------------------------------------
 public static void SaveModulePermissions(ModuleInfo module)
 {
     _provider.SaveModulePermissions(module);
     DataCache.ClearModulePermissionsCache(module.TabID);
 }
 public abstract void UpdateModule(ModuleInfo module);
        private static void ClearPermissionCache(int moduleId)
        {
            ModuleInfo objModule = ModuleController.Instance.GetModule(moduleId, Null.NullInteger, false);

            DataCache.ClearModulePermissionsCache(objModule.TabID);
        }
 /// <inheritdoc/>
 public override Control CreateSettingsControl(TemplateControl containerControl, ModuleInfo moduleConfiguration, string controlSrc)
 {
     return(this.CreateControl(containerControl, string.Empty, controlSrc));
 }
 /// <summary>
 /// Returns a flag indicating whether the current user can administer a module
 /// </summary>
 /// <param name="module">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public static bool CanAdminModule(ModuleInfo module)
 {
     return(_provider.CanAdminModule(module));
 }
 internal ModuleInfo Build(CommandService service, ModuleInfo parent) => BuildImpl(service, parent);
Example #52
0
        public static ModuleInfo ParserTagData1(byte[] tagBuff)
        {
            try
            {
                MemoryStream memStream  = new MemoryStream(tagBuff);
                BinaryReader buffReader = new BinaryReader(memStream);

                if (buffReader.ReadString() != "@@")
                {
                    throw new Exception("数据包开始标志出错");
                }
                string   customer       = buffReader.ReadString();
                string   strProductType = buffReader.ReadString();
                string   strModule_ID   = buffReader.ReadString();
                DateTime packingDate    = DateFormInt16(buffReader.ReadInt16());
                decimal  dPmax          = (decimal)buffReader.ReadInt32() / 100M;
                decimal  dVoc           = (decimal)buffReader.ReadInt16() / 100M;
                decimal  dIsc           = (decimal)buffReader.ReadInt16() / 100M;
                decimal  dVpm           = (decimal)buffReader.ReadInt16() / 100M;
                decimal  dIpm           = (decimal)buffReader.ReadInt16() / 100M;
                decimal  ff             = (decimal)buffReader.ReadInt16() / 100M;
                DateTime cellDate       = DateFormInt16(buffReader.ReadInt16());

                //string s_cell_supplier_country = buffReader.ReadString();
                //string s_iec_date = buffReader.ReadString();
                //string s_iec_verfy = buffReader.ReadString();
                //string s_iso = buffReader.ReadString();
                //string s_mfg_name = buffReader.ReadString();

                string packetEnd = buffReader.ReadString();

                if (packetEnd != "##")
                {
                    throw new Exception("数据包结束标志出错");
                }
                else
                {
                    ModuleInfo rfidTag = new ModuleInfo();
                    rfidTag.customer              = customer;
                    rfidTag.ProductType           = strProductType;
                    rfidTag.Module_ID             = strModule_ID;
                    rfidTag.PackedDate            = packingDate.ToString("yyyy-MM-dd");
                    rfidTag.Pmax                  = dPmax.ToString();
                    rfidTag.Voc                   = dVoc.ToString();
                    rfidTag.Isc                   = dIsc.ToString();
                    rfidTag.Vpm                   = dVpm.ToString();
                    rfidTag.Ipm                   = dIpm.ToString();
                    rfidTag.CellDate              = cellDate.ToString("yyyy-MM-dd");
                    rfidTag.FF                    = ff.ToString() + "%";
                    rfidTag.cell_supplier_country = "";
                    rfidTag.iec_date              = "";
                    rfidTag.iec_verfy             = "";
                    rfidTag.iso                   = "";
                    rfidTag.mfg_name              = "";

                    return(rfidTag);
                }


                //short length = buffReader.ReadInt16();
                //I_V_Point[] pointArray = new I_V_Point[length];
                //for (int i = 0; i < length; i++)
                //{
                //    pointArray[i] = new I_V_Point();
                //    pointArray[i].Current = buffReader.ReadInt32() * 1.0 / 10000000;
                //    pointArray[i].Voltage = buffReader.ReadInt32() * 1.0 / 10000000;
                //}
            }
            catch (Exception ex)
            {
                throw new Exception("解析数据包出错:\r\n" + ex.Message);
            }
        }
 /// <summary>
 /// Returns a flag indicating whether the current user can delete a module
 /// </summary>
 /// <param name="module">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public static bool CanDeleteModule(ModuleInfo module)
 {
     return(_provider.CanDeleteModule(module));
 }
        public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
        {
            var searchDocuments = new Dictionary <string, SearchDocument>();
            var lastJournalId   = Null.NullInteger;

            try
            {
                while (true)
                {
                    using (var reader = DataProvider.Instance()
                                        .ExecuteReader("Journal_GetSearchItems", moduleInfo.PortalID,
                                                       moduleInfo.TabModuleID, beginDateUtc, lastJournalId, Constants.SearchBatchSize))
                    {
                        var journalIds = new Dictionary <int, int>();

                        while (reader.Read())
                        {
                            var journalId = Convert.ToInt32(reader["JournalId"]);

                            // var journalTypeId = reader["JournalTypeId"].ToString();
                            var userId      = Convert.ToInt32(reader["UserId"]);
                            var dateUpdated = Convert.ToDateTime(reader["DateUpdated"]);
                            var profileId   = reader["ProfileId"].ToString();
                            var groupId     = reader["GroupId"].ToString();
                            var title       = reader["Title"].ToString();
                            var summary     = reader["Summary"].ToString();
                            var securityKey = reader["SecurityKey"].ToString();
                            var tabId       = reader["TabId"].ToString();
                            var tabModuleId = reader["ModuleId"].ToString();

                            var key = string.Format("JI_{0}", journalId);
                            if (searchDocuments.ContainsKey(key))
                            {
                                searchDocuments[key].UniqueKey +=
                                    string.Format(",{0}", securityKey);
                            }
                            else
                            {
                                var searchDocument = new SearchDocument
                                {
                                    UniqueKey       = string.Format("JI_{0}_{1}", journalId, securityKey),
                                    PortalId        = moduleInfo.PortalID,
                                    Body            = summary,
                                    ModifiedTimeUtc = dateUpdated,
                                    Title           = title,
                                    AuthorUserId    = userId,
                                    Keywords        = new Dictionary <string, string>
                                    {
                                        { "TabId", tabId },
                                        { "TabModuleId", tabModuleId },
                                        { "ProfileId", profileId },
                                        { "GroupId", groupId },
                                    },
                                };

                                searchDocuments.Add(key, searchDocument);
                            }

                            if (journalId > lastJournalId)
                            {
                                lastJournalId = journalId;
                            }

                            if (!journalIds.ContainsKey(journalId))
                            {
                                journalIds.Add(journalId, userId);
                            }
                        }

                        if (journalIds.Count == 0)
                        {
                            break;
                        }

                        // index comments for this journal
                        this.AddCommentItems(journalIds, searchDocuments);
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }

            return(searchDocuments.Values.ToList());
        }
        public override bool Execute()
        {
            if (string.Compare(Platform, "Web", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                // Trigger JSIL provider download if needed.
                string jsilDirectory, jsilCompilerFile;
                if (!m_JSILProvider.GetJSIL(out jsilDirectory, out jsilCompilerFile))
                {
                    return(false);
                }
            }

            var module = ModuleInfo.Load(Path.Combine(RootPath, "Build", "Module.xml"));

            LogMessage(
                "Starting generation of projects for " + Platform);

            var definitions    = module.GetDefinitionsRecursively(Platform).ToArray();
            var loadedProjects = new List <LoadedDefinitionInfo>();

            foreach (var definition in definitions)
            {
                LogMessage("Loading: " + definition.Name);
                loadedProjects.Add(
                    m_ProjectLoader.Load(
                        Platform,
                        module,
                        definition));
            }

            var                  serviceManager = new ServiceManager(Platform);
            List <Service>       services;
            TemporaryServiceSpec serviceSpecPath;

            if (ServiceSpecPath == null)
            {
                serviceManager.SetRootDefinitions(module.GetDefinitions());

                if (EnableServices == null)
                {
                    EnableServices = new string[0];
                }

                if (DisableServices == null)
                {
                    DisableServices = new string[0];
                }

                foreach (var service in EnableServices)
                {
                    serviceManager.EnableService(service);
                }

                foreach (var service in DisableServices)
                {
                    serviceManager.DisableService(service);
                }

                if (DebugServiceResolution)
                {
                    serviceManager.EnableDebugInformation();
                }

                try
                {
                    services = serviceManager.CalculateDependencyGraph(loadedProjects.Select(x => x.Project).ToList());
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine("Error during service resolution: " + ex.Message);
                    return(false);
                }

                serviceSpecPath = serviceManager.SaveServiceSpec(services);

                foreach (var service in services)
                {
                    if (service.ServiceName != null)
                    {
                        LogMessage("Enabled service: " + service.FullName);
                    }
                }
            }
            else
            {
                services        = serviceManager.LoadServiceSpec(ServiceSpecPath);
                serviceSpecPath = new TemporaryServiceSpec(ServiceSpecPath, true);
            }

            using (serviceSpecPath)
            {
                // Run Protobuild in batch mode in each of the submodules
                // where it is present.
                foreach (var submodule in module.GetSubmodules(Platform))
                {
                    if (_featureManager.IsFeatureEnabledInSubmodule(module, submodule,
                                                                    Feature.OptimizationSkipInvocationOnNoStandardProjects))
                    {
                        if (submodule.GetDefinitionsRecursively(Platform).All(x => !x.IsStandardProject))
                        {
                            // Do not invoke this submodule.
                            LogMessage(
                                "Skipping submodule generation for " + submodule.Name +
                                " (there are no projects to generate)");
                            continue;
                        }
                    }

                    LogMessage(
                        "Invoking submodule generation for " + submodule.Name);
                    var noResolve = _featureManager.IsFeatureEnabledInSubmodule(module, submodule,
                                                                                Feature.PackageManagementNoResolve)
                        ? " -no-resolve"
                        : string.Empty;
                    var noHostPlatform = DisableHostPlatformGeneration &&
                                         _featureManager.IsFeatureEnabledInSubmodule(module, submodule,
                                                                                     Feature.NoHostGenerate)
                        ? " -no-host-generate"
                        : string.Empty;
                    _moduleExecution.RunProtobuild(
                        submodule,
                        _featureManager.GetFeatureArgumentToPassToSubmodule(module, submodule) +
                        "-generate " + Platform +
                        " -spec " + serviceSpecPath +
                        " " + m_PackageRedirector.GetRedirectionArguments() +
                        noResolve + noHostPlatform);
                    LogMessage(
                        "Finished submodule generation for " + submodule.Name);
                }

                var repositoryPaths = new List <string>();

                foreach (var definition in definitions.Where(x => x.ModulePath == module.Path))
                {
                    if (definition.PostBuildHook && RequiresHostPlatform != null)
                    {
                        // We require the host platform projects at this point.
                        RequiresHostPlatform();
                    }

                    string repositoryPath;
                    var    definitionCopy = definition;
                    m_ProjectGenerator.Generate(
                        definition,
                        loadedProjects,
                        RootPath,
                        definition.Name,
                        Platform,
                        services,
                        out repositoryPath,
                        () => LogMessage("Generating: " + definitionCopy.Name));

                    // Only add repository paths if they should be generated.
                    if (module.GenerateNuGetRepositories && !string.IsNullOrEmpty(repositoryPath))
                    {
                        repositoryPaths.Add(repositoryPath);
                    }
                }

                var solution = Path.Combine(
                    RootPath,
                    ModuleName + "." + Platform + ".sln");
                LogMessage("Generating: (solution)");
                m_SolutionGenerator.Generate(
                    module,
                    loadedProjects.Select(x => x.Project).ToList(),
                    Platform,
                    solution,
                    services,
                    repositoryPaths);

                // Only save the specification cache if we allow synchronisation
                if (module.DisableSynchronisation == null || !module.DisableSynchronisation.Value)
                {
                    var serviceCache = Path.Combine(RootPath, ModuleName + "." + Platform + ".speccache");
                    LogMessage("Saving service specification");
                    File.Copy(serviceSpecPath.Path, serviceCache, true);
                }

                LogMessage(
                    "Generation complete.");
            }

            return(true);
        }
Example #56
0
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <history>
        ///     [cnurse]	9/8/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                if ((Request.QueryString["pid"] != null) && (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId || UserInfo.IsSuperUser))
                {
                    intPortalId              = int.Parse(Request.QueryString["pid"]);
                    ctlLogo.ShowUpLoad       = false;
                    ctlBackground.ShowUpLoad = false;
                }
                else
                {
                    intPortalId              = PortalId;
                    ctlLogo.ShowUpLoad       = true;
                    ctlBackground.ShowUpLoad = true;
                }

                //this needs to execute always to the client script code is registred in InvokePopupCal
                cmdExpiryCalendar.NavigateUrl = Calendar.InvokePopupCal(txtExpiryDate);
                ClientAPI.AddButtonConfirm(cmdRestore, Localization.GetString("RestoreCCSMessage", LocalResourceFile));

                // If this is the first visit to the page, populate the site data
                if (Page.IsPostBack == false)
                {
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteMessage", LocalResourceFile));

                    PortalController        objPortalController = new PortalController();
                    ListController          ctlList             = new ListController();
                    ListEntryInfoCollection colProcessor        = ctlList.GetListEntryInfoCollection("Processor");

                    cboProcessor.DataSource = colProcessor;
                    cboProcessor.DataBind();
                    cboProcessor.Items.Insert(0, new ListItem("<" + Localization.GetString("None_Specified") + ">", ""));

                    PortalInfo objPortal = objPortalController.GetPortal(intPortalId);

                    txtPortalName.Text                 = objPortal.PortalName;
                    ctlLogo.Url                        = objPortal.LogoFile;
                    ctlLogo.FileFilter                 = Globals.glbImageFileTypes;
                    txtDescription.Text                = objPortal.Description;
                    txtKeyWords.Text                   = objPortal.KeyWords;
                    ctlBackground.Url                  = objPortal.BackgroundFile;
                    ctlBackground.FileFilter           = Globals.glbImageFileTypes;
                    txtFooterText.Text                 = objPortal.FooterText;
                    optUserRegistration.SelectedIndex  = objPortal.UserRegistration;
                    optBannerAdvertising.SelectedIndex = objPortal.BannerAdvertising;

                    cboSplashTabId.DataSource = Globals.GetPortalTabs(intPortalId, true, true, false, false, false);
                    cboSplashTabId.DataBind();
                    if (cboSplashTabId.Items.FindByValue(objPortal.SplashTabId.ToString()) != null)
                    {
                        cboSplashTabId.Items.FindByValue(objPortal.SplashTabId.ToString()).Selected = true;
                    }
                    cboHomeTabId.DataSource = Globals.GetPortalTabs(intPortalId, true, true, false, false, false);
                    cboHomeTabId.DataBind();
                    if (cboHomeTabId.Items.FindByValue(objPortal.HomeTabId.ToString()) != null)
                    {
                        cboHomeTabId.Items.FindByValue(objPortal.HomeTabId.ToString()).Selected = true;
                    }
                    cboLoginTabId.DataSource = Globals.GetPortalTabs(intPortalId, true, true, false, false, false);
                    cboLoginTabId.DataBind();
                    if (cboLoginTabId.Items.FindByValue(objPortal.LoginTabId.ToString()) != null)
                    {
                        cboLoginTabId.Items.FindByValue(objPortal.LoginTabId.ToString()).Selected = true;
                    }
                    cboUserTabId.DataSource = Globals.GetPortalTabs(intPortalId, true, true, false, false, false);
                    cboUserTabId.DataBind();
                    if (cboUserTabId.Items.FindByValue(objPortal.UserTabId.ToString()) != null)
                    {
                        cboUserTabId.Items.FindByValue(objPortal.UserTabId.ToString()).Selected = true;
                    }

                    ListEntryInfoCollection colList = ctlList.GetListEntryInfoCollection("Currency");

                    cboCurrency.DataSource = colList;
                    cboCurrency.DataBind();
                    if (Null.IsNull(objPortal.Currency) || cboCurrency.Items.FindByValue(objPortal.Currency) == null)
                    {
                        cboCurrency.Items.FindByValue("USD").Selected = true;
                    }
                    else
                    {
                        cboCurrency.Items.FindByValue(objPortal.Currency).Selected = true;
                    }
                    RoleController objRoleController = new RoleController();

                    ArrayList Arr = objRoleController.GetUserRolesByRoleName(intPortalId, objPortal.AdministratorRoleName);
                    int       i;
                    for (i = 0; i <= Arr.Count - 1; i++)
                    {
                        UserRoleInfo objUser = (UserRoleInfo)Arr[i];
                        cboAdministratorId.Items.Add(new ListItem(objUser.FullName, objUser.UserID.ToString()));
                    }
                    if (cboAdministratorId.Items.FindByValue(objPortal.AdministratorId.ToString()) != null)
                    {
                        cboAdministratorId.Items.FindByValue(objPortal.AdministratorId.ToString()).Selected = true;
                    }

                    if (!Null.IsNull(objPortal.ExpiryDate))
                    {
                        txtExpiryDate.Text = objPortal.ExpiryDate.ToShortDateString();
                    }
                    txtHostFee.Text   = objPortal.HostFee.ToString();
                    txtHostSpace.Text = objPortal.HostSpace.ToString();
                    txtPageQuota.Text = objPortal.PageQuota.ToString();
                    txtUserQuota.Text = objPortal.UserQuota.ToString();
                    if (objPortal.SiteLogHistory != 0)
                    {
                        txtSiteLogHistory.Text = objPortal.SiteLogHistory.ToString();
                    }

                    DesktopModuleController objDesktopModules = new DesktopModuleController();
                    ArrayList arrDesktopModules = objDesktopModules.GetDesktopModules();

                    ArrayList arrPremiumModules = new ArrayList();
                    foreach (DesktopModuleInfo objDesktopModule in arrDesktopModules)
                    {
                        if (objDesktopModule.IsPremium)
                        {
                            arrPremiumModules.Add(objDesktopModule);
                        }
                    }

                    ArrayList arrPortalDesktopModules = objDesktopModules.GetPortalDesktopModules(intPortalId, Null.NullInteger);
                    foreach (PortalDesktopModuleInfo objPortalDesktopModule in arrPortalDesktopModules)
                    {
                        foreach (DesktopModuleInfo objDesktopModule in arrPremiumModules)
                        {
                            if (objDesktopModule.DesktopModuleID == objPortalDesktopModule.DesktopModuleID)
                            {
                                arrPremiumModules.Remove(objDesktopModule);
                                break;
                            }
                        }
                    }

                    ctlDesktopModules.Available = arrPremiumModules;
                    ctlDesktopModules.Assigned  = arrPortalDesktopModules;

                    if (!String.IsNullOrEmpty(objPortal.PaymentProcessor))
                    {
                        if (cboProcessor.Items.FindByText(objPortal.PaymentProcessor) != null)
                        {
                            cboProcessor.Items.FindByText(objPortal.PaymentProcessor).Selected = true;
                        }
                        else // default
                        {
                            if (cboProcessor.Items.FindByText("PayPal") != null)
                            {
                                cboProcessor.Items.FindByText("PayPal").Selected = true;
                            }
                        }
                    }
                    else
                    {
                        cboProcessor.Items.FindByValue("").Selected = true;
                    }
                    txtUserId.Text = objPortal.ProcessorUserId;
                    txtPassword.Attributes.Add("value", objPortal.ProcessorPassword);
                    txtHomeDirectory.Text = objPortal.HomeDirectory;

                    //Populate the default language combobox
                    Localization.LoadCultureDropDownList(cboDefaultLanguage, CultureDropDownTypes.NativeName, objPortal.DefaultLanguage);

                    //Populate the timezone combobox (look up timezone translations based on currently set culture)
                    Localization.LoadTimeZoneDropDownList(cboTimeZone, ((PageBase)Page).PageCulture.Name, Convert.ToString(objPortal.TimeZoneOffset));

                    SkinInfo objSkin;

                    ctlPortalSkin.Width    = "275px";
                    ctlPortalSkin.SkinRoot = SkinInfo.RootSkin;
                    objSkin = SkinController.GetSkin(SkinInfo.RootSkin, PortalId, SkinType.Portal);
                    if (objSkin != null)
                    {
                        if (objSkin.PortalId == PortalId)
                        {
                            ctlPortalSkin.SkinSrc = objSkin.SkinSrc;
                        }
                    }
                    ctlPortalContainer.Width    = "275px";
                    ctlPortalContainer.SkinRoot = SkinInfo.RootContainer;
                    objSkin = SkinController.GetSkin(SkinInfo.RootContainer, PortalId, SkinType.Portal);
                    if (objSkin != null)
                    {
                        if (objSkin.PortalId == PortalId)
                        {
                            ctlPortalContainer.SkinSrc = objSkin.SkinSrc;
                        }
                    }

                    ctlAdminSkin.Width    = "275px";
                    ctlAdminSkin.SkinRoot = SkinInfo.RootSkin;
                    objSkin = SkinController.GetSkin(SkinInfo.RootSkin, PortalId, SkinType.Admin);
                    if (objSkin != null)
                    {
                        if (objSkin.PortalId == PortalId)
                        {
                            ctlAdminSkin.SkinSrc = objSkin.SkinSrc;
                        }
                    }
                    ctlAdminContainer.Width    = "275px";
                    ctlAdminContainer.SkinRoot = SkinInfo.RootContainer;
                    objSkin = SkinController.GetSkin(SkinInfo.RootContainer, PortalId, SkinType.Admin);
                    if (objSkin != null)
                    {
                        if (objSkin.PortalId == PortalId)
                        {
                            ctlAdminContainer.SkinSrc = objSkin.SkinSrc;
                        }
                    }

                    LoadStyleSheet();

                    if (Convert.ToString(PortalSettings.HostSettings["SkinUpload"]) == "G" && !UserInfo.IsSuperUser)
                    {
                        lnkUploadSkin.Visible      = false;
                        lnkUploadContainer.Visible = false;
                    }
                    else
                    {
                        ModuleInfo FileManagerModule = (new ModuleController()).GetModuleByDefinition(intPortalId, "File Manager");
                        string[]   parameters        = new string[3];
                        parameters[0]             = "mid=" + FileManagerModule.ModuleID;
                        parameters[1]             = "ftype=" + UploadType.Skin;
                        parameters[2]             = "rtab=" + TabId;
                        lnkUploadSkin.NavigateUrl = Globals.NavigateURL(FileManagerModule.TabID, "Edit", parameters);

                        parameters[1] = "ftype=" + UploadType.Container;
                        lnkUploadContainer.NavigateUrl = Globals.NavigateURL(FileManagerModule.TabID, "Edit", parameters);
                    }

                    if (Request.UrlReferrer != null)
                    {
                        if (Request.UrlReferrer.AbsoluteUri == Request.Url.AbsoluteUri)
                        {
                            ViewState["UrlReferrer"] = "";
                        }
                        else
                        {
                            ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                        }
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "";
                    }
                }

                if (UserInfo.IsSuperUser)
                {
                    dshHost.Visible   = true;
                    tblHost.Visible   = true;
                    cmdDelete.Visible = true;
                    if (Convert.ToString(ViewState["UrlReferrer"]) == "")
                    {
                        cmdCancel.Visible = false;
                    }
                    else
                    {
                        cmdCancel.Visible = true;
                    }
                }
                else
                {
                    dshHost.Visible   = false;
                    tblHost.Visible   = false;
                    cmdDelete.Visible = false;
                    cmdCancel.Visible = false;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #57
0
 public override void CustomizeSearch(Dictionary <string, List <ISearchInfo> > searchInfos, ModuleInfo moduleInfo, DateTime beginDate)
 {
     if (Webpage != null)
     {
         Webpage.CustomizeSearch(searchInfos, moduleInfo, beginDate);
     }
 }
Example #58
0
 public override void HandleModuleLoadError(ModuleInfo moduleInfo, string assemblyName, Exception exception)
 {
     HandleModuleLoadErrorCalled = true;
 }
Example #59
0
 internal static bool IsDesktopRuntimeModule(ModuleInfo module)
 {
     return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && IsModuleEqual(module, DesktopRuntimeModuleName));
 }
Example #60
0
 //constructor with exception message
 public ModuleLoadException(string message, Exception inner, ModuleInfo ModuleConfiguration)
     : base(message, inner)
 {
     m_ModuleConfiguration = ModuleConfiguration;
     InitilizePrivateVariables();
 }