public virtual JObject GetFolders(HttpContext context) { YZRequest request = new YZRequest(context); int folderid = request.GetInt32("node"); bool checkpermision = request.GetBool("checkpermision", false); SecurityModel securitymodel = request.GetEnum <SecurityModel>("securitymodel", SecurityModel.RBAC); bool withfolder = request.GetBool("folder", true); bool withfile = request.GetBool("file", false); bool iconFromExt = request.GetBool("iconFromExt", false); bool expand = request.GetBool("expand", false); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { using (BPMConnection bpmcn = new BPMConnection()) { if (checkpermision && securitymodel == SecurityModel.RBAC) { bpmcn.WebOpen(); } JObject rv = new JObject(); JArray items = new JArray(); rv[YZJsonProperty.children] = items; this.ExpandTree(provider, cn, bpmcn, items, folderid, withfolder, withfile, expand, iconFromExt, checkpermision, securitymodel, true); rv[YZJsonProperty.success] = true; return(rv); } } } }
public virtual JObject LoginTrial(HttpContext context) { YZRequest request = new YZRequest(context); bool isapp = request.GetBool("isapp"); string lang = request.GetString("lang", "zh-chs"); string cordova = request.GetString("cordova"); string model = request.GetString("model"); string name = request.GetString("name", model); string platform = request.GetString("platform"); string uuid = request.GetString("uuid"); string version = request.GetString("version"); string manufacturer = request.GetString("manufacturer"); bool isVirtual = request.GetBool("isVirtual", false); string serial = request.GetString("serial"); string uid = "99199"; string pwd = "1"; string realAccount = null; string token = null; if (!BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, uid, pwd, out realAccount, out token)) { throw new Exception(Resources.YZStrings.Aspx_Login_Fail); } YZAuthHelper.SetAuthCookie(realAccount, token); YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); YZAuthHelper.ClearLogoutFlag(); JObject rv = this.GenLoginResult(realAccount, true); return(rv); }
/* * AZTEC, * CODABAR, * CODE_39, * CODE_93, * CODE_128, * DATA_MATRIX, * EAN_8, * EAN_13, * ITF, * MAXICODE, * PDF_417, * QR_CODE, * RSS_14, * RSS_EXPANDED, * UPC_A, * UPC_E, * All_1D, * UPC_EAN_EXTENSION, * MSI, * PLESSEY, * IMB, */ public virtual void Encode(HttpContext context) { YZRequest request = new YZRequest(context); string text = request.GetString("text"); int width = request.GetInt32("width", 0); int height = request.GetInt32("height", 42); BarcodeFormat format = request.GetEnum <BarcodeFormat>("format", BarcodeFormat.CODE_128); bool pureBarcode = request.GetBool("pureBarcode", false); EncodingOptions options = new EncodingOptions { //DisableECI = true, //CharacterSet = "UTF-8", PureBarcode = pureBarcode, Margin = 0, Width = width, Height = height }; BarcodeWriter writer = new BarcodeWriter(); writer.Format = format; writer.Options = options; using (Bitmap image = writer.Write(text)) { this.ProcessResponseHeader(context, format + ".gif", false); image.Save(context.Response.OutputStream, ImageFormat.Gif); } }
public virtual void MoveOUObjects(HttpContext context) { YZRequest request = new YZRequest(context); string src = request.GetString("src"); string tag = request.GetString("tag"); bool copy = request.GetBool("copy"); JObject post = request.GetPostData <JObject>(); BPMObjectNameCollection roles = post["roles"].ToObject <BPMObjectNameCollection>(); BPMObjectNameCollection members = post["members"].ToObject <BPMObjectNameCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (copy) { OU.CopyRoleAndMembers(cn, src, tag, roles, members); } else { OU.MoveRoleAndMembers(cn, src, tag, roles, members); } } }
public virtual JObject GetFolders(HttpContext context) { YZRequest request = new YZRequest(context); StoreZoneType zone = request.GetEnum <StoreZoneType>("zone"); string path = request.GetString("node"); bool expand = request.GetBool("expand", false); if (path == "root") { path = null; } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); JObject rv = new JObject(); JArray items = new JArray(); rv[YZJsonProperty.children] = items; this.ExpandTree(cn, items, path, zone, expand); rv[YZJsonProperty.success] = true; return(rv); } }
public virtual JObject DirectSend(HttpContext context) { YZRequest request = new YZRequest(context); int stepid = request.GetInt32("StepID"); bool saveFormData = request.GetBool("SaveFormData"); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (saveFormData) { BPMProcess.Post(cn, context.Request.InputStream); } BPMStepCollection newsteps = BPMProcStep.DirectSend(cn, stepid); List <string> to = new List <string>(); foreach (BPMProcStep step in newsteps) { to.Add(String.Format("{0}[{1}]", step.NodeName, YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName))); } JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["tosteps"] = String.Join(";", to.ToArray()); return(rv); } }
public virtual void SetLoginProtect(HttpContext context) { YZRequest request = new YZRequest(context); bool value = request.GetBool("value"); string uid = YZAuthHelper.LoginUserAccount; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); User.SetAppLoginProtect(cn, uid, value); } }
public virtual Library.Library UpdateLibrary(HttpContext context) { YZRequest request = new YZRequest(context); int libid = request.GetInt32("libid"); bool updateProperty = request.GetBool("property", true); bool updateAcl = request.GetBool("acl", true); JObject jPost = request.GetPostData <JObject>(); Library.Library libPost = jPost["data"].ToObject <Library.Library>(); ACL acl = jPost["acl"].ToObject <ACL>(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { Library.Library lib = LibraryManager.GetLibrary(provider, cn, libid); if (updateProperty) { lib.ImageFileID = libPost.ImageFileID; lib.Name = libPost.Name; lib.Desc = libPost.Desc; LibraryManager.Update(provider, cn, lib); } if (updateAcl) { using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); SecurityManager.SaveACL(bpmcn, SecurityResType.Library, lib.LibID.ToString(), null, acl); } } return(lib); } } }
public virtual object GetOUObjects(HttpContext context) { YZRequest request = new YZRequest(context); string path = request.GetString("path", null); bool role = request.GetBool("role", true); bool user = request.GetBool("user", true); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (String.IsNullOrEmpty(path)) { OUCollection ous = cn.GetRootOUs(); if (ous.Count == 1) { return(this.GetOUObjects(cn, ous[0].FullName, role, user)); } } return(this.GetOUObjects(cn, path, role, user)); } }
public virtual object GetEmployeeInfo(HttpContext context) { YZRequest request = new YZRequest(context); string account = request.GetString("account"); bool includeDisabledUser = request.GetBool("includeDisabledUser", false); User user; List <object> rvPositions = new List <object>(); List <object> supervisors = new List <object>(); List <object> directXSs = new List <object>(); List <object> roles = new List <object>(); object[] groups; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); user = User.FromAccount(cn, account); MemberCollection positions = OrgSvr.GetUserPositions(cn, account); foreach (Member member in positions) { rvPositions.Add( new { ou = member.GetParentOU(cn).GetFriendlyFullName(cn), LeaderTitle = member.LeaderTitle, Level = member.Level } ); supervisors.AddRange(OrgManager.GetSupervisors(cn, member.FullName, includeDisabledUser)); directXSs.AddRange(OrgManager.GetDirectXSs(cn, member.FullName, includeDisabledUser)); roles.AddRange(OrgManager.GetRoles(cn, member.FullName)); } groups = OrgManager.GetGroups(cn, account); } return(new { user = user, positions = rvPositions, supervisors = supervisors, directxss = directXSs, roles = roles, groups = groups }); }
public virtual JObject GetTree(HttpContext context) { YZRequest request = new YZRequest(context); string bpmServer = request.GetString("bpmServer", null); bool process = request.GetBool("process", false); bool checkbox = request.GetBool("checkbox", false); bool expand = request.GetBool("expand", false); BPMPermision perm = request.GetEnum <BPMPermision>("perm"); using (BPMConnection cn = new BPMConnection()) { this.OpenConnection(cn, bpmServer); JObject rv = new JObject(); JArray items = new JArray(); rv[YZJsonProperty.children] = items; this.ExpandTree(cn, items, null, perm, expand, process, checkbox); rv[YZJsonProperty.success] = true; return(rv); } }
public virtual void MoveObjectsToFolder(HttpContext context) { YZRequest request = new YZRequest(context); StoreZoneType zone = request.GetEnum <StoreZoneType>("zone"); string srcfolder = request.GetString("srcfolder", null); string tagfolder = request.GetString("tagfolder", null); bool copy = request.GetBool("copy", false); JArray post = request.GetPostData <JArray>(); BPMObjectNameCollection objectNames = post.ToObject <BPMObjectNameCollection>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); cn.MoveObjectsToFolder(zone, srcfolder, objectNames, tagfolder, copy); } }
public virtual object[] GetGroups(HttpContext context) { YZRequest request = new YZRequest(context); bool excludeEveryone = request.GetBool("excludeEveryone", false); string addtosid = request.GetString("addtosid", null); SecurityGroupCollection groups = new SecurityGroupCollection(); bool writePerm; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); writePerm = SecurityManager.CheckPermision(cn, WellKnownRSID.SecurityGroupRoot, BPMPermision.Write); if (SecurityManager.CheckPermision(cn, WellKnownRSID.SecurityGroupRoot, BPMPermision.Read)) { groups = GroupManager.GetSecurityGroups(cn); } } List <object> rv = new List <object>(); foreach (SecurityGroup group in groups) { if (excludeEveryone && group.SID == WellKnownSID.Everyone) { continue; } if (!String.IsNullOrEmpty(addtosid) && group.SID == addtosid) { continue; } rv.Add(new { GroupName = group.GroupName, SID = group.SID, perm = new { Delete = writePerm && !group.IsSystemGroup } }); } return(rv.ToArray()); }
public virtual JObject Public(HttpContext context) { YZRequest request = new YZRequest(context); int count = request.GetInt32("Count"); int sidCount = request.GetInt32("SIDCount"); string dataSource = request.GetString("DataSource", null); string rsid = request.GetString("RSID"); string publicPermision = request.GetString("PublicPerm"); bool leadershipToken = request.GetBool("LeadershipToken", false); string comments = request.GetString("Comments", null); JArray processedItems = new JArray(); BPMObjectNameCollection permisions = new BPMObjectNameCollection(); permisions.Add(publicPermision); SIDPairCollection sidPairs = new SIDPairCollection(); for (int j = 0; j < sidCount; j++) { string sid = request.GetString("SID" + j.ToString()); sidPairs.Add(new SIDPair(SIDType.UserSID, sid)); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); for (int i = 0; i < count; i++) { string key = request.GetString("ID" + i.ToString()); RecordSecurityManager.Public(cn, rsid, key, sidPairs, permisions, leadershipToken, comments, dataSource); JObject processedItem = new JObject(); processedItem["ID"] = key; processedItems.Add(processedItem); } JObject rv = new JObject(); rv["success"] = true; rv["processedItems"] = processedItems; return(rv); } }
public virtual object SearchUser(HttpContext context) { YZRequest request = new YZRequest(context); string keyword = request.GetString("keyword", null); bool includeDisabledUser = request.GetBool("includeDisabledUser", false); //将数据转化为Json集合 JObject rv = new JObject(); JArray children = new JArray(); rv[YZJsonProperty.children] = children; if (!String.IsNullOrEmpty(keyword)) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); UserCollection users = OrgSvr.SearchUser(cn, keyword, includeDisabledUser); foreach (User user in users) { MemberCollection positions = OrgSvr.GetUserPositions(cn, user.Account); MemberCollection members = new MemberCollection(); if (positions.Count != 0) { members.Add(positions[0]); } foreach (Member member in members) { JObject jItem = this.JObjectFromMember(member, user); string oufullName = member.GetParentOU(cn).GetFriendlyFullName(cn); jItem["parentouFriendlyName"] = oufullName; jItem["memberFriendlyName"] = oufullName + "/" + user.Account; jItem["search"] = true; children.Add(jItem); } } } } //输出数据 return(rv); }
public virtual JObject AddFileFromFileSystem(HttpContext context) { YZRequest request = new YZRequest(context); bool thumbnail = request.GetBool("thumbnail", false); string root = request.GetString("root"); string path = request.GetString("path", null); string fileid = request.GetString("fileid"); string rootPath = OSDirectoryManager.GetRootPath(root); string folderPath = Path.Combine(context.Server.MapPath(rootPath), path); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { string file = OSDirectoryManager.AddFileFromFileSystem(provider, cn, folderPath, fileid, thumbnail); OSFileInfo fileinfo = new OSFileInfo(file); return(this.Serialize(fileinfo, path)); } } }
public virtual void MoveOU(HttpContext context) { YZRequest request = new YZRequest(context); string src = request.GetString("src"); string tag = request.GetString("tag"); bool copy = request.GetBool("copy"); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (copy) { OU.CopyOU(cn, src, tag); } else { OU.MoveOU(cn, src, tag); } } }
public virtual JArray GetProcessVersions(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("ProcessName"); bool active = request.GetBool("active", true); BPMProcessCollection processes; //获得数据 using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); string path = cn.GetGlobalObjectFolder(StoreZoneType.Process, processName); processes = cn.GetProcessVersions(path, BPMPermision.Read, processName); } //将数据转化为Json集合 JArray rv = new JArray(); BPMProcess activeProcess = null; foreach (BPMProcess process in processes) { if (process.Active) { activeProcess = process; continue; } rv.Insert(0, this.Serialize(process)); } if (activeProcess != null && active) { rv.Insert(0, this.Serialize(activeProcess)); } return(rv); }
public virtual void RestoreObjects(HttpContext context) { YZRequest request = new YZRequest(context); bool phyDelete = request.GetBool("phyDelete", false); JObject post = request.GetPostData <JObject>(); List <int> fileids = post["fileids"].ToObject <List <int> >(); List <int> folderids = post["folderids"].ToObject <List <int> >(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { foreach (int fileid in fileids) { DirectoryManager.RestoreFile(provider, cn, fileid); } foreach (int folderid in folderids) { DirectoryManager.RestoreFolder(provider, cn, folderid); } } } }
public virtual object GetQueryData(HttpContext context) { YZRequest request = new YZRequest(context); String datasourceName = request.GetString("DataSource", null); String query = request.GetString("Query"); QueryParameterCollection queryParams = JArray.Parse(request.GetString("QueryParams")).ToObject <QueryParameterCollection>(); YZClientParamCollection @params = JArray.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(request.GetString("params", YZJsonHelper.Base64EmptyJArray)))).ToObject <YZClientParamCollection>(); bool clientCursor = request.GetBool("clientCursor", false); //应用查询条件 BPMDBParameterCollection finallyParams = queryParams.CreateNullDBParameters(); foreach (BPMDBParameter @param in finallyParams) { YZClientParam clientParam = @params.TryGetItem(@param.Name); if (clientParam != null && clientParam.value != null) { @param.Value = clientParam.value; } } FlowDataTable table = new FlowDataTable(); int rowcount; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); table.Load(cn, BPMCommandType.Query, query, finallyParams, clientCursor, request.Start, request.Limit, out rowcount); } return(new { total = rowcount, children = table.ToDataTable() }); }
public virtual JArray GetDataSourceAndTables(HttpContext context) { YZRequest request = new YZRequest(context); string datasourceName = request.GetString("node", null); if (datasourceName == "root") { datasourceName = null; } bool expand = request.GetBool("expand", false); if (String.IsNullOrEmpty(datasourceName)) { BPMObjectNameCollection dsNames; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); dsNames = DataSourceManager.GetDataSourceNames(cn); } JArray rv = new JArray(); foreach (string dsName in dsNames) { JObject jitem = new JObject(); rv.Add(jitem); jitem["leaf"] = false; jitem["id"] = dsName; jitem["text"] = dsName; jitem["iconCls"] = "dbdatabase"; jitem["expanded"] = expand; } return(rv); } else { bool includeView = request.GetBool("view", false); BPMObjectNameCollection tables; BPMObjectNameCollection views = new BPMObjectNameCollection(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); tables = DataSourceManager.GetTables(cn, datasourceName); if (includeView) { views = DataSourceManager.GetViews(cn, datasourceName); } } JArray rv = new JArray(); foreach (string tableName in tables) { JObject jitem = new JObject(); rv.Add(jitem); jitem["leaf"] = true; jitem["id"] = datasourceName + '.' + tableName; jitem["text"] = tableName; jitem["iconCls"] = "dbtable"; jitem["data"] = JObject.FromObject(new { DataSourceName = datasourceName, TableName = tableName }); } foreach (string viewName in views) { JObject jitem = new JObject(); rv.Add(jitem); jitem["leaf"] = true; jitem["id"] = datasourceName + '.' + viewName; jitem["text"] = viewName; jitem["iconCls"] = "dbview"; jitem["data"] = JObject.FromObject(new { DataSourceName = datasourceName, TableName = viewName }); } return(rv); } }
public virtual void ExportGrid2Excel(HttpContext context) { YZRequest request = new YZRequest(context); bool dynamicParams = request.GetBool("dynamicParams", false); //获得数据 - jsonResponse string jsonResponse; JObject jRequest = JObject.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(context.Request.Params["request"]))); string url = (string)jRequest["url"]; url = "~/" + url; JToken jToken; using (StringWriter sw = new StringWriter()) { HtmlTextWriter writer = new HtmlTextWriter(sw); HttpResponse response = new HttpResponse(writer); List <string> queryParams = new List <string>(); queryParams.Add("DateFormat=text"); foreach (KeyValuePair <string, JToken> property in (jRequest["params"] as JObject)) { queryParams.Add(property.Key + "=" + HttpUtility.UrlEncode((string)property.Value, Encoding.Default)); } HttpRequest callrequest = new HttpRequest(null, context.Request.Url.ToString(), String.Join("&", queryParams.ToArray())); HttpContext callcontext = new HttpContext(callrequest, response); IHttpHandler handler = PageParser.GetCompiledPageInstance(url, context.Server.MapPath(url), context); handler.ProcessRequest(callcontext); jsonResponse = sw.ToString(); jToken = JToken.Parse(jsonResponse); if (jToken is JObject) { JObject jObject = jToken as JObject; if (jObject["success"] != null && jObject["success"].Type == JTokenType.Boolean && (bool)jObject["success"] == false) { throw new Exception((string)jObject["errorMessage"]); } } } //将数据转化为Table DataTable table; string rootProperty = request.GetString("rootProperty", null); JArray jTable; if (String.IsNullOrEmpty(rootProperty)) { jTable = jToken as JArray; } else { jTable = (jToken as JObject)[rootProperty] as JArray; } foreach (JObject jRow in jTable) { foreach (KeyValuePair <string, JToken> jProperty in jRow) { if (jProperty.Value is JArray) { jRow[jProperty.Key] = Convert.ToString(jProperty.Value); } if (jProperty.Value is JObject) { jRow[jProperty.Key] = Convert.ToString(jProperty.Value); } } } table = jTable.ToObject <DataTable>(); table.TableName = "GridStore"; //SQL Server数据库中monery4位小数点处理 foreach (DataRow row in table.Rows) { foreach (DataColumn column in table.Columns) { object value = row[column]; if (value is decimal) { value = (decimal)Decimal.ToDouble((decimal)value); } row[column] = value; } } //生成Excel string templateExcel = request.GetString("templateExcel", String.Empty); HSSFWorkbook book = null; if (String.IsNullOrEmpty(templateExcel)) { book = this.NoTemplateExport(context, table); } else { if (!templateExcel.StartsWith("~/")) { templateExcel = "~/" + templateExcel; } Dictionary <string, string> reportParams = new Dictionary <string, string>(); //获得查询参数 foreach (KeyValuePair <string, JToken> property in (jRequest["params"] as JObject)) { reportParams.Add(property.Key, (string)property.Value); } if (!reportParams.ContainsKey("Kwd")) { reportParams.Add("Kwd", ""); } if (dynamicParams) { string strRuntimeParams = reportParams["params"]; if (!String.IsNullOrEmpty(strRuntimeParams)) { YZClientParamCollection runtimeParams = JArray.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(strRuntimeParams))).ToObject <YZClientParamCollection>(); foreach (YZClientParam clientParams in runtimeParams) { reportParams[clientParams.name] = Convert.ToString(clientParams.value); } } } //打开文件 using (FileStream file = new FileStream(context.Server.MapPath(templateExcel), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { book = new HSSFWorkbook(file); } DataSet dataset = new DataSet(); dataset.Tables.Add(table); YZExcelGenerate.Fill(book, reportParams, dataset); YZExcelGenerate.PrepareForOutput(book); } //Excel文件保存到流 byte[] bytes; using (MemoryStream ms = new MemoryStream()) { book.Write(ms); bytes = ms.ToArray(); } //导出文件名 string fileName = context.Request.Params["fileName"]; if (String.IsNullOrEmpty(fileName)) { fileName = "Export"; } fileName += YZStringHelper.DateToString(DateTime.Now) + ".xls"; this.ProcessResponseHeader(context, fileName, true); context.Response.BinaryWrite(bytes); //this.OnExported(context, table); //设置Response头 //context.Response.Clear(); //context.Response.ContentType = "application/vnd.ms-excel"; //context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); //context.Response.AppendHeader("Content-Length", bytes.Length.ToString()); //context.Response.BinaryWrite(bytes); //context.Response.End(); }
public virtual void Download(HttpContext context) { YZRequest request = new YZRequest(context); bool osfile = request.GetBool("osfile", false); //if (context.Request.Headers["If-None-Match"] != null || context.Request.Headers["If-Modified-Since"] != null) //{ // context.Response.Status = "304 Not Modified"; // context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); // context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); // context.Response.AppendHeader("ETag", "Never_Modify"); // context.Response.Cache.SetETag("Never_Modify"); // context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); // context.Response.End(); // return; //} string filePath; string fileName; long fileSize; string fileExt; if (osfile) { string root = request.GetString("root"); string path = request.GetString("path"); fileName = request.GetString("name"); string rootPath = context.Server.MapPath(YZSoft.FileSystem.OSDirectoryManager.GetRootPath(root)); filePath = Path.Combine(rootPath, path, fileName); if (!File.Exists(filePath)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Upload_FileIDNotFount, fileName)); } FileInfo fileInfo = new FileInfo(filePath); fileSize = fileInfo.Length; fileExt = fileInfo.Extension; } else { string fileId = request.GetString("fileid"); AttachmentInfo attachment; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { attachment = AttachmentManager.GetAttachmentInfo(provider, cn, fileId); } } fileName = attachment.Name; fileExt = attachment.Ext; fileSize = attachment.Size; filePath = AttachmentInfo.FileIDToPath(fileId, AttachmentManager.AttachmentRootPath); if (!File.Exists(filePath)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Upload_FileIDNotFount, fileId)); } } string fileExtNoDot = fileExt == null ? "" : fileExt.TrimStart('.'); bool contentDisposition = true; string range = context.Request.Headers["Range"]; string contentType = YZMimeMapping.GetMimeType(fileExt); context.Response.AppendHeader("Content-Type", contentType); if (contentDisposition) { context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + context.Server.UrlEncode(fileName)); } context.Response.AppendHeader("Accept-Ranges", "bytes"); if (range == null) { FileInfo fileinfo = new FileInfo(filePath); //全新下载 context.Response.AppendHeader("Content-Length", fileinfo.Length.ToString()); //context.Response.CacheControl = HttpCacheability.Public.ToString(); //context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); //context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); //context.Response.AppendHeader("ETag", "Never_Modify"); //context.Response.Cache.SetETag("Never_Modify"); //context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); context.Response.TransmitFile(filePath); } else { //断点续传以及多线程下载支持 string[] file_range = range.Substring(6).Split(new char[1] { '-' }); if (string.IsNullOrEmpty(file_range[0])) { file_range[0] = "0"; } if (string.IsNullOrEmpty(file_range[1])) { file_range[1] = fileSize.ToString(); } context.Response.Status = "206 Partial Content"; context.Response.AppendHeader("Content-Range", "bytes " + file_range[0] + "-" + file_range[1] + "/" + fileSize.ToString()); context.Response.AppendHeader("Content-Length", (Int32.Parse(file_range[1]) - Int32.Parse(file_range[0])).ToString()); context.Response.TransmitFile(filePath, long.Parse(file_range[0]), (long)(Int32.Parse(file_range[1]) - Int32.Parse(file_range[0]))); } }
public virtual void Preview(HttpContext context) { YZRequest request = new YZRequest(context); bool osfile = request.GetBool("osfile", false); BPMObjectNameCollection supports = BPMObjectNameCollection.FromStringList(request.GetString("supports", null), ','); string filePath; string fileName; long fileSize; string fileExt; if (osfile) { string root = request.GetString("root"); string path = request.GetString("path"); fileName = request.GetString("name"); string rootPath = context.Server.MapPath(YZSoft.FileSystem.OSDirectoryManager.GetRootPath(root)); filePath = Path.Combine(rootPath, path, fileName); if (!File.Exists(filePath)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Upload_FileIDNotFount, fileName)); } FileInfo fileInfo = new FileInfo(filePath); fileSize = fileInfo.Length; fileExt = fileInfo.Extension; } else { string fileId = request.GetString("fileid"); AttachmentInfo attachment; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { attachment = AttachmentManager.GetAttachmentInfo(provider, cn, fileId); } } fileName = attachment.Name; fileExt = attachment.Ext; fileSize = attachment.Size; filePath = AttachmentInfo.FileIDToPath(fileId, AttachmentManager.AttachmentRootPath); if (!File.Exists(filePath)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Upload_FileIDNotFount, fileId)); } } string fileExtNoDot = fileExt == null ? "" : fileExt.TrimStart('.'); //有请求格式并且请求格式非元文件格式 if (supports.Count != 0 && !supports.Contains(fileExtNoDot)) { //发现已有转换文件 string existFile = null; foreach (string format in supports) { string outputFile = Path.Combine(Path.GetDirectoryName(filePath), String.Format("{0}.{1}", Path.GetFileNameWithoutExtension(filePath), format)); if (File.Exists(outputFile)) { existFile = outputFile; break; } } if (!String.IsNullOrEmpty(existFile)) { filePath = existFile; } else { //转换文件 string targetExt = supports[0]; DocumentFormat targetFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), targetExt, true); string outputFile = Path.Combine(Path.GetDirectoryName(filePath), String.Format("{0}.{1}", Path.GetFileNameWithoutExtension(filePath), targetExt)); DocumentFormat srcFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), fileExtNoDot, true); if (srcFormat == DocumentFormat.Pdf && targetFormat == DocumentFormat.Html) { YZSoft.Web.File.FileConvert.Pdf2Html(filePath); filePath = outputFile; } else { DocumentConverterResult result = DocumentConverter.Convert( new GleamTech.IO.BackSlashPath(filePath), new InputOptions(srcFormat), new GleamTech.IO.BackSlashPath(outputFile), targetFormat ); filePath = result.OutputFiles[0]; } } fileExt = Path.GetExtension(filePath); } string range = context.Request.Headers["Range"]; string contentType = YZMimeMapping.GetMimeType(fileExt); context.Response.AppendHeader("Content-Type", contentType); context.Response.AppendHeader("Accept-Ranges", "bytes"); if (range == null) { FileInfo fileinfo = new FileInfo(filePath); //全新下载 context.Response.AppendHeader("Content-Length", fileinfo.Length.ToString()); //context.Response.CacheControl = HttpCacheability.Public.ToString(); //context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); //context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); //context.Response.AppendHeader("ETag", "Never_Modify"); //context.Response.Cache.SetETag("Never_Modify"); //context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); context.Response.TransmitFile(filePath); } else { //断点续传以及多线程下载支持 string[] file_range = range.Substring(6).Split(new char[1] { '-' }); context.Response.Status = "206 Partial Content"; context.Response.AppendHeader("Content-Range", "bytes " + file_range[0] + "-" + file_range[1] + "/" + fileSize.ToString()); context.Response.AppendHeader("Content-Length", (Int32.Parse(file_range[1]) - Int32.Parse(file_range[0]) + 1).ToString()); context.Response.TransmitFile(filePath, long.Parse(file_range[0]), (long)(Int32.Parse(file_range[1]) - Int32.Parse(file_range[0]) + 1)); } }
protected virtual void ApplyMSChartData(YZRequest request, JObject rv, ReportMSChartView view, DataTable dataTable) { Chart chart = new Chart(); YZChartHelper.ApplayChartStyle(chart); //设置报表大小 chart.Width = new Unit(view.ReportWidth, UnitType.Pixel); chart.Height = new Unit(view.ReportHeight, UnitType.Pixel); //添加主副标题 chart.Titles[0].Text = view.ReportTitle; chart.Titles[0].Alignment = ContentAlignment.TopCenter; //设置注释 if (view.Series.Count >= 2) { chart.Legends.Add(new Legend("Default")); chart.Legends[0].Docking = Docking.Bottom; chart.Legends[0].BackColor = Color.Transparent; chart.Legends[0].Alignment = StringAlignment.Center; chart.Legends[0].BorderColor = Color.Black; } //添加系列 BPMObjectNameCollection denySeries = JArray.Parse(request.GetString("DenySeries", "[]")).ToObject <BPMObjectNameCollection>(); foreach (ReportSeries reportSeries in view.Series) { if (denySeries.Contains(reportSeries.Name)) { continue; } Series series = new Series(reportSeries.Name); chart.Series.Add(series); series.ShadowColor = Color.Transparent; series.BorderColor = Color.FromArgb(180, 26, 59, 105); series.Color = Color.FromArgb(180, reportSeries.Color); series.XValueMember = view.XAxisColumnName; series.YValueMembers = reportSeries.DataColumnName; series.Tag = reportSeries; } //应用客户设置 SeriesChartType chartType = request.GetEnum <SeriesChartType>("ChartType", view.ChartType); bool enable3D = request.GetBool("Enable3D", false); int rotation = request.GetInt32("Rotation", 0); foreach (Series chartSeries in chart.Series) { chartSeries.ChartType = chartType; } if (enable3D) { foreach (ChartArea chartArea in chart.ChartAreas) { chartArea.Area3DStyle.Enable3D = true; chartArea.Area3DStyle.Rotation = rotation; } } //执行绑定 chart.DataSource = dataTable; chart.DataBind(); //应用数据显示 foreach (Series series in chart.Series) { foreach (DataPoint point in series.Points) { point.Label = point.YValues[0].ToString() + (series.Tag as ReportSeries).Unit; } } //生成报表图片 string imageId = Guid.NewGuid().ToString(); using (MemoryStream stream = new MemoryStream()) { chart.SaveImage(stream, ChartImageFormat.Png); ChartManager.CurrentStore.Save(imageId, stream.ToArray(), "mschart.png", null); } rv["chartid"] = imageId; rv["width"] = chart.Width.Value; rv["height"] = chart.Height.Value; }
public virtual JObject GetUsers(HttpContext context) { YZRequest request = new YZRequest(context); string keyword = request.GetString("keyword", null); bool position = request.GetBool("position", false); //获得数据 UserCollection users = new UserCollection(); int rowcount; JObject rv = new JObject(); //将数据转化为Json集合 JArray children = new JArray(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); users = OrgSvr.SearchUser(cn, keyword, 100); users.Sort(new UserCompare()); rowcount = users.Count; foreach (User user in users) { JObject item = new JObject(); children.Add(item); item["Name"] = user.DisplayName; item["Account"] = user.Account; item["HRID"] = user.HRID; item["ShortName"] = user.ShortName; item["group"] = YZPinYinHelper.GetShortPinyin(user.ShortName.Substring(0, 1)).ToUpper(); //item["Mobile"] = user.Mobile; //item["HomePhone"] = user.HomePhone; //item["OfficePhone"] = user.OfficePhone; //item["Mail"] = user.EMail; if (position) { JArray jMembers = new JArray(); item["positions"] = jMembers; MemberCollection members = OrgSvr.GetUserPositions(cn, user.Account); foreach (Member member in members) { JObject jMember = new JObject(); jMembers.Add(jMember); jMember["LeaderTitle"] = member.LeaderTitle; jMember["Level"] = member.Level; jMember["OUName"] = member.GetParentOU(cn).Name; } } } } rv[YZJsonProperty.children] = children; rv[YZJsonProperty.total] = rowcount; return(rv); }
public virtual void CheckUser(HttpContext context) { YZRequest request = new YZRequest(context); bool addtoRecently = request.GetBool("addtoRecently", true); int count = request.GetInt32("Count", 0); List <string> uids = new List <string>(); List <string> members = new List <string>(); for (int i = 0; i < count; i++) { string uid = request.GetString("uid" + i.ToString()); uids.Add(uid); string memberfullname = request.GetString("member" + i.ToString(), null); members.Add(memberfullname); } List <string> errUsers = new List <string>(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (string uid in uids) { User user = User.TryGetUser(cn, uid); if (user == null) { continue; } if (user.Disabled) { errUsers.Add(user.FriendlyName); } } } if (errUsers.Count != 0) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Contains_DisabledUser, String.Join(";", errUsers.ToArray()))); } IYZDbProvider provider = YZDbProviderManager.DefaultProvider; using (IDbConnection cn = provider.OpenConnection()) { string uid = YZAuthHelper.LoginUserAccount; for (int i = 0; i < members.Count; i++) { string account = uids[i]; string memberFullName = members[i]; if (String.IsNullOrEmpty(memberFullName)) { continue; } OrgManager.AddRecentlyUser(cn, uid, account, memberFullName); } } }
public virtual object GetFolderObjects(HttpContext context) { YZRequest request = new YZRequest(context); int parentFolderID = request.GetInt32("folderid"); bool checkpermision = request.GetBool("checkpermision", false); SecurityModel securitymodel = request.GetEnum <SecurityModel>("securitymodel", SecurityModel.RBAC); string ext = request.GetString("ext", null); bool withfolder = request.GetBool("folder"); bool withfile = request.GetBool("file"); bool userName = request.GetBool("username", false); Folder folder = new Folder(); List <object> rv = new List <object>(); bool haspermision = true; using (BPMConnection bpmcn = new BPMConnection()) { if (checkpermision && securitymodel == SecurityModel.RBAC) { bpmcn.WebOpen(); haspermision = SecurityManager.CheckPermision(bpmcn, Folder.GetRSID(parentFolderID), BPMPermision.Read); } } using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { folder = DirectoryManager.GetFolderByID(provider, cn, parentFolderID); folder["children"] = rv; if (haspermision) { if (withfile) { FileCollection files = DirectoryManager.GetFiles(provider, cn, parentFolderID, null, null, -1); foreach (File file in files) { AttachmentInfo attachmentInfo = AttachmentManager.TryGetAttachmentInfo(provider, cn, file.FileID); if (attachmentInfo == null) { continue; } if (!String.IsNullOrEmpty(ext) && !NameCompare.EquName(attachmentInfo.Ext, ext)) { continue; } JObject jFile = JObject.FromObject(file); rv.Add(jFile); jFile["Name"] = attachmentInfo.Name; jFile["Size"] = attachmentInfo.Size; jFile["LastUpdate"] = attachmentInfo.LastUpdate; jFile["OwnerAccount"] = attachmentInfo.OwnerAccount; } } if (withfolder) { rv.AddRange(DirectoryManager.GetFolders(provider, cn, parentFolderID, null, null)); } } } } if (userName) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); foreach (object item in rv) { JObject jFile = item as JObject; if (jFile != null) { User user = User.TryGetUser(cn, (string)jFile["OwnerAccount"]); jFile["OwnerDisplayName"] = user != null ? user.ShortName : jFile["OwnerAccount"]; } } } } return(folder); }
public virtual JObject GetTreeOfTables(HttpContext context) { YZRequest request = new YZRequest(context); string serverName = request.GetString("ServerName", null); bool expand = request.GetBool("expand", true); TableIdentityCollection tables = new TableIdentityCollection(); string strTables = request.GetString("tables", "[]"); JArray jtables = JArray.Parse(strTables); foreach (JArray jtable in jtables) { tables.Add(new TableIdentity((string)jtable[0], (string)jtable[1])); } FlowDataSet dataSet; using (BPMConnection cn = new BPMConnection()) { this.OpenConnection(cn, serverName); dataSet = DataSourceManager.LoadDataSetSchema(cn, tables); } JObject rv = new JObject(); JArray jTables = new JArray(); rv[YZJsonProperty.children] = jTables; foreach (FlowDataTable table in dataSet.Tables) { JObject jTable = new JObject(); jTables.Add(jTable); jTable["leaf"] = false; jTable["id"] = table.DataSourceName + ":" + table.TableName; jTable["text"] = TableIdentityHelper.GetTableIdentityName(table.DataSourceName, table.TableName); jTable["iconCls"] = "dbtable"; jTable["expanded"] = expand; JArray children = new JArray(); jTable[YZJsonProperty.children] = children; foreach (FlowDataColumn column in table.Columns) { JObject jColumn = new JObject(); children.Add(jColumn); jColumn["leaf"] = true; jColumn["id"] = table.DataSourceName + ":" + table.TableName + "." + column.ColumnName; jColumn["text"] = column.ColumnName; jColumn["iconCls"] = "dbcolumn"; jColumn["data"] = JObject.FromObject(new { DataSourceName = table.DataSourceName, TableName = table.TableName, ColumnName = column.ColumnName, FullName = table.TableName + "." + column.ColumnName, Type = column.DataType.Name }); } } rv[YZJsonProperty.success] = true; return(rv); }
public virtual JObject Login(HttpContext context) { YZRequest request = new YZRequest(context); string lang = request.GetString("lang", "zh-chs"); string uid = request.GetString("uid"); string pwd = request.GetString("pwd", null); bool isapp = request.GetBool("isapp"); string cordova = request.GetString("cordova"); string model = request.GetString("model"); string name = request.GetString("name", model); string platform = request.GetString("platform"); string uuid = request.GetString("uuid"); string version = request.GetString("version"); string manufacturer = request.GetString("manufacturer"); bool isVirtual = request.GetBool("isVirtual", false); string serial = request.GetString("serial"); bool validationPanelShow = request.GetBool("validationPanelShow"); string smsGuid = request.GetString("smsGuid", null); string vcode = request.GetString("vcode", null); string keystore = request.GetString("keystore", null); //用私钥解密 if (!String.IsNullOrEmpty(keystore)) { string privateKey = (string)YZTempStorageManager.CurrentStore.Load(keystore); RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(1024); rsaProvider.FromXmlString(privateKey); uid = System.Text.Encoding.UTF8.GetString(rsaProvider.Decrypt(Convert.FromBase64String(uid), false)); pwd = System.Text.Encoding.UTF8.GetString(rsaProvider.Decrypt(Convert.FromBase64String(pwd), false)); } Device device = null; SMS sms = null; JObject rv; if (isapp) { using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { device = DeviceManager.TryGetDevice(provider, cn, uid, uuid); } } //设备禁用 if (device != null && device.Disabled) { rv = new JObject(); rv[YZJsonProperty.success] = false; rv["prompt"] = true; rv[YZJsonProperty.errorMessage] = Resources.YZMobile.Aspx_Auth_DeviceDisabled; return(rv); } //账号保护 if (device == null) { bool IsAppLoginProtected; using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); IsAppLoginProtected = User.IsAppLoginProtected(cn, uid); } if (IsAppLoginProtected) { if (!validationPanelShow) { rv = new JObject(); rv[YZJsonProperty.success] = false; rv["needSmsValidation"] = true; rv[YZJsonProperty.errorMessage] = Resources.YZMobile.Aspx_Auth_StrangerDevice; return(rv); } if (String.IsNullOrEmpty(smsGuid)) { throw new Exception(Resources.YZMobile.Aspx_Auth_GetValidationCodeFirst); } using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { sms = SMSManager.TryGetSMS(provider, cn, smsGuid); } } if (sms == null) { throw new Exception(Resources.YZMobile.Aspx_Auth_GetValidationCodeAgain); } if (sms.ValidationCode != vcode) { throw new Exception(Resources.YZMobile.Aspx_Auth_IncorrectValidationCode); } if (sms.ExpireDate < DateTime.Now) { throw new Exception(Resources.YZMobile.Aspx_Auth_GetValidationCodeAgain); } } } } if (String.IsNullOrEmpty(uid) /*|| String.IsNullOrEmpty(password)*/) { throw new Exception(Resources.YZStrings.Aspx_Login_EnterAccountTip); } string realAccount = null; string token = null; if (!BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, uid, pwd, out realAccount, out token)) { throw new Exception(Resources.YZStrings.Aspx_Login_Fail); } YZAuthHelper.SetAuthCookie(realAccount, token); YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); YZAuthHelper.ClearLogoutFlag(); rv = this.GenLoginResult(realAccount, false); //登录成功后处理 if (isapp) { using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { if (device != null) { device.LastLogin = DateTime.Now; DeviceManager.Update(provider, cn, device); } else { device = new Device(); device.Account = realAccount; device.UUID = uuid; device.Name = name; device.Model = model; device.Description = String.Format("{0} {1} {2} {3}", manufacturer, model, platform, version); device.Disabled = false; device.RegisterAt = DateTime.Now; device.LastLogin = device.RegisterAt; DeviceManager.Insert(provider, cn, device); } if (sms != null) { SMSManager.DeleteSMS(provider, cn, sms.ItemGUID); } } } } return(rv); }