Exemplo n.º 1
0
        private static void BasicDimensionAndMeasureUsage(IApp theApp, IGenericObject theObject)
        {
            var theHyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // List Sales per year (1 Dimension, 1 Measure)
            AddInlineDimension(theHyperCube, "Year");
            AddInlineMeasure(theHyperCube, "Sum([Sales Amount])");
            SetHyperCube(theObject, theHyperCube);
            // Columns of data appear in the order they appear in the dimension and measure definition lists
            // for the hypercube. Dimensions first, then measures. Row 0 will therefore contain the years,
            // and row 1 will contain the sum of sales.
            PrintData("Sales per year", theObject,
                      row => String.Format("Year: {0}, Sales: {1}", row[0].Num, row[1].Num));

            // List sales per year and month
            AddInlineDimension(theHyperCube, "Month");
            SetHyperCube(theObject, theHyperCube);
            // Adding a dimension increases the number of columns in the returned data. The new dimension
            // will appear on position 1 (after the year) as AddInlineDimension appends dimensions to the
            // end of the dimension list.
            PrintData("Sales per year and month", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Num));

            // Use predefined library version of the measure.
            // Get the ID of the measure with the title "Sales" by looking up the measures in the measure list.
            theHyperCube.Measures = Enumerable.Empty <NxMeasure>();
            var theMeasureList = theApp.GetMeasureList();
            var measureId      = theMeasureList.Items.First(item => item.Data.Title == "Sales").Info.Id;

            AddLibraryMeasure(theHyperCube, measureId);
            SetHyperCube(theObject, theHyperCube);
            PrintData("Sales per year and month using library measure for sales", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Num));
        }
Exemplo n.º 2
0
        private static IEnumerable <IGenericObject> GetAllChildren(IApp app, IGenericObject obj)
        {
            IEnumerable <IGenericObject> children =
                obj.GetChildInfos().Select(o => app.GetObject <GenericObject>(o.Id)).ToArray();

            return(children.Concat(children.SelectMany(child => GetAllChildren(app, child))));
        }
        private static void ConfigureFormating(IGenericObject theObject)
        {
            var theHyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // List Sales per year (1 Dimension, 1 Measure)
            theHyperCube.Dimensions = Enumerable.Empty <NxDimension>();
            theHyperCube.Measures   = Enumerable.Empty <NxMeasure>();
            AddInlineDimension(theHyperCube, "Year");
            AddInlineDimension(theHyperCube, "Month");
            AddInlineMeasure(theHyperCube, "Sum([Sales Amount])");
            SetHyperCube(theObject, theHyperCube);

            // Use string literal for month by using the Text representation instead of the numeric representation
            // for the month column.
            Console.WriteLine("*** String literal for months");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Num);
            }

            var hyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");
            // Format sales as USD
            var measure = hyperCube.Measures.Single();

            measure.Def.NumFormat = new FieldAttributes {
                Type = FieldAttrType.MONEY, nDec = 2, Dec = ".", UseThou = 1, Thou = ","
            };
            SetHyperCube(theObject, hyperCube);
            Console.WriteLine("*** Use USD as currency");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text);
            }
        }
