예제 #1
0
        /// <summary>
        /// Logs servicecall detail in db. Table: FW_ServiceCallDetail
        /// </summary>
        /// <param name="detail"></param>
        /// <returns></returns>
        public ServiceCallDetail Add(CallerInfo callerInfo)
        {
            ServiceCallDetail detail = new ServiceCallDetail();

            detail.ServiceCall = new ServiceCall()
            {
                Id = callerInfo.ServiceCallId
            };
            detail.InsertDateTime = DateTime.Now;
            if (callerInfo.State == CallerInfo.PipelineState.OnRequest)
            {
                detail.Body   = callerInfo.RequestBody;
                detail.Header = callerInfo.RequestHeader;
                detail.Type   = ServiceCallDetail.Types.Request;
            }
            else
            {
                detail.Body   = callerInfo.ResponseBody;
                detail.Header = callerInfo.ResponseHeader;
                detail.Type   = ServiceCallDetail.Types.Response;
            }
            _serviceCallDetailRepo.Add(detail);
            UnitOfWork.Commit();
            return(detail);
        }
예제 #2
0
        public List <ServiceCallDetail> GetServiceCallDetailListByServiceCallID(Guid serviceCallID)
        {
            List <ServiceCallDetail> serviceCallDetailList = new List <ServiceCallDetail>();

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetServiceCallDetailListByServiceCallID]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@ServiceCallID", SqlDbType.UniqueIdentifier).Value = serviceCallID;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                while (sdr.Read())
                                {
                                    ServiceCallDetail serviceCallDetail = new ServiceCallDetail();
                                    {
                                        serviceCallDetail.ID            = (sdr["ID"].ToString() != "" ? Guid.Parse(sdr["ID"].ToString()) : serviceCallDetail.ID);
                                        serviceCallDetail.ServiceCallID = (sdr["ServiceCallID"].ToString() != "" ? Guid.Parse(sdr["ServiceCallID"].ToString()) : serviceCallDetail.ServiceCallID);
                                        serviceCallDetail.Product       = new Product()
                                        {
                                            ID      = (sdr["ProductID"].ToString() != "" ? Guid.Parse(sdr["ProductID"].ToString()) : Guid.Empty),
                                            Code    = (sdr["ProductCode"].ToString() != "" ? sdr["ProductCode"].ToString() : string.Empty),
                                            Name    = (sdr["ProductName"].ToString() != "" ? sdr["ProductName"].ToString() : string.Empty),
                                            HSNCode = (sdr["HSNCode"].ToString() != "" ? sdr["HSNCode"].ToString() : String.Empty)
                                        };
                                        serviceCallDetail.ProductID                  = (sdr["ProductID"].ToString() != "" ? Guid.Parse(sdr["ProductID"].ToString()) : Guid.Empty);
                                        serviceCallDetail.ProductModelID             = (sdr["ProductModelID"].ToString() != "" ? Guid.Parse(sdr["ProductModelID"].ToString()) : Guid.Empty);
                                        serviceCallDetail.ProductModel               = new ProductModel();
                                        serviceCallDetail.ProductModel.ID            = (sdr["ProductModelID"].ToString() != "" ? Guid.Parse(sdr["ProductModelID"].ToString()) : Guid.Empty);
                                        serviceCallDetail.ProductModel.Name          = (sdr["ProductModelName"].ToString() != "" ? (sdr["ProductModelName"].ToString()) : serviceCallDetail.ProductModel.Name);
                                        serviceCallDetail.ProductSpec                = (sdr["ProductSpec"].ToString() != "" ? sdr["ProductSpec"].ToString().Replace("$n$", "\n") : serviceCallDetail.ProductSpec);
                                        serviceCallDetail.GuaranteeYN                = (sdr["GuaranteeYN"].ToString() != "" ? bool.Parse(sdr["GuaranteeYN"].ToString()) : serviceCallDetail.GuaranteeYN);
                                        serviceCallDetail.DocumentStatus             = new DocumentStatus();
                                        serviceCallDetail.ServiceStatusCode          = (sdr["ServiceStatusCode"].ToString() != "" ? int.Parse(sdr["ServiceStatusCode"].ToString()) : serviceCallDetail.ServiceStatusCode);
                                        serviceCallDetail.DocumentStatus.Code        = (int)(sdr["ServiceStatusCode"].ToString() != "" ? int.Parse(sdr["ServiceStatusCode"].ToString()) : serviceCallDetail.DocumentStatus.Code);
                                        serviceCallDetail.DocumentStatus.Description = (sdr["Status"].ToString() != "" ? sdr["Status"].ToString() : serviceCallDetail.DocumentStatus.Description);
                                        serviceCallDetail.InstalledDate              = (sdr["InstalledDate"].ToString() != "" ? DateTime.Parse(sdr["InstalledDate"].ToString()) : serviceCallDetail.InstalledDate);
                                        serviceCallDetail.InstalledDateFormatted     = (sdr["InstalledDate"].ToString() != "" ? DateTime.Parse(sdr["InstalledDate"].ToString()).ToString(_settings.DateFormat) : serviceCallDetail.InstalledDateFormatted);
                                        serviceCallDetail.Spare      = new Spare();
                                        serviceCallDetail.SpareID    = (sdr["SpareID"].ToString() != "" ? Guid.Parse(sdr["SpareID"].ToString()) : Guid.Empty);
                                        serviceCallDetail.Spare.Name = (sdr["Spare"].ToString() != "" ? sdr["Spare"].ToString() : string.Empty);
                                        serviceCallDetail.Spare.Code = (sdr["SpareCode"].ToString() != "" ? sdr["SpareCode"].ToString() : serviceCallDetail.Spare.Code);
                                    }
                                    serviceCallDetailList.Add(serviceCallDetail);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(serviceCallDetailList);
        }