Exemple #1
0
        //------------------------------------------------------------
        // CSResources.FormatErrorMessage (2)
        //
        /// <summary>
        /// <para>Get the format string by id, create an error message with args and locations</para>
        /// </summary>
        /// <param name="excp"></param>
        /// <param name="errorNo"></param>
        /// <param name="strID"></param>
        /// <param name="errorKind"></param>
        /// <param name="fileName"></param>
        /// <param name="line"></param>
        /// <param name="col"></param>
        /// <param name="lineEnd"></param>
        /// <param name="colEnd"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        static internal string FormatErrorMessage(
            out Exception excp,
            ERRORKIND errorKind,
            string prefix,
            int errorNo,
            ResNo resNo,
            string fileName,
            int line,
            int col,
            int lineEnd,
            int colEnd,
            params Object[] args)
        {
            string message = null;

            if (!ErrorUtil.FormatErrorMessage(out message, out excp, resNo, args) &&
                String.IsNullOrEmpty(message))
            {
                // If failed to format, concatenate args to create a message.
                if (args.Length > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < args.Length; ++i)
                    {
                        string str = args[i].ToString();
                        if (!String.IsNullOrEmpty(str))
                        {
                            if (sb.Length > 0)
                            {
                                sb.Append(", ");
                            }
                            sb.Append(str);
                        }
                    }
                    if (sb.Length > 0)
                    {
                        message = sb.ToString();
                    }
                }
                if (String.IsNullOrEmpty(message))
                {
                    message = "Unknown error.";
                }
            }

            return(FormatStringUtil.FormatErrorMessageCore(
                       fileName,
                       line,
                       col,
                       lineEnd,
                       colEnd,
                       errorKind,
                       prefix,
                       errorNo,
                       message));
        }
Exemple #2
0
        private void CancButton_Click(object sender, EventArgs e)
        {
            if (IsCubicleOnEdit)
            {
                ResetButton.Visible = false;
                SaveButton.Visible  = false;
                CancButton.Visible  = false;
                IsCubicleOnEdit     = false;


                //ArrowKeys used to resize the cubicle
                UPArrow.Visible    = false;
                LeftArrow.Visible  = false;
                resetSize.Visible  = false;
                RightArrow.Visible = false;
                DownArrow.Visible  = false;

                for (int i = 0; i < 6; i++)
                {
                    l[i].Visible = false;
                    l[i].Dispose();
                }

                C_Name.Dispose();
                CubNo.Dispose();
                EmpName.Dispose();
                EmpSno.Dispose();
                C_State.Dispose();
                Other.Dispose();

                S = -1;
            }
            else if (IsResourceOnEdit)
            {
                IsResourceOnEdit    = false;
                ResetButton.Visible = false;
                SaveButton.Visible  = false;
                CancButton.Visible  = false;

                for (int i = 0; i < 7; i++)
                {
                    l[i].Visible = false;
                    l[i].Dispose();
                }

                AssEmpNo.Dispose();
                AssCubNo.Dispose();
                ResNo.Dispose();
                ResType.Dispose();
                ResState.Dispose();
                DateOfIssue.Dispose();
                OtherInfo.Dispose();

                P = -1;
            }
        }
Exemple #3
0
 //------------------------------------------------------------
 // BCErrorInfoManager.ERRORINFO Constructor
 //
 /// <summary></summary>
 /// <param name="errID"></param>
 /// <param name="errNo"></param>
 /// <param name="warnLevel"></param>
 /// <param name="resID"></param>
 /// <param name="argCount"></param>
 //------------------------------------------------------------
 internal ERRORINFO(
     ERRID errID,
     int errNo,
     int warnLevel,
     ResNo resNo)
 {
     this.ErrorID        = errID;
     this.ErrorNumber    = errNo;
     this.WarningLevel   = warnLevel;
     this.ResourceNumber = resNo;
 }
Exemple #4
0
        //------------------------------------------------------------
        // BCErrorInfoManager.GetResourceNumber (1)
        //
        /// <summary>
        /// <para>Return the resource ID for a given CSCERRID.</para>
        /// </summary>
        /// <param name="errID"></param>
        /// <param name="resNo"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal bool GetResourceNumber(
            ERRID errID,
            out ResNo resNo)
        {
            ERRORINFO info = GetInfo(errID);

            if (info != null)
            {
                resNo = info.ResourceNumber;
                return(true);
            }

            resNo = ResNo.Invalid;
            return(false);
        }
