예제 #1
0
파일: Logger.cs 프로젝트: valkiara/SB1Util
        /// <summary>
        /// Retorna as informações das DLL's SB1Util e Model
        /// </summary>
        public void prepare()
        {
            try
            {
                prepared            = true;
                this.user           = DBFacade.getInstance().Connection.Company.UserName;
                this.companyVersion = "" + DBFacade.getInstance().Connection.Company.Version;

                Assembly AssLib = Assembly.LoadFrom("SB1Util.dll");
                Assembly AssMod = Assembly.LoadFrom("Model.dll");

                FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo("SB1Util.dll");
                this.libVersion = versionInfo.FileVersion;// AssLib.GetName().Version.ToString();

                versionInfo       = FileVersionInfo.GetVersionInfo("Model.dll");
                this.addonVersion = versionInfo.FileVersion;// AssMod.GetName().Version.ToString();

                System.Attribute attr = System.Attribute.GetCustomAttribute(AssMod, typeof(ModelName));
                this.addonName = ((ModelName)attr).Name;
            }catch (Exception e)
            {
                //B1Connection.getInstance().App.SetStatusBarMessage("Erro ao Iniciar Log: " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Long);
                SB1ControlException.SB1ControlException.Save(e);
            }
        }
예제 #2
0
        public override long loadFromDB(string key, UserObjectFactory oFactory)
        {
            long ret = 0;

            try
            {
                DBFacade db = DBFacade.getInstance();

                //busca os estagios
                Recordset rs = db.Query(
                    "SELECT APST.Code " +
                    "FROM [@SB1_APPROVAL] APRV " +
                    "INNER JOIN [@SB1_APPROVAL_STAGE] APST " +
                    "ON APRV.Code = APST.U_ApprovalCode " +
                    "WHERE APRV.Code = " + key
                    );
                while (!rs.EoF)
                {
                    ApprovalStage aps = new ApprovalStage();
                    aps.loadFromDB((string)rs.Fields.Item("Code").Value, oFactory);
                    stages.AddLast(new LinkedListNode <ApprovalStage>(aps));
                    rs.MoveNext();
                }


                //busca as condicoes
                rs = db.Query(
                    "SELECT APCD.Code " +
                    "FROM [@SB1_APPROVAL] APRV " +
                    "INNER JOIN [@SB1_APPROVAL_CONDITION] APCD " +
                    "ON APRV.Code = APCD.U_ApprovalCode " +
                    "WHERE APRV.Code =  " + key
                    );
                while (!rs.EoF)
                {
                    ApprovalCondition ac = new ApprovalCondition();
                    ac.loadFromDB((string)rs.Fields.Item("Code").Value, oFactory);
                    conditions.AddLast(new LinkedListNode <ApprovalCondition>(ac));
                    rs.MoveNext();
                }

                long r = base.loadFromDB(key, oFactory);
                isActive = (string)userTable.UserFields.Fields.Item("U_isActive").Value;
            }
            catch (Exception e)
            {
                ret = -1;
            }

            return(ret);
        }
예제 #3
0
 protected Controller()
 {
     this.oConnection  = B1Connection.getInstance();
     this.oDBFacade    = DBFacade.getInstance();
     this.uiUtils      = new UIUtils(oConnection.Company, oConnection.App);
     this.modeMonitors = new LinkedList <FormMode>();
     this.properties   = Properties.getInstance();
     this.log          = Logger.getInstance();
     log.setProperties(properties);
     log.setUiUtils(uiUtils);
     initAddon();
     log.prepare();
     log.log("Addon iniciado", Logger.LogType.INFO, null, false);
 }