Exemplo n.º 4
0
        public async Task <List <NxDataPage> > GetListObjectDataAsync(IGenericObject genericObject)
        {
            try
            {
                var request = JObject.FromObject(new
                {
                    qPath  = "/qListObjectDef",
                    qPages = new List <NxPage>
                    {
                        new NxPage()
                        {
                            qTop    = 0,
                            qLeft   = 0,
                            qWidth  = 1,
                            qHeight = 3,
                        }
                    }
                });

                return(await genericObject.GetListObjectDataAsync(request));
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"The method \"{nameof(GetListObjectDataAsync)}\" was failed.");
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method which is called when any Workspace Rule Action is invoked.
        /// </summary>
        /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param>
        public void RuleActionInvoked(string ActionName)
        {
            string fieldVal = "";

            switch (ActionName)
            {
            case "PartsPriceAdj":

                _partsRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject;
                fieldVal     = GetFieldValue("part_price", _partsRecord); //Get value

                SetFieldValue("part_price_adj", fieldVal, _partsRecord);
                break;

            case "LaborRateAdj":
                _laborRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject;
                fieldVal     = GetFieldValue("labor_rate_rqstd", _laborRecord); //Get value

                SetFieldValue("labor_rate_adj", fieldVal, _laborRecord);

                break;

            case "OtherChargesAdj":
                _otherchRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject;
                fieldVal       = GetFieldValue("other_charges_amount", _otherchRecord);//Get value

                SetFieldValue("other_charges_amount_adj", fieldVal, _otherchRecord);

                break;

            default:
                break;
            }
            _recordContext.RefreshWorkspace();//refresh the workspace
        }
        /// <summary>
        /// Get required details to build WebRequest
        /// </summary>
        /// <param name="partNumber"></param>
        /// <param name="partQty"></param>
        /// <param name="incidentRecord"></param>
        /// <param name="partsOrderID"></param>
        public void GetDetails(List <OELINEREC> lineRecords, IGenericObject workOrder, POEHEADERREC partsHeaderRecord,
                               int shipToSiteID)
        {
            _workOrder         = workOrder;
            _lineRecords       = lineRecords;
            _partsHeaderRecord = partsHeaderRecord;

            //If all required info is valid then form jSon request parameter
            var content     = GetReqParam();
            var jsonContent = WebServiceRequest.JsonSerialize(content);

            jsonContent = jsonContent.Replace("xmlns", "@xmlns");

            //Call webservice
            string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");

            if (jsonResponse == "")
            {
                //Destroy the partsorder objects
                _rnConnectService.DestroyPartsOrder(_lineRecords);
                ReportCommandAddIn.form.Hide();
                MessageBox.Show("Server didn't return any info");
            }
            else
            {
                ExtractResponse(jsonResponse, shipToSiteID);
            }
        }
Exemplo n.º 7
0
        private static void Traverse(IGenericObject genericObject, IApp app)
        {
            if (genericObject == null)
            {
                return;
            }

            // Check if the object is an extensions of a master object.
            if (genericObject.Properties.ExtendsObject != null)
            {
                var masterObject = (IMasterObject)genericObject.Properties.ExtendsObject;
                TextHelper.WriteLine(4, "MasterObject version " + masterObject.Properties.MasterVersion);
            }

            // The information to print for each object depends on the type of the object. The TypeSwitch class can be used
            // for this purpose. For extensions of master objects, property values will automatically be retrieved from the
            // master object.
            TypeSwitch.Do(genericObject,
                          TypeSwitch.Case <Table>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Barchart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Linechart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Piechart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Scatterplot>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Treemap>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Gauge>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Combochart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <TextImage>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Listbox>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Filterpane>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Kpi>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Pivottable>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Map>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Default(() => TextHelper.WriteLine(4, "Unknown type: " + genericObject.GetType().FullName))
                          );
        }
Exemplo n.º 8
0
        public int GetMaxId(IGenericObject obj)
        {
            try
            {
                var query = "Select Max(" + obj.GetPrimaryKeyName() + ") as MaxNumber from " + obj.GetTableName();
                _command = new OleDbCommand(query, _connection, _transaction);
                var reader = _command.ExecuteReader();

                if (reader != null && !reader.Read())
                {
                    return(1);
                }
                try
                {
                    if (reader != null)
                    {
                        return(Convert.ToInt32(reader["MaxNumber"]) + 1);
                    }
                }
                catch
                {
                    // ignored
                }
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        private static void BasicSelection(IApp theApp, IGenericObject theObject)
        {
            // Print data for year 2014 only.
            theApp.GetField("Year").Select("2014");
            PrintData("Sales for year 2014 only", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text));

            var salesRepField = theApp.GetField("Sales Rep Name");

            // Print data for year 2014 only, and for sales rep "Amalia Craig" only.
            salesRepField.Select("Amalia Craig");
            PrintData("Sales for year 2014 and sales rep Amalia Craig", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text));

            // Switch to sales rep "Amanda Honda"
            salesRepField.Clear();
            salesRepField.Select("Amanda Honda");
            // Print data for year 2014 only, and for sales rep "Amanda Honda" only.
            PrintData("Sales for all years", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text));

            // Clear selections and print data for all years and sales reps.
            theApp.ClearAll();
            PrintData("Sales for all years", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text));
        }
