Example #1
0
        private void LoadPlugins()
        {
            IList <PluginInfo> list = ADInfoBll.Instance.GetInfos <PluginInfo>();

            foreach (PluginInfo i in list)
            {
                if (Authority.AuthorizeByRule(i.Permission))
                {
                    try
                    {
                        object ret = ProcessInfoHelper.ExecuteProcess(i.Process.Name, new Dictionary <string, object> {
                            { "mdiForm", this }
                        });
                        IPlugin p = ret as IPlugin;
                        if (p == null)
                        {
                            throw new ArgumentException(string.Format("插件\"{0}\"创建错误", i.Name), new ArgumentException("Plugin should return an instance of IPlugin!"));
                        }
                        p.OnLoad();

                        m_plugins.Add(p);
                    }
                    catch (Exception ex)
                    {
                        ExceptionProcess.ProcessWithNotify(ex);
                    }
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        public static void BindingCommands()
        {
            IList <CommandBindingInfo> list = ADInfoBll.Instance.GetInfos <CommandBindingInfo>();

            foreach (var i in list)
            {
                CommandManager.Register(i.Name, new ExecutedCommandHandler(delegate(object sender, ExecutedEventArgs e)
                {
                    ProcessInfoHelper.ExecuteProcess(i.Command.Name, new Dictionary <string, object> {
                        { "sender", sender }, { "e", e }
                    });
                }));
            }
        }
 private DelegateDaoOperation Generate(string s)
 {
     if (!string.IsNullOrEmpty(s))
     {
         if (s.ToLower() != "null")
         {
             return(new DelegateDaoOperation(delegate(object entity)
             {
                 object o = ProcessInfoHelper.ExecuteProcess(ADInfoBll.Instance.GetProcessInfo(s),
                                                             new Dictionary <string, object> {
                     { "entity", entity }
                 });
             }));
         }
     }
     return(null);
 }
Example #4
0
        static void Main(string[] args)
        {
            //System.Windows.Forms.MessageBox.Show("Debug");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Helper.ReplaceFiles("E:\\MySource\\nbzs\\wlxt\\trunk\\Cd2\\PythonScript", "*.py", "\"Feng.Windows.View\"", "\"Feng.Windows.Application\"");
            //Helper.ReplaceFiles("E:\\MySource\\nbzs\\wlxt\\trunk\\Cd2\\PythonScript", "*.py", "\"Feng.Application\"", "\"Feng.Windows.Model\"");
            ////var i = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManager`1, Feng.Windows.Controller");

            SystemConfiguration.Roles = new string[] { "系统管理员" };
            ProgramHelper.InitProgram();

            PdnResourcesCollection.Instance.AddPdnResource("Feng", "Feng.Resource", "Feng.Resource", true);

            //Feng.Utils.HelpGenerator.GenerateXml("c:\\a.xml");

            //using (Feng.NH.INHibernateRepository rep = new Feng.NH.Repository("default"))
            //{
            //    var i = rep.Session.Get<Feng.WindowInfo>("报表_财务费用开支明细");
            //    rep.Initialize(i.WindowTabs, i);
            //    rep.Initialize(i.WindowTabs[0].GridInfos, i.WindowTabs[0]);
            //}

            string language = System.Configuration.ConfigurationManager.AppSettings["Language"];

            if (string.IsNullOrEmpty(language))
            {
                language = "PythonScript";
            }

            var sm = ServiceProvider.GetService <Feng.NH.ISessionFactoryManager>();

            if (sm != null)
            {
                sm.DeleteSessionFactoryCache();
                Feng.NH.ICacheConfigurationManager cm = sm as Feng.NH.ICacheConfigurationManager;
                if (cm != null)
                {
                    cm.DeleteConfigurationCaches();
                }
            }

            Form form = null;

            if (args.Length > 0)
            {
                //System.Console.ReadLine();
                if (args[0] == "-hbm" && args.Length == 2)
                {
                    Feng.NH.NHMAHelper.ExportMappingAttribute(args[1]);
                    return;
                }
                else if (args[0] == "-p" && args.Length >= 2)
                {
                    DefaultServiceProvider.Instance.SetDefaultService <IExceptionProcess>(new ConsoleExceptionProcess());

                    Dictionary <string, object> processParams = new Dictionary <string, object>();
                    for (int i = 2; i < args.Length; i += 2)
                    {
                        processParams[args[i]] = args[i + 1];
                    }
                    ProcessInfoHelper.ExecuteProcess(args[1], processParams);
                    return;
                }
                else if (args[0] == "-s")
                {
                    if (args.Length >= 2)
                    {
                        language = args[1];
                    }
                    switch (language)
                    {
                    case "PythonScript":
                        form = new Feng.Windows.Forms.PythonScriptForm();
                        break;

                    case "PythonCode":
                        form = new Feng.Windows.Forms.PythonCodeForm();
                        break;

                    case "RubyScript":
                        form = new Feng.Windows.Forms.RubyScriptForm();
                        break;

                    case "RubyCode":
                        form = new Feng.Windows.Forms.RubyCodeForm();
                        break;

                    case "CSharpCode":
                        form = new Feng.Windows.Forms.CSharpCodeForm();
                        break;
                    }
                }
            }
            else
            {
                form = new Form1();
            }

            Application.Run(form);
        }
Example #5
0
        /// <summary>
        /// 按照EventProcessInfo执行
        /// </summary>
        /// <param name="eventProcessInfo"></param>
        /// <param name="processParams"></param>
        /// <returns></returns>
        private static void ExecuteEventProcess(EventProcessInfo eventProcessInfo, object sender, EventArgs e)
        {
            if (eventProcessInfo == null)
            {
                return;
            }

            if (!eventProcessInfo.IsActive)
            {
                return;
            }

            switch (eventProcessInfo.Type)
            {
            case EventProcessType.SelectedDataValueChanged:
            {
                SelectedDataValueChangedEventArgs e2 = e as SelectedDataValueChangedEventArgs;

                string[] ss = eventProcessInfo.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string s in ss)
                {
                    string[] sss = s.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    if (sss.Length >= 2)
                    {
                        if (sss[0].Trim() == e2.DataControlName)
                        {
                            ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(sss[1].Trim()), sender, e);
                        }
                    }
                }
            }
            break;

            case EventProcessType.ReloadNv:
            {
                SelectedDataValueChangedEventArgs e2 = e as SelectedDataValueChangedEventArgs;
                if (e2 != null)
                {
                    IDisplayManager dm = sender as IDisplayManager;

                    IDataControl dc = e2.Container as IDataControl;
                    if (dc != null)
                    {
                        ReloadNvFromDataControl(eventProcessInfo, dm, dc, e2.DataControlName);
                    }
                    else
                    {
                        Xceed.Grid.Cell cell = e2.Container as Xceed.Grid.Cell;
                        //if (cell == null)
                        //{
                        //    throw new ArgumentException("SelectedDataValueChangedEventArgs's Container type is invalid!");
                        //}
                        if (cell != null)
                        {
                            ReloadNvFromGridCell(eventProcessInfo, dm, cell, e2.DataControlName);
                        }
                        else
                        {
                            ReloadNvFromEntity(eventProcessInfo, sender, e2.DataControlName);
                        }
                    }
                }
            }
            break;

            case EventProcessType.Process:
                Dictionary <string, object> dict = new Dictionary <string, object>();
                dict["sender"] = sender;
                dict["e"]      = e;
                ProcessInfoHelper.ExecuteProcess(ADInfoBll.Instance.GetProcessInfo(eventProcessInfo.ExecuteParam), dict);
                break;

            default:
                throw new ArgumentException("Invalid EventProcessInfo'Type of " + eventProcessInfo.Name + "!");
            }
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="gridName"></param>
        /// <returns></returns>
        public Dictionary <string, object> Process(object entity, string gridName)
        {
            Dictionary <string, object> r = new Dictionary <string, object>();

            // grid
            if (!Authority.AuthorizeByRule(ADInfoBll.Instance.GetGridInfo(gridName).Visible))
            {
                return(r);
            }

            // row
            if (!Permission.AuthorizeByRule(ADInfoBll.Instance.GetGridRowInfo(gridName).Visible, entity))
            {
                return(r);
            }

            // column
            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(gridName))
            {
                object v = null;
                if ((m_useColumnVisible && !Authority.AuthorizeByRule(info.ColumnVisible)) ||
                    (!m_useColumnVisible && !Authority.AuthorizeByRule(info.DataControlVisible)))
                {
                    continue;
                }
                else
                {
                    if (info.GridColumnType != GridColumnType.Normal &&
                        info.GridColumnType != GridColumnType.ExpressionColumn)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(info.PropertyName))
                    {
                        v = null;
                    }
                    else if (info.GridColumnType == GridColumnType.Normal)
                    {
                        v = EntityScript.GetPropertyValue(entity, info.Navigator, info.PropertyName);
                    }
                    else if (info.GridColumnType == GridColumnType.ExpressionColumn)
                    {
                        if (info.PropertyName.Contains("%"))
                        {
                            v = EntityScript.CalculateExpression(info.PropertyName, entity);
                        }
                        else
                        {
                            v = ProcessInfoHelper.TryExecutePython(info.PropertyName,
                                                                   new Dictionary <string, object>()
                            {
                                { "entity", entity }
                            });
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                if (v == System.DBNull.Value)
                {
                    v = null;
                }
                if (v == null)
                {
                    r[info.GridColumnName] = null;
                    continue;
                }

                string vs = null;
                if (GridColumnInfoHelper.CreateType(info).IsEnum)
                {
                    vs = v.ToString();
                }

                switch (info.CellViewerManager)
                {
                case "Combo":
                case "MultiCombo":
                    vs = GetViewerText(v, info);
                    break;

                case "Object":
                    vs = EntityHelper.ReplaceEntity(info.CellViewerManagerParam, v, null);
                    break;

                case "Numeric":
                case "Integer":
                case "Long":
                case "Currency":
                    vs = Convert.ToDouble(v).ToString(GetFormatString(info));
                    break;

                case "Date":
                case "DateTime":
                    vs = Convert.ToDateTime(v).ToString(GetFormatString(info));
                    break;

                default:
                    vs = v.ToString();
                    break;
                }

                r[info.GridColumnName] = vs;

                //// cell
                //foreach (GridCellInfo info in GridSettingInfoCollection.Instance[gridName].GridCellInfos)
                //{
                //}
            }

            return(r);
        }