public AttrID(int id, string name, EDataType type, bool isReadWrite) { _id = id; _name = name; _type = type; _isReadWrite = isReadWrite; }
private Task(EDataType dataType, TaskJob job) { Status = TaskStatus.InQueue; Info = new UploadInfo(); Info.Job = job; Info.DataType = dataType; Info.UploadDestination = dataType; }
public static UploadTask CreateDataUploaderTask(EDataType dataType, Stream stream, string fileName, TaskSettings taskSettings) { UploadTask task = new UploadTask(taskSettings); task.Info.Job = TaskJob.DataUpload; task.Info.DataType = dataType; task.Info.FileName = fileName; task.Data = stream; return task; }
public int GetFtpIndex(EDataType dataType) { switch (dataType) { case EDataType.Image: return _config.FTPSelectedImage; case EDataType.Text: return _config.FTPSelectedText; default: return _config.FTPSelectedFile; } }
public static SqlDbType ToSqlDbType(EDataType type) { if (type == EDataType.Bit) { return(SqlDbType.Bit); } if (type == EDataType.Char) { return(SqlDbType.Char); } if (type == EDataType.DateTime) { return(SqlDbType.DateTime); } if (type == EDataType.Decimal) { return(SqlDbType.Decimal); } if (type == EDataType.Float) { return(SqlDbType.Float); } if (type == EDataType.Integer) { return(SqlDbType.Int); } if (type == EDataType.NChar) { return(SqlDbType.NChar); } if (type == EDataType.NText) { return(SqlDbType.NText); } if (type == EDataType.NVarChar) { return(SqlDbType.NVarChar); } if (type == EDataType.Text) { return(SqlDbType.Text); } return(SqlDbType.VarChar); }
public static MySqlDbType ToMySqlDbType(EDataType type) { if (type == EDataType.Bit) { return(MySqlDbType.Bit); } if (type == EDataType.Char) { return(MySqlDbType.String); } if (type == EDataType.DateTime) { return(MySqlDbType.DateTime); } if (type == EDataType.Decimal) { return(MySqlDbType.Decimal); } if (type == EDataType.Float) { return(MySqlDbType.Float); } if (type == EDataType.Integer) { return(MySqlDbType.Int32); } if (type == EDataType.NChar) { return(MySqlDbType.String); } if (type == EDataType.NText) { return(MySqlDbType.LongText); } if (type == EDataType.NVarChar) { return(MySqlDbType.VarString); } if (type == EDataType.Text) { return(MySqlDbType.Text); } return(MySqlDbType.VarString); }
private void AddDestination <T>(int index, EDataType dataType, TaskSettings taskSettings, string overrideText = null) { Enum destination = (Enum)Enum.ToObject(typeof(T), index); if (Program.UploadersConfig.IsValid <T>(index)) { RadioButton rb = new RadioButton() { AutoSize = true }; // TODO: Translate rb.Text = string.IsNullOrEmpty(overrideText) ? destination.GetLocalizedDescription() : "Custom [" + overrideText + "]"; rb.Tag = destination; rb.CheckedChanged += (sender, e) => SetDestinations(rb.Checked, dataType, rb.Tag, taskSettings); flp.Controls.Add(rb); } }
public CompositeRawFile(string fileName, int bitHint, ICompositeFileFactory mmf, EFileAccess access, int partitionID, int fileID, int columnID, EDataType dataType) : this(fileName, bitHint, mmf, access, partitionID, fileID, columnID, dataType, MetadataConstants.MIN_FILE_BIT_HINT_NON_DATA) { }
private void AddDestination <T>(int index, EDataType dataType, TaskSettings taskSettings, string overrideText = null) { Enum destination = (Enum)Enum.ToObject(typeof(T), index); if (UploadersConfigValidator.Validate <T>(index, Program.UploadersConfig)) { RadioButton rb = new RadioButton() { AutoSize = true }; rb.Text = string.IsNullOrEmpty(overrideText) ? destination.GetLocalizedDescription() : string.Format("{0} [{1}]", Resources.BeforeUploadControl_AddDestination_Custom, overrideText); rb.Tag = destination; rb.CheckedChanged += (sender, e) => SetDestinations(rb.Checked, dataType, rb.Tag, taskSettings); flp.Controls.Add(rb); } }
/// <summary> /// 检查语法 /// </summary> /// <returns></returns> public bool Check(ref string mes) { bool result = false; try { Analyze(); SyntaxAnalyzer a = new SyntaxAnalyzer(); EDataType type = a.Execute(_link_OP.Head, _link_OP.Tail); mes = "Success!"; result = true; } catch (Exception ex) { mes = ex.Message; } return(result); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { EDataType eDataType = (EDataType)CmbBox.SelectedItem; switch (eDataType) { case EDataType.Tick: ReadTick(); break; case EDataType.Min: ReadMin(); break; default: ReadTick(); break; } }
public static string GetDefaultString(EDataType dataType) { var retval = string.Empty; if (dataType == EDataType.Char || dataType == EDataType.NChar || dataType == EDataType.NText || dataType == EDataType.NVarChar || dataType == EDataType.Text || dataType == EDataType.VarChar) { return("''"); } if (dataType == EDataType.Decimal || dataType == EDataType.Decimal || dataType == EDataType.Float || dataType == EDataType.Integer) { return("0"); } if (dataType == EDataType.DateTime) { return(WebConfigUtils.IsMySql ? "now()" : "getdate()"); } return(retval); }
/// <summary> /// Universal data managment /// </summary> /// <param name="path">The path to the data file</param> public UniversalData(string path, EDataType DefaultDataType = EDataType.JSON) { this.Path = path + ".dat"; // Set the path this.CreatedNew = !File.Exists(Path); // Check if the file has to be created if (!Directory.Exists(PT.GetDirectoryName(Path))) { Directory.CreateDirectory(PT.GetDirectoryName(Path)); } if (CreatedNew) { DataType = DefaultDataType; // Set the data type switch (DefaultDataType) { case EDataType.JSON: JSON = new JsonData(Path); // Create the JSON file break; case EDataType.XML: XML = new XMLData(Path); // Create the XML file break; } return; // No need to continue } if (XMLData.CheckFile(Path)) { DataType = EDataType.XML; // An XML file XML = new XMLData(Path); } else if (JsonData.CheckFile(Path)) { DataType = EDataType.JSON; // A JSON file JSON = new JsonData(Path); } else { DataType = EDataType.UNKNOWN; // Unknown type/corrupted file } }
public static void UploadFile(string path) { if (!string.IsNullOrEmpty(path)) { if (File.Exists(path)) { EDataType type; EDataType destination = EDataType.Default; if (ZAppHelper.IsImageFile(path)) { type = EDataType.Image; if (ImageUploader == ImageDestination.FileUploader) { destination = EDataType.File; } } else if (ZAppHelper.IsTextFile(path)) { type = EDataType.Text; if (TextUploader == TextDestination.FileUploader) { destination = EDataType.File; } } else { type = EDataType.File; } Task task = Task.CreateFileUploaderTask(type, path, destination); StartUpload(task); } else if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); UploadFile(files); } } }
public static bool IsFixedSize(this EDataType dataType) { switch (dataType) { case EDataType.Symd: case EDataType.Symrk: case EDataType.Symrr: case EDataType.Datar: case EDataType.Datak: case EDataType.Data: case EDataType.Symi: return(false); case EDataType.Index: return(true); default: throw new ArgumentOutOfRangeException("dataType"); } }
/// <summary> /// 判断是否非法值 /// </summary> /// <param name="type">数据类型</param> /// <param name="value">数值</param> /// <returns></returns> private static bool IsInvalidValue(EDataType type, object value) { switch (type) { case EDataType.TypeDouble: case EDataType.TypeByte: case EDataType.TypeInt8: case EDataType.TypeUInt8: case EDataType.TypeInt16: case EDataType.TypeUInt16: case EDataType.TypeInt32: case EDataType.TypeUInt32: case EDataType.TypeInt64: case EDataType.TypeUInt64: case EDataType.TypeFloat: return(IsInvalidDecValue(type, value)); } return(false); }
internal static void SaveFile <T>(T _object, string _path, EDataType _eDataType = EDataType.BINARY) { switch (_eDataType) { case EDataType.BINARY: SaveBinary(_object, _path); break; case EDataType.XML: SaveXml(_object, _path); break; case EDataType.JSON: SaveJSON(_object, _path); break; default: break; } }
public static BaseItem CreateItem(EDataType p_type, Int32 p_staticID) { BaseItem baseItem; if (p_type == EDataType.GENERATED_EQUIPMENT) { GeneratedEquipmentStaticData staticData = StaticDataHandler.GetStaticData <GeneratedEquipmentStaticData>(p_type, p_staticID); m_currentEnchantmentMultiplicators = new Dictionary <EDamageType, Single>(); m_currentEnchantmentMultiplicators[EDamageType.AIR] = staticData.Air; m_currentEnchantmentMultiplicators[EDamageType.EARTH] = staticData.Earth; m_currentEnchantmentMultiplicators[EDamageType.FIRE] = staticData.Fire; m_currentEnchantmentMultiplicators[EDamageType.WATER] = staticData.Water; m_currentEnchantmentMultiplicators[EDamageType.LIGHT] = staticData.Light; m_currentEnchantmentMultiplicators[EDamageType.DARK] = staticData.Dark; m_currentEnchantmentMultiplicators[EDamageType.PRIMORDIAL] = staticData.Primordial; m_currentEnchantmentMultiplicators[EDamageType.NONE] = staticData.None; baseItem = CreateEquipment(staticData.ModelLevels, staticData.PrefixChance, staticData.SuffixChance, staticData.PrefixProbabilities, staticData.SuffixProbabilities, staticData.SpecificationList); m_currentEnchantmentMultiplicators = EnchantmentProbabilityList.DefaultMultiplicators; } else if (p_type == EDataType.GENERATED_CONSUMABLES) { GeneratedConsumableStaticData staticData2 = StaticDataHandler.GetStaticData <GeneratedConsumableStaticData>(p_type, p_staticID); m_currentEnchantmentMultiplicators = new Dictionary <EDamageType, Single>(); m_currentEnchantmentMultiplicators[EDamageType.AIR] = staticData2.Air; m_currentEnchantmentMultiplicators[EDamageType.EARTH] = staticData2.Earth; m_currentEnchantmentMultiplicators[EDamageType.FIRE] = staticData2.Fire; m_currentEnchantmentMultiplicators[EDamageType.WATER] = staticData2.Water; m_currentEnchantmentMultiplicators[EDamageType.LIGHT] = staticData2.Light; m_currentEnchantmentMultiplicators[EDamageType.DARK] = staticData2.Dark; m_currentEnchantmentMultiplicators[EDamageType.PRIMORDIAL] = staticData2.Primordial; m_currentEnchantmentMultiplicators[EDamageType.NONE] = 1f; baseItem = CreateConsumable(staticData2.ModelRange.Random(), staticData2.SpecificationList); } else { baseItem = CreateItem(p_type); baseItem.Init(p_staticID); } return(baseItem); }
public static void AddListItems(ListControl listControl, EDataType dataType) { if (listControl != null) { listControl.Items.Add(GetListItem(EInputType.Text, false)); listControl.Items.Add(GetListItem(EInputType.TextArea, false)); if (dataType == EDataType.NText || dataType == EDataType.Text) { listControl.Items.Add(GetListItem(EInputType.TextEditor, false)); } listControl.Items.Add(GetListItem(EInputType.CheckBox, false)); listControl.Items.Add(GetListItem(EInputType.Radio, false)); listControl.Items.Add(GetListItem(EInputType.SelectOne, false)); listControl.Items.Add(GetListItem(EInputType.SelectMultiple, false)); listControl.Items.Add(GetListItem(EInputType.Date, false)); listControl.Items.Add(GetListItem(EInputType.DateTime, false)); listControl.Items.Add(GetListItem(EInputType.Image, false)); listControl.Items.Add(GetListItem(EInputType.Video, false)); listControl.Items.Add(GetListItem(EInputType.File, false)); listControl.Items.Add(GetListItem(EInputType.RelatedField, false)); } }
private Dictionary <string, FieldInfo> GetTypeInfo(Type type, EDataType eDataType) { if (eDataType != EDataType.NonGenericClass) { return(null); } if (typeCache.ContainsKey(type)) { return(typeCache[type]); } Dictionary <string, FieldInfo> result = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public) .Where(field => options.IsFieldRelevant(type, field)) .ToDictionary(field => { string name = field.GetCustomAttribute <ConfigValueAttribute>()?.name ?? field.Name; Match match = Regex.Match(name, "^<(.+)>k__BackingField"); // TODO implement auto-property deserialize return(name); }, field => field); typeCache[type] = result; return(result); }
private void ExportCsv_Click(object sender, RoutedEventArgs e) { EDataType eDataType = (EDataType)CmbBox.SelectedItem; StringBuilder sb = new StringBuilder(); switch (eDataType) { case EDataType.Tick: sb.AppendLine($@"TradingDay,TickNow,LastPrice,VolumeNow,BidPrice1,AskPrice1,BidVolume1,AskVolume1,HighPrice,OpenPrice,LowPrice,Change,Volume,Turnover"); break; case EDataType.Min: sb.AppendLine($@"TradingDate,BeginTimeStr,EndTimeStr,High,Open,Low,Close,Volume,Turnover"); break; default: break; } foreach (var data in MainListView.SelectedItems) { switch (eDataType) { case EDataType.Tick: ViewTick tick = (ViewTick)data; sb.AppendLine($@"{tick.TradingDay},{tick.TickNow},{tick.LastPrice},{tick.VolumeNow},{tick.BidPrice1},{tick.AskPrice1},{tick.BidVolume1},{tick.AskVolume1},{tick.HighPrice},{tick.OpenPrice},{tick.LowPrice},{tick.Change},{tick.Volume},{tick.Turnover}"); break; case EDataType.Min: ViewMin min = (ViewMin)data; sb.AppendLine($@"{min.TradingDate},{min.BeginTimeStr},{min.EndTimeStr},{min.High},{min.Open},{min.Low},{min.Close},{min.Volume},{min.Turnover}"); break; default: break; } } CsvProxy.AppendToCsv(sb.ToString(), TbxPath.Text, "data.csv"); }
public int Should_calculate_bit_hint_for_symbol_columns( int recordCount, int distinctCount, int avgSize, EDataType dataType) { // Create. ClearJournalFolder(); const string fieldName = "symbolField"; using (var journal = new JournalBuilder() .WithRecordCountHint(recordCount) .WithSymbolColumn(fieldName, distinctCount, avgSize) .WithLocation(DIRECTORY_PATH) .ToJournal <TestJournal>()) { var storage = CreateStorage(journal); // Act. var col = journal.Metadata.GetColumnByPropertyName(fieldName); storage.GetFile(col, 1, dataType, journal.Metadata.Settings.RecordHint); return(_bitHint); } }
public static string GetTextByAuxiliaryTable(EDataType dataType, int dataLength) { var retval = string.Empty; if (dataType == EDataType.NVarChar) { retval = $"文本({dataLength})"; } else if (dataType == EDataType.VarChar) { retval = $"文本({dataLength})"; } else if (dataType == EDataType.NChar) { retval = $"文本({dataLength})"; } else if (dataType == EDataType.NText) { retval = "备注"; } else if (dataType == EDataType.Text) { retval = "备注"; } else if (dataType == EDataType.Integer) { retval = "数字"; } else if (dataType == EDataType.DateTime) { retval = "日期/时间"; } else if (dataType == EDataType.Decimal) { retval = "小数"; } return(retval); }
private object DeserializeSingleFieldType(TokenNode node, Type objectType, object instanceToUse, IReadOnlyList <FieldInfo> fieldChain) { int fieldCount = fieldChain.Count; if (fieldCount <= 0) { throw new InvalidDataException($"Tried to Deserialize SingleFieldType '{objectType.FullName}' but did not find any Fields!"); } FieldInfo lastField = fieldChain[fieldCount - 1]; EDataType lastEType = EDataTypes_Extensions.GetDataType(lastField.FieldType); bool isSingleValueType = lastEType.IsSingleValueType(); if (isSingleValueType && node.simpleValue == null || !isSingleValueType && node.listValues.Count == 0) { return(null); } object lastFieldValue = DeserializeNodeValue(node, lastField.FieldType, lastEType); if (lastFieldValue == null) { return(null); } object resultInstance = instanceToUse ?? Activator.CreateInstance(objectType); object lastInstance = resultInstance; for (int i = 0; i < fieldCount - 1; i++) { FieldInfo fieldInfo = fieldChain[i]; object fieldValue = Activator.CreateInstance(fieldInfo.FieldType); fieldInfo.SetValue(lastInstance, fieldValue); lastInstance = fieldValue; } lastField.SetValue(lastInstance, lastFieldValue); return(resultInstance); }
public static UploadTask CreateFileJobTask(string filePath, TaskSettings taskSettings) { EDataType dataType = Helpers.FindDataType(filePath); UploadTask task = new UploadTask(taskSettings); task.Info.DataType = dataType; task.Info.FilePath = filePath; if (task.Info.TaskSettings.UploadSettings.FileUploadUseNamePattern) { string ext = Path.GetExtension(task.Info.FilePath); task.Info.FileName = TaskHelpers.GetFilename(task.Info.TaskSettings, ext); } task.Info.Job = TaskJob.Job; if (task.Info.IsUploadJob) { task.Data = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); } return(task); }
internal static T LoadFile <T>(string _path, EDataType _eDataType = EDataType.BINARY) { object obj = null; switch (_eDataType) { case EDataType.BINARY: obj = LoadBinary(_path); break; case EDataType.XML: obj = LoadXml(typeof(T), _path); break; case EDataType.JSON: obj = LoadJSON(typeof(T), _path); break; default: break; } return((T)obj); }
public IRawFile GetFile(IColumnMetadata column, int fileID, EDataType dataType, long recordHint) { var fieldName = column.FileName; var filename = fieldName + GetExtension(dataType); Thread.MemoryBarrier(); IRawFile file = _openedFiles[fileID]; if (file == null) { // Size of read chunks. Rounded to power of 2. var bitHint = GetBitHint(dataType, recordHint, column.HintDistinctCount, column.AvgSize); file = Open(filename, fileID, column.ColumnID, dataType, bitHint); var existing = Interlocked.CompareExchange(ref _openedFiles[fileID], file, null); if (existing != null) { file.Dispose(); return(existing); } } return(file); }
public virtual bool validate(EDataType eDataType, object value, DiagnosticChain diagnostics, Dictionary <object, object> context) { if (!eDataType.isInstance(value)) { if (value == null) { return(true); } else { if (diagnostics != null) { reportDataValueTypeViolation(eDataType, value, diagnostics, context); } return(false); } } if (eDataType.eContainer() == getEPackage()) { return(validate(eDataType.getClassifierID(), value, diagnostics, context)); } else { return(true); /*TODO * return * new DynamicEDataTypeValidator(eDataType) * { * // Ensure that the class loader for this class will be used downstream. * // * }.validate(eDataType, value, diagnostics, context); */ } }
public static int GetRecordSize(IColumnMetadata column, EDataType dataType) { if (column.DataType.ColumnType == EFieldType.BitSet) { return(column.AvgSize); } if (column.DataType.IsFixedSize()) { return(column.DataType.Size); } if (dataType.IsFixedSize()) { return(dataType.GetSize()); } if (column.DataType.ColumnType == EFieldType.Symbol && dataType == EDataType.Data) { return(INT32_RECORD_SIZE); } return(-1); }
public void SetTagName(string name) { if (name == null) { throw new System.Exception("name is null"); } name.Trim(); if (name.Length == 0) { throw new System.Exception("name = [" + name + "] is Length==0"); } if (name.Contains("/")) { throw new System.Exception("name = [" + name + "] is Contain slash !"); } EDataType eType = jxUtil.GetTypeByTagName(name, ref _name); if (!(eType == EDataType.e_element && m_EDataType == EDataType.e_string)) { m_EDataType = eType; } m_string_id = jIndexString.GetIndex(_name); }
private void DeserializeNonGenericObject(TokenNode node, Type objectType, EDataType eType, object objectInstance) { //Debug.Assert(node.listValues != null); Dictionary <string, FieldInfo> fieldInfos = GetTypeInfo(objectType, eType); List <string> keysToVerify = options.verifyAllKeysSet ? fieldInfos.Keys.ToList() : null; foreach (TokenNode childNode in node.listValues) { if (childNode.key == null) { throw new InvalidDataException($"Object-Entry on Line {childNode.lineNumber} has no key!"); } if (!fieldInfos.ContainsKey(childNode.key)) { throw new InvalidDataException($"Object-Entry on Line {childNode.lineNumber} has invalid key: '{childNode.key}' possible keys are: ('{string.Join("', '", fieldInfos.Keys)}')"); } FieldInfo fieldInfo = fieldInfos[childNode.key]; if (childNode.listValues == null && childNode.simpleValue == null) { throw new InvalidDataException($"Object-Entry on Line {childNode.lineNumber} with key: '{childNode.key}' does not contain any values!"); } Type fieldType = fieldInfo.FieldType; fieldInfo.SetValue(objectInstance, DeserializeNodeValue(childNode, fieldType, EDataTypes_Extensions.GetDataType(fieldType))); if (options.verifyAllKeysSet) { keysToVerify?.Remove(childNode.key); } } if (options.verifyAllKeysSet) { if (keysToVerify != null && keysToVerify.Count > 0) { throw new InvalidDataException($"Object on Line {node.lineNumber} was missing keys: ('{string.Join("', '", keysToVerify)}')"); } } }
public bool validateEDataType(EDataType obj, DiagnosticChain diagnostics, Dictionary <object, object> context) { if (!validate_NoCircularContainment(obj, diagnostics, context)) { return(false); } bool result = validate_EveryMultiplicityConforms(obj, diagnostics, context); if (result || diagnostics != null) { result &= validate_EveryDataValueConforms(obj, diagnostics, context); } if (result || diagnostics != null) { result &= validate_EveryReferenceIsContained(obj, diagnostics, context); } if (result || diagnostics != null) { result &= validate_EveryBidirectionalReferenceIsPaired(obj, diagnostics, context); } //if (result || diagnostics != null) result &= validate_EveryProxyResolves(obj, diagnostics, context); if (result || diagnostics != null) { result &= validate_UniqueID(obj, diagnostics, context); } if (result || diagnostics != null) { result &= validate_EveryKeyUnique(obj, diagnostics, context); } if (result || diagnostics != null) { result &= validate_EveryMapEntryUnique(obj, diagnostics, context); } return(result); }
public static ListItem GetListItem(EDataType type, string text) { var item = new ListItem(text, GetValue(type)); return(item); }
private void buttonAddRightContext_Click(object sender, EventArgs e) { eDataType = EDataType.RightContext; ActivateListBox(); }
// Add buttons private void buttonAddStress_Click(object sender, EventArgs e) { eDataType = EDataType.Stress; ActivateListBox(); }
public static bool Equals(string typeStr, EDataType type) { return(Equals(type, typeStr)); }
public static Task CreateDataUploaderTask(EDataType dataType, Stream stream, string fileName, EDataType destination = EDataType.Default) { Task task = new Task(dataType, TaskJob.DataUpload); if (destination != EDataType.Default) task.Info.UploadDestination = destination; task.Info.FileName = fileName; task.data = stream; return task; }
private void comboBox_Leave(object sender, EventArgs e) { Button btnAdd = null; switch (eDataType) { case EDataType.InputTypeUndefined: { MessageBox.Show("Internal Error: InputTypeUndefined"); return; // break; } case EDataType.Stress: { btnAdd = buttonAddStress; break; } case EDataType.LeftContext: { btnAdd = buttonAddLeftContext; break; } case EDataType.RightContext: { btnAdd = buttonAddRightContext; break; } case EDataType.Exceptions: { btnAdd = buttonAddException; break; } case EDataType.OutputModifiers: { btnAdd = buttonAddOutputModifier; break; } default: { MessageBox.Show("Internal Error: Illegal input type"); return; } } btnAdd.Enabled = true; comboBox.Visible = false; eDataType = EDataType.InputTypeUndefined; enableDisableButtons(); }
private void buttonAddException_Click(object sender, EventArgs e) { eDataType = EDataType.Exceptions; ActivateListBox(); }
// Image image -> MemoryStream data (in thread) public static Task CreateImageUploaderTask(Image image, EDataType destination = EDataType.Default) { Task task = new Task(EDataType.Image, TaskJob.ImageUpload); if (destination != EDataType.Default) task.Info.UploadDestination = destination; task.Info.FileName = "Require image encoding..."; task.tempImage = image; return task; }
// string filePath -> FileStream data public static Task CreateFileUploaderTask(EDataType dataType, string filePath, EDataType destination = EDataType.Default) { Task task = new Task(dataType, TaskJob.FileUpload); if (destination != EDataType.Default) task.Info.UploadDestination = destination; task.Info.FilePath = filePath; task.data = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); return task; }
private void buttonAddOutputModifier_Click(object sender, EventArgs e) { eDataType = EDataType.OutputModifiers; ActivateListBox(); }
public FileDestination GetFileDestinationByDataType(EDataType dataType) { switch (dataType) { case EDataType.Image: return ImageFileDestination; case EDataType.Text: return TextFileDestination; default: case EDataType.File: return FileDestination; } }
// Combos private void comboBox_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox.SelectedIndex < 0) { return; } KaiListBox.KaiListBox klb = null; Button btnAdd = null; switch (eDataType) { case EDataType.InputTypeUndefined: { MessageBox.Show ("Internal Error: InputTypeUndefined"); return; // break; } case EDataType.Stress: { klb = kaiListBoxStress; btnAdd = buttonAddStress; break; } case EDataType.LeftContext: { klb = kaiListBoxLeftContext; btnAdd = buttonAddLeftContext; break; } case EDataType.RightContext: { klb = kaiListBoxRightContext; btnAdd = buttonAddRightContext; break; } case EDataType.Exceptions: { klb = kaiListBoxExceptions; btnAdd = buttonAddException; break; } case EDataType.OutputModifiers: { klb = kaiListBoxOutputModifiers; btnAdd = buttonAddOutputModifier; break; } default: { MessageBox.Show("Internal Error: Illegal input type"); return; } } klb.DisableEdit = false; // i couldn't figure out how to use ObjectCollection.Contains() bool bDuplicate = false; foreach (DataItem kvpLeft in klb.Items) { DataItem kvpRight = (DataItem)comboBox.Items[comboBox.SelectedIndex]; if ((kvpLeft.Key == kvpRight.Key) && (kvpLeft.Value == kvpRight.Value)) { bDuplicate = true; } } if (!bDuplicate) { klb.Items.Insert(iCurrentItem, comboBox.Items[comboBox.SelectedIndex]); } btnAdd.Enabled = true; comboBox.Visible = false; comboBox.SelectedIndex = -1; eDataType = EDataType.InputTypeUndefined; enableDisableButtons(); }
// string text -> MemoryStream data (in thread) public static Task CreateTextUploaderTask(string text, EDataType destination = EDataType.Default) { Task task = new Task(EDataType.Text, TaskJob.TextUpload); if (destination != EDataType.Default) task.Info.UploadDestination = destination; task.Info.FileName = new NameParser().Convert(Program.Settings.NameFormatPattern) + ".txt"; task.tempText = text; return task; }