Exemplo n.º 1
0
    public void saveCSVTable(string para_fullFilePath, CSVTable para_table)
    {
        StreamWriter sw = File.CreateText(para_fullFilePath);

        // Apply Column Header Row.
        string[] columnHeaders = para_table.getAllColumnHeaders();
        if(columnHeaders != null)
        {
            string columnHeaderCSVRow = "";
            for(int i=0; i<columnHeaders.Length; i++)
            {
                string nxtColumnHeader = columnHeaders[i];
                if(nxtColumnHeader != null)
                {
                    columnHeaderCSVRow += nxtColumnHeader;
                }

                if(i < (columnHeaders.Length-1))
                {
                    columnHeaderCSVRow += ",";
                }
            }

            sw.WriteLine(columnHeaderCSVRow);
        }

        // Apply Data Rows.
        List<CSVTableRow> rowData = para_table.getAllRows();
        if(rowData != null)
        {
            for(int i=0; i<rowData.Count; i++)
            {
                CSVTableRow nxtCSVRow = rowData[i];
                string commaDelimRow = nxtCSVRow.getCommaDelimStr();
                sw.WriteLine(commaDelimRow);
            }
        }

        sw.Close();
        sw.Dispose();
    }
Exemplo n.º 2
0
		//**********************************************************************
		//								CSVAccess()
		//
		//		This function will fetch a handle to the requested table.
		//		If not found in the "open table list" the table will be
		//		opened and added to the list. Eventually this function may
		//		become public with an abstracted return type so that
		//		applications can set options about the table. For now this
		//		isn't done.
		//**********************************************************************
		static CSVTable CSVAccess(string filename)
		{
			if(filename==null||filename=="") return null;

			string Filename=filename.ToLower();
			// --------------------------------------------------------------------
			//		Is the table already in the list.
			// --------------------------------------------------------------------
			if(CSVTableList.ContainsKey(Filename)) return CSVTableList[Filename];

			// --------------------------------------------------------------------
			//		Create an information structure about this table, and add to
			//		the front of the list.
			// --------------------------------------------------------------------
			CSVTable table=new CSVTable();
			table.filename=Filename;

			// --------------------------------------------------------------------
			//		If not, try to open it.
			// --------------------------------------------------------------------
			try
			{
				table.file=new StreamReader(Filename, Encoding.UTF8);
			}
			catch
			{
				return null;
			}

			CSVTableList.Add(Filename, table);

			// --------------------------------------------------------------------
			//		Read the table header record containing the field names.
			// --------------------------------------------------------------------
			table.fieldNames=CSVReadParseLine(table.file);

			return table;
		}
Exemplo n.º 3
0
    public CSVTable loadCSVTable(string para_tableName, string para_fullFilePath)
    {
        UnityEngine.TextAsset ta = (UnityEngine.TextAsset) UnityEngine.Resources.Load(para_fullFilePath,typeof(UnityEngine.TextAsset));
        StringReader sr = new StringReader(ta.text);

        List<string> columnHeaders = new List<string>();
        List<CSVTableRow> dataRows = new List<CSVTableRow>();

        int counter = 0;
        string csvLine = sr.ReadLine();
        while(csvLine != null)
        {
            List<string> parsedLine = parseCSVStringToList(csvLine);

            if(counter == 0)
            {
                // Store column headers.
                columnHeaders = parsedLine;
            }
            else
            {
                // Store next data row.
                dataRows.Add(new CSVTableRow(parsedLine));
            }

            counter++;
            csvLine = sr.ReadLine();
        }

        sr.Close();
        sr.Dispose();

        // Fill Table.
        CSVTable nwTable = new CSVTable(para_tableName,columnHeaders.ToArray(),dataRows);
        return nwTable;
    }
Exemplo n.º 4
0
        public void QuotedValues()
        {
            CSVTable table = m_Parser.Parse("\"key\";\"value\"").Flush();

            AssertEntry(table.Entries[0], "key", "value");
        }
Exemplo n.º 5
0
        public void KeyValuePair()
        {
            CSVTable table = m_Parser.Parse("key;value").Flush();

            AssertEntry(table.Entries[0], "key", "value");
        }
Exemplo n.º 6
0
        public void EmptyString()
        {
            CSVTable table = m_Parser.Parse("").Flush();

            Assert.AreEqual(0, table.Entries.Count);
        }
Exemplo n.º 7
0
 private static CSVTable GetWingmanTable()
 {
     return(g_wingman = g_wingman != null ? g_wingman : LoadConfig("G_Wingman.csv"));
 }
Exemplo n.º 8
0
 public Globals(CSVTable table, int index) : base(table, index)
 {
 }
