public void Update(IDbConnection cn, YZSoft.FileSystem.File file) { using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = cn as OracleConnection; cmd.BindByName = true; StringBuilder sb = new StringBuilder(); sb.Append("UPDATE YZAppFolderFiles SET "); sb.Append("FolderID=:FolderID,"); sb.Append("FileID=:FileID,"); sb.Append("AddBy=:AddBy,"); sb.Append("AddAt=:AddAt,"); sb.Append("Comments=:Comments,"); sb.Append("Deleted=:Deleted,"); sb.Append("DeleteBy=:DeleteBy,"); sb.Append("DeleteAt=:DeleteAt,"); sb.Append("Recyclebin=:Recyclebin "); sb.Append("WHERE ID=:ID"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add(":FolderID", OracleDbType.Int32).Value = this.Convert(file.FolderID, false); cmd.Parameters.Add(":FileID", OracleDbType.NVarchar2).Value = this.Convert(file.FileID, false); cmd.Parameters.Add(":AddBy", OracleDbType.NVarchar2).Value = this.Convert(file.AddBy, true); cmd.Parameters.Add(":AddAt", OracleDbType.Date).Value = this.Convert(file.AddAt, true); cmd.Parameters.Add(":Comments", OracleDbType.NVarchar2).Value = this.Convert(file.Comments, true); cmd.Parameters.Add(":Deleted", OracleDbType.Int16).Value = this.ConvertBoolToInt16(file.Deleted); cmd.Parameters.Add(":DeleteBy", OracleDbType.NVarchar2).Value = this.Convert(file.DeleteBy, true); cmd.Parameters.Add(":DeleteAt", OracleDbType.Date).Value = this.Convert(file.DeleteAt, true); cmd.Parameters.Add(":Recyclebin", OracleDbType.Int16).Value = this.ConvertBoolToInt16(file.Recyclebin); cmd.Parameters.Add(":ID", OracleDbType.Int32).Value = file.ID; cmd.ExecuteNonQuery(); } }
public virtual void ShareFiles(HttpContext context) { YZRequest request = new YZRequest(context); int folderid = request.GetInt32("folderid"); JObject post = request.GetPostData <JObject>(); List <string> fileids = post["fileids"].ToObject <List <string> >(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { YZSoft.FileSystem.FileCollection files = FileSystem.DirectoryManager.GetFiles(provider, cn, folderid, null, null, -1); foreach (string fileid in fileids) { if (files.TryGetFileByID(fileid) == null) { YZSoft.FileSystem.File file = new YZSoft.FileSystem.File(); file.FolderID = folderid; file.FileID = fileid; file.AddBy = YZAuthHelper.LoginUserAccount; file.AddAt = DateTime.Now; file.Comments = "share"; file.OrderIndex = YZSoft.FileSystem.DirectoryManager.GetFileNextOrderIndex(provider, cn, folderid); FileSystem.DirectoryManager.Insert(provider, cn, file); } } } } }
public void Update(IDbConnection cn, YZSoft.FileSystem.File file) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; StringBuilder sb = new StringBuilder(); sb.Append("UPDATE YZAppFolderFiles SET "); sb.Append("FolderID=@FolderID,"); sb.Append("FileID=@FileID,"); sb.Append("AddBy=@AddBy,"); sb.Append("AddAt=@AddAt,"); sb.Append("Comments=@Comments,"); sb.Append("Deleted=@Deleted,"); sb.Append("DeleteBy=@DeleteBy,"); sb.Append("DeleteAt=@DeleteAt,"); sb.Append("Recyclebin=@Recyclebin "); sb.Append("WHERE ID=@ID"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add("@FolderID", SqlDbType.Int).Value = this.Convert(file.FolderID, false); cmd.Parameters.Add("@FileID", SqlDbType.NVarChar).Value = this.Convert(file.FileID, false); cmd.Parameters.Add("@AddBy", SqlDbType.NVarChar).Value = this.Convert(file.AddBy, true); cmd.Parameters.Add("@AddAt", SqlDbType.DateTime).Value = this.Convert(file.AddAt, true); cmd.Parameters.Add("@Comments", SqlDbType.NVarChar).Value = this.Convert(file.Comments, true); cmd.Parameters.Add("@Deleted", SqlDbType.Bit).Value = file.Deleted; cmd.Parameters.Add("@DeleteBy", SqlDbType.NVarChar).Value = this.Convert(file.DeleteBy, true); cmd.Parameters.Add("@DeleteAt", SqlDbType.DateTime).Value = this.Convert(file.DeleteAt, true); cmd.Parameters.Add("@Recyclebin", SqlDbType.Bit).Value = file.Recyclebin; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = file.ID; cmd.ExecuteNonQuery(); } }
public void UpdateOrderIndex(IDbConnection cn, YZSoft.FileSystem.File file) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; StringBuilder sb = new StringBuilder(); sb.Append("UPDATE YZAppFolderFiles SET "); sb.Append("OrderIndex=@OrderIndex "); sb.Append("WHERE ID=@ID"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add("@OrderIndex", SqlDbType.Int).Value = this.Convert(file.OrderIndex, true); cmd.Parameters.Add("@ID", SqlDbType.Int).Value = file.ID; cmd.ExecuteNonQuery(); } }
public void UpdateOrderIndex(IDbConnection cn, YZSoft.FileSystem.File file) { using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = cn as OracleConnection; cmd.BindByName = true; StringBuilder sb = new StringBuilder(); sb.Append("UPDATE YZAppFolderFiles SET "); sb.Append("OrderIndex=:OrderIndex "); sb.Append("WHERE ID=:ID"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add(":OrderIndex", OracleDbType.Int32).Value = this.Convert(file.OrderIndex, true); cmd.Parameters.Add(":ID", OracleDbType.Int32).Value = file.ID; cmd.ExecuteNonQuery(); } }
public void Insert(IDbConnection cn, YZSoft.FileSystem.File file) { using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = cn as OracleConnection; cmd.BindByName = true; cmd.CommandText = "SELECT BPMSEQ_YZAPPFOLDERFILES.NEXTVAL FROM DUAL"; file.ID = System.Convert.ToInt32(cmd.ExecuteScalar()); StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO YZAPPFOLDERFILES("); sb.Append("ID,"); sb.Append("FOLDERID,"); sb.Append("FILEID,"); sb.Append("ADDBY,"); sb.Append("ADDAT,"); sb.Append("COMMENTS,"); sb.Append("ORDERINDEX,"); sb.Append("FLAG) "); sb.Append("VALUES("); sb.Append(":ID,"); sb.Append(":FOLDERID,"); sb.Append(":FILEID,"); sb.Append(":ADDBY,"); sb.Append(":ADDAT,"); sb.Append(":COMMENTS,"); sb.Append(":ORDERINDEX,"); sb.Append(":FLAG)"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add(":ID", OracleDbType.Int32).Value = file.ID; cmd.Parameters.Add(":FOLDERID", OracleDbType.Int32).Value = this.Convert(file.FolderID, false); cmd.Parameters.Add(":FILEID", OracleDbType.NVarchar2).Value = this.Convert(file.FileID, false); cmd.Parameters.Add(":ADDBY", OracleDbType.NVarchar2).Value = this.Convert(file.AddBy, true); cmd.Parameters.Add(":ADDAT", OracleDbType.Date).Value = this.Convert(file.AddAt, true); cmd.Parameters.Add(":COMMENTS", OracleDbType.NVarchar2).Value = this.Convert(file.Comments, true); cmd.Parameters.Add(":ORDERINDEX", OracleDbType.Int32).Value = this.Convert(file.OrderIndex, false); cmd.Parameters.Add(":FLAG", OracleDbType.NVarchar2).Value = this.Convert(file.Flag, true); cmd.ExecuteNonQuery(); } }
public void Insert(IDbConnection cn, YZSoft.FileSystem.File file) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; StringBuilder sb = new StringBuilder(); sb.Append("SET NOCOUNT ON;"); sb.Append("INSERT INTO YZAppFolderFiles("); sb.Append("FolderID,"); sb.Append("FileID,"); sb.Append("AddBy,"); sb.Append("AddAt,"); sb.Append("Comments,"); sb.Append("OrderIndex,"); sb.Append("Flag) "); sb.Append("VALUES("); sb.Append("@FolderID,"); sb.Append("@FileID,"); sb.Append("@AddBy,"); sb.Append("@AddAt,"); sb.Append("@Comments,"); sb.Append("@OrderIndex,"); sb.Append("@Flag);"); sb.Append("SELECT SCOPE_IDENTITY()"); cmd.CommandText = sb.ToString(); cmd.Parameters.Add("@FolderID", SqlDbType.Int).Value = this.Convert(file.FolderID, false); cmd.Parameters.Add("@FileID", SqlDbType.NVarChar).Value = this.Convert(file.FileID, false); cmd.Parameters.Add("@AddBy", SqlDbType.NVarChar).Value = this.Convert(file.AddBy, true); cmd.Parameters.Add("@AddAt", SqlDbType.DateTime).Value = this.Convert(file.AddAt, true); cmd.Parameters.Add("@Comments", SqlDbType.NVarChar).Value = this.Convert(file.Comments, true); cmd.Parameters.Add("@OrderIndex", SqlDbType.Int).Value = this.Convert(file.OrderIndex, false); cmd.Parameters.Add("@Flag", SqlDbType.NVarChar).Value = this.Convert(file.Flag, true); file.ID = System.Convert.ToInt32(cmd.ExecuteScalar()); } }
public virtual object SaveProcessAs(HttpContext context) { YZRequest request = new YZRequest(context); int folder = request.GetInt32("folder"); string fileid = request.GetString("fileid"); int filefolderid = request.GetInt32("filefolderid"); string processName = request.GetString("processName"); string ext = request.GetString("ext"); JObject jPost = request.GetPostData <JObject>(); JObject jProcess = (JObject)jPost["process"]; JObject jChart = (JObject)jPost["chart"]; if (jProcess["Property"] == null) { jProcess["Property"] = new JObject(); } jProcess["Property"]["CreateAt"] = DateTime.Now; jProcess["Property"]["Creator"] = YZAuthHelper.LoginUserAccount; jProcess["Property"]["LastChange"] = DateTime.Now; jProcess["Property"]["ChangeBy"] = YZAuthHelper.LoginUserAccount; string savePath = AttachmentInfo.FileIDToPath(fileid, AttachmentManager.AttachmentRootPath); System.IO.Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\"))); using (System.IO.StreamWriter ws = new System.IO.StreamWriter(savePath, false, System.Text.Encoding.UTF8)) ws.Write(jProcess.ToString()); AttachmentInfo attachment = new AttachmentInfo(); attachment.FileID = fileid; attachment.Name = processName; attachment.Ext = ext; attachment.Size = 101; attachment.LastUpdate = DateTime.Now; attachment.OwnerAccount = YZAuthHelper.LoginUserAccount; attachment.LParam1 = filefolderid; YZSoft.FileSystem.File file = new YZSoft.FileSystem.File(); file.FolderID = folder; file.FileID = fileid; file.AddBy = YZAuthHelper.LoginUserAccount; file.AddAt = DateTime.Now; file.Comments = ""; File bpafile = jProcess.ToObject <File>(); bpafile.FileID = fileid; bpafile.FileName = attachment.Name; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { AttachmentManager.Delete(provider, cn, attachment.FileID); AttachmentManager.Insert(provider, cn, attachment); file.OrderIndex = YZSoft.FileSystem.DirectoryManager.GetFileNextOrderIndex(provider, cn, folder); FileSystem.DirectoryManager.Insert(provider, cn, file); bpafile.UpdateSpritesIdentityAndLink(provider, cn); } } this.SaveChart(savePath, jChart); return(new { success = true, fileid = file.FileID }); }
protected virtual AttachmentInfo GenerateFileReport(HttpContext context, GetFileReportDataHandler handler) { YZRequest request = new YZRequest(context); string fileid = request.GetString("fileid"); string template = request.GetString("template"); int tagfolderid = request.GetInt32("tagfolderid"); string name = request.GetString("name"); string method = request.GetString("method"); string reportType = method.Substring(8, method.Length - 14); JObject jPost = request.GetPostData <JObject>(); JObject jProcess = (JObject)jPost["process"]; JObject jChart = (JObject)jPost["chart"]; Image chart = this.GetImage(jChart); string templatePath = context.Server.MapPath(String.Format("~/YZSoft/BPA/processreport/templates/{0}/{1}", reportType, template)); TemplateFileType templeteFileType = this.GetTemplateFileType(template); string ext = System.IO.Path.GetExtension(template); AttachmentInfo attachment = new AttachmentInfo(); attachment.Name = name + ext; attachment.Ext = ext; DataSet dataset = handler.Invoke(fileid, tagfolderid, jProcess, chart); switch (templeteFileType) { case TemplateFileType.Excel: HSSFWorkbook book; using (System.IO.FileStream stream = new System.IO.FileStream(templatePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) { book = new HSSFWorkbook(stream); } YZExcelGenerate.Fill(book, null, dataset); YZExcelGenerate.PrepareForOutput(book); attachment = AttachmentManager.SaveAsAttachment(book, attachment); break; default: XWPFDocument doc; using (System.IO.FileStream stream = new System.IO.FileStream(templatePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) { doc = new XWPFDocument(stream); } WordGenerator.Fill(doc, dataset); attachment = AttachmentManager.SaveAsAttachment(doc, attachment); break; } YZSoft.FileSystem.File file = new YZSoft.FileSystem.File(); file.FolderID = tagfolderid; file.FileID = attachment.FileID; file.AddBy = YZAuthHelper.LoginUserAccount; file.AddAt = DateTime.Now; file.Flag = "Generate"; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { file.OrderIndex = YZSoft.FileSystem.DirectoryManager.GetFileNextOrderIndex(provider, cn, tagfolderid); FileSystem.DirectoryManager.Insert(provider, cn, file); } } return(attachment); }