예제 #1
0
        /// <summary>
        /// 这侧客户端权限脚本
        /// </summary>
        private void RegistClientAuth()
        {
            string script = "<script>";
            string key = "MenuAuth_" + this.PageGuid;
            try
            {
                NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                invoker.AssemblyName = "IWEHAVE.ERP.AuthBP.Agent.GetMenuItemAuthByPageGUIDBPProxy";
                invoker.DllName = "IWEHAVE.ERP.AuthBP.Agent.dll";
                invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageGUID", FieldValue = this.PageGuid });
                invoker.SourcePage = this.PageGuid;
                object obj = invoker.Do();
                if (obj != null)
                {
                    if (!Page.ClientScript.IsClientScriptBlockRegistered(key))
                    {
                        System.Web.Script.Serialization.JavaScriptSerializer jsConvertor = new System.Web.Script.Serialization.JavaScriptSerializer();
                        script += "window.$Auth=" + jsConvertor.Serialize(obj) + ";";
                        script += "$(document).ready(function(){if(window.Auth){setTimeout(function(){window.Auth.reset();},500);}});";

                    }
                }
            }
            catch (Exception ex)
            {
                NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.BizLogger);
            }
            script += "</script>";
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), key, script);

        }
예제 #2
0
 //检测当前用户是否有当前页面权限
 private bool CheckPageAuth(Auth.AuthContext ctx)
 {
     try
     {
         NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
         string proxy = NHExt.Runtime.Cfg.GetCfg<string>("PageAuthProxy");//配置文件
         if (!string.IsNullOrEmpty(proxy))
         {
             invoker.AssemblyName = proxy;
             invoker.DllName = proxy.Substring(0, proxy.LastIndexOf(".")) + ".dll";
         }
         else
         {
             invoker.AssemblyName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.GetPageAuthByGUIDBPProxy";
             invoker.DllName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.dll";
         }
         invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageGUID", FieldValue = this.PageGuid });
         invoker.SourcePage = this.PageGuid;
         return invoker.Do<bool>();
     }
     catch (NHExt.Runtime.Exceptions.BizException ex)
     {
         NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.BizLogger);
     }
     catch (NHExt.Runtime.Exceptions.RuntimeException ex)
     {
         NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);
     }
     catch (Exception ex)
     {
         NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);
     }
     return false;
 }
예제 #3
0
 /// <summary>
 /// 插入日志到数据库
 /// </summary>
 /// <param name="log"></param>
 /// <param name="type"></param>
 public static void WriteLog(string log, LoggerStatusEnum status)
 {
     NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
     invoker.AssemblyName = "IWEHAVE.ERP.PubBP.Agent.InsertTaskLogBPProxy";
     invoker.DllName = "IWEHAVE.ERP.PubBP.Agent.dll";
     invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "RecordTime", FieldValue = DateTime.Now });
     invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Content", FieldValue = log });
     invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Type", FieldValue = (int)status });
     invoker.Do<bool>();
 }
예제 #4
0
        public ActionResult LogOn(THU.LabSystem.Models.LogOnModel model)
        {
            ViewBag.ErrorMsg = string.Empty;
            if (ModelState.IsValid)
            {
                try
                {
                    NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                    invoker.AssemblyName = "THU.LabSystemBP.Agent.ValidateUserBPProxy";
                    invoker.DllName = "THU.LabSystemBP.Agent.dll";
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Code", FieldValue = model.Code });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Password", FieldValue = NHExt.Runtime.Util.EncryptHelper.Encrypt(model.Password) });
                    // invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Org", FieldValue = model.Org });
                    invoker.SourcePage = "IWEHAVE.Login";
                    THU.LabSystemBE.Deploy.UserDTO usrDTO = invoker.Do<THU.LabSystemBE.Deploy.UserDTO>();
                    if (usrDTO == null)
                    {
                        ViewBag.ErrorMsg = "用户名或密码错误";
                    }
                    else
                    {
                        NHExt.Runtime.Auth.AuthContext.SetContext(usrDTO.ID, usrDTO.Code, usrDTO.Name, usrDTO.Password, string.Empty);
                        THU.LabSystem.AuthExt.AuthExtCookie.SetRole(usrDTO.Type);
                        if (usrDTO.Type == THU.LabSystemBE.Deploy.UserTypeEnumDTO.Admin.EnumValue)
                        {
                            return RedirectToAction("Main", "Admin/AdminConsole");

                        }
                        else if (usrDTO.Type == THU.LabSystemBE.Deploy.UserTypeEnumDTO.User.EnumValue)
                        {
                            return RedirectToAction("Main", "User/UserConsole");
                        }
                        else
                        {
                            AuthExt.AuthExtCookie.Clear();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMsg = "用户登录失败,错误原因:" + ex.Message;
                }
            }
            else
            {
                ViewBag.ErrorMsg = "登录数据录入错误";
            }

            return LogOn();
        }