Exemplo n.º 10
0
        private static void ConfigureSorting(IGenericObject theObject)
        {
            var hyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // List sales per year and month, Sort on Year and Month, both ascending
            {
                var dimensions = hyperCube.Dimensions;
                foreach (var dimension in dimensions)
                {
                    // Sort both dimensions ascending.
                    dimension.Def.SortCriterias = new[] { new SortCriteria {
                                                              SortByNumeric = SortDirection.Ascending
                                                          } };
                }
                SetHyperCube(theObject, hyperCube);
            }
            PrintData("Sales per year and month, sorted", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Text));

            // Sort by month first, then year.
            hyperCube.InterColumnSortOrder = new[] { 1, 0 };
            SetHyperCube(theObject, hyperCube);

            PrintData("Sales per year and month, sorted by month then year", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Text));

            // Revert to sort by year first.
            hyperCube.InterColumnSortOrder = new[] { 0, 1 };
            SetHyperCube(theObject, hyperCube);
        }
Exemplo n.º 11
0
        // Print all data for the hypercube. The argument function is used to print individual rows of data.
        private static void PrintData(string header, IGenericObject theObject, Func <NxCellRows, string> format, string hyperCubePath = "/qHyperCubeDef")
        {
            // Get the data for the hypercube.
            var theData = theObject.GetHyperCubeData(hyperCubePath, new[] { LargePage }).First();

            // Print the page using the format function.
            PrintPage(header, theData, format);
        }
 private static void SetHyperCube(IGenericObject theObject, HyperCubeDef hyperCube)
 {
     using (theObject.SuspendedLayout)
     {
         // A property with the name "qHyperCubeDef" will be interpreted by the engine as being of type HyperCubeDef
         // and evaluated accordingly.
         theObject.Properties.Set("qHyperCubeDef", hyperCube);
     }
 }
        private static void BasicDimensionAndMeasureUsage(IApp theApp, IGenericObject theObject)
        {
            var theHyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // List Sales per year (1 Dimension, 1 Measure)
            AddInlineDimension(theHyperCube, "Year");
            AddInlineMeasure(theHyperCube, "Sum([Sales Amount])");
            SetHyperCube(theObject, theHyperCube);
            // Columns of data appear in the order they appear in the dimension and measure definition lists
            // for the hypercube. Dimensions first, then measures. Column 0 will therefore contain the years,
            // and column 1 will contain the sum of sales.
            Console.WriteLine("*** Sales per year");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Sales: {1}", row[0].Num, row[1].Num);
            }

            // List sales per year and month
            AddInlineDimension(theHyperCube, "Month");
            SetHyperCube(theObject, theHyperCube);
            // Adding a dimension increases the number of columns in the returned data. The new dimension
            // will appear on position 1 (after the year) as AddInlineDimension appends dimensions to the
            // end of the dimension list.
            Console.WriteLine("*** Sales per year and month");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Num);
            }

            // Use predefined library version of the measure.
            // Get the ID of the measure with the title "Sales" by looking up the measures in the measure list.
            theHyperCube.Measures = Enumerable.Empty <NxMeasure>();
            var theMeasureList = theApp.GetMeasureList();
            var measureId      = theMeasureList.Layout.MeasureList.Items.First(item => item.Data.Title == "Sales").Info.Id;

            AddLibraryMeasure(theHyperCube, measureId);
            SetHyperCube(theObject, theHyperCube);
            Console.WriteLine("*** Sales per year and month using library measure for sales");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Num);
            }

            // Use calculated dimension.
            // Calculated dimensions are added just like fields, except that they require a leading '='.
            theHyperCube.Dimensions = Enumerable.Empty <NxDimension>();
            theHyperCube.Measures   = Enumerable.Empty <NxMeasure>();
            AddInlineDimension(theHyperCube, "=Year(TimeStamp)&'-'&Month(TimeStamp)");
            AddInlineDimension(theHyperCube, "YearMonth");
            AddInlineMeasure(theHyperCube, "Sum([Sales Amount])");
            SetHyperCube(theObject, theHyperCube);
            Console.WriteLine("*** Sales per year and Month (calculated dimension)");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("=Year(TimeStamp)&'-'&Month(TimeStamp): {0}, YearMonth: {1}, Sales: {2}", row[0].Text, row[1].Text, row[2].Num);
            }
        }
