Exemple #1
0
        public ActivityPlan(int topicId, ref System.Array inputStrings, ref string validationString)
        {
            // Set to new request
            this.Updated = false;
            //

            string[] requestStrings = inputStrings.Cast <string>().ToArray();

            // add empty string values to fill out array (let SAP do validation)
            if (requestStrings.Length < m_totalNumberOfParameters)
            {
                List <string> ls = new List <string>(requestStrings);
                while (ls.Count < 15)
                {
                    ls.Add(String.Empty);
                }
                requestStrings = ls.ToArray();
            }


            this.TopicID = topicId;
            this.Hash    = inputStrings.Concatenate();
            //this.FunctionType               =  FunctionType.;

            this.FunctionType          = (PlanningFunctionType)Enum.Parse(typeof(PlanningFunctionType), requestStrings[0]);
            this.m_quantity            = requestStrings[1].ToUpper();             // [TOT_VALUE][ACTVTY_QTY]
            this.m_price               = requestStrings[2].ToUpper();             // [TOT_VALUE][PRICE_FIX]
            this.m_controllingArea     = requestStrings[3].ToUpper();             // [HEADER_INFO][CO_AREA]
            this.m_fiscalYear          = requestStrings[4].ToUpper();             // [HEADER_INFO][FISC_YEAR]
            this.m_perFrom             = requestStrings[5].ToUpper();             // [HEADER_INFO][PERIOD_FROM]
            this.m_perTo               = requestStrings[6].ToUpper();             // [HEADER_INFO][PERIOD_TO]
            this.m_distKey             = requestStrings[7].ToUpper();             // [TOT_VALUE][DIST_KEY_PRICE_FIX]
            this.m_version             = requestStrings[8].ToUpper();             // [HEADER_INFO][VERSION]
            this.m_documentTxt         = requestStrings[9].ToUpper();             // [HEADER_INFO][DOC_HDR_TX]
            this.m_currencyType        = requestStrings[10].ToUpper();            // [HEADER_INFO][PLAN_CURRTYPE]
            this.m_delta               = requestStrings[11].ToUpper();            // [DELTA][DELTA]
            this.m_costCenter          = requestStrings[12].ToUpper();            // [OBJECT][COSTCENTER]
            this.m_activityType        = requestStrings[13].ToUpper();            // [OBJECT][ACTTYPE]
            this.m_transactionCurrency = requestStrings[14].ToUpper();            // [TOT_VALUE][CURRENCY]

            this.Signature = requestStrings[requestStrings.Length - 1].ToUpper();

            IPlanningFunction thisFunc = (IPlanningFunction)this;

            MatManErrorDictionary.GetObject().ValidatePlanningFunction(ref thisFunc, ref validationString);
        }