예제 #5
0
 //检测当前用户是否有当前页面权限
 private bool CheckPageAuth(Auth.AuthContext ctx)
 {
     try
     {
         NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
         invoker.AssemblyName = "IWEHAVE.ERP.AuthBP.Agent.GetPageAuthByGUIDBPProxy";
         invoker.DllName = "IWEHAVE.ERP.AuthBP.Agent.dll";
         invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageGUID", FieldValue = this.PageGuid });
         invoker.SourcePage = this.PageGuid;
         return invoker.Do<bool>();
     }
     catch (Exception ex)
     {
         NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.BizLogger);
     }
     return false;
 }
예제 #6
0
        private static void TaskWorker(object state)
        {
            int nTime = (int)state;
            while (true)
            {
                System.Threading.Thread.Sleep(0);
                try
                {
                    NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                    invoker.AssemblyName = "THU.LabSystemBP.Agent.SynDeviceMapBPProxy";
                    invoker.DllName = "THU.LabSystemBP.Agent.dll";
                    invoker.Do();

                }
                catch { }
                System.Threading.Thread.Sleep(new TimeSpan(0, 1, 0));

            }
        }
예제 #7
0
        public void ProcessRequest(HttpContext context)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("Result", "True");
            dic.Add("ErrorEx", string.Empty);
            string result = string.Empty;
            if (!string.IsNullOrEmpty(context.Request.Form["LOGIN"]))
            {
                string authCode = System.Configuration.ConfigurationManager.AppSettings["SkipAuthCode"];
                if (authCode != "1") //验证码校验
                {
                    if (string.IsNullOrEmpty(context.Request.Form["VCode"]))
                    {
                        dic["Result"] = "False";
                        dic["ErrorEx"] = "验证码不能为空";
                    }
                    else if (context.Session["rgimg"] == null)
                    {
                        dic["Result"] = "False";
                        dic["ErrorEx"] = "服务器验证码失效,请刷新重试!";
                    }
                    else if (context.Request.Form["VCode"].ToUpper() != context.Session["rgimg"].ToString().ToUpper())
                    {
                        dic["Result"] = "False";
                        dic["ErrorEx"] = "验证码错误";
                    }
                }
                //校验用户名密码
                string userCode = context.Request.Form["UserCode"];
                string userPwd = context.Request.Form["UserPwd"];
                if (string.IsNullOrEmpty(userCode))
                {
                    dic["Result"] = "False";
                    dic["ErrorEx"] = "用户名为空";
                }
                if (string.IsNullOrEmpty(userPwd))
                {
                    dic["Result"] = "False";
                    dic["ErrorEx"] = "密码为空";
                }
                if (dic["Result"] == "True")
                {
                    try
                    {
                        NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                        invoker.AssemblyName = "IWEHAVE.ERP.CenterBP.Agent.LoginMangeBPProxy";
                        invoker.DllName = "IWEHAVE.ERP.CenterBP.Agent.dll";
                        invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserCode", FieldValue = userCode });
                        invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserPwd", FieldValue = userPwd });
                        NHExt.Runtime.Model.BaseDTO obj = invoker.Do<NHExt.Runtime.Model.BaseDTO>();
                        if (obj != null)
                        {
                            long userID = Convert.ToInt64(obj.GetData("ID"));
                            NHExt.Runtime.Auth.AuthContext.SetContext(userID, userCode, userCode, userPwd, string.Empty);

                        }
                        else
                        {
                            dic["Result"] = "False";
                            dic["ErrorEx"] = "用户名或密码错误";
                        }
                    }
                    catch (Exception)
                    {

                        dic["Result"] = "False";
                        dic["ErrorEx"] = "用户名或密码错误";
                    }
                    finally
                    {
                        context.Session["rgimg"] = null;
                    }

                }
            }
            else
            {
                dic["Result"] = "False";
                dic["ErrorEx"] = "没有请求数据";
            }
            result = IWEHAVE.ERP.GAIA.WEBUtil.JsonHelper.ObjectToJSON(dic);
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
예제 #8
0
        public virtual decimal Evaluate(string expression)
        {
            if (string.IsNullOrEmpty(expression))
            {
                throw new Exception("���ʽ����Ϊ��");
            }
            string[] fields = expression.Split(new char[6] { '+', '-', '*', '/', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
            if (fields.Count() > 0)
            {
                Regex r = new Regex(@"^[1-9]\d*");//ȥ������
                List<string> fieldList = new List<string>(fields);
                fieldList.Sort((a, b) =>
                {
                    if (a.Length > b.Length)
                    {
                        return -1;
                    }
                    else if (a.Length == b.Length)
                    {
                        return 0;
                    }
                    else
                    {
                        return 1;
                    }
                });
                fields = fieldList.ToArray();
                foreach (string field in fields)
                {
                    //��������־Ͳ���
                    if (r.IsMatch(field))
                    {
                        continue;
                    }
                    decimal objV = 0;
                    if (field.StartsWith("$."))
                    {
                        //���÷����ȡ����$.IWEHAVE.ERP.PubBP.Agent.GetYearDaysBPProxy(Month:12,Year:2015)
                        string newStr = field.Replace("$.", "");
                        string bpStr = newStr.Substring(0, newStr.IndexOf("{"));
                        string argStr = newStr.Substring(newStr.IndexOf("{") + 1, (newStr.LastIndexOf("}") - newStr.IndexOf("{") - 1));
                        NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                        invoker.AssemblyName = bpStr;
                        invoker.DllName = bpStr.Substring(0, bpStr.IndexOf("Agent.")) + "Agent.dll";
                        string[] args = argStr.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        if (args.Count() > 0)
                        {
                            foreach (string arg in args)
                            {
                                //$.IWEHAVE.ERP.PubBP.Agent.GetYearDaysBPProxy(Month:#.PMerchantRent.Rent,Year:2015)
                                string fieldName = arg.Substring(0, arg.IndexOf(":"));
                                object fieldValue = new object();
                                if (!arg.Contains("@"))
                                {
                                    throw new Exception("���ʽ��������û�������Զ��庯����������");

                                }
                                string fieldArgV = arg.Substring(arg.IndexOf(":") + 1, (arg.IndexOf("@") - arg.IndexOf(":") - 1));//����ֵ
                                string fieldType = arg.Substring(arg.IndexOf("@") + 1);//��������
                                if (fieldArgV.StartsWith("#."))//�����Ļ���Ҫ�Ȼ�ȡ����
                                {
                                    fieldArgV = fieldArgV.Replace("#.", "");
                                    var objValue = this.GetData(fieldArgV);
                                    if (objValue != null)
                                    {
                                        fieldValue = this.GetValue(objValue, fieldType);
                                    }
                                }
                                else
                                {
                                    fieldValue = this.GetValue(fieldArgV, fieldType);
                                }
                                invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = fieldName, FieldValue = fieldValue });
                            }
                        }
                        Object obj = invoker.Do();
                        if (obj != null)
                        {
                            objV = Convert.ToDecimal(obj);
                        }
                    }
                    else
                    {
                        var obj = this.GetData(field);
                        if (obj != null)
                        {
                            objV = Convert.ToDecimal(obj);
                        }
                    }
                    expression = expression.Replace(field, objV.ToString());
                }
            }
            try
            {
                NHExt.Runtime.Util.RPN rpn = new NHExt.Runtime.Util.RPN();
                rpn.Parse(expression);
                return Convert.ToDecimal(rpn.Evaluate());
            }
            catch (Exception ex)
            {
                throw new Exception("���㹫ʽ��ʽ����");
            }
        }
        protected override string decodeHqlExtend()
        {
            string hqlExtend = "";
            foreach (NHExt.Runtime.Query.QueryTpl tpl in this.entityList)
            {
                if (this.IsDataAuth)
                {
                    ///调用权限服务调获取权限片段
                    try
                    {
                        NHExt.Runtime.Cache.AbstractCache<string, string> dac = null;
                        if (NHExt.Runtime.Cfg.GetCfg<bool>("IsEnableCache"))
                        {
                            dac = NHExt.Runtime.Extend.Cache.AbstractCacheFactory.GetDataAuthCache();
                            string cacheHql = dac.GetCache(tpl.EntityName);
                            if (!string.IsNullOrEmpty(cacheHql))
                            {
                                tpl.Hql = cacheHql;
                            }
                        }
                        if (tpl.Hql == null)
                        {
                            NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                            invoker.AssemblyName = "IWEHAVE.ERP.PubBP.Agent.GetEntityAuthDataBPProxy";
                            invoker.DllName = "IWEHAVE.ERP.PubBP.Agent.dll";
                            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "EntityName", FieldValue = tpl.EntityName });
                            tpl.Hql = invoker.Do<string>();
                            if (NHExt.Runtime.Cfg.GetCfg<bool>("IsEnableCache"))
                            {
                                if (tpl.Hql != null && dac != null)
                                {
                                    //写入缓存
                                    dac.SetCache(tpl.EntityName, tpl.Hql);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("调用权限服务获取数据过滤条件错误:" + ex.Message);
                    }
                }
                ///组织过滤和多组织查询过滤,如果当前登录组织委超级组织的话需要进行特殊处理
                AuthContextExtend authCtx = NHExt.Runtime.Session.SessionCache.Current.AuthContext as AuthContextExtend;
                if (authCtx.Org != 1 && authCtx.Org > 0)
                {

                    if (this.BA.OrgFilter)
                    {
                        string alias = string.IsNullOrEmpty(tpl.Alias) ? "" : (tpl.Alias + ".");
                        //如果是组织过滤数据
                        tpl.Hql += " " + alias + "Orgnization=" + authCtx.Org;
                        if (!NHExt.Runtime.Session.Session.Current.IgnoreOrgFilter)
                        {
                            if (this.BA.Range == NHExt.Runtime.Enums.ViewRangeEnum.ALL)
                            {
                                // tpl.Hql += " and 1=1";
                            }
                            else if (this.BA.Range == NHExt.Runtime.Enums.ViewRangeEnum.UPPER)
                            {
                                tpl.Hql += " and " + alias + "OrgnizationC in(-1";
                                foreach (long dataOrg in authCtx.DataOrgList)
                                {
                                    tpl.Hql += ("," + dataOrg);
                                }
                                tpl.Hql += ")";
                            }
                            else if (this.BA.Range == NHExt.Runtime.Enums.ViewRangeEnum.OWN)
                            {
                                tpl.Hql += " and " + alias + "OrgnizationC=" + authCtx.OrgC;

                            }
                        }

                    }
                }
                NHExt.Runtime.Session.Session.Current.IgnoreOrgFilter = false;

                //获取当前实体在当前登录用户的限制条件
                tpl.Parser();
                if (!string.IsNullOrEmpty(tpl.ParserHql))
                {
                    hqlExtend += " ( " + tpl.ParserHql + " ) ";
                }
            }
            return hqlExtend;
        }
예제 #10
0
        public FileResult ExportApplyFile(DateTime start, DateTime end, long device)
        {
            NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
            invoker.AssemblyName = "THU.LabSystemBP.Agent.GetDeviceUseReportBPProxy";
            invoker.DllName = "THU.LabSystemBP.Agent.dll";
            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageIndex", FieldValue = 1 });
            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageSize", FieldValue = 1000 });
            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "StartTime", FieldValue = start });
            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "EndTime", FieldValue = end });
            invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "DeviceKey", FieldValue = device });
            invoker.SourcePage = "IWEHAVE.Export";
            THU.LabSystemBE.Deploy.DeviceUseReportExDTO titleReport = invoker.Do<THU.LabSystemBE.Deploy.DeviceUseReportExDTO>();

            IWorkbook workbook = new HSSFWorkbook();
            if (titleReport != null && titleReport.ListData.Count > 0)
            {
                foreach (THU.LabSystemBE.Deploy.DeviceUseReportDTO title in titleReport.ListData)
                {

                    invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                    invoker.AssemblyName = "THU.LabSystemBP.Agent.GetDeviceUseReportBPProxy";
                    invoker.DllName = "THU.LabSystemBP.Agent.dll";
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageIndex", FieldValue = 1 });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "PageSize", FieldValue = 1000 });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "StartTime", FieldValue = start });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "EndTime", FieldValue = end });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "Level", FieldValue = 1 });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "TeacherKey", FieldValue = title.TeacherKey });
                    invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "DeviceKey", FieldValue = device });
                    THU.LabSystemBE.Deploy.DeviceUseReportExDTO contentReport = invoker.Do<THU.LabSystemBE.Deploy.DeviceUseReportExDTO>();

                    if (contentReport.ListCount <= 0)
                    {
                        continue;
                    }

                    ISheet sheet = workbook.CreateSheet(title.TeacherName);
                    for (int i = 0; i < 8; i++)
                    {
                        sheet.SetColumnWidth(i, 20 * 256);  //设置列宽,50个字符宽度。宽度参数为1/256,故乘以256
                    }
                    IRow row = sheet.CreateRow(0);
                    row.HeightInPoints = 30;

                    ICellStyle style = workbook.CreateCellStyle();
                    style.Alignment = HorizontalAlignment.Center;
                    style.VerticalAlignment = VerticalAlignment.Center;
                    style.FillForegroundColor = IndexedColors.Grey50Percent.Index;
                    style.LeftBorderColor = IndexedColors.Black.Index;
                    style.RightBorderColor = IndexedColors.Black.Index;
                    style.TopBorderColor = IndexedColors.Black.Index;
                    style.BottomBorderColor = IndexedColors.Black.Index;
                    style.BorderLeft = BorderStyle.Thin;
                    style.BorderRight = BorderStyle.Thin;
                    style.BorderTop = BorderStyle.Thin;
                    style.BorderBottom = BorderStyle.Thin;
                    style.FillPattern = FillPattern.SolidForeground;
                    ICell cell = null;
                    string[] titlesStr = { "导师姓名", "开始时间", "结束时间", "使用时间", "单价", "费用", "使用人", "设备号", "设备名称", "房间号" };
                    for (int i = 0; i < titlesStr.Length; i++)
                    {
                        cell = row.CreateCell(i);
                        cell.CellStyle = style;
                        cell.SetCellValue(titlesStr[i]);
                    }

                    ICellStyle style2 = workbook.CreateCellStyle();
                    style2.CloneStyleFrom(style);
                    style2.FillForegroundColor = IndexedColors.LightYellow.Index;
                    IFont font = workbook.CreateFont();
                    font.Boldweight = (short)FontBoldWeight.Bold;
                    style2.SetFont(font);

                    row = sheet.CreateRow(1);
                    row.HeightInPoints = 30;

                    cell = row.CreateCell(0);
                    cell.CellStyle = style2;
                    cell.SetCellValue(title.TeacherName);

                    cell = row.CreateCell(1);
                    cell.CellStyle = style2;
                    cell.SetCellValue(title.StartTime.ToString("yyyy/MM/dd"));

                    cell = row.CreateCell(2);
                    cell.CellStyle = style2;
                    cell.SetCellValue(title.EndTime.ToString("yyyy/MM/dd"));

                    cell = row.CreateCell(3);
                    cell.CellStyle = style2;
                    cell.SetCellValue("-");

                    cell = row.CreateCell(4);
                    cell.CellStyle = style2;
                    cell.SetCellValue("-");

                    cell = row.CreateCell(5);
                    cell.CellStyle = style2;
                    cell.SetCellValue(title.Fee.ToString("C"));

                    cell = row.CreateCell(6);
                    cell.CellStyle = style2;
                    cell.SetCellValue("-");

                    cell = row.CreateCell(7);
                    cell.CellStyle = style2;
                    cell.SetCellValue(title.SN);

                    cell = row.CreateCell(8);
                    cell.CellStyle = style2;
                    cell.SetCellValue("-");

                    cell = row.CreateCell(9);
                    cell.CellStyle = style2;
                    cell.SetCellValue("-");

                    ICellStyle style3 = workbook.CreateCellStyle();
                    style3.CloneStyleFrom(style);
                    style3.FillForegroundColor = IndexedColors.LightYellow.Index;
                    for (int i = 0; i < contentReport.ListData.Count; i++)
                    {
                        row = sheet.CreateRow(i + 2);
                        row.HeightInPoints = 20;
                        cell = row.CreateCell(0);
                        cell.CellStyle = style3;
                        cell.SetCellValue("");

                        cell = row.CreateCell(1);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].StartTime.ToString("yyyy/MM/dd HH:mm:ss"));

                        cell = row.CreateCell(2);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].EndTime.ToString("yyyy/MM/dd HH:mm:ss"));

                        cell = row.CreateCell(3);
                        cell.CellStyle = style2;
                        cell.SetCellValue(contentReport.ListData[i].Hours.ToString());

                        cell = row.CreateCell(4);
                        cell.CellStyle = style2;
                        cell.SetCellValue(contentReport.ListData[i].Price.ToString("C"));

                        cell = row.CreateCell(5);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].Fee.ToString("C"));

                        cell = row.CreateCell(6);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].UserName);

                        cell = row.CreateCell(7);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].SN);

                        cell = row.CreateCell(8);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].DeviceName);

                        cell = row.CreateCell(9);
                        cell.CellStyle = style3;
                        cell.SetCellValue(contentReport.ListData[i].HouseName);
                    }
                }
            }
            MemoryStream ms = new MemoryStream();
            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return File(ms, "application/vnd.ms-excel", "设备使用记录导出.xls");
        }
