public PLCPoller(string in_ipaddr, int in_polltime, string in_name, string in_path, string srlzpath, int labelslimit) { ipaddr = in_ipaddr; polltime = in_polltime; name = in_name; path = in_path; maxlabels = labelslimit; serialization_path = srlzpath; busy = false; if (File.Exists(serialization_path + "\\" + name + ".save")) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(serialization_path + "\\" + name + ".save", FileMode.Open, FileAccess.Read, FileShare.Read); try { labels = (LabelData)formatter.Deserialize(stream); stream.Close(); } catch { labels = new LabelData(); labels.name = name; } } else { labels = new LabelData(); labels.name = name; } stateTimer = new Timer(TmrCallback, null, 0, polltime); }
public UiCommand(int id, string label, LabelData labelData, bool isChecked = false) { Id = id; Label = label; LabelData = labelData; IsChecked = isChecked; }
/// <summary> /// 删除提示 /// </summary> /// <param name="tree"></param> private void DeleteShowMessage(TreeList tree) { if (tree.FocusedNode.Level == 0) { if (MessageBox.Show($"删除<{tree.FocusedNode.GetValue(0)}>将删除下面的所有子标签,是否删除?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } else { if (MessageBox.Show($"删除<{tree.FocusedNode.GetValue(0)}>标签,是否删除?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } if (!LabelData.DeleteLabel(int.Parse(tree.FocusedNode.GetValue(0).ToString().Split(':').First()))) { MessageBox.Show("删除失败"); return; } Program.log.Error($"删除标签", new Exception($"{tree.FocusedNode.GetValue(0).ToString()}")); }
public Label GetLabelById(string LabelId) { Console.WriteLine("Getting label " + LabelId + "..."); RestRequest request = new RestRequest("/{version}/admin/category_labels/{id}", Method.GET); request.AddParameter("version", _ver, ParameterType.UrlSegment); request.AddParameter("id", LabelId, ParameterType.UrlSegment); request.AddHeader("Content-Type", "application/json"); request.AddParameter("Authorization", _token.token_type + " " + _token.access_token, ParameterType.HttpHeader); IRestResponse response = _client.Execute(request); HttpStatusCode statusCode = response.StatusCode; int numericCode = (int)statusCode; if (numericCode != 200) { throw new FoundryException(response.ErrorMessage, numericCode, response.Content); } LabelData labelData = JsonConvert.DeserializeObject <LabelData>(response.Content); Label label = labelData.Data; label.ConfigureLabel(); return(label); }
async Task <IEnumerable <LabelData> > SerializeMetaDataAsync(TLabel label) { // Get all existing label data var data = await _labelDataStore.GetByLabelIdAsync(label.Id); // Prepare list to search, use dummy list if needed var dataList = data?.ToList() ?? new List <LabelData>(); // Iterate all meta data on the supplied object, // check if a key already exists, if so update existing key var output = new List <LabelData>(); foreach (var item in label.MetaData) { var key = item.Key.FullName; var entityData = dataList.FirstOrDefault(d => d.Key == key); if (entityData != null) { entityData.Value = item.Value.Serialize(); } else { entityData = new LabelData() { Key = key, Value = item.Value.Serialize() }; } output.Add(entityData); } return(output); }
public Label UpdateLabel(Label MyLabel) { Console.WriteLine("Updating label..."); RestRequest request = new RestRequest("/{version}/admin/category_labels/{id}", Method.PATCH); request.AddParameter("version", _ver, ParameterType.UrlSegment); request.AddParameter("id", MyLabel.Id, ParameterType.UrlSegment); request.AddParameter("application/json", API.LabelJson(null, MyLabel), ParameterType.RequestBody); request.AddParameter("Authorization", _token.token_type + " " + _token.access_token, ParameterType.HttpHeader); IRestResponse response = _client.Execute(request); HttpStatusCode statusCode = response.StatusCode; int numericCode = (int)statusCode; if (numericCode != 200) { throw new FoundryException(response.ErrorMessage, numericCode, response.Content); } LabelData labelData = JsonConvert.DeserializeObject <LabelData>(response.Content); Console.WriteLine("Label successfully updated."); Label label = labelData.Data; label.ConfigureLabel(); return(label); }
/// <summary> /// Prints labels for list of people using same date, location /// and security code /// </summary> /// <param name="date"></param> /// <param name="location"></param> /// <param name="securityCode"></param> /// <param name="people"></param> public void PrintLabels(DateTime?date, string location, int securityCode, List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people) { LabelData labelData = new LabelData(); labelData.Date = date; labelData.Location = location; labelData.SecurityCode = securityCode.Equals(0) ? String.Empty : securityCode.ToString(); foreach (CACCCheckInDb.PeopleWithDepartmentAndClassView person in people) { logger.DebugFormat("Printing label for person: Name=[{0} {1}]", person.FirstName, person.LastName); labelData.Persons.Add(new CACCCheckIn.Printing.NameBadgePrinter.Common.Person { Name = String.Format("{0} {1}", person.FirstName, person.LastName), Class = person.ClassName, SpecialConditions = person.SpecialConditions }); } Printer nameBadgePrinter = new Printer(GetLabelPrinter()); nameBadgePrinter.PrintLabels(labelData); }
private ColoredLabel CreateLabel(LabelData uncoloredLabel, string color, HttpRequest request) { if (uncoloredLabel == null) { throw new ArgumentNullException(nameof(uncoloredLabel)); } color = color ?? DefaultColor; ColoredLabel coloredLabel = new ColoredLabel() { Text = uncoloredLabel.Text, Color = color }; if (uncoloredLabel is ReferenceLabel refLabel) { var refInLabel = string.IsNullOrEmpty(refLabel.Reference) ? string.Empty : $"({refLabel.Reference})"; switch (uncoloredLabel.Type) { case "invoice": coloredLabel.Tooltip = $"Received through an invoice {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.InvoiceLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "payment-request": coloredLabel.Tooltip = $"Received through a payment request {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.PaymentRequestLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "app": coloredLabel.Tooltip = $"Received through an app {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.AppLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "pj-exposed": coloredLabel.Tooltip = $"This utxo was exposed through a payjoin proposal for an invoice {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.InvoiceLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; } } else if (uncoloredLabel is PayoutLabel payoutLabel) { coloredLabel.Tooltip = $"Paid a payout of a pull payment ({payoutLabel.PullPaymentId})"; coloredLabel.Link = string.IsNullOrEmpty(payoutLabel.PullPaymentId) || string.IsNullOrEmpty(payoutLabel.WalletId) ? null : _linkGenerator.PayoutLink(payoutLabel.WalletId, payoutLabel.PullPaymentId, request.Scheme, request.Host, request.PathBase); } return(coloredLabel); }
public void DefaultLabelData(LabelData data) { data.labelSize = Vector2.one * 100; data.clearAreaZ = Vector2.one; data.peakZreaZ = new Vector2(0, float.MaxValue); data.fontSize = defalutFontSize; data.labelBackground = defaultSprite; data.color = defaultTextColor; }
private ColoredLabel CreateLabel(LabelData uncoloredLabel, string?color, HttpRequest request) { ArgumentNullException.ThrowIfNull(uncoloredLabel); color ??= DefaultColor; ColoredLabel coloredLabel = new ColoredLabel { Text = uncoloredLabel.Text, Color = color, TextColor = TextColor(color) }; if (uncoloredLabel is ReferenceLabel refLabel) { var refInLabel = string.IsNullOrEmpty(refLabel.Reference) ? string.Empty : $"({refLabel.Reference})"; switch (uncoloredLabel.Type) { case "invoice": coloredLabel.Tooltip = $"Received through an invoice {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.InvoiceLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "payment-request": coloredLabel.Tooltip = $"Received through a payment request {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.PaymentRequestLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "app": coloredLabel.Tooltip = $"Received through an app {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.AppLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; case "pj-exposed": coloredLabel.Tooltip = $"This UTXO was exposed through a PayJoin proposal for an invoice {refInLabel}"; coloredLabel.Link = string.IsNullOrEmpty(refLabel.Reference) ? null : _linkGenerator.InvoiceLink(refLabel.Reference, request.Scheme, request.Host, request.PathBase); break; } } else if (uncoloredLabel is PayoutLabel payoutLabel) { coloredLabel.Tooltip = $"Paid a payout{(payoutLabel.PullPaymentId is null ? string.Empty : $" of a pull payment ({payoutLabel.PullPaymentId})")}"; coloredLabel.Link = string.IsNullOrEmpty(payoutLabel.WalletId) ? null : _linkGenerator.PayoutLink(payoutLabel.WalletId, payoutLabel.PullPaymentId, PayoutState.Completed, request.Scheme, request.Host, request.PathBase); }
/// <summary> /// 初始化 /// </summary> /// <param name="font"></param> /// <param name="textColor"></param> public void Initialize(Font font, LabelData data) { Data = data; Rect.localScale = Vector3.one; InitHide(); //初始化Text组件 Text.font = font; Text.horizontalOverflow = HorizontalWrapMode.Overflow; Text.alignment = TextAnchor.MiddleCenter; OnUpdate(); }
public ApplicationAssociationDefinition(string @from, LabelData labelData, string target, ApplicationAssociationSchemaDefinition applicationAssociationSchema, string showExpression, string toolTip, string defaultValue = null, string extraProjectionFields = null) : base(from, labelData.Label, showExpression, toolTip) { _label = labelData.Label; _labelField = labelData.LabelField; _labelPattern = labelData.LabelPattern; _target = target; _applicationAssociationSchema = applicationAssociationSchema; _defaultValue = defaultValue; }
/// <summary> /// 设置标签 /// </summary> /// <param name="data"></param> public void SetLabel(LabelData data) { Data = data; #if UNITY_EDITOR if (Application.isPlaying) { return; } LateUpdate(); #endif }
void INameBadgeLabel.PrintLabels(LabelData labelData) { if (Environment.Is64BitOperatingSystem) { PrintLabels64Bit(labelData); } else { PrintLabels32Bit(labelData); } }
/// <summary> /// 检验数据是否存在于缓存中 /// </summary> /// <param name="data"></param> /// <returns></returns> public bool CheckInCache(LabelData data) { foreach (var item in labels) { if (item.Key.id == data.id) { data.label = item.Key; return(true); } } return(false); }
/// <summary> /// 设置关联 /// </summary> /// <param name="id"></param> private void SetLabelRef(int id) { List <TreeListNode> nodes = GetcheckList(treeList2); List <int> ids = nodes.Select(t => int.Parse(t.GetValue(0).ToString().Split(':').First())).ToList(); if (!LabelData.RelevanceLabel(ids, id)) { MessageBox.Show("设置关联失败"); } GetLabels(RefreshType.DynamicLabel); Program.log.Error($"设置关联{id},label_ids:{string.Join(",", ids)}"); }
/// <summary> /// 检验数据是否存在于缓存中 /// </summary> /// <param name="data"></param> /// <returns></returns> public bool CheckInCache(LabelData data) { for (int i = 0; i < labels.Count; i++) { if (labels[i].id == data.id) { data.label = labels[i]; return(true); } } return(false); }
public virtual Label DefineLabel () { if (labels == null) labels = new LabelData [defaultLabelsSize]; else if (num_labels >= labels.Length) { LabelData [] t = new LabelData [labels.Length * 2]; Array.Copy (labels, t, labels.Length); labels = t; } labels [num_labels] = new LabelData (-1, 0); return new Label (num_labels++); }
/// <summary> /// 初始化 /// </summary> /// <param name="font"></param> /// <param name="textColor"></param> public void Initialize(Font font, LabelData data) { Data = data; Rect.localScale = Vector3.one; InitHide(); //初始化Text组件 Text.font = font; Text.horizontalOverflow = HorizontalWrapMode.Overflow; Text.alignment = TextAnchor.MiddleCenter; Text.resizeTextForBestFit = true; Text.resizeTextMinSize = 10; Text.resizeTextMaxSize = 40; OnUpdate(); }
private void SetComboBox() { AllLabels = LabelData.GetAllLabel(); List <string> label = AllLabels.DynamicLabel.Union(AllLabels.StaticLabel).OrderBy(t => t.Id).Select(t => t.Id + ":" + t.Name).ToList(); label.Insert(0, "0:新建标签种类"); comboBox1.DataSource = label; if (string.IsNullOrEmpty(comText)) { comboBox1.SelectedIndex = 0; return; } comboBox1.Text = comText; }
private List <LabelData> LoadControlledDrugList(string area) { List <LabelData> controlledDrugList = new List <LabelData>(); string path = Directory.GetCurrentDirectory(); var csv = File.ReadAllText($"{path}\\設定資料\\{area}.csv"); string[] propNames = null; List <string[]> rows = new List <string[]>(); foreach (var line in CsvReader.ParseLines(csv)) { string[] strArray = CsvReader.ParseFields(line).ToArray(); if (propNames == null) { propNames = strArray; } else { rows.Add(strArray); } } for (int r = 0; r < rows.Count; r++) { LabelData labelData = new LabelData(); var cells = rows[r]; for (int c = 0; c < cells.Length; c++) { switch (c) { case 0: labelData.MedID = cells[c]; break; case 1: labelData.MedName = cells[c]; break; default: break; } labelData.Device = area; } controlledDrugList.Add(labelData); } return(controlledDrugList); }
private void AddLabels() { List <string> labels = GetLabels(); if (labels.Count == 0 || comboBox1.Text == "请选择要添加标签的种类") { return; } if (!LabelData.AddLabels(int.Parse(comboBox1.Text.Split(':').First()), labels, GetLabelType(), GetLabelRef())) { MessageBox.Show("添加失败"); return; } Program.log.Error($"添加标签,种类{comboBox1.Text.Split(':').Last()}", new Exception($"{string.Join(",",labels)}")); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text.Trim())) { MessageBox.Show("修改不能为空"); return; } if (!LabelData.UpdateLabelName(index, textBox1.Text.Trim())) { MessageBox.Show("修改失败"); Program.log.Error($"修改标签名,label_id:{index},修改名:{textBox1.Text.Trim()}"); } OnRefresh(type); this.Close(); }
void StartLabeler(bool staging, bool add) { ListBox listBox = staging ? stagingBuildList : liveBuildList; if (listBox.SelectedValue == null) { return; } BuildVersionData buildData = (BuildVersionData)listBox.SelectedValue; LabelData labelData = new LabelData { staging = staging, version = buildData.buildVersion, label = add ? "Live" : "Rollback" }; new Labeler(productData, labelData, add).ShowDialog(); }
/// <summary> /// Post保存标签 /// </summary> public async Task <bool> SaveLabelAsync() { List <VideoLabel> ids = new List <VideoLabel>(); if (Selectlabels.Equals(videoplay.Labels.DynamicLabel)) { return(true); } foreach (TypeLabel tree in staticlabel.Union(Selectlabels)) { ids.AddRange(tree.Labels); } bool win = await LabelData.AddLabelToVideoAsync(videoplay.Id, ids.Select(t => t.Id).ToList()); return(win); }
/// <summary> /// 获取标签 /// </summary> /// <param name="data"></param> /// <returns></returns> public KGUI_Label GetLabel(LabelData data) { KGUI_Label label = data.label; if (label == null) { label = CreatLabel(data); } label.SetLabel(data); if (!labels.Contains(label)) { labels.Add(label); } return(label); }
public Labeler(ProductData productData, LabelData labelData, bool add) { InitializeComponent(); if (add) { Title = "Label"; label.Content = "Label"; } else { Title = "Unlabel"; label.Content = "Unlabel"; } this.labelData = labelData; this.productData = productData; this.add = add; }
private void RunLabel(CheckBox checkBox) { if (checkBox.IsChecked == false) { return; } LabelData labelData = this.labelData; labelData.platform = checkBox.Content.ToString(); ProcessStartInfo cmd = EpicApi.BuildLabelCommand(App.saveData, productData, labelData); if (!add) { cmd = EpicApi.BuildUnlabelCommand(App.saveData, productData, labelData); } EpicApi.Run(cmd); }
/// <summary> /// 获取标签 /// </summary> /// <param name="data"></param> /// <returns></returns> public KGUI_Label GetLabel(LabelData data) { KGUI_Label label = data.label; if (label == null) { label = CreatLabel(data); } if (labels.ContainsKey(data.label) && labels[label] != data.appertaining) { label = CreatLabel(data); } label.SetLabel(data); if (!labels.ContainsKey(label)) { labels.Add(label, data.appertaining); } return(label); }
/// <summary> /// 创建标签 /// </summary> /// <param name="data"></param> /// <returns></returns> private KGUI_Label CreatLabel(LabelData data) { KGUI_Label label; if (string.IsNullOrEmpty(data.labelName)) { data.labelName = data.appertaining.name; DefaultLabelData(data); } GameObject obj = new GameObject(data.labelName, typeof(RectTransform)); obj.transform.SetParent(transform); label = obj.AddComponent <KGUI_Label>(); label.hideFlags = HideFlags.HideInInspector; data.label = label; label.Initialize(defaultFont, data); return(label); }
public void BeforeEachTest() { _labelData = new LabelData("Id"); }
public void Should_return_a_TextBoxData_with_Label_initialized_given_a_string_label_text() { const string labeltext = "Id"; var tBox = TextBoxData.WithLabel(labeltext); Assert.AreSame(TextBoxData, tBox); var label = new LabelData { Text = labeltext }; tBox.ToString().Contains(label.ToString()).ShouldBeTrue(); }
public void Should_return_a_TextBoxData_with_Label_initialized_given_a_Label_object() { var label = new LabelData { Text = "Id" }; var tBox = TextBoxData.WithLabel(label); Assert.AreSame(TextBoxData, tBox); var textBox = tBox.ToString(); textBox.Contains(label.ToString()).ShouldBeTrue(); }
private void UpdateProgressBar(ProgressBar progressBar, double valueToSet, LabelData labelData) { labelData.newValue = valueToSet; if (labelData.newValue != labelData.setValue) { if (!labelData.labelSetInvokeAwaiting) { labelData.labelSetInvokeAwaiting = true; this.Dispatcher.Invoke( new Action<TextBlock, double>((textBox, val) => { progressBar.Value = valueToSet; labelData.setValue = val; labelData.labelSetInvokeAwaiting = false; }), progressBar, labelData.newValue ); } } }
/// <summary> /// this method updates label with new value, /// you can use this method as much as you want (e.g. 10000 times per second) /// it wont lead to stackoverflow (standard invoke would lead to stack overflow (and did it!)) /// /// the reason this method has sense is events which are updating textblock values sometimes are /// invoked very frequently (like few hundred times a second) /// </summary> /// <param name="textBlock"></param> /// <param name="valueToSet"></param> /// <param name="labelData"></param> private void UpdateTextBlock(TextBlock textBlock, double valueToSet, LabelData labelData) { labelData.newValue = valueToSet; if (labelData.newValue != labelData.setValue) { if (!labelData.labelSetInvokeAwaiting) { labelData.labelSetInvokeAwaiting = true; this.Dispatcher.Invoke( new Action<TextBlock, double>((textBox, val) => { textBox.Text = String.Format("{0:0.###}", val); labelData.setValue = val; labelData.labelSetInvokeAwaiting = false; }), textBlock, labelData.newValue ); } } }
public static CheckBoxData WithLabel(this CheckBoxData checkBoxData, LabelData label) { checkBoxData.Label = label; return checkBoxData; }
protected void btnUpload_Click(object sender, EventArgs e) { if (!fileUpload.HasFile) { mvImportMaster.AddError("ファイルを見つかりません・・・"); return; } CsvReader csvRead = null; Hashtable artistKeyMap = new Hashtable(); Hashtable labelKeyMap = new Hashtable(); Hashtable albumKeyMap = new Hashtable(); StringBuilder updSql = new StringBuilder(); string[] excAlbumName = { "パッケージナシ", "パッケージなし", "パッケージ未発売", "パッケージ未発売のためなし", "先行配信", "配信シングル", "配信限定", "配信限定パッケージのためなし", "配信限定楽曲", "未定", "タイトル未定", "配信限定商品" }; string[] excAlbumNameYomi = { "パッケージナシ", "ハッケージミハツバイ", "ハッケージミハツバイノタメナシ", "センコウハイシン", "ハイシンゲンテイシングル", "ハイシンゲンテイ", "ハイシンゲンテイパッケージノタメナシ", "ハイシンゲンテイガッキョク", "ミテイ", "タイトルミテイ", "ハイシンゲンテイショウヒン"}; try { string[] array = fileUpload.FileName.Split('.'); string ext = string.Empty; if (array.Length > 0) { ext = array[array.Length - 1]; } if (ext.Length == 0) return; ext = ext.ToUpper(); if (!"csv".Equals(ext.ToLower())) { mvImportMaster.AddError("CSVファイルを選択してください・・・"); return; } if (File.Exists(Server.MapPath("./") + fileUpload.FileName)) { File.Delete(Server.MapPath("./") + fileUpload.FileName); } fileUpload.SaveAs(Server.MapPath("./") + fileUpload.FileName); csvRead = new CsvReader(Server.MapPath("./") + fileUpload.FileName, true, ','); csvRead.IsCheckQuote = true; string sql = "DELETE FROM SongImport WHERE SessionId='" + Session.SessionID + "' and ImportType = '"+ importType +"'"; DbHelper.ExecuteNonQuery(sql); sql = "DELETE FROM SongMediaTemp WHERE SessionId='" + Session.SessionID + "' and ImportType = '" + importType + "'"; DbHelper.ExecuteNonQuery(sql); DataTable dt = new DataTable(); DataTable dtTmp = new DataTable(); dt.Load(csvRead); string[] header = csvRead.GetFieldHeaders(); if (!validFormat(dt)) { return; } if (dt.Rows.Count > 0) { //フォーマットチェック for (int i = 0; i < Constants.ImportDataHeader.Length; i++) { if (!Constants.ImportDataHeader[i].Equals(header[i])) { mvImportMaster.AddError("CSVファイルのヘッダー部分が間違っています・・・"); return; } } dt.Columns.Add("SessionId", Type.GetType("System.String")); dt.Columns.Add("ImportType", Type.GetType("System.String")); dt.Columns.Add("Status"); dt.Columns.Add("DelFlag", Type.GetType("System.String")); dt.Columns.Add("Updated", Type.GetType("System.String")); dt.Columns.Add("Updator", Type.GetType("System.String")); dt.Columns.Add("Created", Type.GetType("System.String")); dt.Columns.Add("Creator", Type.GetType("System.String")); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["SessionId"] = Session.SessionID; dt.Rows[i]["ImportType"] = importType; dt.Rows[i]["DelFlag"] = "0"; dt.Rows[i]["Updated"] = DateTime.Now.ToString("yyyyMMddHHmmss"); dt.Rows[i]["Updator"] = Page.User.Identity.Name; dt.Rows[i]["Created"] = DateTime.Now.ToString("yyyyMMddHHmmss"); dt.Rows[i]["Creator"] = Page.User.Identity.Name; } using (SqlBulkCopy copy = new SqlBulkCopy(Gnt.Configuration.ApplicationConfiguration.ConnectionString)) { copy.DestinationTableName = "SongImport"; copy.BatchSize = 3000; copy.BulkCopyTimeout = 99999; for (int i = 0; i < Constants.ImportDataHeader.Length; i++) { copy.ColumnMappings.Add(i, Constants.ImportDataDbRef[i]); } copy.ColumnMappings.Add(dt.Columns.Count - 8, "SessionId"); copy.ColumnMappings.Add(dt.Columns.Count - 7, "ImportType"); copy.ColumnMappings.Add(dt.Columns.Count - 6, "Status"); copy.ColumnMappings.Add(dt.Columns.Count - 5, "DelFlag"); copy.ColumnMappings.Add(dt.Columns.Count - 4, "Updated"); copy.ColumnMappings.Add(dt.Columns.Count - 3, "Updator"); copy.ColumnMappings.Add(dt.Columns.Count - 2, "Created"); copy.ColumnMappings.Add(dt.Columns.Count - 1, "Creator"); copy.WriteToServer(dt); } } DbHelper.ExecuteNonQuery("Update SongImport set Status = 1 where SessionId = '" + Session.SessionID + "' and ImportType = '"+ importType +"' and SongId in (Select SongMediaId from SongMedia where TypeId = '1')"); sql = "Select * from SongImport where SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'"; SqlDatabase db = new SqlDatabase(); DataSet ds = new DataSet(); DataSet dsTmp = new DataSet(); SqlCommand cm = db.CreateCommand(sql); SqlDataAdapter da = new SqlDataAdapter(cm); da.Fill(ds); dt = ds.Tables[0]; string autoKeyArtist = ""; string autoKeyLabel = ""; string autoKeyAlbum = ""; //record foreach (DataRow row in dt.Rows) { //曲ID string songId = row["SongId"].ToString().ToUpper(); //アーティスト名(半角) ArtistName string artistName = row["ArtistName"].ToString().Replace("'", "''").ToUpper(); //アーティスト名ヨミ(半角) ArtistNameReadingFull string artistNameReadingFull = row["ArtistNameReadingFull"].ToString().Replace("'", "''").ToUpper(); string artistId = row["ArtistId"].ToString().ToUpper(); if ("".Equals(artistId) || artistId == null) { if (!artistKeyMap.Contains(artistName) && !artistKeyMap.Contains(artistNameReadingFull) && !artistKeyMap.Contains(artistName + "_" + artistNameReadingFull)) { ArtistData artistData = new ArtistData(); string sqlArtist01 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColName + ") = '" + artistName + "' and UPPER(" + artistData.ObjectKeyTableName + artistData.ColNameReadingFull + ") = '" + artistNameReadingFull + "'"; string sqlArtist02 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColName + ") = '" + artistName + "' "; string sqlArtist03 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColNameReadingFull + ") = '" + artistNameReadingFull + "'"; string[] sqlWhereArtist = { sqlArtist01 }; artistId = GetKey(artistData, sqlWhereArtist); if ("".Equals(artistId) || artistId == null) { string sqlTemp = "SELECT count(*) " + artistData.ObjectKeyColumnName + " FROM " + artistData.ObjectKeyTableName + " WHERE " + sqlArtist02; int count1 = Func.ParseInt(DbHelper.GetScalar(sqlTemp)); sqlTemp = "SELECT count(*) FROM " + artistData.ObjectKeyTableName + " WHERE " + sqlArtist03; int count2 = Func.ParseInt(DbHelper.GetScalar(sqlTemp)); if (count1 + count2 >= 1) { artistId = "ERROR"; } else { if ("".Equals(autoKeyArtist) || autoKeyArtist == null) { artistId = CreateKey(artistData, artistData.ObjectType.Prefix); } else { string prefix = artistData.ObjectType.Prefix; int length = artistData.KeyAttributeData.MaxLength; string tmp = autoKeyArtist.Replace(prefix, ""); int i = Func.ParseInt(tmp) + 1; artistId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0'); } autoKeyArtist = artistId; } } if (!artistKeyMap.Contains(artistName)) { artistKeyMap.Add(artistName, artistId); } if (!artistKeyMap.Contains(artistNameReadingFull)) { artistKeyMap.Add(artistNameReadingFull, artistId); } if (!artistKeyMap.Contains(artistName + "_" + artistNameReadingFull)) { artistKeyMap.Add(artistName + "_" + artistNameReadingFull, artistId); } } else { if (!"".Equals((string)artistKeyMap[artistName])) { artistId = (string)artistKeyMap[artistName]; } if ("".Equals(artistId) || artistId == null) { if (!"".Equals((string)artistKeyMap[artistNameReadingFull])) { artistId = (string)artistKeyMap[artistNameReadingFull]; } } if ("".Equals(artistId) || artistId == null) { if (!"".Equals((string)artistKeyMap[artistName + "_" + artistNameReadingFull])) { artistId = (string)artistKeyMap[artistName + "_" + artistNameReadingFull]; } } } } //レーベル名(半角) LabelName string labelName = row["LabelName"].ToString().Replace("'", "''").ToUpper(); string labelId = row["LabelId"].ToString().ToUpper(); if ("".Equals(labelId) || labelId == null) { if (!labelKeyMap.Contains(labelName)) { LabelData labelData = new LabelData(); string labelSql01 = "UPPER(" + labelData.ObjectKeyTableName + labelData.ColName + ") = '" + labelName + "' "; string[] sqlWhereLabel = { labelSql01 }; labelId = GetKey(labelData, sqlWhereLabel); if ("".Equals(labelId) || labelId == null) { if ("".Equals(autoKeyLabel) || autoKeyLabel == null) { labelId = CreateKey(labelData, labelData.ObjectType.Prefix); } else { string prefix = labelData.ObjectType.Prefix; int length = labelData.KeyAttributeData.MaxLength; string tmp = autoKeyLabel.Replace(prefix, ""); int i = Func.ParseInt(tmp) + 1; labelId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0'); } autoKeyLabel = labelId; } labelKeyMap.Add(labelName, labelId); } else { labelId = (string)labelKeyMap[labelName]; } } string songTitleReading = row["SongTitleReading"].ToString(); string yomi = ""; if (!String.IsNullOrEmpty(songTitleReading)) { yomi = songTitleReading.Substring(0, 1); yomi = Strings.StrConv(Strings.StrConv(yomi, VbStrConv.Wide, 0x0411), VbStrConv.Hiragana, 0x0411); } updSql.AppendLine("Update SongImport set ArtistId = '" + artistId + "' , LabelId = '" + labelId + "', SongYomi = '" + yomi + "' where SongId = '" + songId + "' and SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'"); } DbHelper.ExecuteNonQuery(updSql.ToString()); db = new SqlDatabase(); ds = new DataSet(); dsTmp = new DataSet(); cm = db.CreateCommand(sql); da = new SqlDataAdapter(cm); updSql = new StringBuilder(); sql = "Select * from SongImport where SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'"; cm = db.CreateCommand(sql); da = new SqlDataAdapter(cm); da.Fill(ds); dt = ds.Tables[0]; foreach (DataRow row in dt.Rows) { string contractorId = row["ContractorId"].ToString(); string hbunRitsu = ""; string uta_rate = ""; string video_rate = ""; if (!"".Equals(contractorId)) { ContractorData data = new ContractorData(); ITransaction tran = factory.GetLoadObject(data, contractorId); Execute(tran); if (!HasError) { //編集の場合、DBに既存データを取得して設定する。 data = (ContractorData)tran.Result; hbunRitsu = data.HbunRitsu; uta_rate = data.uta_rate; video_rate = data.video_rate; } } //アーティストID string artistId = row["ArtistId"].ToString().ToUpper(); /////////// //アルバム名(半角) ", " AlbumTitle ", string albumTitle = row["AlbumTitle"].ToString().Replace("'", "''").ToUpper(); //アルバム名ヨミ(半角) ", " AlbumTitleReadingFull ", string albumTitleReadingFull = row["AlbumTitleReadingFull"].ToString().Replace("'", "''").ToUpper(); //CD品番 ", " AlbumCdId ", string albumCdId = row["AlbumCdId"].ToString().Replace("'", "''").ToUpper(); string albumId = row["AlbumId"].ToString().Replace("'", "''").ToUpper(); if ("".Equals(albumId) || albumId == null) { if (!albumKeyMap.Contains(albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId)) { if (excAlbumName.Contains(albumTitle) || excAlbumNameYomi.Contains(albumTitleReadingFull)) { albumId = "ERROR"; } else { AlbumData albumData = new AlbumData(); db = new SqlDatabase(); ds = new DataSet(); dsTmp = new DataSet(); string albumSql = "UPPER(" + albumData.ObjectKeyTableName + albumData.ColTitle + ") = '" + albumTitle + "' AND " + "UPPER(" + albumData.ObjectKeyTableName + albumData.ColTitleReadingFull + ") = '" + albumTitleReadingFull + "' AND " + "UPPER(" + albumData.ObjectKeyTableName + albumData.ColCdId + ") = '" + albumCdId + "' "; string[] sqlWhereAlbum = { albumSql }; albumId = GetKey(albumData, sqlWhereAlbum); albumSql = "Select count(*) from " + albumData.ObjectKeyTableName + " where " + albumSql; int count = Func.ParseInt(DbHelper.GetScalar(albumSql)); if (count > 1) { albumId = "ERROR"; } else if (count == 1) { } else { db = new SqlDatabase(); ds = new DataSet(); dsTmp = new DataSet(); string sqlGetArtist = "SELECT distinct Song.ArtistId, Album.AlbumId, Album.Title FROM Album INNER JOIN Song ON Album.AlbumId = Song.AlbumId WHERE (Album.Title = '" + albumTitle + "') OR (Album.TitleReadingFull = '" + albumTitleReadingFull + "')"; cm = db.CreateCommand(sqlGetArtist); da = new SqlDataAdapter(cm); da.Fill(dsTmp); dtTmp = dsTmp.Tables[0]; foreach (DataRow rowTmp in dtTmp.Rows) { string artistIdTmp = rowTmp["ArtistId"].ToString().ToUpper(); string albumIdTmp = rowTmp["AlbumId"].ToString().ToUpper(); if (artistId.Equals(artistIdTmp)) { albumId = albumIdTmp; } } if ("".Equals(albumId) || albumId == null) { if ("".Equals(autoKeyAlbum) || autoKeyAlbum == null) { albumId = CreateKey(albumData, albumData.ObjectType.Prefix + "0"); } else { string prefix = albumData.ObjectType.Prefix; int length = albumData.KeyAttributeData.MaxLength; string tmp = autoKeyAlbum.Replace(prefix, ""); int i = Func.ParseInt(tmp) + 1; albumId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0'); } autoKeyAlbum = albumId; } } } albumKeyMap.Add(albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId, albumId); } else { albumId = (string)albumKeyMap[albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId]; } } string price = row["Price"].ToString(); string rate = hbunRitsu; string priceNoTax = ""; string buyUnique = ""; string copyrightFeeUnique = ""; string KDDICommissionUnique = ""; string profitUnique = ""; if (!"".Equals(price) && !"".Equals(rate)) { priceNoTax = Func.GetPriceNoTax(price); buyUnique = Func.GetBuyUnique(priceNoTax, rate); copyrightFeeUnique = Func.GetCopyrightFeeUnique(row["CopyrightContractId"].ToString(), priceNoTax, "1"); KDDICommissionUnique = Func.GetKDDICommissionUnique(priceNoTax); profitUnique = Func.GetProfitUnique(priceNoTax, buyUnique, copyrightFeeUnique, KDDICommissionUnique); } string songId = row["SongId"].ToString(); updSql.AppendLine("Update SongImport set AlbumId = '" + albumId + "', hbunRitsu = '" + hbunRitsu + "', uta_rate = '" + uta_rate + "', video_rate = '" + video_rate + "' , PriceNoTax = '" + priceNoTax + "', BuyUnique = '" + buyUnique + "', CopyrightFeeUnique = '" + copyrightFeeUnique + "', KDDICommissionUnique = '" + KDDICommissionUnique + "', ProfitUnique = '" + profitUnique + "'where SongId = '" + songId + "' and SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'"); ArrayList sqlAddSongMedia = GetSqlAddSongMediaKey(row,uta_rate,video_rate); for (int i = 0; i < sqlAddSongMedia.Count; i++) { updSql.AppendLine(sqlAddSongMedia[i].ToString()); } } DbHelper.ExecuteNonQuery(updSql.ToString()); //うた既存 => status=1 DbHelper.ExecuteNonQuery("Update SongMediaTemp set Status = 1 where SessionId = '" + Session.SessionID + "' and SongMediaId in (Select SongMediaId from SongMedia where TypeId = '2') and ImportType = '" + importType + "'"); //ビデオ既存 => status=1 DbHelper.ExecuteNonQuery("Update SongMediaTemp set Status = 1 where SessionId = '" + Session.SessionID + "' and SongMediaId in (Select SongMediaId from SongMedia where TypeId = '3') and ImportType = '" + importType + "'"); db.Close(); /////////// Session["FolderPath"] = fileUpload.FileName; Response.Redirect("NewListMasterImport.aspx", false); } catch (Exception ex) { mvImportMaster.AddError("エラーが発生しました: " + ex.Message); } finally { if (csvRead != null) { csvRead.Dispose(); } } }
public void Should_return_a_RadioButtonData_With_Label_initialized() { var label = new LabelData("Id"); var blankLabel = new LabelData { Text = " " }; var checkBoxData = RadioButtonData.WithLabel(label); Assert.AreSame(RadioButtonData, checkBoxData); checkBoxData.ToString().Contains(label.ToString()).ShouldBeTrue(); checkBoxData.ToString().Contains(blankLabel.ToString()).ShouldBeTrue(); }
private ObservableCollection<LabelData> ListReload(List<Labels> inp) { string linkAssembly = Assembly.GetExecutingAssembly().Location; var directoryName = new FileInfo(linkAssembly).DirectoryName; if (directoryName != null) { string link = Path.Combine(directoryName, "Images"); if (!Directory.Exists(link)) { Directory.CreateDirectory(link); } foreach (Labels i in inp) { var j = new LabelData(); j.Name = i.Name; j.Information = i.Information; j.Latitude = i.Latitude.ToString().Replace(',', '.'); j.Longitude = i.Longitude.ToString().Replace(',', '.'); var fs = new FileStream( string.Format("{0}\\{1}", link, Guid.NewGuid() + ".jpg"), FileMode.OpenOrCreate, FileAccess.ReadWrite); var bw = new BinaryWriter(fs); bw.Write(i.Image); j.Image = fs.Name; bw.Close(); fs.Close(); _listMarks.Add(j); } } return _listMarks; }
private static void SetLabel(CheckBoxData checkBoxData) { var label = new LabelData { Text = "Label:" }; checkBoxData.WithLabel(label); }
public static SpanData WithLabel(this SpanData spanData, LabelData label) { spanData.Label = label; return spanData; }
public static RadioButtonData WithLabelAlignedLeft(this RadioButtonData radioButtonData, LabelData label) { radioButtonData.LabelAlignAttribute = AlignAttribute.Left; return radioButtonData.WithLabel(label); }
public static RadioButtonData WithLabel(this RadioButtonData radioButtonData, LabelData label) { radioButtonData.Label = label; return radioButtonData; }
public void Should_return_a_TextAreaData_With_Width_initialized() { var label = new LabelData("Id"); var tArea = TextAreaData.WithLabel(label); Assert.AreSame(TextAreaData, tArea); tArea.ToString().Contains(label.ToString()).ShouldBeTrue(); }
public static TextAreaData WithLabel(this TextAreaData textAreaData, LabelData label) { textAreaData.Label = label; return textAreaData; }
public void Should_return_a_CheckBoxData_With_Label_initialized() { var label = new LabelData("Id"); var blankLabel = new LabelData { Text = " " }; var checkBoxData = CheckBoxData.WithLabelAlignedLeft(label); Assert.AreSame(CheckBoxData, checkBoxData); checkBoxData.ToString().Contains(label.ToString()).ShouldBeTrue(); checkBoxData.ToString().Contains(blankLabel.ToString()).ShouldBeFalse(); }
public void Should_return_a_ComboSelectData_With_Label_initialized() { var label = new LabelData("Id"); var listData = ComboSelectData.WithLabel(label); Assert.AreSame(ComboSelectData, listData); listData.ToString().Contains(label.ToString()).ShouldBeTrue(); }
public static CheckBoxData WithLabelAlignedLeft(this CheckBoxData checkBoxData, LabelData label) { checkBoxData.LabelAlignAttribute = AlignAttribute.Left; return checkBoxData.WithLabel(label); }
private static void SetLabel(RadioButtonData checkBoxData) { var label = new LabelData { Text = "Label" }; checkBoxData.WithLabel(label); checkBoxData.WithLabelAlignedLeft(label); }