Exemple #2
0
        public CostPlan(int topicId, ref System.Array inputStrings, ref string validationString)
        {
            // Set to new request
            this.Updated = false;
            //

            string[] requestStrings = inputStrings.Cast <string>().ToArray();

            // add empty string values to fill out array (let SAP do validation)
            if (requestStrings.Length < m_totalNumberOfParameters)
            {
                List <string> ls = new List <string>(requestStrings);
                while (ls.Count < m_totalNumberOfParameters)
                {
                    ls.Add(String.Empty);
                }
                requestStrings = ls.ToArray();
            }


            this.TopicID      = topicId;
            this.Hash         = inputStrings.Concatenate();
            this.FunctionType = PlanningFunctionType.CostPlan;

            this.m_fixedInputValue    = requestStrings[1].ToUpper();               // [TOTVALUE][FIX_VALUE]
            this.m_controllingArea    = requestStrings[2].ToUpper();               // [HEADERINFO][CO_AREA]
            this.m_fiscalYear         = requestStrings[3].ToUpper();               // [HEADERINFO][FISC_YEAR]
            this.m_periodFrom         = requestStrings[4].ToUpper();               // [HEADERINFO][PERIOD_FROM]
            this.m_periodTo           = requestStrings[5].ToUpper();               // [HEADERINFO][PERIOD_TO]
            this.m_distributionKey    = requestStrings[6].ToUpper();               // [TOTVALUE][DIST_KEY_FIX_VAL]
            this.m_version            = requestStrings[7].ToUpper();               // [HEADERINFO][VERSION]
            this.m_documentHeaderText = requestStrings[8].ToUpper();               // [HEADERINFO][DOC_HDR_TXT]
            this.m_planningCurrency   = requestStrings[9].ToUpper();               // [HEADERINFO][PLAN_CURRTYPE]
            this.m_delta               = requestStrings[10].ToUpper();             // [DELTA][DELTA]
            this.m_costCenter          = requestStrings[11].ToUpper();             // [COOBJECT][COSTCENTER]
            this.m_costElement         = requestStrings[12].ToUpper();             // [TOTVALUE][COST_ELEM]
            this.m_activityType        = requestStrings[13].ToUpper();             // [COOBJECT][ACTTYPE]
            this.m_orderID             = requestStrings[14].ToUpper();             // [COOBJECT][ORDERID]
            this.m_wbsElement          = requestStrings[15].ToUpper();             // [COOBJECT][WBS_ELEMENT]
            this.m_functionalArea      = requestStrings[16].ToUpper();             // [TOTVALUE][FUNCTION]
            this.m_fund                = requestStrings[17].ToUpper();             // [TOTVALUE][FUND]
            this.m_grant               = requestStrings[18].ToUpper();             // [TOTVALUE][GRANT_NBR]
            this.m_transactionCurrency = requestStrings[19].ToUpper();             // [TOTVALUE][TRANS_CURR]

            this.Signature = requestStrings[requestStrings.Length - 1].ToUpper();

            if (this.m_functionalArea != string.Empty)
            {
                this.m_functionalArea = this.m_functionalArea.TrimStart('0');
                this.m_functionalArea = "000" + this.m_functionalArea;
            }

            if (this.m_wbsElement != string.Empty)
            {
                this.m_wbsElement = this.m_wbsElement.TrimStart(' ');
                if (this.m_wbsElement.ToUpper().StartsWith("WBS"))
                {
                    this.m_wbsElement = this.m_wbsElement.Remove(0, 3);
                }
                this.m_wbsElement = this.m_wbsElement.TrimStart(' ');
            }

            IPlanningFunction thisFunc = (IPlanningFunction)this;

            MatManErrorDictionary.GetObject().ValidatePlanningFunction(ref thisFunc, ref validationString);
        }
