public List <InvenCentralPurRequisitonDTO> GetRequisition_PurOrderpage(string FromDate, string ToDate, int CompanyId, int Recno)
        {
            using (var Container = new InventoryContainer())
            {
                var query = from s in Container.InvenCentralPurRequisitions

                            join pro in Container.Products on s.ProductId equals pro.ProductId
                            select new { s, pro };
                DateTime From, To;
                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.RequisitionDate >= From && c.s.RequisitionDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.s.RequisitionDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.RequisitionDate == From);
                }
                if (CompanyId != 0)
                {
                    query = query.Where(c => c.pro.CompanyInfo.CompId == CompanyId);
                }
                if (Recno != 0)
                {
                    query = query.Where(c => c.s.RequisitionNo == Recno);
                }

                var result = from o in query
                             orderby o.s.CenPurReqId descending
                             where o.s.PurReqStatus == "0"
                             select new InvenCentralPurRequisitonDTO
                {
                    CenPurReqId  = o.s.CenPurReqId,
                    PurReqStatus = o.s.PurReqStatus,
                    ProductId    = o.pro.ProductId,
                    PurReqId     = o.s.PurReqId,

                    RequisitionBy   = o.s.RequisitionBy,
                    RequisitionDate = o.s.RequisitionDate,
                    RequisitionNo   = o.s.RequisitionNo,
                    UnitPrice       = o.s.UnitPrice,
                    CompId          = o.pro.CompanyInfo.CompId,
                    CompName        = o.pro.CompanyInfo.CompName,

                    Priority = o.s.Priority,
                    Quantity = o.s.Quantity
                };
                return(result.ToList <InvenCentralPurRequisitonDTO>());
            }
        }
Beispiel #2
0
        //load sales  payument company
        public List <InvenCentralPurchasePaymentDTO> PurchaseStatementLaod(int purid, int compid, string FromDate, string ToDate)
        {
            DateTime From, To;

            using (var Container = new InventoryContainer())
            {
                var query = from purpay in Container.InvenCentralPurchcasePayments
                            join payinfo in Container.InvenCentralPurchaseInfoes on purpay.PurId equals payinfo.PurId
                            //     join purdtl in Container.InvenCentralPurchaseDtls on payinfo.PurId equals purdtl.PurId

                            select new { purpay, payinfo };

                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.payinfo.CreateDate >= From && c.payinfo.CreateDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.payinfo.CreateDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.payinfo.CreateDate == From);
                }
                if (purid != 0)
                {
                    query = query.Where(c => c.payinfo.PurId.Equals(purid));
                }

                if (compid != 0)
                {
                    query = query.Where(c => c.purpay.CompanyInfo.CompId.Equals(compid));
                }


                var result = from o in query
                             orderby o.payinfo.PurId ascending

                             select new InvenCentralPurchasePaymentDTO
                {
                    PurId      = o.payinfo.PurId,
                    CompId     = o.purpay.CompanyInfo.CompId,
                    CompName   = o.purpay.CompanyInfo.CompName,
                    CreateBy   = o.payinfo.CreateBy,
                    CreateDate = o.payinfo.CreateDate,
                    TotalPrice = o.purpay.TotalPrice,
                    PaidAmount = o.purpay.PaidAmount,
                    DueAmount  = o.purpay.DueAmount,
                };
                return(result.ToList <InvenCentralPurchasePaymentDTO>());
            }
        }
