private void list_template_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } if (e.ColumnIndex == -1) { return; } ztinfo zt = (ztinfo)cmbZTList.SelectedItem; string type = zt.DbType; string id = this.dgwtemplate.Rows[e.RowIndex].Cells["Id"].Value.ToString(); string tmpname = this.dgwtemplate.Rows[e.RowIndex].Cells["name"].Value.ToString(); if (Path.GetExtension(this.txtFileName.Text.Trim()).IndexOf(".xls") >= 0) { ExcelProView ex = new ExcelProView(this.txtFileName.Text, tmpname, type, id); if (ex.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.tmplate = ex.tmp; this.txtTemplate.Text = tmplate.Name; this.panTemplate.Visible = false; } } else { this.txtTemplate.Text = tmpname; this.panTemplate.Visible = false; } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { UnitOfWork unitOfWork = new UnitOfWork(); ImportedRecordsView = new ObservableCollection <ImportDataRowModel>(); MachineTypes = new ObservableCollection <MachineType>(unitOfWork.MachineTypeRepository.GetQuery().Where(type => type.LangId == 2).ToList()); SelectedMachineType = MachineTypes.FirstOrDefault(); LoadCommand = new RelayCommand(() => Load()); ImportToDataBaseCommand = new RelayCommand(() => SaveToDataBase(), () => ImportedRecordsView.Any()); _templateView = new ImportTemplate(); _templateView.ModelColName = "B"; _templateView.ArticleColName = "C"; _templateView.DescriptionColName = "D"; _templateView.QuantityColName = "E"; _templateView.CostBaseColName = "F"; _templateView.CostNativeColName = "G"; _templateView.OEMColName = "H"; _templateView.ManufColName = "I"; _templateView.StartRowNumber = 6; _templateView.EndRowNumber = 200; }
public ExcelImport(string filename, string ztname, int zid, string type, ImportTemplate temp) : base(filename, ztname, zid) { this.Template = temp; this.Type = (DataType)Enum.Parse(typeof(DataType), type); dt = ExcelLib.NPOIHelper.Excel2DataTable(Filename, Template.HasHeadColumn, 1, Template.FirstRowNum); }
public string GetImportTemplate() { if (string.IsNullOrEmpty(ImportTemplate)) { return(Name); } var tempaltes = ImportTemplate.Replace("\r", "").Split('\n'); return(tempaltes[0]); }
public static void Main(string[] args) { LogHelper.writeBasic("Init provisioning..."); ParamsModel allParams = ParamsHelper.ParseParams(args); DefinedParamsModel options = allParams.basicParams; // Select type try { IService action; switch (options.action.value) { case "import": action = new ImportTemplate(); break; case "export": action = new ExportTemplate(); break; case "help": default: action = new HelpTemplate(); break; } // Generate Secore Password SecureString passwordSecore = new SecureString(); foreach (char c in options.password.value.ToCharArray()) { passwordSecore.AppendChar(c); } // Do the action if (action != null) { LogHelper.writeBasic("Action found and start to run the program..."); action.RunAction(options, passwordSecore); LogHelper.writeBasic("Action finished."); } else { LogHelper.writeWarning(string.Concat("Action not defined in code, please review readme.md.")); } // Code problem } catch (Exception ex) { LogHelper.writeError(string.Concat("An error not recognise happend, please review the code. ", ex.Message)); } LogHelper.writeBasic("Finished process provisioning."); Console.ReadLine(); }
public ExcelProView(string ExcelFileName, string tmpName, string type, string id) : this() { tmp = TemplateHelper.getTemplate(tmpName, type); tmp.Id = id; this.FileName = ExcelFileName; this.TmpName = tmpName; this.chkfirstrowiscolname.Checked = tmp.HasHeadColumn; this.numFirstRow.Value = tmp.FirstRowNum; showTOP10Excel(); }
public ExcelTemplate(ImportTemplate importtmp) : this() { this.tmp = importtmp; this.txtTemple.Text = tmp.Name; this.cmbType.Text = tmp.Type; if (tmp.Type.ToUpper() == "WPI") { chkWPI_AN.Checked = true; chkWPI_PN.Checked = true; } else if (tmp.Type.ToUpper() == "EPODOC") { chkEPO_AN.Checked = true; chkEPO_PN.Checked = true; } }
static void Main(string[] args) { PreproccessFolder(); var allTableList = ReadAllTables(); SqlScript.GenerateSqlScript("CreateDeviceSql", allTableList); ImportTemplate.GenerateTemplate(allTableList); Backend_Devices.GenerateCode(allTableList); Frontend_Devices.GenerateCode(allTableList); Backend_Retrieval.GenerateCode(allTableList); Frontend_Retrieval.GenerateCode(allTableList); Backend_Anchors.GenerateCode(allTableList); Frontend_Anchors.GenerateCode(allTableList); Backend_Statistic.GenerateCode(allTableList); Frontend_Statistic.GenerateCode(allTableList); Frontend_Api_Url.GenerateCode(allTableList); }
public void Index(ABS_Conversion.ConversionForm frm, string database, string sqlTable, string primVal, string altVal, string idx, string remoteServer, string remotePath) { string primary = ""; string secondary = ""; string rec = ""; string[] recs; string[] indxs; string outRec = ""; long position = 0; long recNum = 0; bool eof = false; char tab = '\t'; FileStream fs; StreamWriter sw; if (fileInfo.Exists == true) { string text = fileInfo.FullName.ToString(); int num = text.IndexOf(".", 0); if (num > -1) { text = text.Substring(0, num); } else { num = text.Length; } FileInfo f = new FileInfo(text + ".dat"); if (f.Exists == false) { fs = f.OpenWrite(); sw = new StreamWriter(fs); DateTime sDate = DateTime.Now; frm.DisplayResults(sDate.ToLongTimeString()); while (eof == false) { rec = reader.ReadLine(); if (rec == "" || rec == null) { break; } else if (char.Parse(rec.Substring(1 - 1, 1)) == (char)26) { break; } else { if (idx == "") { if (altVal.Trim() == "") { primary = GetValueInFile(primVal, rec); } else { primary = GetValueInFile(primVal, rec); secondary = GetValueInFile(altVal, rec); } primary = primary.Trim(); secondary = secondary.Trim(); outRec = position.ToString() + "%" + primary + "%" + secondary; sw.WriteLine(outRec); sw.Flush(); primary = ""; secondary = ""; recNum++; if (recNum % 100 == 0) { frm.DisplayResults("Creating Index File " + f.Name.ToUpper() + "..." + recNum.ToString()); } //position = (rec.Length + 1) + position; position = (rec.Length + 2) + position; } else { //recs = rec.Split('\t'); recs = rec.Split('|'); if (idx.IndexOf("|", 0) > -1) { indxs = idx.Split('|'); for (int iCnt = 0; iCnt < indxs.Length; iCnt++) { primary = primary + recs[int.Parse(indxs[iCnt])]; } } else { primary = recs[int.Parse(idx)]; } outRec = position.ToString() + "%" + primary + "%" + secondary; sw.WriteLine(outRec); sw.Flush(); primary = ""; secondary = ""; recNum++; if (recNum % 100 == 0) { frm.DisplayResults("Creating Index File " + f.Name.ToUpper() + "..." + recNum.ToString()); } //position = (rec.Length + 1) + position; position = (rec.Length + 2) + position; } } } sw.Close(); fs.Close(); frm.DisplayResults("Removing..." + sqlTable); SqlCommand removeCommand = new SqlCommand("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" + sqlTable + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE " + sqlTable, conn); removeCommand.ExecuteNonQuery(); SqlCommand createCommand = new SqlCommand("CREATE TABLE [dbo].[" + sqlTable + "] ([RecPosition] [numeric](11, 0) NULL ,[PrimaryVal] [varchar] (25) NULL ,[SecondaryVal] [varchar] (25) NULL ) ON [PRIMARY]", conn); createCommand.CommandType = CommandType.Text; createCommand.ExecuteNonQuery(); DataTable tbl = ImportTemplate.IndexTable(); tbl.TableName = sqlTable; Import(f.FullName, false, tbl, "%", 3); // //FileInfo fi = new FileInfo(f.FullName); // //fi.CopyTo(@"\\" + remoteServer + remotePath.Replace(":","$") + f.Name,true); // string command = "BULK INSERT " + database + ".." + sqlTable + " FROM '" + f.FullName + "' WITH (DATAFILETYPE = 'char',FIELDTERMINATOR = '%',ROWTERMINATOR = '\n')"; // ////command = command.Replace(f.FullName, @"\\mphsmdev02\Input\" + f.Name); //// //@"D:\HospitalData\jap\Delta\temp\Pathology\" mphsmsqldev01 // //command = command.Replace(f.FullName, remotePath + fi.Name); // SqlCommand bulkCommand = new SqlCommand(command, conn); // bulkCommand.CommandType = CommandType.Text; // bulkCommand.CommandTimeout = 1800; // bulkCommand.Connection = conn; // bulkCommand.ExecuteNonQuery(); SqlCommand idxCommand = new SqlCommand("CREATE INDEX [IX_PRIMARY] ON [dbo].[" + sqlTable + "]([PrimaryVal]) ON [PRIMARY]", conn); idxCommand.CommandType = CommandType.Text; idxCommand.CommandTimeout = 1800; idxCommand.ExecuteNonQuery(); DateTime eDate = DateTime.Now; frm.DisplayResults(sDate.ToLongTimeString() + " " + eDate.ToLongTimeString()); } } }