예제 #4
0
파일: Logger.cs 프로젝트: valkiara/SB1Util
        /// <summary>
        /// Salva o log em banco de dados. Caso ocorra falha, o log será gerado no diretório raiz, dentro do diretório LogSystem
        /// </summary>
        /// <param name="text">A mensagem da exceção</param>
        /// <param name="type">O tipo de exceção</param>
        private void printText(string text, LogType type)
        {
            DateTime   dt            = DateTime.Now;
            LoggerData LoggerDataObj = null;
            string     Time          = String.Format("{0:HH:mm:ss}", dt);

            try
            {
                LoggerDataObj = new LoggerData();
                string form = "";
                if (DBFacade.getInstance().Connection.App.Forms.ActiveForm != null)
                {
                    try
                    {
                        form = DBFacade.getInstance().Connection.App.Forms.ActiveForm.TypeEx;
                    }
                    catch (Exception e)
                    {
                        form = "";
                    }
                }


                UserTable table = DBFacade.getInstance().getUserTable("SB1_ADDON_LOG");
                table.Code = "" + (dt.Ticks + 1);
                table.Name = "" + (dt.Ticks + 1);

                //Ajusta valores nos campos pois pode ocorrer exception caso esteja NULL
                addonVersion   = addonVersion == null ? "" : addonVersion;
                addonName      = addonName == null ? "" : addonName;
                companyVersion = companyVersion == null ? "" : companyVersion;
                libVersion     = libVersion == null ? "" : libVersion;
                type           = type == null ? LogType.INFO : type;
                text           = text == null ? "" : text;

                table.UserFields.Fields.Item("U_AddonVersion").Value   = addonVersion;
                table.UserFields.Fields.Item("U_AddonName").Value      = addonName;
                table.UserFields.Fields.Item("U_CompanyVersion").Value = companyVersion;
                table.UserFields.Fields.Item("U_Date").Value           = dt;
                table.UserFields.Fields.Item("U_LibVersion").Value     = libVersion;
                table.UserFields.Fields.Item("U_LogType").Value        = type.ToString();
                table.UserFields.Fields.Item("U_Text").Value           = text;
                table.UserFields.Fields.Item("U_Time").Value           = Time;
                table.UserFields.Fields.Item("U_User").Value           = user;
                table.UserFields.Fields.Item("U_FormID").Value         = form;
                table.UserFields.Fields.Item("U_XMLException").Value   = "";
                table.UserFields.Fields.Item("U_Operation").Value      = (opStack.Count == 0 ? "" : opStack.Peek());

                table.Add();
                table = null;

                LoggerDataObj.U_AddonVersion   = addonVersion;
                LoggerDataObj.U_CompanyVersion = companyVersion;
                LoggerDataObj.U_Date           = dt;
                LoggerDataObj.U_LibVersion     = libVersion;
                LoggerDataObj.U_LogType        = type.ToString();
                LoggerDataObj.U_Text           = text;
                LoggerDataObj.U_Time           = Time;
                LoggerDataObj.U_User           = user;
            }
            catch (Exception e)
            {
                LogManager.SaveLoggerData(LoggerDataObj);
                SB1ControlException.SB1ControlException.Save(e);
                //B1Connection.getInstance().App.SetStatusBarMessage("Erro ao escrever Log: " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Long);
            }
        }
예제 #5
0
 public AlertMessage()
 {
     this.logger   = Logger.getInstance();
     this.dbFacade = DBFacade.getInstance();
 }
예제 #6
0
파일: B1C.cs 프로젝트: valkiara/SB1Util
 public B1C()
 {
     this.connection = B1Connection.getInstance();
     this.dbFacade   = DBFacade.getInstance();
     this.uiUtils    = new UIUtils(connection);
 }
예제 #7
0
 public ApprovalProcedures()
 {
     this.oDBFacade = DBFacade.getInstance();
 }
예제 #8
0
 public SAPObject()
 {
     this.logger    = Logger.getInstance();
     this.oDBFacade = DBFacade.getInstance();
 }
예제 #9
0
 public JournalEntryOp()
 {
     this.logger     = Logger.getInstance();
     this.dbFacade   = DBFacade.getInstance();
     this.connection = B1Connection.getInstance();
 }