Beispiel #3
0
        public List <InvenPerRequisitionDto> GetRequisitionNo_BranchChallen(string FromDate, string ToDate, int brproid, int Recno)
        {
            using (var Container = new InventoryContainer())
            {
                var query = from s in Container.InvenPerRequisitions
                            join brance in Container.InvenBranchProfiles on s.BrProId equals brance.BrProId

                            select new { s, brance };
                DateTime From, To;
                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.RequisitionDate >= From && c.s.RequisitionDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.s.RequisitionDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.RequisitionDate == From);
                }

                if (Recno != 0)
                {
                    query = query.Where(c => c.s.RequisitionNo == Recno);
                }
                if (brproid != 0)
                {
                    query = query.Where(c => c.brance.BrProId == brproid);
                }

                var result = from o in query
                             //   orderby o.s.PurReqId descending
                             // where o.s.PurReqStatus == "0"
                             select new InvenPerRequisitionDto
                {
                    PurReqId     = o.s.PurReqId,
                    PurReqStatus = o.s.PurReqStatus,

                    BrProId         = o.brance.BrProId,
                    RequisitionBy   = o.s.RequisitionBy,
                    RequisitionDate = o.s.RequisitionDate,
                    RequisitionNo   = o.s.RequisitionNo,
                    UnitPrice       = o.s.UnitPrice,

                    BrProName = o.brance.BrProName,
                    Priority  = o.s.Priority,
                    Quantity  = o.s.Quantity
                };
                return(result.ToList <InvenPerRequisitionDto>());
            }
        }
        //load sales  payument company
        public List <InvenSalePaymentDtlDto> BranchWise_SalesInfoLaod(int salid, int brid, string FromDate, string ToDate)
        {
            DateTime From, To;

            using (var Container = new InventoryContainer())
            {
                var query = from salpay in Container.InvenSalePayments
                            join salinfo in Container.InvenSalesInfoes on salpay.SalId equals salinfo.SalId

                            select new { salpay, salinfo };

                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.salinfo.CreateDate >= From && c.salinfo.CreateDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.salinfo.CreateDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.salinfo.CreateDate == From);
                }
                if (salid != 0)
                {
                    query = query.Where(c => c.salinfo.SalId.Equals(salid));
                }

                if (brid != 0)
                {
                    query = query.Where(c => c.salinfo.InvenBranchProfile.BrProId.Equals(brid));
                }


                var result = from o in query
                             orderby o.salinfo.SalId descending

                             select new InvenSalePaymentDtlDto
                {
                    SalId      = o.salinfo.SalId,
                    BrProName  = o.salinfo.InvenBranchProfile.BrProName,
                    CreateBy   = o.salinfo.CreateBy,
                    CreateDate = o.salinfo.CreateDate,
                    TotalPrice = o.salpay.TotalPrice,
                    PaidAmount = o.salpay.PaidAmount,
                    DueAmount  = o.salpay.DueAmount,
                };
                return(result.ToList <InvenSalePaymentDtlDto>());
            }
        }
Beispiel #5
0
        public List <InvenCentralPurOrderDTO> GetOrderNo_CentralPurchasepage(string FromDate, string ToDate, int CompanyId, int Recno)
        {
            using (var Container = new InventoryContainer())
            {
                var query = from s in Container.InvenCentrealPurOrders
                            join pro in Container.Products on s.ProductId equals pro.ProductId
                            select new { s, pro };
                DateTime From, To;
                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.PurOrderDate >= From && c.s.PurOrderDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.s.PurOrderDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.PurOrderDate == From);
                }
                if (CompanyId != 0)
                {
                    query = query.Where(c => c.pro.CompanyInfo.CompId == CompanyId);
                }
                if (Recno != 0)
                {
                    query = query.Where(c => c.s.PurOrderNO == Recno);
                }

                var result = (from o in query
                              orderby o.s.PurOrderNO descending
                              where o.s.PurOrderStatus == "0"
                              select new InvenCentralPurOrderDTO
                {
                    PurOrderNO = o.s.PurOrderNO
                }).Distinct();
                return(result.ToList <InvenCentralPurOrderDTO>());
            }
        }
        // load data for  log file journal data
        public List <LogPayUserRollDTO> LoadLog_UserRole(string FromDate, string ToDate)
        {
            using (var Container = new InventoryContainer())
            {
                var query = from s in Container.Log_PayuserRole

                            select new { s };
                DateTime To, From;
                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.LogDate >= From && c.s.LogDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.s.LogDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.s.LogDate == From);
                }

                var result = from o in query

                             //     where o.s.LogDate >= fromdate && o.s.LogDate <= todate

                             orderby o.s.LogFilePayUserRoleId descending
                             select new LogPayUserRollDTO
                {
                    LogBy                = o.s.LogBy,
                    LogDate              = o.s.LogDate,
                    LogField             = o.s.LogField,
                    LogFilePayUserRoleId = o.s.LogFilePayUserRoleId
                };
                return(result.ToList <LogPayUserRollDTO>());
            }
        }
Beispiel #7
0
 private void MoveDate(int days = 1)
 {
     To   = To.AddDays(days);
     From = From.AddDays(days);
 }
 public override IDateRange GetNextRange() => new RangeWeek(To.AddDays(1), FirstDayOfWeekProvider);