Exemplo n.º 14
0
 public async Task ClearSelectionsAsync(IGenericObject genericObject)
 {
     try
     {
         await genericObject.ClearSelectionsAsync("/qListObjectDef");
     }
     catch (Exception ex)
     {
         logger.Error(ex, $"The method \"{nameof(ClearSelectionsAsync)}\" was failed.");
     }
 }
        /// <summary>
        ///
        /// </summary>
        public void Execute(IList <IReportRow> rows)
        {
            _selectedRows   = rows;
            _recordContext  = _globalContext.AutomationContext.CurrentWorkspace;
            _workOrder      = (IGenericObject)_recordContext.GetWorkspaceRecord("TOA$Work_Order");
            _workOrderExtra = (IGenericObject)_recordContext.GetWorkspaceRecord("TOA$Work_Order_Extra");

            System.Threading.Thread th = new System.Threading.Thread(ProcessSelectedRowInfo);
            th.Start();
            form.Show();
        }
Exemplo n.º 16
0
        public void Execute(IList <IReportRow> rows)
        {
            _selectedRows   = rows;
            _recordContext  = _globalContext.AutomationContext.CurrentWorkspace;
            _incidentRecord = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident;
            _incidentExtra  = _recordContext.GetWorkspaceRecord("CO$Incident_Extra") as IGenericObject;

            System.Threading.Thread th = new System.Threading.Thread(ProcessSelectedRowInfo);
            th.Start();
            form.Show();
        }
