Beispiel #1
0
        public ActionResult GetFileDowUrl(string keyValue, string type)
        {
            try
            {
                if (dataItemDetailBLL.GetItemValue("flag") == "1")
                {
                    type = "0";
                }
                if (type == "0")
                {
                    DataTable fie = fileInfoBLL.GetFiles(keyValue);
                    if (fie != null && fie.Rows.Count > 0)
                    {
                        string path = fie.Rows[0]["FileName"].ToString();
                        return(ToJsonResult(path));
                    }
                    return(ToJsonResult(0));
                }
                else
                {
                    string fid = string.Empty;
                    if (keyValue.Contains('.'))
                    {
                        fid = keyValue;
                    }
                    else
                    {
                        //fast文件
                        //根据法规ID获取FID(带后缀)
                        string    sql = string.Format(@"select t.var_fid from ex_attachment t where t.id 
in(select attachment_id from ex_law_attachment t where t.law_id='{0}' and t.law_type='01')", keyValue);
                        DataTable dt  = seb.SelectData(sql);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            fid = dt.Rows[0][0].ToString();
                        }
                        else
                        {
                            return(ToJsonResult(0));
                        }
                    }
                    var    di          = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
                    long   expiresLong = DateTime.Now.Ticks / 1000 + 180;
                    string expires     = expiresLong.ToString();
                    string token       = Md5Helper.MD5(di.GetItemValue("userKey", "Resource") + expires, 32);
                    string url         = string.Format(di.GetItemValue("FileDowUrl", "Resource"), fid, di.GetItemValue("user", "Resource"), expires, token);
                    return(ToJsonResult(url));
                }
            }
            catch (Exception)
            {
                return(ToJsonResult(0));
            }
        }