Exemple #3
0
        public void ValidatePlanningFunction(ref IPlanningFunction _function, ref string validationResponse)
        {
            switch (_function.FunctionType)
            {
                #region CostPlan
            case PlanningFunctionType.CostPlan:
            {
                CostPlan costPlanFunction = (CostPlan)_function;

                try
                {
                    #region Check Period From, Period To Check
                    /// Check Period from greater than period to
                    int pFromInt = Convert.ToInt32(costPlanFunction.PeriodFrom);
                    int pToInt   = Convert.ToInt32(costPlanFunction.PeriodTo);
                    int diff     = pToInt - pFromInt;

                    if (diff < 0)
                    {
                        throw new Exception("Period From must be less than Period To");
                    }
                    else if (pFromInt < 1 || pFromInt > 12 || pToInt < 1 || pToInt > 12)
                    {
                        throw new Exception("Period From and Period To must be a numeric value between 1 and 12");
                    }
                    #endregion

                    #region Check Trial Version Restriction
                    //                        /// Check trial version restriction
                    //					    string productName = Excel4apps.Connector_SAP.Product.GetProductName(Excel4apps.Connector_SAP.Product.Code.PlanningWand);
                    //                        if (Excel4apps.Connector_SAP.Product.GetProductLicenseType(productName) == Excel4apps.Connector_SAP.Product.LicenseType.Trial)
                    //                        {
                    //	                        if ((pToInt < 1 || pToInt > 3) || (pFromInt < 1 || pFromInt > 3))
                    //                            {
                    //		                        throw new Exception("Trial version may only post from periods 1 to 3, please reduce difference between From and To periods");
                    //	                        }
                    //                        }
                    #endregion

                    #region Check Delta
                    /// Check Delta is empty or X
                    if (costPlanFunction.Delta != " " && costPlanFunction.Delta != "X")
                    {
                        costPlanFunction.Delta = " ";
                    }
                    #endregion

                    #region Check Fiscal Year is Numeric
                    //// Check Fiscal Year is Numeric
                    try
                    {
                        costPlanFunction.FiscalYear = costPlanFunction.FiscalYear.TrimStart(new char[] { '0', ' ' });
                        int.Parse(costPlanFunction.FiscalYear);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Fiscal Year must be a valid numeric year");
                    }
                    #endregion

                    #region Check Planning Currency Type
                    try
                    {
                        if (costPlanFunction.PlanningCurrency.ToUpper() != "C" && costPlanFunction.PlanningCurrency.ToUpper() != "O" && costPlanFunction.PlanningCurrency.ToUpper() != "T")
                        {
                            throw new Exception("Planning Currency must be C, O or T");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Check Fixed Input is Numeric

                    try
                    {
                        Decimal.Parse(costPlanFunction.FixedInputValue);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Fixed Value must be a numeric");
                    }

                    #endregion
                }
                catch (Exception e)
                {
                    costPlanFunction.ValidationResult = "mmError (" + e.Message + ")";
                    validationResponse = "mmError (" + e.Message + ")";
                }
            }
            break;
                #endregion


                #region ActivityPlan
            case PlanningFunctionType.ActivityPlan:
            {
                ActivityPlan activityPlanFunction = (ActivityPlan)_function;

                try
                {
                    #region Check Period From, Period To Check
                    /// Check Period from greater than period to
                    int pFromInt = Convert.ToInt32(activityPlanFunction.PeriodFrom);
                    int pToInt   = Convert.ToInt32(activityPlanFunction.PeriodTo);
                    int diff     = pToInt - pFromInt;

                    if (diff < 0)
                    {
                        throw new Exception("Period From must be less than Period To");
                    }
                    else if (pFromInt < 1 || pFromInt > 12 || pToInt < 1 || pToInt > 12)
                    {
                        throw new Exception("Period From and Period To must be a numeric value between 1 and 12");
                    }
                    #endregion

                    #region Check Trial Version Restriction
                    //                        /// Check trial version restriction
                    //					    string productName = Excel4apps.Connector_SAP.Product.GetProductName(Excel4apps.Connector_SAP.Product.Code.PlanningWand);
                    //                        if (Excel4apps.Connector_SAP.Product.GetProductLicenseType(productName) == Excel4apps.Connector_SAP.Product.LicenseType.Trial)
                    //                        {
                    //	                        if ((pToInt < 1 || pToInt > 3) || (pFromInt < 1 || pFromInt > 3))
                    //                            {
                    //		                        throw new Exception("Trial version may only post from periods 1 to 3, please reduce difference between From and To periods");
                    //	                        }
                    //                        }
                    #endregion

                    #region Check Delta
                    /// Check Delta is empty or X
                    if (activityPlanFunction.Delta != " " && activityPlanFunction.Delta != "X")
                    {
                        activityPlanFunction.Delta = " ";
                    }
                    #endregion

                    #region Check Fiscal Year is Numeric
                    //// Check Fiscal Year is Numeric
                    try
                    {
                        activityPlanFunction.FiscalYear = activityPlanFunction.FiscalYear.TrimStart(new char[] { '0', ' ' });
                        int.Parse(activityPlanFunction.FiscalYear);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Fiscal Year must be a valid numeric year");
                    }
                    #endregion

                    #region Check Planning Currency Type
                    try
                    {
                        if (activityPlanFunction.PlanningCurrency.ToUpper() != "C" && activityPlanFunction.PlanningCurrency.ToUpper() != "O" && activityPlanFunction.PlanningCurrency.ToUpper() != "T")
                        {
                            throw new Exception("Planning Currency must be C, O or T");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion
                }
                catch (Exception e)
                {
                    activityPlanFunction.ValidationResult = "mmError (" + e.Message + ")";
                    validationResponse = "mmError (" + e.Message + ")";
                }
            }
            break;
                #endregion

            default:
                break;
            }
        }