示例#1
0
 public void Main(int processId, ScriptType scriptType)
 {
     int electricSchemeTypeCode = 0;
     E3Project project = new E3Project(processId);
     Sheet sheet = project.GetSheetById(0);
     E3Text text = project.GetTextById(0);
     HashSet<int> electricSchemeSheetIds = GetElectricSchemeSheetIds(project, sheet, electricSchemeTypeCode);
     Dictionary<int, DeviceConnection> deviceConnectionById;
     Dictionary<int, CableInfo> cableInfoById;
     GetDeviceConnectionByIdAndCableInfoById(project, electricSchemeSheetIds, out deviceConnectionById, out cableInfoById);
     Dictionary<int, DeviceSymbol> deviceSymbolById = GetDeviceSymbolById(project, text, deviceConnectionById);
     Dictionary<string, List<SymbolScheme>> schemesByAssignment = GetSchemesByAssignment(deviceConnectionById, deviceSymbolById, cableInfoById, sheet, text);
     if (scriptType == ScriptType.Scheme)
     {
         foreach (string assignment in schemesByAssignment.Keys)
             PlaceSchemes(schemesByAssignment[assignment], project, sheet, text, assignment);
     }
     else
     {
         Dictionary<string, List<int>> OWSSheetIdsByAssignment = GetOWSSheetIdsByAssignment(project, sheet, schemesByAssignment.Keys);
         foreach (string assignment in schemesByAssignment.Keys)
         {
             IEnumerable<int> allDeviceIds = schemesByAssignment[assignment].SelectMany(s => s.AllDeviceIds).Distinct();
             int schemeSheetCount = OWSSheetIdsByAssignment[assignment].Count;
             new SpecificationScript(allDeviceIds, ++schemeSheetCount, subProjectAttribute, "СВП", sheetMarkAttribute, assignment);
         }
     }
     project.Release();
 }
示例#2
0
        private void Start(ScriptType scriptType)
        {
            UI.Cursor = System.Windows.Input.Cursors.Wait;
            Settings settings = new Settings();
            settings.electricSchemeTypeCode = 0;
            settings.firstPageFormat = "Формат А3 лист 1";
            settings.firstPageHeaderLineX = 0;
            settings.firstPageHeaderLineY = -12;
            settings.firstPageUttermostPositionY = -225;
            settings.subsequentPageFormat = "Формат А3_каб.журнал";
            settings.subsequentPageHeaderLineX = 0;
            settings.subsequentPageHeaderLineY = 287;
            settings.subsequentPageUttermostPositionY = 20;
            settings.lineFont = new E3Font();
            settings.headerFont = new E3Font(height: 3.5);
            settings.separatingSymbols = "?!.:, -";
            settings.verticalLineWidth = 0.5;
            settings.horizontalLineWidth = 0.2;
            settings.headerVerticalLineWidth = 0.5;
            settings.headerHorizontalLineWidth = 0.5;
            settings.bottomLineWidth = 0.5;
            settings.sheetTypeAttribute = "marka2";
            SaveSettings(settings);

            E3Project project = new E3Project(applicationInfo.ProcessId);
            Sheet sheet = project.GetSheetById(0);

            List<ConnectionInfo> connectionInfos;

            if (scriptType == ScriptType.ByConnections)
                connectionInfos = GetConnectionInfosByConnections(project, sheet, settings.electricSchemeTypeCode);
            else
                connectionInfos = GetConnectionInfosByCoresAndWires(project);

            connectionInfos.RemoveAll(ci => ci.assignmentFrom != ci.assignmentTo || String.IsNullOrEmpty(ci.assignmentFrom)); // удаляем все соединения, не идущие внутри одного шкафа
            ConnectionInfoComparer comparer = new ConnectionInfoComparer();
            connectionInfos.Sort(comparer);

            StringSeparator separator = new StringSeparator(settings.separatingSymbols.ToCharArray(), settings.lineFont, project.GetTextById(0));
            LineTemplate lineTemplate = new LineTemplate(new List<double>() { 35, 45, 45, 45, 45, 45, 45, 45, 45 }, settings.lineFont, 8, settings.verticalLineWidth, settings.horizontalLineWidth);
            LineTemplate headerLineTemplate = new LineTemplate(new List<double>() { 35, 45, 45, 45, 45, 45, 45, 45, 45 }, settings.headerFont, 8, settings.headerVerticalLineWidth, settings.headerHorizontalLineWidth);
            List<string> headerColumnNames = new List<string>(9){"Имя цепи", "От \"Места\"", "От \"Поз. обозначения\"", "От \"Вывода\"", "К \"Месту\"", "К \"Поз. обозначению\"", "К \"Выводу\"", "Тип провода", "Примечание"};
            Dictionary<string, Table> assignmentTables = new Dictionary<string, Table>();
            foreach (ConnectionInfo info in connectionInfos)
            {
                if (!assignmentTables.ContainsKey(info.assignmentFrom))
                {
                    HeaderText headerText = new HeaderText("Таблица соединений шкафа "+info.assignmentFrom, settings.headerFont, settings.headerFont.height + 1);
                    TablePageTemplate firstPageTemplate = new TablePageTemplate(settings.firstPageFormat, settings.firstPageHeaderLineX, settings.firstPageHeaderLineY, settings.firstPageUttermostPositionY, headerText);
                    TablePageTemplate subsequentPageTemplate = new TablePageTemplate(settings.subsequentPageFormat, settings.subsequentPageHeaderLineX, settings.subsequentPageHeaderLineY, settings.subsequentPageUttermostPositionY);
                    assignmentTables.Add(info.assignmentFrom, new Table(project, headerLineTemplate, headerColumnNames, lineTemplate, settings.bottomLineWidth, separator, firstPageTemplate, subsequentPageTemplate));
                }
                assignmentTables[info.assignmentFrom].AddLine(new List<string>(8) { info.signal, info.locationFrom, info.deviceFrom, info.pinFrom, info.locationTo, info.deviceTo, info.pinTo, info.type });
            }
            foreach (string key in assignmentTables.Keys)
            {
                assignmentTables[key].AddFinalGraphicLine();
                foreach (int id in assignmentTables[key].SheetIds)
                {
                    sheet.Id = id;
                    sheet.SetAttribute(settings.sheetTypeAttribute, key);
                }
            }
            project.Release();
            UI.Cursor = System.Windows.Input.Cursors.Arrow;
        }