-
-
Save ShilGen/8ed57978e4f0b967f76b508d4df01cb1 to your computer and use it in GitHub Desktop.
Скрипт для ПБК: получаем словарь MeterPoint.Caption и результат разбивки строки на части с помощью разделителя слеш.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ObjStudioClasses; | |
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Xml; | |
using System.Threading.Tasks; | |
using GemBox.Spreadsheet; | |
using System.Text.RegularExpressions; | |
public class Script | |
{ | |
public static object Execute() | |
{ | |
var meterPoints = MeterPoint.GetInstances().ToHashSet(); | |
Dictionary<MeterPoint, string[]> dictionary = new Dictionary<MeterPoint, string[]>(); | |
using (var sw = new StreamWriter(@"C:\Users\GShilov\Documents\pbk.csv", false, Encoding.UTF8)) | |
{ | |
int i = 0; | |
foreach(var meterPoint in meterPoints) | |
{ | |
string[] mp_name = Regex.Split(meterPoint.Caption, @"\\"); | |
dictionary.Add(meterPoint, mp_name); | |
switch (mp_name.Length) | |
{ | |
case 1: | |
sw.WriteLine((i+1).ToString() +";"+ meterPoint.Caption +";"+ mp_name[0] +";" ); | |
break; | |
case 2: | |
sw.WriteLine((i+1).ToString() +";"+ meterPoint.Caption +";"+ mp_name[0] +";"+ mp_name[1] +";" ); | |
break; | |
case 3: | |
sw.WriteLine((i+1).ToString() +";"+ meterPoint.Caption +";"+ mp_name[0] +";"+ mp_name[1] +";"+ mp_name[2] +";" ); | |
break; | |
} // end switch | |
i=i+1; | |
} | |
} // end using | |
return dictionary; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment