Beispiel #1
0
        public TicketEsTime Get(int EsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select EsID,TicketID,Week,QaAdjust,DevAdjust,GrapTime,DocTime,TrainingTime,TotalTimes,EsByUserId,CreatedTime,Remark,IsPM from EsDetail ");
            strSql.Append(" where EsID=@EsID ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "EsID", DbType.Int32, EsID);
                    TicketEsTime model = null;
                    using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                    {
                        if (dataReader.Read())
                        {
                            model = TicketEsTime.ReaderBind(dataReader);
                        }
                    }
                    return(model);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]", strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(null);
                }
            }
        }
Beispiel #2
0
        public bool Update(TicketEsTime model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update EsDetail set ");
            strSql.Append("TicketID=@TicketID,");
            strSql.Append("Week=@Week,");
            strSql.Append("QaAdjust=@QaAdjust,");
            strSql.Append("DevAdjust=@DevAdjust,");
            strSql.Append("GrapTime=@GrapTime,");
            strSql.Append("DocTime=@DocTime,");
            strSql.Append("TrainingTime=@TrainingTime,");
            strSql.Append("TotalTimes=@TotalTimes,");
            strSql.Append("EsByUserId=@EsByUserId,");
            strSql.Append("CreatedTime=@CreatedTime,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("IsPM=@IsPM");
            strSql.Append(" where EsID=@EsID ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "EsID", DbType.Int32, model.EsID);
                    db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID);
                    db.AddInParameter(dbCommand, "Week", DbType.String, model.Week);
                    db.AddInParameter(dbCommand, "QaAdjust", DbType.Decimal, model.QaAdjust);
                    db.AddInParameter(dbCommand, "DevAdjust", DbType.Decimal, model.DevAdjust);
                    db.AddInParameter(dbCommand, "GrapTime", DbType.Decimal, model.GrapTime);
                    db.AddInParameter(dbCommand, "DocTime", DbType.Decimal, model.DocTime);
                    db.AddInParameter(dbCommand, "TrainingTime", DbType.Decimal, model.TrainingTime);
                    db.AddInParameter(dbCommand, "TotalTimes", DbType.Decimal, model.TotalTimes);
                    db.AddInParameter(dbCommand, "EsByUserId", DbType.Int32, model.EsByUserId);
                    db.AddInParameter(dbCommand, "CreatedTime", DbType.DateTime, model.CreatedTime);
                    db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark);
                    db.AddInParameter(dbCommand, "IsPM", DbType.Boolean, model.IsPM);
                    int rows = db.ExecuteNonQuery(dbCommand);
                    if (rows > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]", strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(false);
                }
            }
        }
Beispiel #3
0
        public int Insert(TicketEsTime model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into EsDetail(");
            strSql.Append("TicketID,Week,QaAdjust,DevAdjust,GrapTime,DocTime,TrainingTime,TotalTimes,EsByUserId,CreatedTime,Remark,IsPM)");

            strSql.Append(" values (");
            strSql.Append("@TicketID,@Week,@QaAdjust,@DevAdjust,@GrapTime,@DocTime,@TrainingTime,@TotalTimes,@EsByUserId,@CreatedTime,@Remark,@IsPM)");
            strSql.Append(";select @@IDENTITY");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID);
                    db.AddInParameter(dbCommand, "Week", DbType.String, model.Week);
                    db.AddInParameter(dbCommand, "QaAdjust", DbType.Decimal, model.QaAdjust);
                    db.AddInParameter(dbCommand, "DevAdjust", DbType.Decimal, model.DevAdjust);
                    db.AddInParameter(dbCommand, "GrapTime", DbType.Decimal, model.GrapTime);
                    db.AddInParameter(dbCommand, "DocTime", DbType.Decimal, model.DocTime);
                    db.AddInParameter(dbCommand, "TrainingTime", DbType.Decimal, model.TrainingTime);
                    db.AddInParameter(dbCommand, "TotalTimes", DbType.Decimal, model.TotalTimes);
                    db.AddInParameter(dbCommand, "EsByUserId", DbType.Int32, model.EsByUserId);
                    db.AddInParameter(dbCommand, "CreatedTime", DbType.DateTime, model.CreatedTime);
                    db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark);
                    db.AddInParameter(dbCommand, "IsPM", DbType.Boolean, model.IsPM);
                    int    result;
                    object obj = db.ExecuteScalar(dbCommand);
                    if (!int.TryParse(obj.ToString(), out result))
                    {
                        return(0);
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]", strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(0);
                }
            }
        }
Beispiel #4
0
        private void DateBind(string isFinal, int tid)
        {
            List <TicketEsTime> list = TicketApp.GetListEs(tid);

            this.trNoTickets.Visible   = list.Count <= 0 ? true : false;
            this.trNoTickets02.Visible = true;
            if (isFinal == "iushau02u340final")
            {
                List <TicketEsTime> listEsFinal = list.FindAll(x => x.IsPM == true);
                TicketEsTime        model2      = new TicketEsTime();
                model2.TotalTimes   = listEsFinal.Sum(x => x.TotalTimes);
                model2.DevAdjust    = listEsFinal.Sum(x => x.DevAdjust);
                model2.DocTime      = listEsFinal.Sum(x => x.DocTime);
                model2.GrapTime     = listEsFinal.Sum(x => x.GrapTime);
                model2.QaAdjust     = listEsFinal.Sum(x => x.QaAdjust);
                model2.TrainingTime = listEsFinal.Sum(x => x.TrainingTime);
                model2.Week         = "Total:";
                listEsFinal.Add(model2);
                this.trNoTickets02.Visible            = listEsFinal.Count <= 0 ? true : false;
                this.rptTicketsEsListFinal.DataSource = listEsFinal;
                this.rptTicketsEsListFinal.DataBind();
            }

            List <TicketEsTime> listEs = list.FindAll(x => x.IsPM == false);
            TicketEsTime        model  = new TicketEsTime();

            model.TotalTimes   = listEs.Sum(x => x.TotalTimes);
            model.TotalTimes   = listEs.Sum(x => x.TotalTimes);
            model.DevAdjust    = listEs.Sum(x => x.DevAdjust);
            model.DocTime      = listEs.Sum(x => x.DocTime);
            model.GrapTime     = listEs.Sum(x => x.GrapTime);
            model.QaAdjust     = listEs.Sum(x => x.QaAdjust);
            model.TrainingTime = listEs.Sum(x => x.TrainingTime);
            model.Week         = "Total:";
            listEs.Add(model);

            this.rptTicketsEsList.DataSource = listEs;
            this.rptTicketsEsList.DataBind();
        }
Beispiel #5
0
        public int AddEsTime(TicketEsTime es)
        {
            this.ClearBrokenRuleMessages();

            BaseValidator <TicketEsTime> validator = new AddTicketEsValidator();

            if (!validator.Validate(es))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }

            int id = esRepository.Insert(es);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }

            return(id);
        }