예제 #11
0
        protected override string decodeHqlExtend()
        {
            //获取数据权限
            string hqlExtend = "";

            ///只对于最后一个实体进行过滤
            NHExt.Runtime.Query.QueryTpl tpl = this.entityList[this.entityList.Count - 1];
            tpl.Hql = "1=1";
            ///调用权限服务调获取权限片段
            if (!this.IgnoreDataFilter)
            {
                tpl.Hql += " and(1!=1";
                try
                {
                    NHExt.Runtime.Cache.AbstractCache<string, string> dac = NHExt.Runtime.GAIA.Cache.CacheFactory.GetDataAuthCache();
                    if (!dac.Contains(tpl.EntityName))
                    {
                        NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                        string proxy = NHExt.Runtime.Cfg.GetCfg<string>("DataAuthProxy");
                        if (!string.IsNullOrEmpty(proxy))
                        {
                            invoker.AssemblyName = proxy;
                            invoker.DllName = proxy.Substring(0, proxy.LastIndexOf(".")) + ".dll";
                        }
                        else
                        {
                            invoker.AssemblyName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.GetDataAuthBPProxy";
                            invoker.DllName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.dll";
                        }
                        invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "EntityName", FieldValue = tpl.EntityName });
                        string hql = invoker.Do<string>();
                        //写入缓存
                        dac.SetCache(tpl.EntityName, hql);
                    }
                    string cacheHql = dac.GetCache(tpl.EntityName);
                    if (!string.IsNullOrEmpty(cacheHql))
                    {
                        tpl.Hql += " or (" + cacheHql + ")";
                    }
                    else
                    {
                        tpl.Hql += " or (1=1) ";
                    }
                }
                catch (NHExt.Runtime.Exceptions.BizException ex)
                {
                    NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.BizLogger);
                    throw new NHExt.Runtime.Exceptions.RuntimeException("调用权限服务获取数据过滤条件错误:" + ex.Message);
                }

                tpl.Hql += ")";

            }
            tpl.Hql += " and (1=1";

            //获取实体多组织过滤标识
            NHExt.Runtime.EntityAttribute.BussinesAttribute ba = this.getEntityBA(tpl.EntityName);
            ///组织过滤和多组织查询过滤,如果当前登录组织委超级组织的话需要进行特殊处理
            AuthContext authCtx = NHExt.Runtime.Session.SessionCache.Current.AuthContext as AuthContext;
            if (authCtx.Org != 1 && authCtx.Org > 0)
            {

                if (ba.OrgFilter)
                {
                    string alias = string.IsNullOrEmpty(tpl.Alias) ? "" : (tpl.Alias + ".");
                    //如果是组织过滤数据
                    if (!NHExt.Runtime.Session.Session.Current.IgnoreRootOrgFilter)
                    {
                        tpl.Hql += " and " + alias + "Orgnization=" + authCtx.Org;
                    }
                    if (!NHExt.Runtime.Session.Session.Current.IgnoreOrgFilter)
                    {
                        if (ba.Range == NHExt.Runtime.Enums.ViewRangeEnum.ALL)
                        {
                            // tpl.Hql += " and 1=1";
                        }
                        else if (ba.Range == NHExt.Runtime.Enums.ViewRangeEnum.UPPER)
                        {
                            tpl.Hql += " and " + alias + "OrgnizationC in(-1";
                            foreach (long dataOrg in authCtx.DataOrgList)
                            {
                                tpl.Hql += ("," + dataOrg);
                            }
                            tpl.Hql += ")";
                        }
                        else if (ba.Range == NHExt.Runtime.Enums.ViewRangeEnum.OWN)
                        {
                            tpl.Hql += " and " + alias + "OrgnizationC=" + authCtx.OrgC;

                        }
                    }

                }
            }
            tpl.Hql += " )";
            NHExt.Runtime.Session.Session.Current.IgnoreRootOrgFilter = false;
            NHExt.Runtime.Session.Session.Current.IgnoreOrgFilter = false;
            NHExt.Runtime.Session.Session.Current.IgnoreDataFilter = false;

            //获取当前实体在当前登录用户的限制条件
            tpl.Parser();
            if (!string.IsNullOrEmpty(tpl.ParserHql))
            {
                hqlExtend += " ( " + tpl.ParserHql + " ) ";
            }

            return hqlExtend;
        }