Beispiel #2
0
        public ActionResult GetFileUrl(string keyValue)
        {
            try
            {
                if (dataItemDetailBLL.GetItemValue("flag") == "1")
                {
                    DataTable fie = fileInfoBLL.GetFiles(keyValue);
                    if (fie != null && fie.Rows.Count > 0)
                    {
                        string   path = fie.Rows[0]["FilePath"].ToString();
                        string[] str  = path.Split('/');
                        if (str[str.Length - 1].EndsWith(".pdf"))
                        {
                            return(ToJsonResult(path));
                        }
                        else
                        {
                            path = Server.MapPath(path);
                            string str1     = "~/Resource/Temp/" + str[str.Length - 1].Replace("docx", "pdf").Replace("doc", "pdf");
                            string savePath = Server.MapPath(str1);
                            if (!System.IO.File.Exists(savePath))
                            {
                                System.IO.File.Copy(path, savePath);
                                Aspose.Words.Document doc = new Aspose.Words.Document(savePath);
                                doc.Save(savePath, Aspose.Words.SaveFormat.Pdf);
                            }
                            return(ToJsonResult(str1));
                        }
                    }
                    return(ToJsonResult(0));
                }
                else
                {
                    string fid = string.Empty;
                    if (keyValue.Contains('.'))
                    {
                        fid = keyValue;
                    }
                    else
                    {
                        //根据法规ID获取FID(带后缀)
                        string    sql = string.Format(@"select t.var_fid from ex_attachment t where t.id 
in(select attachment_id from ex_law_attachment t where t.law_id='{0}' and t.law_type='01')", keyValue);
                        DataTable dt  = seb.SelectData(sql);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            fid = dt.Rows[0][0].ToString();
                        }
                        else
                        {
                            return(ToJsonResult(0));
                        }
                    }
                    var    di          = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
                    long   expiresLong = DateTime.Now.Ticks / 1000 + 180;
                    string expires     = expiresLong.ToString();
                    string token       = Md5Helper.MD5(di.GetItemValue("antiStealLink.key", "Resource") + fid + expires, 32);
                    string url         = string.Format(di.GetItemValue("LawWebUrl", "Resource"), di.GetItemValue("appId", "Resource"), fid, expires, token);
                    return(ToJsonResult(url));
                }
            }
            catch (Exception)
            {
                return(ToJsonResult(0));
            }
        }
        /// <summary>
        /// 获取功能数据
        /// </summary>
        /// <returns></returns>
        private object GetModuleData()
        {
            var bzweb      = string.Empty;
            var appSetting = ConfigurationManager.AppSettings["bzweb"];

            if (appSetting != null)
            {
                bzweb = appSetting.ToString();
            }

            var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            List <ModuleEntity> list      = new List <ModuleEntity>();
            DataTable           dtModules = new DepartmentBLL().GetDataTable(string.Format("select moduleid from BASE_APPSETTINGASSOCIATION t where t.deptid='{0}' and PALTFORMTYPE=3", user.OrganizeId));

            if (dtModules.Rows.Count > 0)
            {
                string[] mIds = dtModules.AsEnumerable().Select(d => d.Field <string>("moduleid")).ToArray();
                list = moduleBLL.GetListBySql(string.Format("select * from base_module t where moduleid in('{0}') order by sortcode asc", string.Join(",", mIds).Replace(",", "','"))).ToList();
            }
            else
            {
                list = authorizeBLL.GetModuleList(SystemInfo.CurrentUserId).ToList();
            }
            var              di  = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
            string           val = new DataItemDetailBLL().GetItemValue("TrainSyncWay"); //对接方式,0:账号,1:身份证,不配置默认为账号
            string           way = new DataItemDetailBLL().GetItemValue("WhatWay");      //对接平台 0:.net培训平台 1:java培训平台
            DepartmentEntity org = new DepartmentBLL().GetEntity(user.OrganizeId);

            foreach (ModuleEntity entity in list)
            {
                if (!string.IsNullOrEmpty(entity.UrlAddress))
                {
                    if (!string.IsNullOrEmpty(bzweb))
                    {
                        entity.UrlAddress = entity.UrlAddress.Replace("{bzweb}", bzweb);
                    }
                    if (entity.EnCode == "SafetyTrain")
                    {
                        string url = di.GetItemValue("TrainWebUrl");
                        if (!string.IsNullOrEmpty(url))
                        {
                            if (way == "1")
                            {
                                UserEntity ue      = new UserBLL().GetEntity(user.UserId);
                                string     account = string.IsNullOrWhiteSpace(ue.NewAccount) ? user.Account : ue.NewAccount;
                                entity.UrlAddress = url + "?account=" + account + "&psw=" + Md5Helper.MD5(account, 32).ToLower() + "&companyId=" + org.InnerPhone;
                            }
                            else
                            {
                                if (string.IsNullOrWhiteSpace(user.IdentifyID))
                                {
                                    entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.Account);
                                }
                                else
                                {
                                    if (!string.IsNullOrWhiteSpace(val))
                                    {
                                        if (val == "0")
                                        {
                                            entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.Account);
                                        }
                                        else
                                        {
                                            entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.IdentifyID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        string bzUrl = di.GetItemValue("bzWebUrl");
                        if (!string.IsNullOrWhiteSpace(bzUrl))
                        {
                            if (entity.UrlAddress.ToLower().StartsWith("http://") && entity.UrlAddress.ToLower().Contains(bzUrl.ToLower()))
                            {
                                string args = args = BSFramework.Util.DESEncrypt.Encrypt(string.Concat(user.Account, "^" + entity.UrlAddress + "^", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "^DLBZ"));
                                entity.UrlAddress = bzUrl + "login/signin?args=" + args;
                            }
                        }

                        if (entity.EnCode == "TaskSchedulerManager")
                        {
                            entity.UrlAddress += "?args=" + BSFramework.Util.DESEncrypt.Encrypt("admin|1", "!2#3@1YV");
                        }
                    }
                }
            }
            return(list);
        }