Beispiel #9
0
        //load pharm pur Due payument company

        public List <InvenCentralPurchasePaymentDTO> PharmPurchase_Due_Payment(int purid, int orderid, int Compid, string SalesManName, string FromDate, string ToDate)
        {
            DateTime From, To;

            using (var Container = new InventoryContainer())
            {
                var query = from payinfo in Container.InvenCentralPurchcasePayments
                            join purinfo in Container.InvenCentralPurchaseInfoes on payinfo.PurId equals purinfo.PurId
                            // join purdtl in Container.InvenCentralPurchaseDtls on purinfo.PurId equals purdtl.PurId
                            // join Comp in Container.CompanyInfoes on purinfo.DurgCompId equals Comp.CompId
                            select new { payinfo, purinfo };

                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.purinfo.CreateDate >= From && c.purinfo.CreateDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.purinfo.CreateDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.purinfo.CreateDate == From);
                }
                if (purid != 0)
                {
                    query = query.Where(c => c.purinfo.PurId.Equals(purid));
                }

                if (orderid != 0)
                {
                    query = query.Where(c => c.purinfo.PurOrderNo.Equals(orderid));
                }

                if (!string.IsNullOrEmpty(SalesManName))
                {
                    query = query.Where(c => c.purinfo.SalesManName.Contains(SalesManName));
                }


                var result = from o in query
                             orderby o.purinfo.PurId ascending
                             where o.payinfo.DueAmount != 0
                             select new InvenCentralPurchasePaymentDTO
                {
                    //  CompId = o.purdtl.Product.CompanyInfo.CompId,
                    //  CompName = o.purdtl.Product.CompanyInfo.CompName,
                    // CompId=o.payinfo.InvenCentralPurchaseInfo.InvenCentralPurchaseDtls.pro
                    SalesManName       = o.purinfo.SalesManName,
                    PurId              = o.purinfo.PurId,
                    PurOrderNo         = o.purinfo.PurOrderNo,
                    CreateDate         = o.purinfo.CreateDate,
                    TotalPrice         = o.payinfo.TotalPrice,
                    PurPaymentId       = o.payinfo.PurPaymentId,
                    FirstPaymentStatus = o.payinfo.FirstPaymentStatus
                };
                return(result.ToList <InvenCentralPurchasePaymentDTO>());
            }
        }
        //load return product send branch to central
        public List <InvenChangePaymentDtlDto> Branchwise_Return_Product(int chdtlid, int catid, int compid, int brid, string FromDate, string ToDate)
        {
            DateTime From, To;

            using (var Container = new InventoryContainer())
            {
                var query = from chdtl in Container.InvenChangeDtls
                            join chinfo in Container.InvenChangeInfoes on chdtl.ChangeId equals chinfo.ChangeId

                            select new { chdtl, chinfo };

                if (!String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    To    = To.AddDays(1);
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.chinfo.CreateDate >= From && c.chinfo.CreateDate <= To);
                }
                else if (String.IsNullOrEmpty(FromDate.ToString()) && !String.IsNullOrEmpty(ToDate.ToString()))
                {
                    To    = Convert.ToDateTime(ToDate);
                    query = query.Where(c => c.chinfo.CreateDate == To);
                }
                else if (!String.IsNullOrEmpty(FromDate.ToString()) && String.IsNullOrEmpty(ToDate.ToString()))
                {
                    From  = Convert.ToDateTime(FromDate);
                    query = query.Where(c => c.chinfo.CreateDate == From);
                }
                if (catid != 0)
                {
                    query = query.Where(c => c.chdtl.Product.Category.CatId.Equals(catid));
                }

                if (compid != 0)
                {
                    query = query.Where(c => c.chdtl.Product.CompanyInfo.CompId.Equals(compid));
                }
                if (brid != 0)
                {
                    query = query.Where(c => c.chinfo.InvenBranchProfile.BrProId.Equals(brid));
                }
                if (chdtlid != 0)
                {
                    query = query.Where(c => c.chdtl.ChangeDtlId.Equals(chdtlid));
                }


                var result = from o in query
                             orderby o.chdtl.ChangeDtlId ascending
                             where o.chdtl.Caused == "Rejection" && o.chdtl.CentranlReturnStatus == "0"
                             select new InvenChangePaymentDtlDto
                {
                    ChangeDtlId  = o.chdtl.ChangeDtlId,
                    CreateDate   = o.chinfo.CreateDate,
                    CategoryName = o.chdtl.Product.Category.CategoryName,
                    CompName     = o.chdtl.Product.CompanyInfo.CompName,
                    ProductName  = o.chdtl.Product.ProductName,
                    Quantity     = o.chdtl.Quantity,
                    ProductId    = o.chdtl.Product.ProductId,
                };
                return(result.ToList <InvenChangePaymentDtlDto>());
            }
        }
Beispiel #11
0
 public Period AddDays(int days)
 {
     return(new Period(From.AddDays(days), To.AddDays(days)));
 }
Beispiel #12
0
        void HandleStateConfirm(ManageDataSession Data, BudgetSession S)
        {
            switch (Data.State)
            {
            case ManageDataState.Main: {
                MainRadioButton Next = GetMainRadioButton(Data);
                HandleShowState(Data, Next.NewState, true);
                return;
            }

            case ManageDataState.AddSingle: {
                if (!float.TryParse(inCurAmt.Value, out float Amt))
                {
                    throw new DisplayException("Could not parse currency amount");
                }

                if (!DateTime.TryParse(dateBegin.Value, out DateTime Date))
                {
                    throw new DisplayException("Could not parse date");
                }

                DAL         DbDAL = new DAL();
                Transaction T     = new Transaction(S.CurrentUser, Date, Amt);
                T.Description = inComment.Value.Trim();

                DbDAL.Insert(T);
                break;
            }

            case ManageDataState.AddMultiple: {
                if (!float.TryParse(inCurAmt.Value, out float Amt))
                {
                    throw new DisplayException("Could not parse currency amount");
                }

                if (!DateTime.TryParse(dateBegin.Value, out DateTime From))
                {
                    throw new DisplayException("Could not parse From date");
                }

                if (!DateTime.TryParse(dateEnd.Value, out DateTime To))
                {
                    throw new DisplayException("Could not parse To date");
                }
                else
                {
                    To = To.AddDays(1);
                }

                DAL DbDAL = new DAL();

                while (From < To)
                {
                    Transaction T = new Transaction(S.CurrentUser, From, Amt);
                    T.Description = inComment.Value.Trim();

                    DbDAL.Insert(T);
                    From = From.AddMonths(1);
                }

                break;
            }

            case ManageDataState.AddRepeating:
                break;

            case ManageDataState.AddMaestroPlus: {
                DAL DbDAL = new DAL();
                MaestroPlusCalculator MaestroCalc = new MaestroPlusCalculator(DbDAL);

                int      MonthCount = int.Parse(inMonthCount.Value);
                float    Amt        = float.Parse(inCurAmt.Value);
                DateTime From       = DateTime.Parse(dateBegin.Value);
                string   Comment    = inComment.Value.Trim();

                MaestroCalc.Calculate(MonthCount, Amt, out float OneTime, out float Monthly);

                MaestroEntry MaestroEntry = new MaestroEntry();
                MaestroEntry.Description = Comment;
                DbDAL.Insert(MaestroEntry);

                Transaction TOneTime = new Transaction(S.CurrentUser, From, -OneTime);
                TOneTime.Description = "Maestro OneTime " + Comment;
                TOneTime.Maestro     = MaestroEntry.ID;
                DbDAL.Insert(TOneTime);

                Transaction MaestroPayment = new Transaction(S.CurrentUser, From, Amt);
                MaestroPayment.Description = Comment;
                MaestroPayment.Maestro     = MaestroEntry.ID;
                DbDAL.Insert(MaestroPayment);

                From = From.AddMonths(1);

                for (int i = 0; i < MonthCount; i++)
                {
                    Transaction MaestroMonthly = new Transaction(S.CurrentUser, From, -Monthly);
                    MaestroMonthly.Description = Comment;
                    MaestroMonthly.Maestro     = MaestroEntry.ID;
                    DbDAL.Insert(MaestroMonthly);

                    From = From.AddMonths(1);
                }

                break;
            }

            case ManageDataState.ManageMaestroPlus:
                break;

            default:
                throw new Exception("Invalid state " + Data.State);
            }
        }
Beispiel #13
0
 private Period(Period currentPeriod)
 {
     To     = currentPeriod.From;
     From   = To.AddDays(-currentPeriod.Days);
     UserId = currentPeriod.UserId;
 }
