public static bool UnzipCsfFile(s_CfgFileInfo ConfigFileInfo) { try { System.Guid fileGuid = ConfigFileInfo.FID; string filename = fileGuid.ToString() + ".csf"; string filePath = System.IO.Path.Combine(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.ProjectPath, ConfigFileInfo.RelativePath); filePath = System.IO.Path.Combine(filePath, filename); if (System.IO.File.Exists(filePath)) { string Ext = System.IO.Path.GetExtension(filePath); if (Ext.Equals(".csf", StringComparison.OrdinalIgnoreCase)) { string err = string.Empty; if (PMS.Libraries.ToolControls.PMSPublicInfo.ZipClass.UnZipFile(filePath, string.Empty, out err)) { return(true); } } } } catch (System.IO.IOException e) { return(false); } return(false); }
public static bool DownloadFiles(Dictionary <System.Guid, s_CfgFileInfo> FilesToDownloadDictionary) { // 通过UserInfo调用权限管理模块获得查询s_CfgFileInfo结果var foreach (System.Guid key in FilesToDownloadDictionary.Keys) { s_CfgFileInfo FileToDownloadInfo = null; if (FilesToDownloadDictionary.TryGetValue(key, out FileToDownloadInfo)) { DownloadFile(FileToDownloadInfo); } } return(true); }
private void buttonEdit_Click(object sender, EventArgs e) { MESCustomViewIdentity id = GetSelectedIdentity(); if (null != id) { s_CfgFileInfo info = CurrentPrjInfo.GetCfgFileInfo(id); if (null != info) { int msgID = PMS.Libraries.ToolControls.PMSPublicInfo.Message.USER_OPENDOC; byte[] theBytes = PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.ObjToByte(info); if (PMS.Libraries.ToolControls.PMSPublicInfo.Message.PMSDeveloperControlHandle != IntPtr.Zero) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.SendCopyData(PMS.Libraries.ToolControls.PMSPublicInfo.Message.PMSDeveloperControlHandle, msgID, theBytes); } } } }
public static bool SaveRptFile(s_CfgFileInfo ConfigFileInfo) { try { string filePath = ConfigFileInfo.Description; if (ConfigFileInfo.Content != null) { byte[] data = ConfigFileInfo.Content.ToArray(); if (PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.SaveFile(filePath, data)) { return(true); } } } catch (System.IO.IOException) { return(false); } return(false); }
public static bool SaveCsfFile(s_CfgFileInfo ConfigFileInfo) { try { System.Guid fileGuid = ConfigFileInfo.FID; string filename = fileGuid.ToString() + ".csf"; string filePath = System.IO.Path.Combine(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.UserCustomPath, filename); string[] fileNameArray = Directory.GetFiles(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.UserCustomPath, fileGuid.ToString() + ".*", SearchOption.TopDirectoryOnly); if (fileNameArray.Length == 0) { return(false); } List <string> fileNameList = new List <string>(); foreach (string strfileName in fileNameArray) { if (Path.GetExtension(strfileName).ToLower() == ".xml" || Path.GetExtension(strfileName).ToLower() == ".sco" || Path.GetExtension(strfileName).ToLower() == ".dll") { fileNameList.Add(strfileName); } } string err = string.Empty; string strCsfPath = Path.Combine(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.UserCustomPath, fileGuid.ToString() + ".csf"); if (!PMS.Libraries.ToolControls.PMSPublicInfo.ZipClass.ZipFile(fileNameList, strCsfPath, out err)) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(PMS.Libraries.ToolControls.PMSPublicInfo.CurrentPrjInfo.CurrentLoginUserID, err, true); return(false); } } catch (System.IO.IOException ex) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(ex.Message); return(false); } return(true); }
public static bool UpdateFile(s_CfgFileInfo ConfigFileInfo, bool acceptChangesDuringSave) { try { var q = (from PMSInfo in PMSDBStructure.PMSCenterDataContext.s_CfgFileInfo where PMSInfo.FID == ConfigFileInfo.FID select PMSInfo).First(); q = ConfigFileInfo; if (acceptChangesDuringSave) { PMSDBStructure.PMSCenterDataContext.SaveChanges(); } //else // PMSDBStructure.PMSCenterDataContext.SaveChanges(acceptChangesDuringSave); } catch (System.Exception e) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(PMS.Libraries.ToolControls.PMSPublicInfo.CurrentPrjInfo.CurrentLoginUserID, e.Message, true); return(false); } return(true); }
public static bool DownloadCsfFile(s_CfgFileInfo ConfigFileInfo) { try { System.Guid fileGuid = ConfigFileInfo.FID; string filename = fileGuid.ToString() + ".csf"; string filePath = System.IO.Path.Combine(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.UserCustomPath, filename); if (ConfigFileInfo.Content != null) { byte[] data = ConfigFileInfo.Content.ToArray(); if (PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.SaveFile(filePath, data)) { return(true); } } } catch (System.IO.IOException) { return(false); } return(false); }
private void buttonNew_Click(object sender, EventArgs e) { if (this.treeView1.SelectedNode == null) { return; } if (this.treeView1.SelectedNode.ImageIndex == 2 || this.treeView1.SelectedNode.ImageIndex == 3) { int msgID = PMS.Libraries.ToolControls.PMSPublicInfo.Message.USER_NEWFORM; byte[] theBytes = PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.ObjToByte(this.treeView1.SelectedNode.Tag); if (PMS.Libraries.ToolControls.PMSPublicInfo.Message.UserViewNavigationBarFormHandle != IntPtr.Zero) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.SendCopyData(PMS.Libraries.ToolControls.PMSPublicInfo.Message.UserViewNavigationBarFormHandle, msgID, theBytes); } if (null != CurrentPrjInfo.CurrentNewFormCfgFileInfo as s_CfgFileInfo) { SelectedNode = this.treeView1.SelectedNode; s_CfgFileInfo info = CurrentPrjInfo.CurrentNewFormCfgFileInfo as s_CfgFileInfo; _Identity = new MESCustomViewIdentity(); _Identity.IsSpecifiedVersion = false; _Identity.ViewName = info.Name; _Identity.FullPath = Path.Combine(SelectedNode.FullPath, info.Name); if (null != SelectedNode) { s_CfgFInfoMap mapinfo = SelectedNode.Tag as s_CfgFInfoMap; if (null != mapinfo) { _Identity.ParentID = mapinfo.MAPID; } } } this.DialogResult = DialogResult.OK; this.Close(); } }
public static bool UploadFile(s_CfgFileInfo ConfigFileInfo, bool acceptChangesDuringSave) { // try { PMSDBStructure.PMSCenterDataContext.AddTos_CfgFileInfo(ConfigFileInfo); if (acceptChangesDuringSave) { PMSDBStructure.PMSCenterDataContext.SaveChanges(); } //else // PMSDBStructure.PMSCenterDataContext.SaveChanges(acceptChangesDuringSave); // System.Data.SqlClient.SqlConnection connection = SqlStructure.GetSqlConncetion(); // System.Data.SqlClient.SqlCommand command = connection.CreateCommand(); // System.Data.SqlClient.SqlParameter parameter; // int rowsInserted; // System.DateTime startTime; // System.DateTime endTime; // command.CommandText = @"INSERT INTO [s_CfgFileInfo] ([FID] // ,[Name] // ,[RelativePath] // ,[Type] // ,[Content] // ,[TimeStamp] // ,[Version] // ,[Check] // ,[Current] // ,[CheckUserID]) // VALUES // (@FID // ,@Name // ,@RelativePath // ,@Type // ,@Content // ,@TimeStamp // ,@Version // ,@Check // ,@Current // ,@CheckUserID)"; // command.CommandType = System.Data.CommandType.Text; // parameter = new System.Data.SqlClient.SqlParameter("@FID", System.Data.SqlDbType.UniqueIdentifier); // parameter.Value = System.Guid.NewGuid(); file.Substring(file.LastIndexOf('\\') + 1); // command.Parameters.Add(parameter); // parameter = new System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 50); // parameter.Value = file.Substring(file.LastIndexOf('\\') + 1); // command.Parameters.Add(parameter); // parameter = new System.Data.SqlClient.SqlParameter("@Data", System.Data.SqlDbType.VarBinary); // parameter.Value = System.IO.File.ReadAllBytes(file); // command.Parameters.Add(parameter); // command.Transaction = connection.BeginTransaction(); // startTime = System.DateTime.Now; // for (int counter = 0; counter < repeatCount; counter++) // { // rowsInserted = command.ExecuteNonQuery(); // } // endTime = System.DateTime.Now; // command.Transaction.Commit(); // connection.Close(); } catch (System.Exception e) { PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(PMS.Libraries.ToolControls.PMSPublicInfo.CurrentPrjInfo.CurrentLoginUserID, e.Message, true); return(false); } return(true); }
public static bool UploadFile(s_CfgFileInfo ConfigFileInfo) { return(UploadFile(ConfigFileInfo, true)); }
public static bool DownloadFile(s_CfgFileInfo ConfigFileInfo) { System.Guid fileGuid = ConfigFileInfo.FID; string filename = fileGuid.ToString() + ".zip"; string filePath = System.IO.Path.Combine(PMS.Libraries.ToolControls.PMSPublicInfo.ProjectPathClass.ProjectPath, ConfigFileInfo.RelativePath); filePath = System.IO.Path.Combine(filePath, filename); //方案1 直接下载覆盖 不判断条件 if (ConfigFileInfo.Content != null) { byte[] data = ConfigFileInfo.Content.ToArray(); SaveZipFileAndUnzipThenDelZipfile(filePath, data); } //方案2 //1. 查看本地是否有此文件FID存在, //1.1 不存在直接下载, //1.2 存在 比较版本号,版本号不一样直接下载 ,版本号一样,比较修改时间,修改时间新于本机下载,修改时间相等,不下载 /* * Dictionary<System.Guid, s_CfgFileInfo> DownloadedFilesDictionary = * PMSDBStructure.PMSCenterDataContext.GetTable<s_CfgFileInfo>().ToDictionary(s_CfgFileInfo => s_CfgFileInfo.FID); * * if(DownloadedFilesDictionary.ContainsKey(fileGuid)) * { * // 本地存在 * s_CfgFileInfo ExistedConfigFileInfo = null; * if(DownloadedFilesDictionary.TryGetValue(fileGuid,out ExistedConfigFileInfo)) * { * if(ExistedConfigFileInfo.Version != ConfigFileInfo.Version) * { * // 版本号不一样直接下载 * byte[] data = ConfigFileInfo.Content.ToArray(); * //PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.SaveFile(filePath, data); * SaveZipFileAndUnzipThenDelZipfile(filePath, data); * } * else * { * // 版本号一样 * if(ExistedConfigFileInfo.TimeStamp < ConfigFileInfo.TimeStamp) * { * // 修改时间新于本机文件,下载替换,否则不予处理 * byte[] data = ConfigFileInfo.Content.ToArray(); * //PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.SaveFile(filePath, data); * SaveZipFileAndUnzipThenDelZipfile(filePath, data); * } * } * } * } * else * { * // 本地不存在 * byte[] data = ConfigFileInfo.Content.ToArray(); * //PMS.Libraries.ToolControls.PMSPublicInfo.PMSFileClass.SaveFile(filePath, data); * SaveZipFileAndUnzipThenDelZipfile(filePath, data); * } * */ //System.Data.Linq.Binary binary = ConfigFileInfo.Content; //var DownloadFiles = // from p in _PMSCenterDataContext.PMSSys_ConfigFileInfos //System.Data.Linq.Table<s_CfgFileInfo> PMSSys_ConfigFileInfos = _PMSCenterDataContext.GetTable<s_CfgFileInfo>(); //PMSSys_ConfigFileInfos.InsertOnSubmit(ConfigFileInfo); //PMSSys_ConfigFileInfos.InsertOnSubmit(ConfigFileInfo); //_PMSCenterDataContext.SubmitChanges(); return(true); }
public static bool UploadFiles(s_CfgFileInfo ConfigFileInfo) { return(false); }