Beispiel #1
0
        /// <summary>
        /// 案件列表
        /// </summary>
        public ChangeAssignedViewModel(MobileCallogSearch Callog, string ZoName, string DoName)
        {
            this.Sn          = Callog.Sn;
            this.Zo_Name     = ZoName;
            this.Do_Name     = DoName;
            this.Store_Name  = Callog.StoreName;
            this.Asset_Name  = Callog.AssetName;
            this.Damage_Desc = Callog.DamageDesc;
            this.Fi_Date     = Callog.FiDate;
            this.Fd_Date     = Callog.FdDate;
            this.Name        = Callog.Acceptname;

            colData = new string[]
            {
                this.Sn,
                this.Sn,
                this.Zo_Name,
                this.Do_Name,
                this.Store_Name,
                this.Asset_Name,
                this.Damage_Desc,
                this.Fi_Date.ToString("yyyy-MM-dd HH:mm"),
                this.Fd_Date,
                this.Name
            };
        }
        //public CallogDetailApiViewModel(Tcallog data, Tvender vender) : this()
        //{
        //    //案件明細

        //}
        public CallogDetailApiViewModel(MobileCallogSearch data) : this()
        {
            //案件明細
            this.Sn              = data.Sn;
            this.CompCd          = data.CompCd;
            this.StoreName       = data.StoreName;
            this.StoreAddress    = data.StoreAddr;
            this.StoreTel        = data.Telno;
            this.AssetCd         = data.AssetCd;
            this.AssetName       = data.AssetCd + " " + data.AssetName;
            this.CallLevel       = data.CallLevel == "1" ? "普通" : "緊急";
            this.DamageDesc      = data.DamageDesc;
            this.FcDate          = data.FcDate;
            this.FiDate          = data.FiDate.ToString("yyyy/MM/dd HH:mm:ss");
            this.FvDate          = data.FvDate;
            this.FdDate          = data.FdDate;
            this.CallDesc        = data.CallDesc;
            this.RemarkAdd       = data.RemarkAdd;
            this.IsAccept        = data.AcceptAccount == null ? false : true;
            this.CallName        = data.CallerName;
            this.VenderName      = "";
            this.VenderCd        = data.VenderCd;
            this.FixMark         = data.Workdesc;
            this.AcceptedAccount = data.AcceptAccount;
            this.AcceptedName    = data.Acceptname;
            this.AcceptDatetime  = data.AcceptDatetime?.ToString("yyyy/MM/dd HH:mm:ss");
            this.WorkName        = data.WorkName;
            this.Finish_Name     = data.Finish_Name;
            this.Mtn_Desc        = data.Mtn_Desc;
            this.ArriveDate      = data.ArriveDate;
            this.FcDate          = data.FcDate;
            if (data.CoffeeCup == null)
            {
                this.CoffeeCup = "";
            }
            else
            {
                this.CoffeeCup = data.CoffeeCup.ToString();
            }
        }
 /// <summary>
 /// 案件列表
 /// </summary>
 public NotifyAssignedViewModel(MobileCallogSearch Callog, string ZoName, string DoName)
 {
     this.Sn          = Callog.Sn;
     this.Zo_Name     = ZoName;
     this.Do_Name     = DoName;
     this.Store_Name  = Callog.StoreName;
     this.Asset_Name  = Callog.AssetName;
     this.Damage_Desc = Callog.DamageDesc;
     this.Fi_Date     = Callog.FiDate;
     this.Fd_Date     = Callog.FdDate;
     colData          = new string[]
     {
         this.Sn,
         this.Sn,
         this.Zo_Name,
         this.Do_Name,
         this.Store_Name,
         this.Asset_Name,
         this.Damage_Desc,
         this.Fi_Date.ToString("yyyy/MM/dd HH:mm:ss"),
         this.Fd_Date
     };
 }
        public CallogResultApiViewModel(MobileCallogSearch data, bool Enable)
        {
            this.Sn             = data.Sn;
            this.StoreCd        = data.StoreCd;
            this.StoreName      = data.StoreName;
            this.AssetName      = data.AssetName;
            this.DamageDesc     = data.DamageDesc;
            this.StoreAddress   = data.StoreAddr;
            this.CallDesc       = data.CallDesc;
            this.CallLevel      = data.CallLevel;
            this.FaDate         = data.FaDate;
            this.Enable         = Enable;
            this.AcceptDatetime = data.AcceptDatetime?.ToString("yyyy/MM/dd HH:mm:ss");
            this.IsRcvDate      = data.RcvDate == null ? false : true;

            this.IsSISOVender = true;


            DateTime now = DateTime.Now;

            if (data.CloseSts == (int)Seteng.CloseSts.process)  //處理中
            {
                DateTime Fadate = Convert.ToDateTime(data.FaDate);

                if (!string.IsNullOrEmpty(data.ArriveDate) && DateTime.TryParse(data.ArriveDate, out DateTime ArriveDate))
                {
                    this.TimeDescription = "已到店";
                }
                else if (data.FvDate == data.FaDate)
                {
                    this.TimeDescription = "無時效";
                }
                else if (Fadate > now)
                {
                    TimeSpan ts = Fadate.Subtract(now);

                    if (ts.Days > 0)
                    {
                        this.TimeDescription = string.Format("{0}:{1}:{2}", ts.Days, ts.Hours, ts.Minutes);
                    }
                    else if (ts.Hours > 0)
                    {
                        this.TimeDescription = string.Format("{0}:{1}", ts.Hours, ts.Minutes);
                    }
                    else
                    {
                        this.TimeDescription = string.Format("{0}分", ts.Minutes);
                    }
                    this.Overtime = true;
                }
                else
                {
                    this.TimeDescription = "逾時";
                    this.Overtime        = false;
                }
            }
            else  //已銷案
            {
                if (!string.IsNullOrEmpty(data.ArriveDate) && DateTime.TryParse(data.ArriveDate, out DateTime ArriveDate))
                {
                    #region  完成時間

                    DateTime FaDate  = Convert.ToDateTime(data.FaDate);
                    DateTime ArrDate = Convert.ToDateTime(data.ArriveDate);


                    if (ArrDate > FaDate)
                    {
                        this.TimeDescription = "逾時";
                    }
                    else
                    {
                        this.TimeDescription = "時效內";
                    }
                    this.Overtime = false;
                    #endregion
                }
                else
                {
                    //沒有完成時間,無法計算
                    this.TimeDescription = "無";
                    this.Overtime        = false;
                }
            }
            this.Timepoint = data.Timepoint;
        }
        public CallogDetailApiViewModel(MobileCallogSearch data, IEnumerable <string> BeforeFix, IEnumerable <string> AfterFix, IEnumerable <string> WorkOrder, IEnumerable <string> Signature, string SpcAssetKind) : this()
        {
            //案件明細
            this.Sn              = data.Sn;
            this.CompCd          = data.CompCd;
            this.StoreName       = data.StoreName;
            this.StoreAddress    = data.StoreAddr;
            this.StoreTel        = data.Telno;
            this.AssetCd         = data.AssetCd;
            this.AssetName       = data.AssetCd + " " + data.AssetName;
            this.CallLevel       = data.CallLevel == "1" ? "普通" : "緊急";
            this.DamageDesc      = data.DamageDesc;
            this.FcDate          = data.FcDate;
            this.FiDate          = data.FiDate.ToString("yyyy/MM/dd HH:mm:ss");
            this.FvDate          = data.FvDate;
            this.FdDate          = data.FdDate;
            this.CallDesc        = data.CallDesc;
            this.RemarkAdd       = data.RemarkAdd;
            this.IsAccept        = data.AcceptAccount == null ? false : true;
            this.CallName        = data.CallerName;
            this.VenderCd        = data.VenderCd;
            this.FixMark         = data.Workdesc;
            this.AcceptedAccount = data.AcceptAccount;
            this.AcceptedName    = data.Acceptname;
            this.AcceptDatetime  = data.AcceptDatetime?.ToString("yyyy/MM/dd HH:mm:ss");
            this.WorkName        = data.WorkName;
            this.Finish_Name     = data.Finish_Name;
            this.Mtn_Desc        = data.Mtn_Desc;
            this.ArriveDate      = data.ArriveDate;
            this.FcDate          = data.FcDate;

            this.ImgBeforeFix = new List <string>();
            foreach (var beforeImg in BeforeFix.ToList())
            {
                this.ImgBeforeFix.Add(beforeImg);
            }

            this.ImgAfterFix = new List <string>();
            foreach (var AfterImg in AfterFix.ToList())
            {
                this.ImgAfterFix.Add(AfterImg);
            }

            this.Img = new List <string>();
            foreach (var WorkOrderImg in WorkOrder.ToList())
            {
                this.Img.Add(WorkOrderImg);
            }

            this.ImgSignature = new List <string>();
            foreach (var SignatureImg in Signature.ToList())
            {
                this.ImgSignature.Add(SignatureImg);
            }

            if (SpcAssetKind == "1") //0.一般設備  1.咖啡機  2: 燈管招牌類  3.AJ濾材
            {
                this.IsCoffeeAsset = true;
                if (data.CoffeeCup == null)
                {
                    this.CoffeeCup = "";
                }
                else
                {
                    this.CoffeeCup = data.CoffeeCup.ToString();
                }
            }
            else
            {
                this.IsCoffeeAsset = false;
            }
        }
        public CallogDetailApiViewModel(MobileCallogSearch data, PagedList <Twrkknd> knd, PagedList <Tfinish> fin, PagedList <Tdammtn> mtn, IEnumerable <string> BeforeFix, IEnumerable <string> AfterFix, IEnumerable <string> WorkOrder, IEnumerable <string> Signature, string SpcAssetKind, Dictionary <RecordType, List <TCallLogDateRecord> > dateRecords) : this()
        {
            //案件明細
            this.Sn              = data.Sn;
            this.CompCd          = data.CompCd;
            this.StoreName       = data.StoreName;
            this.StoreAddress    = data.StoreAddr;
            this.StoreTel        = data.Telno;
            this.AssetCd         = data.AssetCd;
            this.AssetName       = data.AssetCd + " " + data.AssetName;
            this.SapAssetNo      = data.SapAssetNo;
            this.CallLevel       = data.CallLevel == "1" ? "普通" : "緊急";
            this.DamageDesc      = data.DamageDesc;
            this.FiDate          = data.FiDate.ToString("yyyy/MM/dd HH:mm:ss");
            this.FvDate          = data.FvDate;
            this.FdDate          = data.FdDate;
            this.CallDesc        = data.CallDesc;
            this.RemarkAdd       = data.RemarkAdd;
            this.IsAccept        = data.AcceptAccount == null ? false : true;
            this.CallName        = data.CallerName;
            this.VenderCd        = data.VenderCd;
            this.VenderName      = data.VenderName;
            this.FixMark         = data.Workdesc;
            this.AcceptedAccount = data.AcceptAccount;
            this.AcceptedName    = data.Acceptname;
            this.AcceptDatetime  = data.AcceptDatetime?.ToString("yyyy/MM/dd HH:mm:ss");
            this.WorkName        = data.WorkName;
            this.Finish_Name     = data.Finish_Name;
            this.Mtn_Desc        = data.Mtn_Desc;
            this.ArriveDate      = data.ArriveDate;
            this.FcDate          = data.FcDate;
            this.Work            = knd.Select(x => new Twrkknd(x));
            this.Finish          = fin.Select(x => new Tfinish(x));
            this.Proc            = mtn.Select(x => new Tdammtn(x));
            this.Pre_Amt         = data.Pre_Amt;

            this.ImgBeforeFix = new List <string>();
            foreach (var beforeImg in BeforeFix.ToList())
            {
                this.ImgBeforeFix.Add(beforeImg);
            }

            this.ImgAfterFix = new List <string>();
            foreach (var AfterImg in AfterFix.ToList())
            {
                this.ImgAfterFix.Add(AfterImg);
            }

            this.Img = new List <string>();
            foreach (var WorkOrderImg in WorkOrder.ToList())
            {
                this.Img.Add(WorkOrderImg);
            }

            this.ImgSignature = new List <string>();
            foreach (var SignatureImg in Signature.ToList())
            {
                this.ImgSignature.Add(SignatureImg);
            }

            if (SpcAssetKind == "1") //0.一般設備  1.咖啡機  2: 燈管招牌類  3.AJ濾材
            {
                this.IsCoffeeAsset = true;
                if (data.CoffeeCup == null)
                {
                    this.CoffeeCup = "";
                }
                else
                {
                    this.CoffeeCup = data.CoffeeCup.ToString();
                }
            }
            else
            {
                this.IsCoffeeAsset = false;
            }

            if (dateRecords != null)
            {
                this.IsStoreScanSI = dateRecords.Keys.Count(x => x == RecordType.ArriveDateNotScan) <= 0;


                this.IsStoreScanSO = dateRecords.Keys.Count(x => x == RecordType.LeaveDateNotScan) <= 0;
                if (this.IsStoreScanSO)
                {
                    List <DateTime> SO = new List <DateTime>();
                    if (dateRecords.Count(x => x.Key == RecordType.LeaveDate) > 0)
                    {
                        SO.AddRange(dateRecords[RecordType.LeaveDate].Select(x => x.RecordDate));
                    }
                    if (dateRecords.Count(x => x.Key == RecordType.LeaveDateTemp) > 0)
                    {
                        SO.AddRange(dateRecords[RecordType.LeaveDateTemp].Select(x => x.RecordDate));
                    }
                    this.LeaveDate = SO.Count() > 0 ? SO.Min(x => x).ToString("yyyy/MM/dd HH:mm:ss") : null;
                }

                else
                {
                    this.LeaveDate = dateRecords[RecordType.LeaveDateNotScan].Min(x => x.RecordDate).ToString("yyyy/MM/dd HH:mm:ss");
                }

                this.IsSignature = dateRecords.Keys.Count(x => x == RecordType.SignatureNot) <= 0;

                if (this.IsSignature)
                {
                    this.SignatureDate = dateRecords.Count(x => x.Key == RecordType.Signature) > 0 ? dateRecords[RecordType.Signature].Min(x => x.RecordDate).ToString("yyyy/MM/dd HH:mm:ss") : "";
                }
                else
                {
                    this.SignatureDate = dateRecords[RecordType.SignatureNot].Min(x => x.RecordDate).ToString("yyyy/MM/dd HH:mm:ss");
                }
            }
            else
            {
                this.IsStoreScanSI = true;
                this.IsStoreScanSO = true;
                this.IsSignature   = true;
            }
        }