Exemplo n.º 17
0
 /// <summary>
 /// Method called by data load event. It does the following:
 /// 1> Get Onload FSAR value
 /// 2> Get all affected VIN mapped to currently opened FSAR
 /// </summary>
 private void _recordContext_DataLoaded(object sender, System.EventArgs e)
 {
     _affectedBusId = new List <string>();
     _fsarRecord    = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$FSAR");
     if (_fsarRecord != null)
     {
         string[] response = RightNowConnectService.GetService().GetAffectedBus(_fsarRecord.Id);
         if (response != null)
         {
             _affectedBusId = response.ToList();
         }
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Method which is called when any Workspace Rule Action is invoked.
        /// </summary>
        /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param>
        public void RuleActionInvoked(string ActionName)
        {
            switch (ActionName)
            {
            case "Send_SupplierCredit":
                _incidentRecord = _recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident) as IIncident;
                _sClaimRecord   = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$sClaim");

                _form.Show();    //start progress form
                SendSupplierCredit();
                break;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Method which is called when any Workspace Rule Action is invoked.
        /// </summary>
        /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param>
        public void RuleActionInvoked(string ActionName)
        {
            if (ActionName == "selectVIN")
            {
                _fsarRecord = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$FSAR");

                //Get the List of Unique Model Names from Sales Release CO
                string[] modelList = RightNowConnectService.GetService().GetModel();


                SalesReleaseVINSelection form = new SalesReleaseVINSelection(modelList, _recordContext, _fsarRecord.Id, _affectedBusId);
                form.ShowDialog();
            }
        }
Exemplo n.º 20
0
        private static void PrintGroupedData(string header, IGenericObject theObject)
        {
            var hyperCubeLayout = theObject.GetLayout().Get <HyperCube>("qHyperCube");
            // The hypercube has only a single dimension. Which dimension is active depends on the state
            // of the hypercube.
            var dimensionInfo = hyperCubeLayout.DimensionInfo.Single();
            var template      = dimensionInfo.FallbackTitle + ": {0}, Sales: {1}";
            var isYear        = dimensionInfo.GroupPos == 0;

            // If the current group position is 0, then the dimension represents a year, if it is 1, then it
            // represents a month. Use Num property of cell for Year and Text for month.
            PrintData(header, theObject,
                      row => String.Format(template, isYear ? (object)row[0].Num : row[0].Text, row[1].Text));
        }
Exemplo n.º 21
0
 public List <IGenericObject> GetAllObjects(IGenericObject obj)
 {
     try
     {
         var query = "SELECT * FROM " + obj.GetTableName();
         _command = new OleDbCommand(query, _connection, _transaction);
         var reader = _command.ExecuteReader();
         return(obj.GetList(reader));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Method which is called when any Workspace Rule Action is invoked.
        /// </summary>
        /// <param name="ActionName">The name of the Workspace Rule Action that was invoked.</param>
        public void RuleActionInvoked(string ActionName)
        {
            string[] pResults;
            Decimal  calc = 0;
            Decimal  dAmt = 0;
            string   amt  = "";

            try
            {
                _sClaimRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject;
                string sClaim = _sClaimRecord.Id.ToString();

                pResults = _rnConnectService.getCredits(sClaim);


                List <string> creds = new List <string>();


                switch (ActionName)
                {
                case "Recovered":


                    if (pResults != null && pResults.Length > 0)
                    {
                        creds = pResults.ToList();

                        foreach (string c in creds)
                        {
                            amt  = c.Split('~')[0];
                            dAmt = Convert.ToDecimal(amt);

                            calc = calc + dAmt;
                        }
                        calc = Math.Round(calc, 2);
                    }
                    break;

                default:
                    break;
                }


                SetFieldValue("recovered_amount", calc.ToString());
                _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save);
            }
            catch (Exception e)
            { MessageBox.Show("error in recovered calculation"); }
        }
        private static void ConfigureSorting(IGenericObject theObject)
        {
            var hyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // List sales per year and month, Sort on Year and Month, both ascending
            {
                var dimensions = hyperCube.Dimensions;
                foreach (var dimension in dimensions)
                {
                    // Sort both dimensions ascending.
                    dimension.Def.SortCriterias = new[] { new SortCriteria {
                                                              SortByNumeric = SortDirection.Ascending
                                                          } };
                }
                SetHyperCube(theObject, hyperCube);
            }
            Console.WriteLine("*** Sales per year and month, sorted");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text);
            }

            // Sort by month first, then year, then sales.
            hyperCube.InterColumnSortOrder = new[] { 1, 0, 2 };
            SetHyperCube(theObject, hyperCube);

            Console.WriteLine("*** Sales per year and month, sorted by month then year");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Text);
            }

            // Sort by sales (descending), then year, then month.
            hyperCube.InterColumnSortOrder = new[] { 2, 0, 1 };
            hyperCube.Measures.First().SortBy = new SortCriteria {
                SortByNumeric = SortDirection.Descending
            };
            SetHyperCube(theObject, hyperCube);

            Console.WriteLine("*** Sales per year and month, sorted by sales (descending)");
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Num, row[2].Text);
            }

            // Revert to sort by year first.
            hyperCube.InterColumnSortOrder = new[] { 0, 1, 2 };
            SetHyperCube(theObject, hyperCube);
        }