예제 #12
0
        /// <summary>
        /// 获取实体属性标识
        /// </summary>
        /// <param name="entityKey"></param>
        /// <returns></returns>
        private NHExt.Runtime.EntityAttribute.BussinesAttribute getEntityBA(string entityKey)
        {
            if (QueryParser.dacOrgFilter == null)
            {
                QueryParser.dacOrgFilter = NHExt.Runtime.GAIA.Cache.CacheFactory.GetBACache();
                lock (QueryParser.dacOrgFilter)
                {
                    try
                    {
                        NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();

                        string proxy = NHExt.Runtime.Cfg.GetCfg<string>("EntityStrProxy");
                        if (!string.IsNullOrEmpty(proxy))
                        {
                            invoker.AssemblyName = proxy;
                            invoker.DllName = proxy.Substring(0, proxy.LastIndexOf(".")) + ".dll";
                        }
                        else
                        {
                            invoker.AssemblyName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.GetEntityStrBPProxy";
                            invoker.DllName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.dll";
                        }
                        List<string> entityStrList = invoker.Do<List<string>>();
                        QueryParser.dacOrgFilter.ClearAll();
                        if (entityStrList != null)
                        {
                            foreach (string entityStr in entityStrList)
                            {
                                string[] entityStrArray = entityStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                NHExt.Runtime.EntityAttribute.BussinesAttribute attribute = new EntityAttribute.BussinesAttribute();
                                attribute.EntityName = entityStrArray[0];
                                attribute.Table = entityStrArray[1];
                                attribute.OrgFilter = entityStrArray[2] == "1" ? true : false;
                                attribute.Range = (NHExt.Runtime.Enums.ViewRangeEnum)Convert.ToInt32(entityStrArray[3]);

                                QueryParser.dacOrgFilter.SetCache(attribute.EntityName, attribute);
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        NHExt.Runtime.Logger.LoggerHelper.Info(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);

                        string assemblyStr = entityKey.Substring(0, entityKey.LastIndexOf("."));
                        Assembly ass = Assembly.LoadFrom(NHExt.Runtime.Cfg.AppLibPath + assemblyStr + ".dll");
                        Type t = ass.GetType(entityKey);
                        if (t != null)
                        {
                            NHExt.Runtime.EntityAttribute.BussinesAttribute attribute = NHExt.Runtime.Util.AttributeHelper.GetClassAttr<NHExt.Runtime.EntityAttribute.BussinesAttribute>(t);
                            QueryParser.dacOrgFilter.SetCache(entityKey, attribute);
                        }
                    }
                }
            }
            NHExt.Runtime.EntityAttribute.BussinesAttribute ba = QueryParser.dacOrgFilter.GetCache(entityKey);
            if (ba == null)
            {
                string assembly = entityKey.Substring(0, entityKey.LastIndexOf(".")) + ".dll";
                Assembly asmb = Assembly.LoadFrom(NHExt.Runtime.Cfg.AppLibPath + assembly);
                if (asmb != null)
                {
                    Type supType = asmb.GetType(entityKey);
                    if (supType == null)
                    {
                        throw new NHExt.Runtime.Exceptions.RuntimeException("实体类型不存在:" + entityKey);
                    }
                    ba = NHExt.Runtime.Util.AttributeHelper.GetClassAttr<NHExt.Runtime.EntityAttribute.BussinesAttribute>(supType);
                }
                else
                {
                    throw new NHExt.Runtime.Exceptions.RuntimeException("实体“" + entityKey + "”所在的程序集不存在");
                }
            }
            return ba;
        }
        public override void ValidateAuth()
        {
            try
            {
                NHExt.Runtime.Proxy.AgentInvoker authCheckInvoker = new NHExt.Runtime.Proxy.AgentInvoker();
                authCheckInvoker.AssemblyName = "IWEHAVE.ERP.OrgnizationBP.Agent.LoginBPProxy";
                authCheckInvoker.DllName = "IWEHAVE.ERP.OrgnizationBP.Agent.dll";
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserCode", FieldValue = this.UserCode });
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserPwd", FieldValue = this.UserPwd });
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "OrgID", FieldValue = this.OrgC });
                object obj = authCheckInvoker.Do();
                if (obj == null)
                {
                    throw new Exception("调用远程服务失败,失败原因:用户名或者密码错误!");
                }
            }
            catch (Exception ex)
            {
                Logger.LoggerInstance.RuntimeLogger.Error(ex);
                throw new Exception("调用远程服务失败,失败原因:用户名或者密码错误!");
            }


        }