Exemplo n.º 9
0
        /*  this method is called from framework to show the report row (data)
         *  It combines the incident report (ConfigurationSetting.incidentsByContactReportID)
         *  and the ServiceRequest.LookupSRbyContactPartyID(contactPartyID)
         *  Currently this list is only showing certain fields (because of combining 2 lists with common fields)
         *  The Right Now incidents by a contact report is hidden, meaning the Report control of a contact
         *  workspace tab is based on the EBS Service Request List Table report definition
         *  Also, do not change the default column heading of Right Now incidents by a contact report
         *  (they are hard coded to uppercase). Because they are hidden anyway.
         *  The EBS Service Request List Table report definition column headings can be changed and those are
         *  the ones being displayed.
         */
        public override IList <IReportRow> GetRows(IList <string> columns, IReportFilterNode filterNode)
        {
            IList <IReportRow> reportRows = new List <IReportRow>();
            IRecordContext     _context   = ((EBSVirtualReportTablesPackage)this.Parent)._globalContext.AutomationContext.CurrentWorkspace;

            if (_context == null)
            {
                return(reportRows);
            }

            IContact contactRecord = _context.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact;

            /* report framework refresh every 30 sec (default) even though the tab is not active
             * so need to check contactRecord for null (when the editor is different)
             */
            if (contactRecord == null)
            {
                return(reportRows);
            }

            int contactPartyID = 0;

            // get the ebs contact party custom attribute on the contact workspace
            contactPartyID = getContactPartyIdCustomAttr(contactRecord);

            // following to get the rNow incidents report and filter is the rNow contactID
            AnalyticsReport reportIncident = new AnalyticsReport();
            ID rId = new ID();

            rId.id            = ConfigurationSetting.incidentsByContactReportID;
            rId.idSpecified   = true;
            reportIncident.ID = rId;
            byte[] outByte = new byte[1000];

            AnalyticsReportFilter[] filter = new AnalyticsReportFilter[3];
            filter[0] = new AnalyticsReportFilter();

            String[] filterString = new String[1];
            filterString[0]  = "" + contactRecord.ID;
            filter[0].Values = filterString;
            filter[0].Name   = "Contact"; // incidents by a contact, thus Contact filter

            NamedID datatype = new NamedID();

            datatype.Name      = "Integer";
            filter[0].DataType = datatype;

            reportIncident.Filters = filter;

            ClientInfoHeader _cih = new ClientInfoHeader();

            _cih.AppID = "Accelerator Report Add-In";

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            CSVTableSet tableSet = ConfigurationSetting.client.RunAnalyticsReport(
                _cih, reportIncident, 100, 0, "\t", false, false, out outByte
                );

            stopwatch.Stop();
            string logMessage = "Called RightNowSyncPortClient.RunAnalyticsReport." +
                                "reportID: " + ConfigurationSetting.incidentsByContactReportID;

            ConfigurationSetting.logWrap.DebugLog(0, contactRecord.ID, logMessage: logMessage, timeElapsed: (int)stopwatch.ElapsedMilliseconds);

            CSVTable[] csvTables = tableSet.CSVTables;
            CSVTable   table     = csvTables[0];

            string[] rowData             = table.Rows;
            int      rNowIncidentCount   = table.Rows.Length;
            int      srVirtualTableCount = this.Columns.Count;

            string[] colHeadingIncidentReport = table.Columns.Split('\t');

            foreach (String commaRow in table.Rows)
            {
                ReportDataRow reportDataRow = new ReportDataRow(srVirtualTableCount);
                string[]      colValue      = commaRow.Split('\t');

                // the report output is stored as <columnHeading, value>
                Dictionary <string, string> dictRow = new Dictionary <string, string>();
                int i = 0;
                foreach (string val in colValue)
                {   /* make the column heading upper case (because the custom attribute heading
                     * in the report designer sometime all in lower case, sometime the reverse)
                     */
                    dictRow.Add(colHeadingIncidentReport[i].ToUpper(), val);
                    i++;
                }

                addRnowIncidentRow(ref columns, ref reportDataRow, ref reportRows, dictRow);
            }

            if (contactPartyID > 0)
            {
                ServiceRequest[] sRs = ServiceRequest.LookupSRbyContactPartyID(contactPartyID, 0, contactRecord.ID);

                foreach (ServiceRequest req in sRs)
                {
                    ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count);
                    if (req != null) // live ebs row 316 of 319 of contact 4431 return null
                    {
                        addEBSsrRow(ref columns, ref reportDataRow, ref reportRows, req);
                    }
                }
            }
            return(reportRows);
        }
        /// <summary>
        /// Search for VIN records based on SR No or VIN No
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Search_Button_Click(object sender, EventArgs e)
        {
            SelectAll_Checkbox.Checked = false;
            ClearAll_CheckBox.Checked  = false;

            var filters = new List <KeyValuePair <string, string> >();

            #region SR and VIN null
            if ((SR_Combobox.SelectedItem == null || ((KeyValuePair <int, string>)SR_Combobox.SelectedItem).Key == 0) &&
                VIN_Textbox.Text == String.Empty && CustomerName_txtbx.Text == String.Empty && Model_ComboBox.SelectedItem == null)
            {
                if (DataGridView != null)
                {
                    clearDataGrid();//clear old view
                }
                MessageBox.Show("Select at least one Filter", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            #region SR not null

            if ((SR_Combobox.SelectedItem != null && ((KeyValuePair <int, string>)SR_Combobox.SelectedItem).Key != 0))
            {
                filters.Add(new KeyValuePair <string, string>("Sales Release", ((KeyValuePair <int, string>)SR_Combobox.SelectedItem).Value));
            }
            #endregion

            #region VIN not null
            if (VIN_Textbox.Text != String.Empty)
            {
                filters.Add(new KeyValuePair <string, string>("VIN", VIN_Textbox.Text));
            }
            #endregion

            #region if Customer Name is not null
            if (CustomerName_txtbx.Text != String.Empty)
            {
                filters.Add(new KeyValuePair <string, string>("Customer Name", CustomerName_txtbx.Text));
            }
            #endregion

            #region if Model Name is not null
            if (Model_ComboBox.SelectedItem != null && ((KeyValuePair <int, string>)Model_ComboBox.SelectedItem).Key != 0)
            {
                filters.Add(new KeyValuePair <string, string>("Model Name", ((KeyValuePair <int, string>)Model_ComboBox.SelectedItem).Value));
            }
            #endregion
            CSVTable resulttable = RightNowConnectService.GetService().GetReportDetails(filters);

            if (resulttable.Rows.Length > 0)
            {
                PopulateGrid(resulttable);
                SelectExistingVins();
            }
            else
            {
                if (DataGridView != null)
                {
                    clearDataGrid();//clear old view
                }
                MessageBox.Show("No data found");
            }
        }
Exemplo n.º 11
0
 private static CSVTable GetBossTable()
 {
     return(g_boss = g_boss != null ? g_boss : LoadConfig("G_Boss.csv"));
 }
Exemplo n.º 12
0
 private static CSVTable GetBulletTable()
 {
     return(g_bullet = g_bullet != null ? g_bullet : LoadConfig("G_Bullet.csv"));
 }
Exemplo n.º 13
0
 private static CSVTable GetPropTable()
 {
     return(g_prop = g_prop != null ? g_prop : LoadConfig("G_Prop.csv"));
 }
Exemplo n.º 14
0
 private static CSVTable GetMobTable()
 {
     return(g_mob = g_mob != null ? g_mob : LoadConfig("G_Mob.csv"));
 }
Exemplo n.º 15
0
        public void QuotedSeparator()
        {
            CSVTable table = m_Parser.Parse("\"1;2\";\"3\"").Flush();

            AssertEntry(table.Entries[0], "1;2", "3");
        }
Exemplo n.º 16
0
        public void MultiLineValue()
        {
            CSVTable table = m_Parser.Parse("\"key\";\"value\nvalue\"").Flush();

            AssertEntry(table.Entries[0], "key", "value\nvalue");
        }
Exemplo n.º 17
0
 public EnumGenerator()
 {
     table = CSVTable.Create<EnumData>("NewTable/EnumConstants.csv", ArrayTool.Create("enumConstantID", "name"));
 }
Exemplo n.º 18
0
 static Matching()
 {
     blockCommandTable = TableLoader.GetTable<BlockCommandEntity>();
 }
Exemplo n.º 19
0
		//**********************************************************************
		//						CSVScanLinesIngested()
		//
		//		Read the file scanline for lines where the key field equals
		//		the indicated value with the suggested comparison criteria.
		//		Return the first matching line split into fields.
		//**********************************************************************
		static string[] CSVScanLinesIngested(CSVTable table, int keyField, string value, CSVCompareCriteria criteria)
		{
			int nTestValue=0;
			if(criteria==CSVCompareCriteria.CC_Integer) nTestValue=atoi(value);

			// --------------------------------------------------------------------
			//		Short cut for indexed files.
			// --------------------------------------------------------------------
			if(keyField==0&&criteria==CSVCompareCriteria.CC_Integer&&table.index!=null)
			{
				if(table.index.ContainsKey(nTestValue)) return table.index[nTestValue];
				return null;
			}

			// --------------------------------------------------------------------
			//		Scan from in-core lines.
			// --------------------------------------------------------------------
			foreach(string[] line in table.cache)
			{
				if(line.Length<keyField+1) continue; // not selected

				bool selected=false;
				if(criteria==CSVCompareCriteria.CC_Integer&&atoi(line[keyField])==nTestValue)
					selected=true;
				else selected=CSVCompare(line[keyField], value, criteria);

				if(selected) return line;
			}

			return null;
		}
Exemplo n.º 20
0
 public static string Encode(CSVTable table)
 {
     return(table.GetContent());
 }
Exemplo n.º 21
0
 public CSVRow(CSVTable table)
 {
     m_vCSVTable = table;
     m_vRowStart = m_vCSVTable.GetColumnRowCount();
     m_vCSVTable.AddRow(this);
 }
Exemplo n.º 22
0
 public LogicClientGlobals(CSVTable table, LogicDataType index) : base(table, index)
 {
 }
Exemplo n.º 23
0
 private static CSVTable GetRoleTable()
 {
     return(g_role = g_role != null ? g_role : LoadConfig("G_Role.csv"));
 }