public XHelperCreateOrUpdateCommand(XHelper ent) { this.ent = ent; }
public string DownLoadFile(string fileId, string filePath, string fileName) { string sql = "SELECT AtchImag,AtchName,AtchType FROM " + this.TableName + " WHERE FileId = '" + fileId + "'"; DbConnection conn = this.m_DataAccess.Connection; DbDataAdapter adp = this.m_DataAccess.GetDbDataAdapter(conn, sql); DataTable dt = new DataTable(); byte[] bData = null; string fName = fileName; try { //从服务器获取文件 adp.Fill(dt); DataRow dr = null; if (dt.Rows.Count > 0) { dr = dt.Rows[0]; if (((!object.ReferenceEquals(dr["AtchImag"], DBNull.Value)))) { bData = (byte[])dr["AtchImag"]; } if (fName == string.Empty) { fName = XHelper.GetString(dr["AtchName"]); } else { fName += XHelper.GetString(dr["AtchType"]); } } } catch (Exception ex) { XErrorLogTool.WriteLog(ex.ToString()); return(string.Empty); } finally { adp.Dispose(); } //存文件 if (((bData != null))) { fName = filePath + "\\" + fName; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } FileInfo fi = new FileInfo(fName); //不存在 if (!fi.Exists) { using (FileStream fs = fi.Create()) { fs.Write(bData, 0, bData.Length); } } else { XMessageBox.ShowError("要下载的文件[" + fi.Name + "]在目录:\r\n" + filePath + "已存在!"); return(string.Empty); } } return(fName); }
public MappingLevels(string levelsDir) : this(XHelper.Load(Path.Combine(levelsDir, "mapping.xml")).Root, levelsDir) { }
public void Deserialize(object obj, XElement root, AXMLSerializationSettings opt) { var current = PropInfo.GetValue(obj); switch (_objectType) { case SettingObjectTypeEnum.Integer: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (int)current)); return; case SettingObjectTypeEnum.Double: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (double)current)); return; case SettingObjectTypeEnum.NullableInteger: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (int?)current)); return; case SettingObjectTypeEnum.Boolean: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (bool)current)); return; case SettingObjectTypeEnum.Guid: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (Guid)current)); return; case SettingObjectTypeEnum.NGuid: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (Guid?)current)); return; case SettingObjectTypeEnum.EncryptedString: PropInfo.SetValue(obj, AlephXMLSerializerHelper.Decrypt(XHelper.GetChildValue(root, PropInfo.Name, AlephXMLSerializerHelper.Encrypt((string)current, opt)), opt)); return; case SettingObjectTypeEnum.String: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, (string)current)); return; case SettingObjectTypeEnum.Enum: PropInfo.SetValue(obj, XHelper.GetChildValue(root, PropInfo.Name, current, PropInfo.PropertyType)); break; case SettingObjectTypeEnum.RemoteStorageAccount: var currUUID = ((RemoteStorageAccount)current).ID; PropInfo.SetValue(obj, new RemoteStorageAccount(XHelper.GetChildValue(root, PropInfo.Name, currUUID), null, null)); break; case SettingObjectTypeEnum.ListRemoteStorageAccount: var list = (IList <RemoteStorageAccount>)current; var child = XHelper.GetChildOrNull(root, PropInfo.Name); if (child != null) { list.Clear(); foreach (var elem in child.Elements()) { list.Add(DeserializeRemoteStorageAccount(elem, opt)); } } break; case SettingObjectTypeEnum.CustomSerializable: var currCust = ((IAlephCustomSerializableField)current); var cchild = XHelper.GetChildOrNull(root, PropInfo.Name); if (cchild != null) { PropInfo.SetValue(obj, currCust.DeserializeNew(cchild, opt)); } break; case SettingObjectTypeEnum.DirectoryPath: var dp = DirectoryPath.Deserialize(XHelper.GetChildrenOrEmpty(root, PropInfo.Name, "PathComponent")); PropInfo.SetValue(obj, dp); break; case SettingObjectTypeEnum.StringSet: var set = (ISet <string>)current; var setchild = XHelper.GetChildOrNull(root, PropInfo.Name); if (setchild != null) { set.Clear(); foreach (var elem in setchild.Elements()) { set.Add(elem.Value); } } break; default: throw new ArgumentOutOfRangeException(nameof(obj), _objectType, null); } }
public Privileges(string path = null) : this(XHelper.Load(path ?? Path).Root) { }