Beispiel #14
0
        /// <summary>
        /// Created a list of device definitions from the passed in reference. Needs work....
        /// </summary>
        /// <param name="InputReference"></param>
        /// <param name="InLocalTempDir"></param>
        /// <param name="ObeyConstraints"></param>
        public void AddDevices(UnrealTargetPlatform DefaultPlatform, string InputReference, bool ObeyConstraints = true)
        {
            lock (LockObject)
            {
                List <ITargetDevice> NewDevices = new List <ITargetDevice>();

                int SlashIndex = InputReference.IndexOf("\\") >= 0 ? InputReference.IndexOf("\\") : InputReference.IndexOf("/");

                bool PossibleFileName = InputReference.IndexOfAny(Path.GetInvalidPathChars()) < 0 &&
                                        (InputReference.IndexOf(":") == -1 || (InputReference.IndexOf(":") == SlashIndex - 1));
                // Did they specify a file?
                if (PossibleFileName && File.Exists(InputReference))
                {
                    Gauntlet.Log.Info("Adding devices from {0}", InputReference);
                    List <DeviceDefinition> DeviceDefinitions = JsonConvert.DeserializeObject <List <DeviceDefinition> >(File.ReadAllText(InputReference));

                    foreach (DeviceDefinition Def in DeviceDefinitions)
                    {
                        Gauntlet.Log.Info("Adding {0}", Def);

                        // use Legacy field if it exists
                        if (Def.Platform == null)
                        {
                            Def.Platform = Def.Type;
                        }

                        // check for an availability constraint
                        if (string.IsNullOrEmpty(Def.Available) == false && ObeyConstraints)
                        {
                            // check whether disabled
                            if (String.Compare(Def.Available, "disabled", true) == 0)
                            {
                                Gauntlet.Log.Info("Skipping {0} due to being disabled", Def.Name);
                                continue;
                            }

                            // availability is specified as a range, e.g 21:00-09:00.
                            Match M = Regex.Match(Def.Available, @"(\d{1,2}:\d\d)\s*-\s*(\d{1,2}:\d\d)");

                            if (M.Success)
                            {
                                DateTime From, To;

                                if (DateTime.TryParse(M.Groups[1].Value, out From) && DateTime.TryParse(M.Groups[2].Value, out To))
                                {
                                    // these are just times so when parsed will have todays date. If the To time is less than
                                    // From (22:00-06:00) time it spans midnight so move it to the next day
                                    if (To < From)
                                    {
                                        To = To.AddDays(1);
                                    }

                                    // if From is in the future (e.g. it's 01:00 and range is 22:00-08:00) we may be in the previous days window,
                                    // so move them both back a day
                                    if (From > DateTime.Now)
                                    {
                                        From = From.AddDays(-1);
                                        To   = To.AddDays(-1);
                                    }

                                    if (DateTime.Now < From || DateTime.Now > To)
                                    {
                                        Gauntlet.Log.Info("Skipping {0} due to availability constraint {1}", Def.Name, Def.Available);
                                        continue;
                                    }
                                }
                                else
                                {
                                    Gauntlet.Log.Warning("Failed to parse availability {0} for {1}", Def.Available, Def.Name);
                                }
                            }
                        }

                        Def.RemoveOnShutdown = true;

                        if (Def.Platform == null)
                        {
                            Def.Platform = DefaultPlatform;
                        }

                        UnprovisionedDevices.Add(Def);
                    }

                    // randomize devices so if there's a bad device st the start so we don't always hit it (or we do if its later)
                    UnprovisionedDevices = UnprovisionedDevices.OrderBy(D => Guid.NewGuid()).ToList();
                }
                else
                {
                    if (string.IsNullOrEmpty(InputReference) == false)
                    {
                        string[] DevicesList = InputReference.Split(',');

                        foreach (string DeviceRef in DevicesList)
                        {
                            // check for <platform>:<address>:<port>|<model>. We pass address:port to device constructor
                            Match M = Regex.Match(DeviceRef, @"(.+?):(.+)");

                            UnrealTargetPlatform DevicePlatform = DefaultPlatform;
                            string DeviceAddress = DeviceRef;
                            string Model         = string.Empty;

                            // when using device service, skip adding local non-desktop devices to pool
                            bool IsDesktop = UnrealBuildTool.Utils.GetPlatformsInClass(UnrealPlatformClass.Desktop).Contains(DevicePlatform);
                            if (!IsDesktop && DeviceRef.Equals("default", StringComparison.OrdinalIgnoreCase) && !String.IsNullOrEmpty(DeviceURL))
                            {
                                continue;
                            }

                            if (M.Success)
                            {
                                if (!UnrealTargetPlatform.TryParse(M.Groups[1].ToString(), out DevicePlatform))
                                {
                                    throw new AutomationException("platform {0} is not a recognized device type", M.Groups[1].ToString());
                                }

                                DeviceAddress = M.Groups[2].ToString();

                                // parse device model
                                if (DeviceAddress.Contains("|"))
                                {
                                    string[] Components = DeviceAddress.Split(new char[] { '|' });
                                    DeviceAddress = Components[0];
                                    Model         = Components[1];
                                }
                            }

                            Log.Info("Added device {0}:{1} to pool", DevicePlatform, DeviceAddress);
                            DeviceDefinition Def = new DeviceDefinition();
                            Def.Address  = DeviceAddress;
                            Def.Name     = DeviceAddress;
                            Def.Platform = DevicePlatform;
                            Def.Model    = Model;
                            UnprovisionedDevices.Add(Def);
                        }
                    }
                }
            }
        }