Exemplo n.º 24
0
        public IGenericObject GetObjectByCondition(IGenericObject obj)
        {
            try
            {
                var query = "SELECT * FROM " + obj.GetTableName() + " WHERE " + obj.GetCondition();
                _command = new OleDbCommand(query, _connection, _transaction);
                var reader = _command.ExecuteReader();

                return(obj.GetObject(reader));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 25
0
 public void RuleActionInvoked(string ActionName)
 {
     if (ActionName == "CrearActividad")
     {
         SWorkOrder = recordContext.GetWorkspaceRecord("TOA$Work_Order") as IGenericObject;
         if (Init())
         {
             if (SWorkOrder != null)
             {
                 recordContext.ExecuteEditorCommand(EditorCommand.Save);
                 WorkOrderId = SWorkOrder.Id.ToString();
                 ObtenerInfoWorkOrder(WorkOrderId);
                 CrearActividad();
                 recordContext.ExecuteEditorCommand(EditorCommand.Save);
             }
             else
             {
                 MessageBox.Show("El objeto es Nulo");
             }
         }
         else
         {
             MessageBox.Show("No hay Init");
         }
     }
     if (ActionName == "PopularContacto")
     {
         recordContext.ExecuteEditorCommand(EditorCommand.Save);
         PopulateContactDetails();
     }
     if (ActionName == "ValidaFecha")
     {
         _workOrderRecord = recordContext.GetWorkspaceRecord(recordContext.WorkspaceTypeName) as ICustomObject;
         IList <IGenericField> fields = _workOrderRecord.GenericFields;
         foreach (IGenericField field in fields)
         {
             if (field.Name == "WO_Date")
             {
                 DateTime WDate = Convert.ToDateTime(field.DataValue.Value);
                 if (WDate.Date < DateTime.Now.Date)
                 {
                     MessageBox.Show("La fecha de la cita no puede ser menor al día de hoy");
                     field.DataValue.Value = DateTime.Now.Date;
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Method which is use to set sClaim field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value of field</param>
        public void SetSclaimField(string fieldName, string value)
        {
            IGenericObject sClaim = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$sClaim");

            foreach (IGenericField genfield in sClaim.GenericFields)
            {
                if (genfield.Name == fieldName)
                {
                    switch (genfield.DataType)
                    {
                    case RightNow.AddIns.Common.DataTypeEnum.BOOLEAN:
                        if (value == "1" || value.ToLower() == "true")
                        {
                            genfield.DataValue.Value = true;
                        }
                        else if (value == "0" || value.ToLower() == "false")
                        {
                            genfield.DataValue.Value = false;
                        }
                        break;

                    case RightNow.AddIns.Common.DataTypeEnum.INTEGER:
                        if (value.Trim() == "" || value.Trim() == null)
                        {
                            genfield.DataValue.Value = null;
                        }
                        else
                        {
                            genfield.DataValue.Value = Convert.ToInt32(value);
                        }
                        break;

                    case RightNow.AddIns.Common.DataTypeEnum.STRING:
                        if (value.Trim() == "" || value.Trim() == null)
                        {
                            genfield.DataValue.Value = null;
                        }
                        else
                        {
                            genfield.DataValue.Value = value;
                        }
                        break;
                    }
                    break;
                }
            }
            return;
        }
        private static void GroupedDimensions(IApp theApp, IGenericObject theObject)
        {
            var hyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");

            // Make YearMonth, Year and Month stacked dimensions
            hyperCube.Dimensions = Enumerable.Empty <NxDimension>();
            AddInlineDimension(hyperCube, "Year");
            var dimension = hyperCube.Dimensions.ToArray()[0];

            dimension.Def.FieldDefs = dimension.Def.FieldDefs.Concat(new[] { "Month" });
            // The Grouping property indicates that the Dimension is stacked.
            dimension.Def.Grouping      = NxGrpType.GRP_NX_HIEARCHY;
            dimension.Def.SortCriterias = new[]
            {
                new SortCriteria {
                    SortByNumeric = SortDirection.Ascending
                },
                new SortCriteria {
                    SortByNumeric = SortDirection.Ascending
                }
            };
            SetHyperCube(theObject, hyperCube);

            // Prints sales per Year
            PrintGroupedData("Stacked, Sales per Year", theObject);
            // When selecting a single field of the top dimension of the stack, the hypercube
            // will use the next dimension of the stack instead.
            theApp.GetField("Year").Select("2016");
            // Prints sales per month for the selected year.
            PrintGroupedData("Stacked, Sales per Month for selected Year 2016", theObject);

            // Clear year selection.
            theApp.ClearAll();
            // Set group mode to cyclic and add dimension YearMonth
            dimension.Def.Grouping  = NxGrpType.GRP_NX_COLLECTION;
            dimension.Def.FieldDefs = dimension.Def.FieldDefs.Concat(new[] { "YearMonth" });
            SetHyperCube(theObject, hyperCube);
            // Print data for Year
            PrintGroupedData("Cyclic, Sales per Year (group 0)", theObject);
            // Print data for Month
            dimension.Def.ActiveField = 1;
            SetHyperCube(theObject, hyperCube);
            PrintGroupedData("Cyclic, Sales per Month (group 1)", theObject);
            // Print data for YearMonth
            dimension.Def.ActiveField = 2;
            SetHyperCube(theObject, hyperCube);
            PrintGroupedData("Cyclic, Sales per YearMonth (group 2)", theObject);
        }
Exemplo n.º 28
0
        private static void Traverse(IGenericObject genericObject, IApp app)
        {
            if (genericObject == null)
            {
                return;
            }

            // Check if the object is an extensions of a master object.
            if (genericObject.Properties.ExtendsObject != null)
            {
                var masterObject = (IMasterObject)genericObject.Properties.ExtendsObject;
                TextHelper.WriteLine(4, "MasterObject version " + masterObject.Properties.MasterVersion);
            }

            switch (genericObject)
            {
            case Table o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Barchart o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Linechart o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Piechart o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Scatterplot o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Treemap o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Gauge o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Combochart o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case TextImage o: TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app); break;

            case Listbox o: TextHelper.Print(o.GetType().Name, o.Title); break;

            case Filterpane o: TextHelper.Print(o.GetType().Name, o.Title); break;

            case Kpi o: TextHelper.Print(o.GetType().Name, o.Title); break;

            case Pivottable o: TextHelper.Print(o.GetType().Name, o.Title); break;

            case Map o: TextHelper.Print(o.GetType().Name, o.Title); break;

            default: TextHelper.WriteLine(4, "Unknown type: " + genericObject.GetType().FullName); break;
            }
        }
        private static void PrintGroupedData(string header, IGenericObject theObject)
        {
            var hyperCubeLayout = theObject.GetLayout().Get <HyperCube>("qHyperCube");
            // The hypercube has only a single dimension. Which dimension is active depends on the state
            // of the hypercube.
            var dimensionInfo = hyperCubeLayout.DimensionInfo.Single();
            var template      = dimensionInfo.FallbackTitle + ": {0}, Sales: {1}";
            var isYear        = dimensionInfo.GroupPos == 0;

            // If the current group position is 0, then the dimension represents a year, if it is 1, then it
            // represents a month. Use Num property of cell for Year and Text for month.
            Console.WriteLine(header);
            foreach (var row in GetAllRows(theObject.GetHyperCubePager("/qHyperCubeDef")))
            {
                Console.WriteLine(template, isYear ? row[0].Num.ToString() : row[0].Text, row[1].Text);
            }
        }
Exemplo n.º 30
0
        private static void ConfigureFormating(IGenericObject theObject)
        {
            // Use string literal for month by using the Text representation instead of the numeric representation
            // for the month column.
            PrintData("String literal for months", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Num));

            var hyperCube = theObject.Properties.Get <HyperCubeDef>("qHyperCubeDef");
            // Format sales as USD
            var measure = hyperCube.Measures.Single();

            measure.Def.NumFormat = new FieldAttributes {
                Type = FieldAttrType.MONEY, nDec = 2, Dec = ".", UseThou = 1, Thou = ","
            };
            SetHyperCube(theObject, hyperCube);
            PrintData("Use USD as currency", theObject,
                      row => String.Format("Year: {0}, Month: {1}, Sales: {2}", row[0].Num, row[1].Text, row[2].Text));
        }