Ejemplo n.º 1
0
        public int SaveNewLabselectList(int testid, DataTable theDTselectList, int UserID)
        {
            try
            {
                int theRowAffected = 0;
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject LabManager = new ClsObject();
                LabManager.Connection  = this.Connection;
                LabManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@testID", SqlDbType.Int, testid.ToString());

                theRowAffected = (Int32)LabManager.ReturnObject(ClsUtility.theParams, "pr_Admin_deleteLabTestselectList_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                if (theRowAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in delete Lab Result record. Try Again..";
                    AppException.Create("#C1", theBL);
                }


                for (int i = 0; i < theDTselectList.Rows.Count; i++)
                {
                    ClsUtility.Init_Hashtable();
                    ClsUtility.AddParameters("@LabName", SqlDbType.VarChar, theDTselectList.Rows[i]["selectlist"].ToString());
                    ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());
                    ClsUtility.AddParameters("@testID", SqlDbType.Int, testid.ToString());

                    theRowAffected = (Int32)LabManager.ReturnObject(ClsUtility.theParams, "pr_Admin_AddLabTestselectList_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                    if (theRowAffected == 0)
                    {
                        MsgBuilder theBL = new MsgBuilder();
                        theBL.DataElements["MessageText"] = "Error in Saving Lab record. Try Again..";
                        AppException.Create("#C1", theBL);
                    }
                }
                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(theRowAffected);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
 public ExceptionResponse Map(Exception exception)
 {
     return(exception switch
     {
         DomainException ex => new ExceptionResponse(new { code = ex.Code, reason = ex.Message },
                                                     HttpStatusCode.BadRequest),
         AppException ex => new ExceptionResponse(new { code = ex.Code, reason = ex.Message },
                                                  HttpStatusCode.BadRequest),
         _ => new ExceptionResponse(new { code = "error", reason = "We obtained a problem, try again later." },
                                    HttpStatusCode.BadRequest)
     });
Ejemplo n.º 3
0
        /// <summary>
        /// 查询总的图书藏书与可借书信息
        /// </summary>
        /// <param name="conn">IDbConnection数据库连接对象</param>
        /// <returns>总的图书藏书与可借书信息</returns>
        public List <DisplayInfo> QuerySumISLoan(IDbConnection conn)
        {
            // 用来显示
            List <DisplayInfo> displayInfolist = new List <DisplayInfo>();

            // 统计数量查询语句
            string sqlforbookitem = "select OrderNum, BookID, ISLoan from BookItem";

            try
            {
                // 统计数量
                using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlforbookitem, null))
                {
                    if (result.HasRows)
                    {
                        // 统计数量
                        List <BookItem> booknum = new List <BookItem>();
                        while (result.Read())
                        {
                            BookItem tempBookItem = new BookItem();

                            // 条形码
                            if (!result.IsDBNull(0))
                            {
                                tempBookItem.OrderNum = result.GetGuid(0);
                            }

                            // 图书ID
                            if (!result.IsDBNull(1))
                            {
                                tempBookItem.BookID = result.GetGuid(1);
                            }

                            // 图书是否可借
                            if (!result.IsDBNull(2))
                            {
                                tempBookItem.ISLoan = result.GetInt32(2);
                            }

                            booknum.Add(tempBookItem);
                        }

                        displayInfolist = this.GetRepeat(booknum);
                    }
                }
            }
            catch (Exception exp)
            {
                AppException appexp = new AppException("查询总的图书藏书与可借书信息", exp, ExceptionLevel.Error);
                LogManager.Log.WriteException(appexp);
            }

            return(displayInfolist);
        }
Ejemplo n.º 4
0
        public int SaveExposedInfant(int Id, int Ptn_Pk, int ExposedInfantId, string FirstName, string LastName, DateTime DOB, string FeedingPractice3mos,
                                     string CTX2mos, string HIVTestType, string HIVResult, string FinalStatus, DateTime?DeathDate, int UserID)
        {
            int       theRowAffected = 0;
            ClsObject VisitManager   = new ClsObject();

            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                VisitManager.Connection  = this.Connection;
                VisitManager.Transaction = this.Transaction;
                ClsUtility.Init_Hashtable();

                ClsUtility.AddParameters("@Id", SqlDbType.Int, Id.ToString());
                ClsUtility.AddParameters("@Ptn_Pk", SqlDbType.Int, Ptn_Pk.ToString());
                ClsUtility.AddParameters("@ExposedInfantId", SqlDbType.Int, ExposedInfantId.ToString());
                ClsUtility.AddParameters("@FirstName", SqlDbType.VarChar, FirstName.ToString());
                ClsUtility.AddParameters("@LastName", SqlDbType.VarChar, LastName.ToString());
                ClsUtility.AddParameters("@DOB", SqlDbType.DateTime, DOB.ToString());
                ClsUtility.AddParameters("@FeedingPractice3mos", SqlDbType.VarChar, FeedingPractice3mos.ToString());
                ClsUtility.AddParameters("@CTX2mos", SqlDbType.VarChar, CTX2mos.ToString());
                ClsUtility.AddParameters("@HIVResult", SqlDbType.VarChar, HIVResult.ToString());
                ClsUtility.AddParameters("@HIVTestType", SqlDbType.VarChar, HIVTestType.ToString());
                ClsUtility.AddParameters("@FinalStatus", SqlDbType.VarChar, FinalStatus.ToString());
                ClsUtility.AddParameters("@UserID", SqlDbType.VarChar, UserID.ToString());
                if (DeathDate != null)
                {
                    ClsUtility.AddParameters("@DeathDate", SqlDbType.VarChar, DeathDate == null ? null : DeathDate.ToString());
                }
                theRowAffected = (int)VisitManager.ReturnObject(ClsUtility.theParams, "pr_Clinical_SaveExposedInfant", ClsUtility.ObjectEnum.ExecuteNonQuery);
                if (theRowAffected == 0)
                {
                    MsgBuilder theMsg = new MsgBuilder();
                    theMsg.DataElements["MessageText"] = "Error in Saving Custom Field. Try Again..";
                    AppException.Create("#C1", theMsg);
                }
            }
            catch
            {
                DataMgr.RollBackTransation(this.Transaction);
                throw;
            }
            finally
            {
                VisitManager = null;
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
            return(theRowAffected);
        }
Ejemplo n.º 5
0
        public async Task <string> ScheduleCallAsync([FromBody] ScheduleCallDTO callInfo)
        {
            try
            {
                if (callInfo == null)
                {
                    return("NotFound");
                }

                //Widget wgt = context.Widgets.Find(Guid.Parse(callInfo.token));
                //wgt.User = context.Users.Find(wgt.UserID);

                Widget wgt = await context.Widgets.Include(widget => widget.User)
                             .Where(widget => widget.ID == Guid.Parse(callInfo.token))
                             .FirstOrDefaultAsync();

                if (wgt == null)
                {
                    return("NotFound");
                }

                CallbackSchedule schedule = new CallbackSchedule();
                schedule.widget          = wgt;
                schedule.LeadName        = callInfo.name;
                schedule.LeadEmail       = callInfo.email;
                schedule.LeadMessage     = callInfo.message ?? "";
                schedule.LeadPhoneNumber = callInfo.phone;

                schedule.CallDone = false;
                schedule.EmailNotificationDone = false;

                schedule.ScheduledDateTime = ParseDateTime(callInfo.date, callInfo.time);
                context.CallbackSchedules.Add(schedule);
                await context.SaveChangesAsync();

                try
                {
                    EmailManager.SendCallNotificationEmail(wgt.DomainURL, wgt.NotificationEmail, wgt.User.Name, schedule.LeadName, schedule.LeadEmail, schedule.LeadPhoneNumber, schedule.ScheduledDateTime.ToString(), schedule.LeadMessage);
                }catch (Exception) { }

                return("OK: Call request sent");
            }catch (Exception ex)
            {
                AppException exception = new AppException();
                exception.ErrorDateTime = DateTime.Now;
                exception.Message       = ex.Message;
                exception.FullString    = ex.ToString();
                context.AppExceptions.Add(exception);
                await context.SaveChangesAsync();

                return("Error");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Bulids the app exception global log.
        /// </summary>
        /// <param name="trackId">The track id.</param>
        /// <param name="appex">The appex.</param>
        /// <returns>GlobalLog.</returns>
        public GlobalLog BulidAppExceptionGlobalLog(TrackID trackId, AppException appex)
        {
            GlobalLog log = new GlobalLog()
            {
                CurrentTrackID = trackId,
                AppException = appex,
                LogType = LogType.AppExceptionLog,
                TimePoint = DateTime.Now,
            };

            return log;
        }
Ejemplo n.º 7
0
        private async void HandleFunctionError(string functionToCall, AppException ex)
        {
            string message = "It looks like your backend is not set up correctly. " +
                             $"Did the \"{functionToCall}\" function get " +
                             $"created? See the 'Set up the Task Tracker " +
                             $"Tutorial Backend' steps in the tutorial." +
                             $"\r\n\r\n{ex.Message}";

            await DisplayAlert("Error", message, "OK");

            LogFunctionError();
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            try
            {
                HttpConfiguration = new HttpConfiguration();

                GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Re‌​ferenceLoopHandling = ReferenceLoopHandling.Ignore;

                ConfigureOAuth(app);

                app.UseCors(CorsOptions.AllowAll);

                //HttpConfiguration.EnableCors();

                //AreaRegistration.RegisterAllAreas();
                AppConfiguration.RegisterApi(HttpConfiguration);
                app.UseWebApi(HttpConfiguration);

                HttpConfiguration.MessageHandlers.Add(new ApiKeyHandler());
                HttpConfiguration.Filters.Add(new CustomExceptionFilter());

                //app.MapSignalR("/websocket", new HubConfiguration());
                var idProvider = new CustomUserProvider();

                IoC.InitializeWith(new DependencyResolverFactory());

                GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => idProvider);

                app.Map("/websocket", map =>
                {
                    // Setup the CORS middleware to run before SignalR.
                    // By default this will allow all origins. You can
                    // configure the set of origins and/or http verbs by
                    // providing a cors options with a different policy.
                    map.UseCors(CorsOptions.AllowAll);

                    var hubConfiguration = new HubConfiguration
                    {
                        // You can enable JSONP by uncommenting line below.
                        // JSONP requests are insecure but some older browsers (and some
                        // versions of IE) require JSONP to work cross domain
                        // EnableJSONP = true
                    };

                    map.RunSignalR(hubConfiguration);
                });
            }
            catch (Exception ex)
            {
                var exception = new AppException(ex.ToString(), ex.InnerException);
                logger.Error(exception.FullDetail);
            }
        }
Ejemplo n.º 9
0
        //public int SaveNewLabType(string LabTypeName, int UserID)
        //{
        //    try
        //    {
        //        this.Connection = DataMgr.GetConnection();
        //        this.Transaction = DataMgr.BeginTransaction(this.Connection);

        //        ClsObject LabManager = new ClsObject();
        //        LabManager.Connection = this.Connection;
        //        LabManager.Transaction = this.Transaction;

        //        ClsUtility.Init_Hashtable();
        //        ClsUtility.AddParameters("@LabTypeName", SqlDbType.VarChar, LabTypeName);
        //        ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());

        //        DataRow theDR;
        //        int RowsAffected = (Int32)LabManager.ReturnObject(ClsUtility.theParams, "pr_Admin_AddLabtype_Constella", ClsDBUtility.ObjectEnum.ExecuteNonQuery);
        //        if (RowsAffected == 0)
        //        {
        //            MsgBuilder theBL = new MsgBuilder();
        //            theBL.DataElements["MessageText"] = "Error in Saving Lab type record. Try Again..";
        //            AppException.Create("#C1", theBL);
        //        }


        //        DataMgr.CommitTransaction(this.Transaction);
        //        DataMgr.ReleaseConnection(this.Connection);
        //        return Convert.ToInt32(RowsAffected);
        //    }
        //    catch
        //    {
        //        throw;
        //    }
        //    finally
        //    {
        //        if (this.Connection != null)
        //            DataMgr.ReleaseConnection(this.Connection);
        //    }
        //}
        //public int UpdateLabType(int LabTypeID, string LabTypeName, int UserID)
        //{
        //    try
        //    {
        //        this.Connection = DataMgr.GetConnection();
        //        this.Transaction = DataMgr.BeginTransaction(this.Connection);

        //        ClsObject LabManager = new ClsObject();
        //        LabManager.Connection = this.Connection;
        //        LabManager.Transaction = this.Transaction;

        //        ClsUtility.Init_Hashtable();
        //        ClsUtility.AddParameters("@LabTypeName", SqlDbType.VarChar, LabTypeName);
        //        ClsUtility.AddParameters("@LabTypeID", SqlDbType.Int, LabTypeID.ToString());
        //        ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());

        //        DataRow theDR;
        //        int RowsAffected = (Int32)LabManager.ReturnObject(ClsUtility.theParams, "Pr_Admin_UpdateLabType_Constella", ClsDBUtility.ObjectEnum.ExecuteNonQuery);
        //        if (RowsAffected == 0)
        //        {
        //            MsgBuilder theBL = new MsgBuilder();
        //            theBL.DataElements["MessageText"] = "Error in Saving Lab type record. Try Again..";
        //            AppException.Create("#C1", theBL);
        //        }


        //        DataMgr.CommitTransaction(this.Transaction);
        //        DataMgr.ReleaseConnection(this.Connection);
        //        return Convert.ToInt32(RowsAffected);
        //    }
        //    catch
        //    {
        //        throw;
        //    }
        //    finally
        //    {
        //        if (this.Connection != null)
        //            DataMgr.ReleaseConnection(this.Connection);
        //    }
        //}


        public DataTable UpdateLab(int LabID, string LabName, int LabDepartmentID, int LabTypeID, int UserID, int DeleteFlag, string DataType, decimal MaxBoundary, decimal MinBoundary, int LabValueId, int Sequence, int UnitId)
        {
            try
            {
                DataTable theAffectedDT;
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject LabManager = new ClsObject();
                LabManager.Connection  = this.Connection;
                LabManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@LabName", SqlDbType.VarChar, LabName);
                ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());
                ClsUtility.AddParameters("@LabDepartmentId", SqlDbType.Int, LabDepartmentID.ToString());
                ClsUtility.AddParameters("@LabTypeId", SqlDbType.Int, LabTypeID.ToString());
                ClsUtility.AddParameters("@LabTestId", SqlDbType.Int, LabID.ToString());
                ClsUtility.AddParameters("@DeleteFlag", SqlDbType.Int, DeleteFlag.ToString());
                ClsUtility.AddParameters("@DataType", SqlDbType.NVarChar, DataType.ToString());
                ClsUtility.AddParameters("@MaxBoundary", SqlDbType.Decimal, MaxBoundary.ToString());
                ClsUtility.AddParameters("@MinBoundary", SqlDbType.Decimal, MinBoundary.ToString());
                ClsUtility.AddParameters("@LabValueId", SqlDbType.Int, LabValueId.ToString());

                ClsUtility.AddParameters("@Sequence", SqlDbType.Int, Sequence.ToString());
                ClsUtility.AddParameters("@UnitId", SqlDbType.Int, UnitId.ToString());
                //DataRow theDR;
                theAffectedDT = (DataTable)LabManager.ReturnObject(ClsUtility.theParams, "Pr_Admin_UpdateLabTest_Constella", ClsDBUtility.ObjectEnum.DataTable);
                if (theAffectedDT.Rows[0][0].ToString() == "-1")
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Lab test record. Try Again..";
                    AppException.Create("#C1", theBL);
                }


                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(theAffectedDT);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 10
0
        public int SaveUpdateSatellite(String ID, String SatelliteID, String SatelliteName, String status, int priority, int Flag, int UserID, String Createdate)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject SatelliteMgr = new ClsObject();
                SatelliteMgr.Connection  = this.Connection;
                SatelliteMgr.Transaction = this.Transaction;

                oUtility.Init_Hashtable();

                oUtility.AddParameters("@SatelliteID", SqlDbType.VarChar, SatelliteID);
                oUtility.AddParameters("@SatelliteName", SqlDbType.VarChar, SatelliteName);
                oUtility.AddParameters("@DeleteFlag", SqlDbType.Int, status.ToString());
                oUtility.AddParameters("@SRNo", SqlDbType.Int, priority.ToString());
                oUtility.AddParameters("@UserID", SqlDbType.Int, UserID.ToString());
                int RowsAffected = 0;
                if (Flag == 0)
                {
                    RowsAffected = (Int32)SatelliteMgr.ReturnObject(oUtility.theParams, "pr_Admin_SaveSatellite_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                }
                else if (Flag == 1)
                {
                    oUtility.AddParameters("@ID", SqlDbType.Int, ID.ToString());
                    RowsAffected = (Int32)SatelliteMgr.ReturnObject(oUtility.theParams, "pr_Admin_UpdateSatellite_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                }
                /*********/
                if (RowsAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Reason record. Try Again..";
                    AppException.Create("#C1", theBL);
                }

                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(Convert.ToInt32(RowsAffected));
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            try
            {
            }
            catch (Exception ex)
            {
                var exception = new AppException(ex.ToString(), ex.InnerException);
                logger.Error(exception.FullDetail);
            }
        }
Ejemplo n.º 12
0
 public override void Handle(ExceptionHandlerContext context)
 {
     try
     {
         context.Exception.Handle();
     }
     catch (AppException)
     {
         AppException ex = (context.Exception as AppException) ?? new AppException(context.Exception.Message);
         context.Result = new TextPlainErrorResult(Request: context.ExceptionContext.Request, Content: ex.ExceptionData, HttpStatusCode: ex.HttpStatus);
     }
     base.Handle(context);
 }
Ejemplo n.º 13
0
        public static BadRequestObjectResult BadRequest(AppException ex)
        {
            var result = new List <ErrorObjectResult>
            {
                new ErrorObjectResult("Business", ex.Message)
            };

            return(new BadRequestObjectResult(new
            {
                Errors = result,
                Success = false
            }));
        }
        public int CreateAppException(Exception e)
        {
            var appException = new AppException
            {
                Message         = e.Message,
                StackTrace      = e.StackTrace,
                ExceptionString = e.ToString(),
                WhenCreated     = DateTime.UtcNow
            };

            context.AppException.Add(appException);
            context.SaveChanges();
            return(appException.AppExceptionID);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 获取全部图书信息
        /// </summary>
        /// <param name="conn">数据库连接</param>
        /// <returns>图书信息</returns>
        public List <Bookinfo> GetAllBookInfo(IDbConnection conn)
        {
            // 图书信息查询语句
            string          sqlforbookinfo = "select Top(100) BookID, Title, Decrible from BookInfo";
            List <Bookinfo> bookinfoList   = new List <Bookinfo>();

            try
            {
                using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlforbookinfo, null))
                {
                    if (result.HasRows)
                    {
                        while (result.Read())
                        {
                            Bookinfo bookinfo = new Bookinfo();

                            // 图书名
                            if (!result.IsDBNull(0))
                            {
                                bookinfo.BookID = result.GetGuid(0);
                            }

                            // 图书名
                            if (!result.IsDBNull(1))
                            {
                                bookinfo.Title = result.GetString(1);
                            }

                            // 图书描述
                            if (!result.IsDBNull(2))
                            {
                                bookinfo.Decrible = result.GetString(2);
                            }

                            bookinfoList.Add(bookinfo);
                        }
                    }

                    result.Close();
                }
            }
            catch (Exception exp)
            {
                AppException appexp = new AppException("获取全部图书信息", exp, ExceptionLevel.Error);
                LogManager.Log.WriteException(appexp);
            }

            return(bookinfoList);
        }
Ejemplo n.º 16
0
        public override void OnException(HttpActionExecutedContext context)
        {
            AppException hbiEx = null;

            if (context.Exception is AppException)
            {
                hbiEx = context.Exception as AppException;
            }
            else
            {
                hbiEx = new AppException(Unhandled_Error, context.Exception);
            }
            Logger.Error(hbiEx.InnerException != null ? hbiEx.InnerException.ToString() : hbiEx.ToString());
            context.Response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, hbiEx.Errors);
        }
Ejemplo n.º 17
0
 protected void ShowError(AppException ex, string title)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         MessageBoxResult result = T360ViewUtlity.Handle(CultureManager.Instance, ex, title);
         if (result == MessageBoxResult.OK || result == MessageBoxResult.None)
         {
             SetFocus();
         }
         if (T360ErrorCodes.AppSessionExpired.Equals(ex.ErrorCodes[0].Code))
         {
             RedirectToLogin();
         }
     });
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 立即缴纳并归还图书
        /// </summary>
        /// <param name="orderNum">条形码</param>
        /// <param name="fine">罚款</param>
        /// <returns>是否成功</returns>
        private bool ReturnBookPay(Guid orderNum, decimal fine)
        {
            bool issuccess = false;

            // 写入罚款
            if (this.loanInfoAccess.WritePaied(orderNum, fine, this.Transaction) == 1)
            {
                // 是否罚款置1
                if (this.loanInfoAccess.PayMoneyByguid(orderNum, this.Transaction) == 1)
                {
                    // 写入还书日期
                    if (this.loanInfoAccess.ReturnBook(orderNum, this.Transaction) == 1)
                    {
                        // 图书入库
                        if (this.bookItemAccess.ReturnBook(orderNum, this.Transaction))
                        {
                            issuccess = true;
                        }
                        else
                        {
                            AppException appexp = new AppException("图书入库失败,还书失败", ExceptionLevel.Info);
                            issuccess = false;
                            throw appexp;
                        }
                    }
                    else
                    {
                        AppException appexp = new AppException("图书入库失败,还书失败", ExceptionLevel.Info);
                        issuccess = false;
                        throw appexp;
                    }
                }
                else
                {
                    AppException appexp = new AppException("还书失败", ExceptionLevel.Info);
                    issuccess = false;
                    throw appexp;
                }
            }
            else
            {
                AppException appexp = new AppException("还书失败", ExceptionLevel.Info);
                issuccess = false;
                throw appexp;
            }

            return(issuccess);
        }
Ejemplo n.º 19
0
        public static void SendActivationEmail(Cxt cxt, string userName)
        {
            User user = User.GetUser(cxt, userName);

            if (user.IsNew)
            {
                AppException.Throw("Msg.UserNameNotExists(userName)");
            }

            MailVerifyResult result = EmailTemplate.Send(cxt, EmailTemplateE.NewAccount, user);

            if (result == MailVerifyResult.Ok)
            {
                AppException.Throw("Msg.ActivationEmailOk(userName)");
            }
        }
Ejemplo n.º 20
0
        public int SaveUpdateRegimenGeneric(string RegimenName, string RegimenCode, int RegimenID, string Stage, int Status, string GenericID, int UserID, int SRNo, int flag)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject DrugManager = new ClsObject();
                DrugManager.Connection  = this.Connection;
                DrugManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@RegimenName", SqlDbType.VarChar, RegimenName);
                ClsUtility.AddParameters("@RegimenCode", SqlDbType.VarChar, RegimenCode);
                ClsUtility.AddParameters("@Rid", SqlDbType.Int, RegimenID.ToString());
                ClsUtility.AddParameters("@Stage", SqlDbType.VarChar, Stage);
                ClsUtility.AddParameters("@Status", SqlDbType.Int, Status.ToString());
                ClsUtility.AddParameters("@GenericID", SqlDbType.VarChar, GenericID);
                ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());
                ClsUtility.AddParameters("@SRNo", SqlDbType.Int, SRNo.ToString());
                ClsUtility.AddParameters("@flag", SqlDbType.Int, flag.ToString());

                Int32 RowsAffected = (Int32)DrugManager.ReturnObject(ClsUtility.theParams, "pr_Admin_SaveRegimenGeneric_Constella", ClsDBUtility.ObjectEnum.ExecuteNonQuery);
                if (RowsAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Regimen Generic Combinations. Try Again..";
                    Exception ex = AppException.Create("#C1", theBL);
                    throw ex;
                }
                DrugManager = null;
                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(RowsAffected);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
        public async Task <IActionResult> Login([FromBody] VmLoginRequest LoginRequest)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User user = await _userService.ValidateUserToLogin(LoginRequest.UserName, LoginRequest.Password);

                    List <Claim> authClaims = new()
                    {
                        new Claim(ClaimTypes.Name, user.Username),
                        new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()),
                        new Claim(ClaimTypes.Role, user.Role.ToString()),
                    };

                    SymmetricSecurityKey authSigningKey = new(Encoding.UTF8.GetBytes(_config.JWTConfig.Secret));

                    JwtSecurityToken token = new(
                        issuer : _config.JWTConfig.ValidIssuer,
                        audience : _config.JWTConfig.ValidAudience,
                        expires : DateTime.Now.AddHours(_config.JWTConfig.Expires),
                        claims : authClaims,
                        signingCredentials : new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
                        );

                    string JWTToken = new JwtSecurityTokenHandler().WriteToken(token);

                    return(Ok(DataMessage.Data(new VmLoginResponse()
                    {
                        Token = JWTToken
                    })));
                }
                catch (AppException ex)
                {
                    return(BadRequest(ex.ReturnBadRequest()));
                }
                catch (Exception ex)
                {
                    return(BadRequest(AppException.ReturnBadRequest(ex.Message)));
                }
            }
            else
            {
                return(BadRequest(AppException.ReturnBadRequest(ModelState)));
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 模糊查询图书数
        /// </summary>
        /// <param name="bookname">查询关键字</param>
        /// <param name="conn">IDbConnection(数据库连接对象)</param>
        /// <returns>获得满足筛选条件的图书信息</returns>
        public List <Bookinfo> QueryBookByName(string bookname, IDbConnection conn)
        {
            string          sqlText      = "select top(100) BookID, Title, Decrible from BookInfo  WHERE Title LIKE '%" + bookname + "%'";
            List <Bookinfo> bookinfolist = new List <Bookinfo>();

            try
            {
                using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlText, null))
                {
                    if (result.HasRows)
                    {
                        while (result.Read())
                        {
                            Bookinfo stbookinfo = new Bookinfo();

                            // 图书ID
                            if (!result.IsDBNull(0))
                            {
                                stbookinfo.BookID = result.GetGuid(0);
                            }

                            // 图书名字
                            if (!result.IsDBNull(1))
                            {
                                stbookinfo.Title = result.GetString(1).Trim();
                            }

                            // 图书描述
                            if (!result.IsDBNull(2))
                            {
                                stbookinfo.Decrible = result.GetString(2).Trim();
                            }

                            bookinfolist.Add(stbookinfo);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                AppException appexp = new AppException("模糊查询图书数", exp, ExceptionLevel.Error);
                LogManager.Log.WriteException(appexp);
            }

            return(bookinfolist);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 查询显示用户信息
        /// </summary>
        /// <param name="coll">传入参数</param>
        /// <returns>视图</returns>
        public ActionResult LibrayMgr(FormCollection coll)
        {
            this.trackID = TrackIdManager.GetInstance("shaoyu");
            List <DisplayInfo> displayInfolist = new List <DisplayInfo>();
            List <Bookinfo>    bookinfoList    = new List <Bookinfo>();

            try
            {
                // 初始信息
                if (coll.Count == 0)
                {
                    QueryAllBook queryAllBook = new QueryAllBook();
                    displayInfolist = queryAllBook.GetAllBookInfo();
                }
                else if (coll.Count > 0)
                {
                    // 查询信息
                    if (Request.IsAjaxRequest())
                    {
                        string     bookname   = coll["bookname"] != null ? coll["bookname"].Trim() : string.Empty;
                        DisplayMgr displayMgr = new DisplayMgr();

                        // 模糊查询
                        displayInfolist = displayMgr.QueryByName(bookname);
                        return(this.PartialView("BookList", displayInfolist));
                    }
                }
            }
            catch (AppException appexp)
            {
                return(this.View("Shared/Error", appexp.ToString()));
            }
            catch (Exception exp)
            {
                AppException appexp = new AppException(" 查询显示用户信息 ", exp, ExceptionLevel.Error);
                LogManager.Log.WriteException(appexp);
                return(this.View("Shared/Error", exp.ToString()));
            }
            finally
            {
                LogManager.Log.WriteUiAcc("shaoyu", "UserInfo", "shaoyu", "127.0.0.1", string.Empty, string.Empty, "查询显示用户信息", null);
            }

            return(this.View(displayInfolist));
        }
Ejemplo n.º 24
0
        public int UpdateOccupation(int OccupationID, string OccupationName, int UserID, int DeleteFlag, int Sequence)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject OccupationManager = new ClsObject();
                OccupationManager.Connection  = this.Connection;
                OccupationManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@OccupationName", SqlDbType.VarChar, OccupationName);
                ClsUtility.AddParameters("@OccupationID", SqlDbType.Int, OccupationID.ToString());
                ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());
                ClsUtility.AddParameters("@DeleteFlag", SqlDbType.Int, DeleteFlag.ToString());
                ClsUtility.AddParameters("@Sequence", SqlDbType.Int, Sequence.ToString());



                int RowsAffected = (Int32)OccupationManager.ReturnObject(ClsUtility.theParams, "Pr_Admin_UpdateOccupation_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                if (RowsAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Occupation record. Try Again..";
                    AppException.Create("#C1", theBL);
                }


                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(RowsAffected);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 25
0
        public int SaveNewReason(string ReasonName, int CategoryID, int SRNo, int UserID)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject ReasonManager = new ClsObject();
                ReasonManager.Connection  = this.Connection;
                ReasonManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@ReasonName", SqlDbType.VarChar, ReasonName);
                ClsUtility.AddParameters("@CategoryID", SqlDbType.Int, CategoryID.ToString());
                ClsUtility.AddParameters("@SRNo", SqlDbType.Int, SRNo.ToString());
                ClsUtility.AddParameters("@UserId", SqlDbType.Int, UserID.ToString());
//              ClsUtility.AddParameters("@DeleteFlag", SqlDbType.Int, DeleteFlag.ToString());


                // DataRow theDR;
                int RowsAffected = (Int32)ReasonManager.ReturnObject(ClsUtility.theParams, "Pr_Admin_InsertReason_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                if (RowsAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Reason record. Try Again..";
                    AppException.Create("#C1", theBL);
                }


                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(Convert.ToInt32(RowsAffected));
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 26
0
        public ErrorList BadRequest(AppException appException, HttpRequest request)
        {
            var error = new Error
            {
                Id             = Guid.NewGuid(),
                Status         = HttpStatus.BadRequest,
                Code           = HttpStatus.BadRequest.ToString(),
                Title          = "Bad Request",
                Detail         = appException.Message,
                InnerException = appException,
                HttpRequest    = request.ToHttpRequestMeta()
            };

            _context.Errors.Add(error);
            _context.SaveChanges();

            return(error.ToErrorList());
        }
Ejemplo n.º 27
0
        public DataTable SaveLabUnitLinks(int ID, int SubTestID, decimal MinBoundaryValue, decimal MaxBoundaryValue, int UnitID, int DefaultUnit, int Undetectable)
        {
            try
            {
                DataTable theAffectedDT;
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject LabManager = new ClsObject();
                LabManager.Connection  = this.Connection;
                LabManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@ID", SqlDbType.Int, ID.ToString());
                ClsUtility.AddParameters("@SubTestID", SqlDbType.Int, SubTestID.ToString());
                ClsUtility.AddParameters("@MinBoundaryValue", SqlDbType.Decimal, MinBoundaryValue.ToString());
                ClsUtility.AddParameters("@MaxBoundaryValue", SqlDbType.Decimal, MaxBoundaryValue.ToString());
                ClsUtility.AddParameters("@UnitID", SqlDbType.Int, UnitID.ToString());
                ClsUtility.AddParameters("@DefaultUnit", SqlDbType.Int, DefaultUnit.ToString());
                ClsUtility.AddParameters("@Undetectable", SqlDbType.Int, Undetectable.ToString());
                DataRow theDR;
                theAffectedDT = (DataTable)LabManager.ReturnObject(ClsUtility.theParams, "pr_Admin_SaveLabUnitLinks_Constella", ClsDBUtility.ObjectEnum.DataTable);
                if (theAffectedDT.Rows[0][0].ToString() == "-1")
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Lab record. Try Again..";
                    AppException.Create("#C1", theBL);
                }
                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(theAffectedDT);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 28
0
        public int SaveNewEducation(int UserID, string EducationName, int Sequence)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject EducationManager = new ClsObject();
                EducationManager.Connection  = this.Connection;
                EducationManager.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();

                ClsUtility.AddParameters("@UserID", SqlDbType.Int, UserID.ToString());
                ClsUtility.AddParameters("@EducationName", SqlDbType.VarChar, EducationName);
                ClsUtility.AddParameters("@Sequence", SqlDbType.Int, Sequence.ToString());

                DataRow theDR;
                theDR = (DataRow)EducationManager.ReturnObject(ClsUtility.theParams, "Pr_Admin_Insert_Education_Constella", ClsUtility.ObjectEnum.DataRow);

                if (Convert.ToInt32(theDR[0]) == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Education record. Try Again..";
                    AppException.Create("#C1", theBL);
                }


                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(Convert.ToInt32(theDR[0]));
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 29
0
        public int SaveUpdate(string ID, string PatientId, string TransferfromId, string TransfertoId, string TransfertoDate, int userId, string createdate, int flag)
        {
            try
            {
                this.Connection  = DataMgr.GetConnection();
                this.Transaction = DataMgr.BeginTransaction(this.Connection);

                ClsObject SaveUpdateMgr = new ClsObject();
                SaveUpdateMgr.Connection  = this.Connection;
                SaveUpdateMgr.Transaction = this.Transaction;

                ClsUtility.Init_Hashtable();
                ClsUtility.AddParameters("@ID", SqlDbType.VarChar, ID);
                ClsUtility.AddParameters("@PatientId", SqlDbType.VarChar, PatientId);
                //ClsUtility.AddParameters("@LocationId", SqlDbType.VarChar, LocationId);
                ClsUtility.AddParameters("@TransferfromId", SqlDbType.VarChar, TransferfromId);
                ClsUtility.AddParameters("@TransfertoId", SqlDbType.VarChar, TransfertoId);
                ClsUtility.AddParameters("@TransfertoDate", SqlDbType.VarChar, TransfertoDate);
                ClsUtility.AddParameters("@UserId", SqlDbType.Int, userId.ToString());
                ClsUtility.AddParameters("@Createdate", SqlDbType.VarChar, createdate);
                ClsUtility.AddParameters("@Flag", SqlDbType.Int, flag.ToString());
                int RowsAffected = (Int32)SaveUpdateMgr.ReturnObject(ClsUtility.theParams, "pr_Clinical_PatientSatelliteTransferSaveUpdate_Constella", ClsUtility.ObjectEnum.ExecuteNonQuery);
                if (RowsAffected == 0)
                {
                    MsgBuilder theBL = new MsgBuilder();
                    theBL.DataElements["MessageText"] = "Error in Saving Reason record. Try Again..";
                    AppException.Create("#C1", theBL);
                }
                DataMgr.CommitTransaction(this.Transaction);
                DataMgr.ReleaseConnection(this.Connection);
                return(Convert.ToInt32(RowsAffected));
            }
            catch
            {
                throw;
            }
            finally
            {
                if (this.Connection != null)
                {
                    DataMgr.ReleaseConnection(this.Connection);
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 综合还书
        /// </summary>
        /// <param name="flag">还书类型</param>
        /// <param name="bookid">图书条形码</param>
        /// <returns>返回还书信息</returns>
        public string RetrunBook(string flag, Guid bookid)
        {
            string reslut = string.Empty;

            try
            {
                OutTimeBookInfo outTimeBookInfo = new OutTimeBookInfo();
                GetLoanInfoMgr  getLoanInfoMgr  = new GetLoanInfoMgr();

                // 获取未还图书信息
                outTimeBookInfo = getLoanInfoMgr.GetReturnBookInfo(bookid);
                switch (flag)
                {
                // 正常还书无罚款
                case "0":
                    ReturnbookNomle returnbookNomMgr = new ReturnbookNomle(bookid);
                    returnbookNomMgr.Execute();
                    break;

                // 立即缴纳并归还图书
                case "1":
                    ReturnBookPayMoney returnBookPayMoney = new ReturnBookPayMoney(bookid, (decimal)outTimeBookInfo.Money);
                    returnBookPayMoney.Execute();
                    break;

                // 还书但暂时不缴纳罚款
                case "2":
                    ReturnOutTimeBookNoPay returnOutTimeBookNoPay = new ReturnOutTimeBookNoPay(bookid, (decimal)outTimeBookInfo.Money);
                    returnOutTimeBookNoPay.Execute();
                    break;
                }
            }
            catch (AppException exp)
            {
                reslut = exp.Message;
            }
            catch (Exception exp)
            {
                AppException appexp = new AppException("还书失败", exp, ExceptionLevel.Info);
                throw appexp;
            }

            return(reslut);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Writes the app exception.
        /// </summary>
        /// <param name="appex">The appex.</param>
        /// <param name="timepoint">The timepoint.</param>
        /// <param name="routeModuleName">Name of the route module.</param>
        public void WriteAppException(AppException appex, DateTime timepoint, string routeModuleName)
        {
            try
            {
                string trackID = appex.Data["TrackID"] as string;
                Dictionary<string, object> parameters = new Dictionary<string, object>();

                if (appex.Data != null)
                {
                    foreach (var key in appex.Data.Keys)
                    {
                        if (key is string)
                        {
                            string keyStr = key as string;
                            parameters.Add(keyStr, appex.Data[key]);
                        }
                    }
                }

                string originalException = appex.InnerException != null ? appex.InnerException.Message : string.Empty;
                string exceptionContext = JsonHelper.JsonSerializer<Dictionary<string, object>>(parameters);
                string localip = IPAddressHelper.GetLocalIpAddress();
                MAppException mappex = new MAppException()
                {
                    OrginalExceptionMsg = originalException,
                    ExceptionContext = exceptionContext,
                    ExceptionMsg = appex.ToString(),
                    ErrorCode = appex.ErrorCode,
                    LocalIP = localip,
                    ApplicationName = AppKeySettings.ApplicationName,
                    LogID = Guid.NewGuid().ToString(),
                    TrackID = trackID,
                    TimePoint = DateTime.Now,
                    ExceptionLevel = appex.Level,
                };

                DALFactory.GetAppExceptionDAL(LogRecordType.DBLog).InsertAppException(mappex);
            }
            catch (Exception ex)
            {
                TextDataAccess.AddLog(ex.StackTrace.ToString());
            }
        }
Ejemplo n.º 32
0
 public int DeleteCustomField(int fieldID, int flag)
 {
     lock (this)
     {
         ClsObject CustomField = new ClsObject();
         ClsUtility.Init_Hashtable();
         int theRowAffected = 0;
         ClsUtility.AddParameters("@ID", SqlDbType.Int, fieldID.ToString());
         ClsUtility.AddParameters("@flag", SqlDbType.Int, flag.ToString());
         theRowAffected = (int)CustomField.ReturnObject(ClsUtility.theParams, "Pr_PMTCT_DeleteCustomFields_Future", ClsUtility.ObjectEnum.ExecuteNonQuery);
         if (theRowAffected == 0)
         {
             MsgBuilder theMsg = new MsgBuilder();
             theMsg.DataElements["MessageText"] = "Error in Deleting Custom Field. Try Again..";
             AppException.Create("#C1", theMsg);
         }
         return(theRowAffected);
     }
 }
Ejemplo n.º 33
0
 private AppException MapException(Exception ex)
 {
     if (ex == null) return null;
     var exception = new AppException
     {
         HelpLink = ex.HelpLink,
         Message = ex.Message,
         Source = ex.Source,
         StackTrace = ex.StackTrace,
         TargetSite = ex.TargetSite != null ? ex.TargetSite.ToString() : string.Empty,
         ExceptionTypeName = ex.GetType().FullName,
     };
     exception.InnerException = MapException(ex.InnerException);
     return exception;
 }
Ejemplo n.º 34
0
 public bool validateUser(string username, string password , out User user, out AppException error)
 {
     try
     {
         user= DBManager.Instance.users.login(username, password);
         error = null;
         return true;
     }
     catch(AppException e)
     {
         user = null;
         error = e;
         return false;
     }
 }
 protected void OnAppException(AppException exception)
 {
     var task = DispatcherHelper.RunAsync(async () => { await new MessageDialog("Error:\r\n" + exception.Message).ShowAsync(); });
 }