예제 #14
0
        public void ExcuteTasks()
        {
            //执行前先需要登陆下看用户名和密码是否正确
            try
            {
                NHExt.Runtime.Proxy.AgentInvoker invoker = new NHExt.Runtime.Proxy.AgentInvoker();
                string loginProxy = NHExt.Runtime.Cfg.GetCfg<string>("LoginProxy");
                if (!string.IsNullOrEmpty(loginProxy))
                {
                    invoker.AssemblyName = loginProxy;
                    invoker.DllName = loginProxy.Substring(0, loginProxy.LastIndexOf(".")) + ".dll";
                }
                else
                {
                    invoker.AssemblyName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.LoginBPProxy";
                    invoker.DllName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.dll";
                }
                invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserCode", FieldValue = this._context.UserCode });
                invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserPwd", FieldValue = this._context.UserPwd });
                invoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "OrgID", FieldValue = this._context.GetData<long>("Org") });
                NHExt.Runtime.Model.BaseDTO userDTO = invoker.Do<NHExt.Runtime.Model.BaseDTO>();
                if (userDTO != null)
                {
                    string address = "127.0.0.1";
                    System.Net.IPHostEntry ipe = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
                    foreach (System.Net.IPAddress ipa in ipe.AddressList)
                    {
                        //IPV4
                        if (ipa.AddressFamily.ToString() == "InterNetwork")
                        {
                            address = ipa.ToString();
                            break;
                        }
                    }
                    long userID = (long)userDTO.GetData("ID");
                    string userCode = (string)userDTO.GetData("Code");
                    string userName = (string)userDTO.GetData("Name");
                    string userPwd = (string)userDTO.GetData("Password");
                    long rootOrgKey = (long)userDTO.GetData("RootOrgId");
                    long orgKey = (long)userDTO.GetData("OrgId");
                    NHExt.Runtime.GAIA.AuthContext.SetContext(userID, userCode, userName, userPwd, orgKey, rootOrgKey, address);
                    NHExt.Runtime.Logger.LoggerHelper.Error("登陆信息:ORG:" + orgKey + " User:"******"登陆失败,执行自动任务出错", LoggerStatusEnum.Failed);
            }
            foreach (TaskEntity te in this._taskList)
            {
                te.ExcuteTask();
            }

            NHExt.Runtime.Auth.AuthContext.ClearContext();

        }
