Example #1
0
 public PlugInWraperPage(PlugInWrapper p)
 {
     InitializeComponent();
     mPlugInWrapper = p;
     try
     {
         Init();
     }
     catch (Exception ex)
     {
         LoadErrorLbl.Visibility = Visibility.Visible;
         Reporter.ToUser(eUserMsgKeys.FailedToLoadPlugIn, p.Name, ex.Message);
     }
 }
Example #2
0
        private void AddNewPlugIn(bool IsEmbeddedPlugin)
        {
            PlugInWrapper PW = Ginger.PlugInsLib.PlugInsIntegration.AddNewPlugIn(IsEmbeddedPlugin, App.UserProfile.Solution.Folder.ToUpper());

            if (PW != null)
            {
                ITreeViewItem PTI;
                if (IsEmbeddedPlugin)
                {
                    PTI = new PlugInEmbeddedTreeItem();
                    ((PlugInEmbeddedTreeItem)PTI).PlugInWrapper = PW;
                }
                else
                {
                    PTI = new PlugInSystemTreeItem();
                    ((PlugInSystemTreeItem)PTI).PlugInWrapper = PW;
                }
                ITreeViewItem addTreeViewItem = mTreeView.Tree.AddChildItemAndSelect(this, PTI);
                App.LocalRepository.AddItemToCache(PW);
                mTreeView.Tree.RefreshHeader(addTreeViewItem);
            }

            App.AutomateTabGingerRunner.PlugInsList = App.LocalRepository.GetSolutionPlugIns();
        }
Example #3
0
 void Start()
 {
     print("Native random number: " + PlugInWrapper.GetRanNum());
 }
Example #4
0
        public static PlugInWrapper AddNewPlugIn(bool IsEmbeddedPlugin, string SolutionFolder)
        {
            string PlugInSourcePath = General.OpenSelectFolderDialog("Select Plugin Root Folder");

            if (PlugInSourcePath == null)
            {
                return(null);
            }
            string[] JsonFile               = Directory.GetFiles(PlugInSourcePath, "GingerPluginInfo.json", SearchOption.AllDirectories);
            string   PlugInConfigFile       = JsonFile[0];
            string   PlugInConfigFileFolder = Directory.GetParent(PlugInConfigFile).ToString();

            //Read PluginInfo json file
            if (!File.Exists(PlugInConfigFile))
            {
                Reporter.ToUser(eUserMsgKeys.PlugInFileNotFound, PlugInConfigFile);
                return(null);
            }
            string StringPluginInfo = System.IO.File.ReadAllText(PlugInConfigFile);
            Dictionary <string, object> PluginInfoDict = JsonConvert.DeserializeObject <Dictionary <string, object> >(StringPluginInfo);

            if (!PluginInfoDict.ContainsKey("PlugInName") || !PluginInfoDict.ContainsKey("DllFile") || !PluginInfoDict.ContainsKey("DllRelativePath") || !PluginInfoDict.ContainsKey("ClassName"))
            {
                Reporter.ToUser(eUserMsgKeys.StaticWarnMessage, "Cannot add new Plugin, GingerPluginInfo.json file missing value/s.");
                Reporter.ToLog(eLogLevel.ERROR, "Cannot add new Plugin, GingerPluginInfo.json file missing value/s.");
                return(null);
            }
            // plugInName for the directory before loading the DLL file
            string plugInName            = PluginInfoDict["PlugInName"].ToString();
            string PlugInDllFile         = PluginInfoDict["DllFile"].ToString();
            string PlugInDllRelativePath = PluginInfoDict["DllRelativePath"].ToString();
            string PlugInClassName       = PluginInfoDict["ClassName"].ToString();

            string solutionPlugInsPath = Path.Combine(SolutionFolder, "Plugins", plugInName);

            if (Directory.Exists(solutionPlugInsPath))
            {
                DeletePlugInDirectory(solutionPlugInsPath);//delete the existing one and copy
            }
            string      PlugInRootPath = string.Empty;
            ePluginType PlugInType;

            if (IsEmbeddedPlugin)
            {
                GingerCore.General.DirectoryCopy(PlugInSourcePath, solutionPlugInsPath, true);
                PlugInRootPath = solutionPlugInsPath;
                PlugInType     = ePluginType.Embedded;
            }
            else
            {
                Directory.CreateDirectory(solutionPlugInsPath);
                PlugInRootPath = PlugInSourcePath;
                PlugInType     = ePluginType.System;
            }
            PlugInWrapper PW = new PlugInWrapper(PlugInClassName, PlugInRootPath, Path.Combine(PlugInDllRelativePath, PlugInDllFile), PlugInType);

            try
            {
                PW.Init();
            }
            catch (Exception ex)
            {
                Reporter.ToUser(eUserMsgKeys.PlugInFileNotFound, ex.Message + " " + ex.InnerException);
                return(null);
            }
            PW.SaveToFile(LocalRepository.GetRepoItemFileName(PW, solutionPlugInsPath));
            return(PW);
        }
Example #5
0
        private void LoadEditPage()
        {
            try
            {
                // Edit Page can be .xaml or a classname of a page, or empty if no config needed
                PlugInWrapper PIW      = App.LocalRepository.GetSolutionPlugIns().Where(x => x.ID == mAct.PlugInID).FirstOrDefault();
                string        editpage = string.Empty;
                if (PIW != null)
                {
                    editpage = PIW.GetEditPage(mAct.PlugInActionID);
                }

                if (string.IsNullOrEmpty(editpage))
                {
                    EditFrame.Visibility     = Visibility.Collapsed;
                    NoConfigLabel.Visibility = Visibility.Visible;
                    // There is no Edit page configured = action without params in
                    return;
                }

                NoConfigLabel.Visibility = Visibility.Collapsed;


                if (editpage.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
                {
                    if (!File.Exists(editpage))
                    {
                        EditFrame.Content = "Error: xaml file not found - " + editpage;
                        return;
                    }

                    FileStream s           = new FileStream(editpage, FileMode.Open);
                    UIElement  rootElement = (UIElement)XamlReader.Load(s);
                    s.Close();

                    EditFrame.Content = rootElement;

                    BindControlsToAction((Panel)rootElement);
                }
                else
                {
                    Type t = PIW.Assembly.GetType(editpage);
                    if (t == null)
                    {
                        EditFrame.Content = "Error: Action edit page not found - " + editpage;
                        return;
                    }

                    Page p = (Page)Activator.CreateInstance(t, mAct.GingerAction);

                    foreach (ActionParam AP in mAct.GingerAction.ParamsIn)
                    {
                        mAct.AddOrUpdateInputParamValue(AP.Name, AP.Value == null? string.Empty : AP.Value.ToString());
                        AP.PropertyChanged -= GingerAction_PropertyChanged;
                        AP.PropertyChanged += GingerAction_PropertyChanged;
                    }
                    EditFrame.Content = p;
                }
            }
            catch (Exception ex)
            {
                LoadErrorLbl.Visibility = Visibility.Visible;
                EditFrame.Visibility    = Visibility.Collapsed;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to load the plugin edit page for the action '" + mAct.Description + "'", ex);
            }
        }