Exemple #5
0
        //------------------------------------------------------------
        // BCErrorInfoManager.FormatErrorMessage (2)
        //
        /// <summary>
        /// <para>Get the format string by id,
        /// create an error message with args and locations</para>
        /// </summary>
        /// <param name="excp"></param>
        /// <param name="errID"></param>
        /// <param name="errKind"></param>
        /// <param name="fileName"></param>
        /// <param name="lineStart"></param>
        /// <param name="colStart"></param>
        /// <param name="lineEnd"></param>
        /// <param name="colEnd"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal string FormatErrorMessage(
            out Exception excp,
            ERRID errID,
            ERRORKIND errKind,
            string fileName,
            int lineStart,
            int colStart,
            int lineEnd,
            int colEnd,
            params Object[] args)
        {
            int   errorNo = -1;
            ResNo resNo   = ResNo.Invalid;

            ERRORINFO eInfo = GetInfo(errID);

            if (eInfo != null)
            {
                errorNo = eInfo.ErrorNumber;
                resNo   = eInfo.ResourceNumber;
                if (!ErrorUtil.IsValidErrorKind(errKind))
                {
                    errKind = ErrorUtil.GetErrorKind(eInfo.WarningLevel);
                }
            }
            else
            {
                resNo = ResNo.CSCSTR_InternalError;
                args  = new Object[] { "invalid error ID in CSResources.FormatErrorMessage" };
            }

            return(ErrorUtil.FormatErrorMessage(
                       out excp,
                       errKind,
                       this.Prefix,
                       errorNo,
                       resNo,
                       fileName,
                       lineStart,
                       colStart,
                       lineEnd,
                       colEnd,
                       args));
        }
Exemple #6
0
        //------------------------------------------------------------
        // CController.ShowMessage (3)
        //
        /// <summary></summary>
        /// <param name="msg"></param>
        //------------------------------------------------------------
        internal void ShowMessage(ResNo resNo, params Object[] args)
        {
            string    fmt   = null;
            int       count = 0;
            Exception excp  = null;

            if (CResources.GetString(resNo, out fmt, out count, out excp))
            {
                FormatStringUtil.FillupArguments(ref args, count);
                WriteLine(fmt, args);
            }
            else
            {
                if (excp != null)
                {
                    WriteLine(excp.Message);
                }
                else
                {
                    WriteLine("Unknow error in ShowMessage");
                }
            }
        }
Exemple #7
0
        //------------------------------------------------------------
        // ErrorUtil.FormatErrorMessage (1)
        //
        /// <summary>
        /// <para>Get the format string by id, create an error message with args</para>
        /// </summary>
        /// <param name="formatted"></param>
        /// <param name="excp"></param>
        /// <param name="strID"></param>
        /// <param name="args"></param>
        /// <returns>Return false if failed to make an error message.</returns>
        //------------------------------------------------------------
        static internal bool FormatErrorMessage(
            out string formatted,
            out Exception excp,
            ResNo resNo,
            params Object[] args)
        {
            formatted = null;
            int    argCount = 0;
            string format   = null;

            excp = null;

            if (CResources.GetString(resNo, out format, out argCount, out excp))
            {
                return(FormatStringUtil.FormatString(
                           out formatted,
                           out excp,
                           format,
                           argCount,
                           args));
            }
            return(false);
        }
Exemple #8
0
        //------------------------------------------------------------
        // ConsoleOutput.PrintString (1)
        //
        /// <summary>
        /// Load a string from a resource and print it, followed by an optional newline.
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="newline"></param>
        /// <param name="prettyprint"></param>
        /// <remarks>
        /// ALink's PrintHelp() function will just iterate through a range of ids,
        /// and only print the ones which exist.
        /// Thus, the string may not exist for ALink, but it should for CSC.
        /// </remarks>
        //------------------------------------------------------------
        internal void PrintString(
            ResNo resNo,
            bool newLine,       // = true,
            bool prettyPrint)   // = false
        {
            string    buffer;
            Exception excp = null;

            if (!CResources.GetString(resNo, out buffer, out excp))
            {
                return;
            }

            if (prettyPrint)
            {
                //DebugUtil.Assert(newline);
                PrettyPrint(buffer, 0);
            }
            else
            {
                PrintInternal(buffer, newLine);
            }
        }
Exemple #9
0
        private void ClearMyAccessPanel()
        {
            IsResourceOnEdit    = false;
            ResetButton.Visible = false;
            SaveButton.Visible  = false;
            CancButton.Visible  = false;

            for (int i = 0; i < 7; i++)
            {
                l[i].Visible = false;
                l[i].Dispose();
            }

            AssEmpNo.Dispose();
            AssCubNo.Dispose();
            ResNo.Dispose();
            ResType.Dispose();
            ResState.Dispose();
            DateOfIssue.Dispose();
            OtherInfo.Dispose();

            P = -1;
        }