예제 #15
0
        public override void ValidateAuth()
        {
            if (!string.IsNullOrEmpty(this.UserCode))
            {

                NHExt.Runtime.Proxy.AgentInvoker authCheckInvoker = new NHExt.Runtime.Proxy.AgentInvoker();
                string loginProxy = NHExt.Runtime.Cfg.GetCfg<string>("LoginProxy");
                if (!string.IsNullOrEmpty(loginProxy))
                {
                    authCheckInvoker.AssemblyName = loginProxy;
                    authCheckInvoker.DllName = loginProxy.Substring(0, loginProxy.LastIndexOf(".")) + ".dll";
                }
                else
                {
                    authCheckInvoker.AssemblyName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.LoginBPProxy";
                    authCheckInvoker.DllName = "IWEHAVE.ERP.Auth.ServiceBP.Agent.dll";
                }
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserCode", FieldValue = this.UserCode });
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "UserPwd", FieldValue = this.UserPwd });
                authCheckInvoker.AppendField(new NHExt.Runtime.Proxy.PropertyField() { FieldName = "OrgID", FieldValue = this.OrgC });
                object obj = authCheckInvoker.Do();
                if (obj == null)
                {
                    throw new NHExt.Runtime.Exceptions.BizException("调用远程服务失败,失败原因:用户名或者密码错误!");
                }
            }
            else
            {
                NHExt.Runtime.Logger.LoggerHelper.Info("没有用户登陆编码信息,跳过校验", NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);
            }

        }