Beispiel #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }

                #region get value

                string JsonString  = context.Request["JsonString"];
                bool   FirstUpdate = Convert.ToBoolean(context.Request["FirstUpdate"]);
                bool   uType       = bool.Parse(context.Request["type"]);
                int    EsId        = int.Parse(context.Request["EsId"]);
                int    tid         = int.Parse(context.Request["tid"]);

                #endregion

                IList <TicketEsTime> list = JsonConvert.DeserializeObject <IList <TicketEsTime> >(JsonString); //新加的估时数据
                int  result    = 0;
                bool HasError  = false;
                bool UpdateSuc = false;
                if (EsId > 0)                                                           //是更新吗?
                {
                    TicketEsTime model = TicketApp.GetEsTimeModel(EsId);
                    model.DevAdjust    = list[0].DevAdjust;
                    model.DocTime      = list[0].DocTime;
                    model.GrapTime     = list[0].GrapTime;
                    model.QaAdjust     = list[0].QaAdjust;
                    model.Remark       = list[0].Remark;
                    model.TotalTimes   = list[0].TotalTimes;
                    model.TrainingTime = list[0].TrainingTime;
                    model.Week         = list[0].Week;
                    UpdateSuc          = TicketApp.UpdateEsTime(model);
                }
                else                                                  //添加的情况
                {
                    foreach (TicketEsTime item in list)
                    {
                        item.CreatedTime = DateTime.Now.Date;
                        item.EsByUserId  = IdentityContext.UserID;
                        item.IsPM        = uType;
                        item.Week        = item.Week;
                        result           = TicketApp.AddEsTime(item);
                        if (result < 0)
                        {
                            HasError = true;
                        }
                    }
                }
                if (uType)                                                                                    //用于判断是否是PM估时,如果是PM
                {
                    List <TicketEsTime> listPmEsTime = TicketApp.GetListEs(tid).FindAll(x => x.IsPM == true); //如果是PM就把所计算所有PM估时的总和 然后做为final time更新到tickets表。
                    decimal             pmTime       = listPmEsTime.Count > 0 ? listPmEsTime.Sum(x => x.TotalTimes) : 0;
                    TicketApp.UpdateEs(pmTime, tid, UserID, true);                                            //这里更新的是Es
                }
                else                                                                                          //否则如果是Leader的情况会把第一次估时,也就是initial time写入到Ticket表中
                {
                    List <TicketEsTime> listLeaderEsTime = TicketApp.GetListEs(tid).FindAll(x => x.IsPM == false);
                    decimal             InitialTime      = listLeaderEsTime.Count > 0 ? listLeaderEsTime.Sum(x => x.TotalTimes) : 0;
                    TicketApp.UpdateEs(InitialTime, tid, UserID, false);
                }

                if ((result > 0 && !HasError) || UpdateSuc)
                {
                    if (UpdateSuc)
                    {
                        context.Response.Write("Update Es Time Success!");
                    }
                    else
                    {
                        context.Response.Write("Add Es Time Success! ");
                    }
                }
                else
                {
                    if (UpdateSuc)
                    {
                        context.Response.Write("Update Es Time Fail!");
                    }
                    else
                    {
                        context.Response.Write("Add Es Time Fail!");
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("para error!");
                WebLogAgent.Write(string.Format("Error Ashx:DoTicketEsTimeUpdateHandler.ashx Messages:\r\n{0}", ex));
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int tid = int.Parse(context.Request.Params["tid"]);

            List <TicketEsTime> list       = ticketApp.GetListEs(tid);
            List <TicketEsTime> listEsUser = list.FindAll(x => x.IsPM == false);
            List <TicketEsTime> listPm     = list.FindAll(x => x.IsPM == true);

            #region
            StringBuilder sb = new StringBuilder();
            sb.Append("<table id= 'esTable' width= '90%' border='1' align='center' cellpadding='5' cellspacing='0'  class='tabStyle'>");
            sb.Append("<tr class='owlistTitle'>");
            sb.Append("<th style='width: 40px;'>Week</th>");
            sb.Append("<th style='width: 40px;'>QA</th>");
            sb.Append("<th style='width: 40px;'>Dev</th>");
            sb.Append("<th style='width: 60px;'>Grap Time</th>");
            sb.Append("<th style='width: 60px;'>Doc Time</th>");
            sb.Append("<th style='width: 80px;'>Training Time</th>");
            sb.Append("<th style='width: 60px;'>Total</th>");
            sb.Append("<th style='width: 110px;'>Remark</th>");
            sb.Append("<th style='width: 60px;'>Create By</th>");
            sb.Append("</tr>");
            sb.Append("{row}");
            sb.Append("</table>");
            #endregion

            StringBuilder FillData   = new StringBuilder();
            int           rows       = 1;
            int           totalCount = 0;
            if (listPm.Count <= 0)
            {
                if (listEsUser.Count <= 0)
                {
                    sb.Replace("{row}", NotDataRow());
                }
                else
                {
                    totalCount = listEsUser.Count;
                    TicketEsTime model = new TicketEsTime();
                    model.TotalTimes   = listEsUser.Sum(x => x.TotalTimes);
                    model.DevAdjust    = listEsUser.Sum(x => x.DevAdjust);
                    model.DocTime      = listEsUser.Sum(x => x.DocTime);
                    model.GrapTime     = listEsUser.Sum(x => x.GrapTime);
                    model.QaAdjust     = listEsUser.Sum(x => x.QaAdjust);
                    model.TrainingTime = listEsUser.Sum(x => x.TrainingTime);
                    model.EsByUserId   = 0;
                    model.Week         = "Total:";
                    listEsUser.Add(model);
                    foreach (TicketEsTime item in listEsUser)
                    {
                        rows++;
                        FillData.Append(DataRowTemplete().Replace("{EsID}", item.EsID.ToString())
                                        .Replace("{Week}", item.Week)
                                        .Replace("{QaAdjust}", item.QaAdjust.ToString())
                                        .Replace("{DevAdjust}", item.DevAdjust.ToString())
                                        .Replace("{GrapTime}", item.GrapTime.ToString())
                                        .Replace("{DocTime}", item.DocTime.ToString())
                                        .Replace("{TrainingTime}", item.TrainingTime.ToString())
                                        .Replace("{TotalTimes}", item.TotalTimes.ToString())
                                        .Replace("{Remark}", item.Remark)
                                        .Replace("{CreateUser}", GetUserNameByCreateID(item.EsByUserId))
                                        .Replace("{class}", rows % 2 == 0 ? "bg1" : "bg2")
                                        );
                    }
                    sb.Replace("{row}", FillData.ToString());
                }
            }
            else
            {
                totalCount = listPm.Count;
                TicketEsTime model = new TicketEsTime();
                model.TotalTimes   = listPm.Sum(x => x.TotalTimes);
                model.DevAdjust    = listPm.Sum(x => x.DevAdjust);
                model.DocTime      = listPm.Sum(x => x.DocTime);
                model.GrapTime     = listPm.Sum(x => x.GrapTime);
                model.QaAdjust     = listPm.Sum(x => x.QaAdjust);
                model.TrainingTime = listPm.Sum(x => x.TrainingTime);
                model.EsByUserId   = 0;
                model.Week         = "Total:";
                listPm.Add(model);
                foreach (TicketEsTime item in listPm)
                {
                    rows++;
                    FillData.Append(DataRowTemplete().Replace("{EsID}", item.EsID.ToString())
                                    .Replace("{Week}", item.Week)
                                    .Replace("{QaAdjust}", item.QaAdjust.ToString())
                                    .Replace("{DevAdjust}", item.DevAdjust.ToString())
                                    .Replace("{GrapTime}", item.GrapTime.ToString())
                                    .Replace("{DocTime}", item.DocTime.ToString())
                                    .Replace("{TrainingTime}", item.TrainingTime.ToString())
                                    .Replace("{TotalTimes}", item.TotalTimes.ToString())
                                    .Replace("{Remark}", item.Remark)
                                    .Replace("{CreateUser}", GetUserNameByCreateID(item.EsByUserId))
                                    .Replace("{class}", rows % 2 == 0 ? "bg1" : "bg2")
                                    );
                }
                sb.Replace("{row}", FillData.ToString());
            }
            context.Response.Write(string.Format("{0}{1}", totalCount.ToString().PadLeft(2, '0'), sb));
        }